@webmate-studio/builder 0.2.116 → 0.2.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/design-tokens.js +31 -0
- package/src/index.js +2 -2
package/package.json
CHANGED
package/src/design-tokens.js
CHANGED
|
@@ -1160,6 +1160,37 @@ export function generateTailwindConfig(tokens) {
|
|
|
1160
1160
|
};
|
|
1161
1161
|
}
|
|
1162
1162
|
|
|
1163
|
+
/**
|
|
1164
|
+
* Generate @import rules for Fontsource/Bunny Fonts used in the design tokens.
|
|
1165
|
+
* Works in both browser (preview) and build contexts.
|
|
1166
|
+
* Returns a CSS string with @import statements (or empty string if no web fonts).
|
|
1167
|
+
*/
|
|
1168
|
+
export function generateFontImports(tokens) {
|
|
1169
|
+
const imports = [];
|
|
1170
|
+
const processedFonts = new Set();
|
|
1171
|
+
|
|
1172
|
+
function processFontId(fontId) {
|
|
1173
|
+
if (!fontId || processedFonts.has(fontId)) return;
|
|
1174
|
+
processedFonts.add(fontId);
|
|
1175
|
+
|
|
1176
|
+
if (fontId.startsWith('fontsource:')) {
|
|
1177
|
+
const fontsourceName = fontId.replace('fontsource:', '');
|
|
1178
|
+
const fontFamily = fontsourceName
|
|
1179
|
+
.split('-')
|
|
1180
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
1181
|
+
.join(' ');
|
|
1182
|
+
imports.push(`@import url('https://fonts.bunny.net/css?family=${fontFamily.replace(/\s+/g, '+')}:100,200,300,400,500,600,700,800,900&display=swap');`);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
if (tokens?.typography?.fontHeadingId) processFontId(tokens.typography.fontHeadingId);
|
|
1187
|
+
if (tokens?.typography?.fontBodyId) processFontId(tokens.typography.fontBodyId);
|
|
1188
|
+
if (tokens?.typography?.fontMonoId) processFontId(tokens.typography.fontMonoId);
|
|
1189
|
+
if (tokens?.typography?.fontAccentId) processFontId(tokens.typography.fontAccentId);
|
|
1190
|
+
|
|
1191
|
+
return imports.length > 0 ? imports.join('\n') + '\n\n' : '';
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1163
1194
|
/**
|
|
1164
1195
|
* Generate CSS Variables from Design Tokens
|
|
1165
1196
|
*/
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { deduplicateCSS } from './css-deduplicator.js';
|
|
|
6
6
|
import { markdownToHtml, processMarkdownProps } from './markdown.js';
|
|
7
7
|
import TemplateProcessor, { templateProcessor } from './template-processor.js';
|
|
8
8
|
import { SafeHtml } from './safe-html.js';
|
|
9
|
-
import { defaultDesignTokens, generateTailwindV4Theme, generateTailwindConfig, generateCSSFromTokens } from './design-tokens.js';
|
|
9
|
+
import { defaultDesignTokens, generateTailwindV4Theme, generateTailwindConfig, generateCSSFromTokens, generateFontImports } from './design-tokens.js';
|
|
10
10
|
import { readFileSync } from 'fs';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
12
|
import { dirname, join } from 'path';
|
|
@@ -19,4 +19,4 @@ function getMotionRuntime() {
|
|
|
19
19
|
return readFileSync(join(__dirname, '../dist/motion-runtime.min.js'), 'utf-8');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export { build, generateComponentCSS, generateTailwindCSS, extractTailwindClasses, cleanComponentHTML, bundleIsland, bundleComponentIslands, deduplicateCSS, markdownToHtml, processMarkdownProps, SafeHtml, getMotionRuntime, TemplateProcessor, templateProcessor, defaultDesignTokens, generateTailwindV4Theme, generateTailwindConfig, generateCSSFromTokens };
|
|
22
|
+
export { build, generateComponentCSS, generateTailwindCSS, extractTailwindClasses, cleanComponentHTML, bundleIsland, bundleComponentIslands, deduplicateCSS, markdownToHtml, processMarkdownProps, SafeHtml, getMotionRuntime, TemplateProcessor, templateProcessor, defaultDesignTokens, generateTailwindV4Theme, generateTailwindConfig, generateCSSFromTokens, generateFontImports };
|