50 lines
2.5 KiB
JavaScript
50 lines
2.5 KiB
JavaScript
// components/fontTransforms.jsx
|
||
|
||
export const fontList = [
|
||
"abril-fatface", "alegreya", "alfa-slab-one", "almendra", "amatic-sc", "andika",
|
||
"architects-daughter", "audiowide", "averia-libre", "bebas-neue", "black-ops-one",
|
||
"caveat", "cinzel-decorative", "courgette", "dancing-script", "exo", "fjalla-one",
|
||
"germania-one", "glass-antiqua", "gloria-hallelujah", "great-vibes", "holtwood-one-sc",
|
||
"indie-flower", "italiana", "jost", "kaushan-script", "lato", "metal-mania", "montserrat",
|
||
"neucha", "noto-sans", "open-sans", "orbitron", "oswald", "pacifico", "permanent-marker",
|
||
"philosopher", "playfair-display", "poppins", "press-start-2p", "questrial", "quicksand",
|
||
"rajdhani", "raleway", "righteous", "roboto", "sacramento", "satisfy", "space-mono",
|
||
"spectral", "staatliches", "stint-ultra-condensed", "syncopate", "ultra", "unica-one",
|
||
"work-sans", "yellowtail"
|
||
];
|
||
|
||
const getCategory = (name) => {
|
||
if (["caveat", "dancing-script", "pacifico", "amatic-sc", "kaushan-script", "courgette", "great-vibes", "satisfy", "sacramento", "neucha", "gloria-hallelujah", "almendra", "indie-flower", "architects-daughter"].includes(name)) return "handwriting";
|
||
if (["bebas-neue", "black-ops-one", "holtwood-one-sc", "abril-fatface", "playfair-display", "permanent-marker", "alfa-slab-one", "germania-one", "oswald", "stint-ultra-condensed"].includes(name)) return "statement";
|
||
if (["exo", "orbitron", "audiowide", "rajdhani", "space-mono", "questrial", "syncopate", "unica-one", "italiana", "staatliches"].includes(name)) return "futuristic";
|
||
if (["press-start-2p", "righteous", "metal-mania", "alegreya", "spectral", "fjalla-one", "glass-antiqua", "cinzel-decorative", "andika"].includes(name)) return "aesthetic";
|
||
return "modern";
|
||
};
|
||
|
||
export const fontTransforms = Object.fromEntries(
|
||
fontList.map((font) => {
|
||
const name = font.replace(/-/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
|
||
const category = getCategory(font);
|
||
return [font, {
|
||
category,
|
||
description: `Eine moderne, saubere Schriftart.`,
|
||
className: `font-${font}`
|
||
}];
|
||
})
|
||
);
|
||
|
||
export const transformText = (text, fontName) => {
|
||
const font = fontTransforms[fontName];
|
||
if (!font || !text) return { transformed: text, fontClassName: "" };
|
||
return {
|
||
transformed: text,
|
||
fontClassName: font.className
|
||
};
|
||
};
|
||
|
||
export const getPopularFonts = () => fontList.slice(0, 10);
|
||
|
||
export const getFontsByCategory = (category) =>
|
||
category === "all"
|
||
? fontList
|
||
: fontList.filter((f) => getCategory(f) === category); |