Skip to content

Commit

Permalink
brand colors from tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
konfig-bot committed Oct 26, 2023
1 parent 2305a2d commit c022421
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export function OperationRequest({
<button
className={clsx(
{
['border-emerald-500 text-emerald-500']: selected,
['border-brand-800 text-brand-800 dark:border-brand-600 dark:text-brand-600']:
selected,
['border-transparent hover:text-white']: !selected,
},
'border-b py-4 transition ui-not-focus-visible:outline-none'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,32 @@ import { generateShadePalette } from './generate-shade-palette'
export function generateMantineThemeColors({
primaryColor,
colors,
label = 'brand',
}: {
primaryColor?: string | null
colors: MantineTheme['colors']
label?: string
}): {
colors: Partial<MantineThemeColors>
} {
const color =
primaryColor !== undefined && primaryColor != null
? generateShadePalette(primaryColor)
: colors.blue

if (typeof window !== 'undefined') {
// create CSS variables for every color shade labeled as --color-brand-50, --color-brand-100, etc.
for (const [key, value] of Object.entries(color)) {
document.documentElement.style.setProperty(
`--color-${label}-${key}00`,
value
)
}
}

return {
colors: {
brand:
primaryColor !== undefined && primaryColor != null
? generateShadePalette(primaryColor)
: colors.blue,
[label]: color,
},
}
}
12 changes: 12 additions & 0 deletions generator/konfig-next-app/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ module.exports = {
theme: {
extend: {
colors: {
brand: {
// 100-900 from css variables --color-brand-100, --color-brand-200, etc.
100: 'var(--color-brand-100)',
200: 'var(--color-brand-200)',
300: 'var(--color-brand-300)',
400: 'var(--color-brand-400)',
500: 'var(--color-brand-500)',
600: 'var(--color-brand-600)',
700: 'var(--color-brand-700)',
800: 'var(--color-brand-800)',
900: 'var(--color-brand-900)',
},
'mantine-gray': '#868e96',
'mantine-gray': {
0x000: '#F8F9FA',
Expand Down

0 comments on commit c022421

Please sign in to comment.