diy-template-components 5.0.0 → 5.1.1
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/build/index.es.js +39 -51
- package/build/index.es.js.map +1 -1
- package/build/index.js +39 -51
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -2466,6 +2466,25 @@ const fontWeight = {
|
|
|
2466
2466
|
superBold: 900
|
|
2467
2467
|
};
|
|
2468
2468
|
|
|
2469
|
+
/**
|
|
2470
|
+
* Central font name resolver.
|
|
2471
|
+
* Maps legacy/display names to canonical Google Fonts family names.
|
|
2472
|
+
*/
|
|
2473
|
+
const FONT_NAME_ALIASES = {
|
|
2474
|
+
'Ibm Plex Sans': 'IBM Plex Sans'
|
|
2475
|
+
};
|
|
2476
|
+
|
|
2477
|
+
/**
|
|
2478
|
+
* Resolves a font family name to its canonical form for loading/rendering.
|
|
2479
|
+
* @param {string} fontFamily - Raw font name (e.g. from metadata or user selection)
|
|
2480
|
+
* @returns {string} Resolved font name for CSS/Google Fonts URL
|
|
2481
|
+
*/
|
|
2482
|
+
function resolveFont(fontFamily) {
|
|
2483
|
+
if (!fontFamily || typeof fontFamily !== 'string') return fontFamily;
|
|
2484
|
+
const normalized = fontFamily.trim();
|
|
2485
|
+
return FONT_NAME_ALIASES[normalized] || normalized;
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2469
2488
|
const getBorderRadius = roundness => {
|
|
2470
2489
|
const mapping = {
|
|
2471
2490
|
sharp: {
|
|
@@ -2502,8 +2521,9 @@ const getBorderRadius = roundness => {
|
|
|
2502
2521
|
};
|
|
2503
2522
|
function getTheme(colorTheme = 'blue', fontFamily = 'Arial', isMobile, roundness = 'rounded') {
|
|
2504
2523
|
const palette = palettes[colorTheme] || palettes['blue'];
|
|
2524
|
+
const resolvedFont = resolveFont(fontFamily);
|
|
2505
2525
|
const typography = {
|
|
2506
|
-
fontFamily: `"${
|
|
2526
|
+
fontFamily: `"${resolvedFont}", "Roboto", "Helvetica", "Arial", "sans-serif"`,
|
|
2507
2527
|
fontSize: isMobile ? fontSizeMob : fontSize,
|
|
2508
2528
|
fontWeight
|
|
2509
2529
|
};
|
|
@@ -2520,58 +2540,25 @@ function getTheme(colorTheme = 'blue', fontFamily = 'Arial', isMobile, roundness
|
|
|
2520
2540
|
};
|
|
2521
2541
|
}
|
|
2522
2542
|
|
|
2523
|
-
const
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
'Merriweather Sans': MerriweatherSans,
|
|
2527
|
-
'Arima Madurai': ArimaMadurai,
|
|
2528
|
-
'Nanum Square': NanumSquare
|
|
2529
|
-
};
|
|
2530
|
-
const getFontComponent = font => fontComponents[font] || (() => null);
|
|
2543
|
+
const NANUM_SQUARE_URL = 'https://cdn.jsdelivr.net/gh/moonspam/NanumSquare@2.0/nanumsquare.css';
|
|
2544
|
+
const FONT_LINK_ID_PREFIX = 'diy-font-seeder-';
|
|
2545
|
+
const getGoogleFontsUrl = fontFamily => `https://fonts.googleapis.com/css2?family=${fontFamily.replace(/ /g, '+')}:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap`;
|
|
2531
2546
|
function FontSeeder({
|
|
2532
2547
|
fontFamily
|
|
2533
2548
|
}) {
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
const
|
|
2538
|
-
|
|
2539
|
-
})
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
});
|
|
2548
|
-
function IbmPlexSans() {
|
|
2549
|
-
// to import "Ibm Plex Sans" font css
|
|
2550
|
-
useIbmPlexSansFont();
|
|
2551
|
-
return null;
|
|
2552
|
-
}
|
|
2553
|
-
const useMerriweatherSansFont = reactJss.createUseStyles({
|
|
2554
|
-
'@import': 'url(https://fonts.googleapis.com/css2?family=Merriweather+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap)'
|
|
2555
|
-
});
|
|
2556
|
-
function MerriweatherSans() {
|
|
2557
|
-
// to import "Merriweather Sans" font css
|
|
2558
|
-
useMerriweatherSansFont();
|
|
2559
|
-
return null;
|
|
2560
|
-
}
|
|
2561
|
-
const useArimaMaduraiFont = reactJss.createUseStyles({
|
|
2562
|
-
'@import': 'url(https://fonts.googleapis.com/css2?family=Arima+Madurai:wght@400;500;700&display=swap)'
|
|
2563
|
-
});
|
|
2564
|
-
function ArimaMadurai() {
|
|
2565
|
-
// to import "Arima Madurai" font css
|
|
2566
|
-
useArimaMaduraiFont();
|
|
2567
|
-
return null;
|
|
2568
|
-
}
|
|
2569
|
-
const useNanumSqaureFont = reactJss.createUseStyles({
|
|
2570
|
-
'@import': 'url(https://cdn.jsdelivr.net/gh/moonspam/NanumSquare@2.0/nanumsquare.css)'
|
|
2571
|
-
});
|
|
2572
|
-
function NanumSquare() {
|
|
2573
|
-
// to import "Nanum Square" font css
|
|
2574
|
-
useNanumSqaureFont();
|
|
2549
|
+
React.useEffect(() => {
|
|
2550
|
+
if (!fontFamily || typeof document === 'undefined') return;
|
|
2551
|
+
const normalizedName = String(fontFamily).trim();
|
|
2552
|
+
const fontForUrl = resolveFont(normalizedName);
|
|
2553
|
+
const url = normalizedName.toLowerCase() === 'nanum square' ? NANUM_SQUARE_URL : getGoogleFontsUrl(fontForUrl);
|
|
2554
|
+
const linkId = `${FONT_LINK_ID_PREFIX}${normalizedName.replace(/\s+/g, '-')}`;
|
|
2555
|
+
if (document.getElementById(linkId)) return;
|
|
2556
|
+
const link = document.createElement('link');
|
|
2557
|
+
link.id = linkId;
|
|
2558
|
+
link.rel = 'stylesheet';
|
|
2559
|
+
link.href = url;
|
|
2560
|
+
document.head.appendChild(link);
|
|
2561
|
+
}, [fontFamily]);
|
|
2575
2562
|
return null;
|
|
2576
2563
|
}
|
|
2577
2564
|
|
|
@@ -3040,8 +3027,9 @@ const generateTheme = (theme = 'blue', fontFamily = 'Arial', isMobile, roundness
|
|
|
3040
3027
|
headerText: allColors[color],
|
|
3041
3028
|
headerHover: allColors['tertiary' + color]
|
|
3042
3029
|
};
|
|
3030
|
+
const resolvedFont = resolveFont(fontFamily);
|
|
3043
3031
|
const typography = {
|
|
3044
|
-
fontFamily: `"${
|
|
3032
|
+
fontFamily: `"${resolvedFont}", "Roboto", "Helvetica", "Arial", "sans-serif"`,
|
|
3045
3033
|
fontSize: isMobile ? fontSizeMob : fontSize,
|
|
3046
3034
|
fontWeight
|
|
3047
3035
|
};
|