Skip to content

Commit

Permalink
chore: co-locate related code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaidev committed Sep 6, 2024
1 parent df583ca commit 3af6234
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,6 @@ function transformRadixPalette(radixPalette: Palette): Palette {
return transformedPalette;
}

/**
* Replace Radix color names with their aliases.
*/
function aliasRadixPalette(
radixPalette: Palette,
aliases: Record<string, string>,
): Palette {
const aliasedPalette: Palette = {};

for (const [radixColorName, radixColor] of Object.entries(radixPalette)) {
const colorNameComponents = parseColorName(radixColorName);
const aliasedBase =
aliases[colorNameComponents.base] ?? colorNameComponents.base;
const aliasedColorName = buildColorName({
...colorNameComponents,
base: aliasedBase,
});
aliasedPalette[aliasedColorName] = radixColor;
}

return aliasedPalette;
}

/**
* Radix color name: `blueDarkP3A`
*
Expand Down Expand Up @@ -140,6 +117,29 @@ function transformRadixColor(radixColor: Color): Color {
return transformedColor;
}

/**
* Replace Radix color names with their aliases.
*/
function aliasRadixPalette(
radixPalette: Palette,
aliases: Record<string, string>,
): Palette {
const aliasedPalette: Palette = {};

for (const [radixColorName, radixColor] of Object.entries(radixPalette)) {
const colorNameComponents = parseColorName(radixColorName);
const aliasedBase =
aliases[colorNameComponents.base] ?? colorNameComponents.base;
const aliasedColorName = buildColorName({
...colorNameComponents,
base: aliasedBase,
});
aliasedPalette[aliasedColorName] = radixColor;
}

return aliasedPalette;
}

/**
* Create a function that checks whether a Radix color name should be included,
* i.e. be transformed and added to the new palette.
Expand Down

0 comments on commit 3af6234

Please sign in to comment.