mirror of
https://github.com/shadoll/sLogos.git
synced 2025-12-20 11:32:01 +00:00
feat: add color conversion and target/sets configuration for logos
- Updated Makefile to include a new target for converting logo colors format. - Added a new script `convertColorsFormat.js` to convert colors from array to object format in `logos.json`. - Modified `logos.json` structure to use an object for colors and added targets and sets for SVG logos. - Updated `scanLogos.js` to set default colorConfig, targets, and sets for SVG logos. - Enhanced Svelte components (`Grid.svelte`, `List.svelte`, `Preview.svelte`, `InlineSvg.svelte`) to support new targets, sets, and colors structure. - Updated color theme utility functions to handle the new colors object format. - Removed deprecated `mono_white.svg` logo file.
This commit is contained in:
@@ -1,19 +1,31 @@
|
||||
// Utility to pick the logo color for the current theme using the "theme" key only
|
||||
export function getDefaultLogoColor(colors, theme = 'light') {
|
||||
if (!colors || colors.length === 0) return undefined;
|
||||
// Use the color with the matching theme key if present
|
||||
const match = colors.find(c => c.theme === theme);
|
||||
if (match) return match.value;
|
||||
if (!colors || Object.keys(colors).length === 0) return undefined;
|
||||
|
||||
// Look through all colors to find one with a theme property
|
||||
for (const [colorName, colorValue] of Object.entries(colors)) {
|
||||
// If color value is an object with theme property matching current theme
|
||||
if (typeof colorValue === 'object' && colorValue.theme === theme) {
|
||||
return colorValue.value;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: do not colorize (undefined)
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Utility to select the color with the matching theme key from the colors array
|
||||
// Utility to select the color with the matching theme key from the colors object
|
||||
export function getThemeColor(colors, theme = 'light') {
|
||||
if (!colors || colors.length === 0) return undefined;
|
||||
// Try to find a color with the matching theme key
|
||||
const match = colors.find(c => c.theme === theme);
|
||||
if (match) return match.value;
|
||||
if (!colors || Object.keys(colors).length === 0) return undefined;
|
||||
|
||||
// Look through all colors to find one with a theme property
|
||||
for (const [colorName, colorValue] of Object.entries(colors)) {
|
||||
// If color value is an object with theme property matching current theme
|
||||
if (typeof colorValue === 'object' && colorValue.theme === theme) {
|
||||
return colorValue.value;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: pick the first color
|
||||
return colors[0].value;
|
||||
return Object.values(colors)[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user