Skip to content

Instantly share code, notes, and snippets.

@AlvisonHunterArnuero
Last active October 24, 2024 16:14
Show Gist options
  • Save AlvisonHunterArnuero/2c90ef491a1f849f4b431e4b07dea48d to your computer and use it in GitHub Desktop.
Save AlvisonHunterArnuero/2c90ef491a1f849f4b431e4b07dea48d to your computer and use it in GitHub Desktop.
This code defines a theme color system and retrieves hex color codes based on a given color name, logging the result.
const themeTextColorPalette = {
primary: "#3B5998",
secondary: "#8B9DC3",
dark: "#333333",
light: "#F7F7F7",
muted: "#CCC222",
} as const;
type ThemeTextColorName = keyof typeof themeTextColorPalette;
const getHexColorCode = (colorName: ThemeTextColorName): string => {
return themeTextColorPalette[colorName];
}
const newColor: ThemeTextColorName = "dark";
const hexColor = getHexColorCode(newColor);
console.log(`Hex Color for ${newColor} is ${hexColor}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment