UNPKG

igniteui-theming

Version:

A set of Sass variables, mixins, and functions for generating palettes, typography, and elevations used by Ignite UI components.

68 lines (67 loc) 2.33 kB
import { PLATFORM_METADATA } from "../../knowledge/platforms/index.js"; import { SASS_USE_ASSEMBLY_NOTE } from "../../utils/sass.js"; import { generateTypography } from "../../generators/sass.js"; import { formatCssOutput, generateTypographyCss } from "../../generators/css.js"; //#region src/tools/handlers/typography.ts /** * Handler for create_typography tool. */ async function handleCreateTypography(params) { if ((params.output ?? (params.platform === "angular" ? "sass" : "css")) === "css") return handleCssOutput(params); return handleSassOutput(params); } async function handleCssOutput(params) { try { const result = await generateTypographyCss({ fontFamily: params.fontFamily, designSystem: params.designSystem }); const formattedCss = formatCssOutput(result.css, result.description); const responseParts = [result.description]; responseParts.push(""); responseParts.push("Output format: CSS custom properties"); responseParts.push(""); responseParts.push("```css"); responseParts.push(formattedCss.trimEnd()); responseParts.push("```"); return { content: [{ type: "text", text: responseParts.join("\n") }] }; } catch (error) { return { content: [{ type: "text", text: `**Error generating CSS typography**\n\n${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } function handleSassOutput(params) { const result = generateTypography({ platform: params.platform, licensed: params.licensed, fontFamily: params.fontFamily, designSystem: params.designSystem, customScale: params.customScale, name: params.name }); const responseParts = [result.description]; const platformNote = params.platform ? `Platform: ${PLATFORM_METADATA[params.platform]?.name ?? params.platform}` : "Platform: Not specified (generic output). Specify `platform` for optimized code."; responseParts.push(""); responseParts.push(platformNote); responseParts.push(""); responseParts.push(`Variables used: ${result.variables.join(", ")}`); responseParts.push(""); responseParts.push("```scss"); responseParts.push(result.code.trimEnd()); responseParts.push("```"); responseParts.push(SASS_USE_ASSEMBLY_NOTE); return { content: [{ type: "text", text: responseParts.join("\n") }] }; } //#endregion export { handleCreateTypography };