Skip to content

Commit

Permalink
bugfix(themes): fixed theme generation for dark and light themes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Sep 6, 2020
1 parent be52568 commit 8ecf8e3
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions packages/dev-utils/src/utils/createThemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,20 @@ function getThemeVariables(theme: string): [string, string, string, string] {
}

function getThemes(): string[] {
return (
colors
.flatMap((primary) =>
secondaries.flatMap((secondary) => {
if (primary === secondary) {
return [];
}

primary = toCSSColor(primary);
secondary = toCSSColor(secondary);
return weights.flatMap((weight) =>
tones.map((theme) => `${primary}-${secondary}-${weight}-${theme}`)
);
})
)
// sorting is really a hack to fix replacing colors correctly since `red` is
// an error color so might regex replace incorrectly
.sort()
// sorting is really a hack to fix replacing colors correctly since `red` is
// an error color so might regex replace incorrectly
return colors.sort().flatMap((primary) =>
secondaries.flatMap((secondary) => {
if (primary === secondary) {
return [];
}

primary = toCSSColor(primary);
secondary = toCSSColor(secondary);
return weights.flatMap((weight) =>
tones.map((theme) => `${primary}-${secondary}-${weight}-${theme}`)
);
})
);
}

Expand Down

0 comments on commit 8ecf8e3

Please sign in to comment.