feat: simplify color scheme options, enhance theme provider, and add density styles
This commit is contained in:
@@ -27,8 +27,6 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set
|
|||||||
data={[
|
data={[
|
||||||
{ value: 'light', label: 'Light' },
|
{ value: 'light', label: 'Light' },
|
||||||
{ value: 'dark', label: 'Dark' },
|
{ value: 'dark', label: 'Dark' },
|
||||||
{ value: 'dracula', label: 'Dracula' },
|
|
||||||
{ value: 'blue', label: 'Blue' },
|
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
@@ -47,7 +45,7 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set
|
|||||||
{/* Showcase Area */}
|
{/* Showcase Area */}
|
||||||
<Card withBorder shadow="sm" radius="md" p="md">
|
<Card withBorder shadow="sm" radius="md" p="md">
|
||||||
<Stack gap="lg">
|
<Stack gap="lg">
|
||||||
<div>
|
<div className="bg-brand-100">
|
||||||
<Title order={3} mb="sm">
|
<Title order={3} mb="sm">
|
||||||
Typography
|
Typography
|
||||||
</Title>
|
</Title>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { MantineProvider, createTheme, MantineThemeOverride } from '@mantine/core';
|
import { MantineProvider, createTheme, MantineThemeOverride } from '@mantine/core';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { brandColors, errorColors, warningColors, successColors, infoColors, draculaColors, blueColors } from '../theme/tokens/colors';
|
import { brandColors, errorColors, warningColors, successColors, infoColors } from '../theme/tokens/colors';
|
||||||
import { typography } from '../theme/tokens/typography';
|
import { typography } from '../theme/tokens/typography';
|
||||||
import { radius } from '../theme/tokens/radius';
|
import { radius } from '../theme/tokens/radius';
|
||||||
|
import { densityStyles } from '../theme/tokens/density';
|
||||||
|
|
||||||
export type ColorSchemeType = 'light' | 'dark' | 'dracula' | 'blue';
|
export type ColorSchemeType = 'light' | 'dark';
|
||||||
export type DensityType = 'compact' | 'standard' | 'spacious';
|
export type DensityType = 'compact' | 'standard' | 'spacious';
|
||||||
|
|
||||||
interface ThemeProviderProps {
|
interface ThemeProviderProps {
|
||||||
@@ -14,18 +15,6 @@ interface ThemeProviderProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ThemeProvider({ children, colorScheme = 'light', density = 'standard' }: ThemeProviderProps) {
|
export function ThemeProvider({ children, colorScheme = 'light', density = 'standard' }: ThemeProviderProps) {
|
||||||
const densityStyles = {
|
|
||||||
compact: {
|
|
||||||
spacing: { xs: '0.25rem', sm: '0.5rem', md: '0.75rem', lg: '1rem', xl: '1.25rem' },
|
|
||||||
},
|
|
||||||
standard: {
|
|
||||||
spacing: { xs: '0.5rem', sm: '0.75rem', md: '1rem', lg: '1.5rem', xl: '2rem' },
|
|
||||||
},
|
|
||||||
spacious: {
|
|
||||||
spacing: { xs: '0.75rem', sm: '1rem', md: '1.5rem', lg: '2rem', xl: '3rem' },
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const baseTheme = createTheme({
|
const baseTheme = createTheme({
|
||||||
colors: {
|
colors: {
|
||||||
brand: brandColors,
|
brand: brandColors,
|
||||||
@@ -33,8 +22,6 @@ export function ThemeProvider({ children, colorScheme = 'light', density = 'stan
|
|||||||
warning: warningColors,
|
warning: warningColors,
|
||||||
success: successColors,
|
success: successColors,
|
||||||
info: infoColors,
|
info: infoColors,
|
||||||
dracula: draculaColors,
|
|
||||||
bluetheme: blueColors,
|
|
||||||
},
|
},
|
||||||
primaryColor: 'brand',
|
primaryColor: 'brand',
|
||||||
fontFamily: typography.fontFamily,
|
fontFamily: typography.fontFamily,
|
||||||
@@ -43,27 +30,15 @@ export function ThemeProvider({ children, colorScheme = 'light', density = 'stan
|
|||||||
radius: radius,
|
radius: radius,
|
||||||
});
|
});
|
||||||
|
|
||||||
let mantineColorScheme: 'light' | 'dark' = 'light';
|
const mantineColorScheme: 'light' | 'dark' = colorScheme;
|
||||||
let themeOverride: MantineThemeOverride = baseTheme;
|
const themeOverride: MantineThemeOverride = baseTheme;
|
||||||
|
|
||||||
if (colorScheme === 'dark') {
|
|
||||||
mantineColorScheme = 'dark';
|
|
||||||
} else if (colorScheme === 'dracula') {
|
|
||||||
mantineColorScheme = 'dark';
|
|
||||||
themeOverride = createTheme({
|
|
||||||
...baseTheme,
|
|
||||||
primaryColor: 'dracula',
|
|
||||||
});
|
|
||||||
} else if (colorScheme === 'blue') {
|
|
||||||
mantineColorScheme = 'light';
|
|
||||||
themeOverride = createTheme({
|
|
||||||
...baseTheme,
|
|
||||||
primaryColor: 'bluetheme',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MantineProvider theme={themeOverride} forceColorScheme={mantineColorScheme} defaultColorScheme={mantineColorScheme}>
|
<MantineProvider
|
||||||
|
theme={themeOverride}
|
||||||
|
forceColorScheme={mantineColorScheme}
|
||||||
|
defaultColorScheme={mantineColorScheme}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</MantineProvider>
|
</MantineProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,3 +15,84 @@
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@theme {
|
||||||
|
/* -------------------------------
|
||||||
|
COLORS: PALETTE
|
||||||
|
------------------------------- */
|
||||||
|
/* Brand (Purple based on your code) */
|
||||||
|
--color-brand-50: #f5f3fd;
|
||||||
|
--color-brand-100: #e6dbfb;
|
||||||
|
--color-brand-200: #d0b6f8;
|
||||||
|
--color-brand-300: #b78ff5;
|
||||||
|
--color-brand-400: #9f64f1;
|
||||||
|
--color-brand-500: #7d39ed; /* Primary */
|
||||||
|
--color-brand-600: #652ed9;
|
||||||
|
--color-brand-700: #4a23a5;
|
||||||
|
--color-brand-800: #321a7a;
|
||||||
|
--color-brand-900: #1b0f4a;
|
||||||
|
|
||||||
|
/* Neutrals */
|
||||||
|
--color-gray-50: #f5f6f7;
|
||||||
|
--color-gray-100: #eceff1;
|
||||||
|
--color-gray-200: #e0e3e7;
|
||||||
|
--color-gray-300: #d1d5db;
|
||||||
|
--color-gray-400: #9ca3af;
|
||||||
|
--color-gray-500: #6b7280;
|
||||||
|
--color-gray-600: #4b5563;
|
||||||
|
--color-gray-700: #374151;
|
||||||
|
--color-gray-800: #1f2937;
|
||||||
|
--color-gray-900: #111827;
|
||||||
|
|
||||||
|
/* -------------------------------
|
||||||
|
COLORS: SEMANTICS (COMPLETED)
|
||||||
|
------------------------------- */
|
||||||
|
|
||||||
|
/* Error (Red) */
|
||||||
|
--color-error-50: #fef2f2;
|
||||||
|
--color-error-100: #fee2e2;
|
||||||
|
--color-error-200: #fecaca;
|
||||||
|
--color-error-300: #fca5a5;
|
||||||
|
--color-error-400: #f87171;
|
||||||
|
--color-error-500: #ef4444;
|
||||||
|
--color-error-600: #dc2626;
|
||||||
|
--color-error-700: #b91c1c;
|
||||||
|
--color-error-800: #991b1b;
|
||||||
|
--color-error-900: #7f1d1d;
|
||||||
|
|
||||||
|
/* Warning (Amber/Orange) */
|
||||||
|
--color-warning-50: #fffbeb;
|
||||||
|
--color-warning-100: #fef3c7;
|
||||||
|
--color-warning-200: #fde68a;
|
||||||
|
--color-warning-300: #fcd34d;
|
||||||
|
--color-warning-400: #fbbf24;
|
||||||
|
--color-warning-500: #f59e0b;
|
||||||
|
--color-warning-600: #d97706;
|
||||||
|
--color-warning-700: #b45309;
|
||||||
|
--color-warning-800: #92400e;
|
||||||
|
--color-warning-900: #78350f;
|
||||||
|
|
||||||
|
/* Success (Green) */
|
||||||
|
--color-success-50: #f0fdf4;
|
||||||
|
--color-success-100: #dcfce7;
|
||||||
|
--color-success-200: #bbf7d0;
|
||||||
|
--color-success-300: #86efac;
|
||||||
|
--color-success-400: #4ade80;
|
||||||
|
--color-success-500: #22c55e;
|
||||||
|
--color-success-600: #16a34a;
|
||||||
|
--color-success-700: #15803d;
|
||||||
|
--color-success-800: #166534;
|
||||||
|
--color-success-900: #14532d;
|
||||||
|
|
||||||
|
/* Info (Blue/Sky) */
|
||||||
|
--color-info-50: #f0f9ff;
|
||||||
|
--color-info-100: #e0f2fe;
|
||||||
|
--color-info-200: #bae6fd;
|
||||||
|
--color-info-300: #7dd3fc;
|
||||||
|
--color-info-400: #38bdf8;
|
||||||
|
--color-info-500: #0ea5e9;
|
||||||
|
--color-info-600: #0284c7;
|
||||||
|
--color-info-700: #0369a1;
|
||||||
|
--color-info-800: #075985;
|
||||||
|
--color-info-900: #0c4a6e;
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,37 +14,66 @@ export const brandColors: MantineColorsTuple = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const errorColors: MantineColorsTuple = [
|
export const errorColors: MantineColorsTuple = [
|
||||||
'#fef2f2', '#fee2e2', '#fecaca', '#fca5a5', '#f87171',
|
'#fef2f2',
|
||||||
'#ef4444', '#dc2626', '#b91c1c', '#991b1b', '#7f1d1d',
|
'#fee2e2',
|
||||||
|
'#fecaca',
|
||||||
|
'#fca5a5',
|
||||||
|
'#f87171',
|
||||||
|
'#ef4444',
|
||||||
|
'#dc2626',
|
||||||
|
'#b91c1c',
|
||||||
|
'#991b1b',
|
||||||
|
'#7f1d1d',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const warningColors: MantineColorsTuple = [
|
export const warningColors: MantineColorsTuple = [
|
||||||
'#fffbeb', '#fef3c7', '#fde68a', '#fcd34d', '#fbbf24',
|
'#fffbeb',
|
||||||
'#f59e0b', '#d97706', '#b45309', '#92400e', '#78350f',
|
'#fef3c7',
|
||||||
|
'#fde68a',
|
||||||
|
'#fcd34d',
|
||||||
|
'#fbbf24',
|
||||||
|
'#f59e0b',
|
||||||
|
'#d97706',
|
||||||
|
'#b45309',
|
||||||
|
'#92400e',
|
||||||
|
'#78350f',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const successColors: MantineColorsTuple = [
|
export const successColors: MantineColorsTuple = [
|
||||||
'#f0fdf4', '#dcfce7', '#bbf7d0', '#86efac', '#4ade80',
|
'#f0fdf4',
|
||||||
'#22c55e', '#16a34a', '#15803d', '#166534', '#14532d',
|
'#dcfce7',
|
||||||
|
'#bbf7d0',
|
||||||
|
'#86efac',
|
||||||
|
'#4ade80',
|
||||||
|
'#22c55e',
|
||||||
|
'#16a34a',
|
||||||
|
'#15803d',
|
||||||
|
'#166534',
|
||||||
|
'#14532d',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const infoColors: MantineColorsTuple = [
|
export const infoColors: MantineColorsTuple = [
|
||||||
'#f0f9ff', '#e0f2fe', '#bae6fd', '#7dd3fc', '#38bdf8',
|
'#f0f9ff',
|
||||||
'#0ea5e9', '#0284c7', '#0369a1', '#075985', '#0c4a6e',
|
'#e0f2fe',
|
||||||
];
|
'#bae6fd',
|
||||||
|
'#7dd3fc',
|
||||||
export const draculaColors: MantineColorsTuple = [
|
'#38bdf8',
|
||||||
'#f8f8f2', '#f1fa8c', '#8be9fd', '#50fa7b', '#ffb86c',
|
'#0ea5e9',
|
||||||
'#ff79c6', '#bd93f9', '#6272a4', '#44475a', '#282a36',
|
'#0284c7',
|
||||||
]; // Reusing standard dracula palette as a tuple for simplicity,
|
'#0369a1',
|
||||||
// usually this would be mapped to specific grays/primary.
|
'#075985',
|
||||||
|
'#0c4a6e',
|
||||||
export const blueColors: MantineColorsTuple = [
|
|
||||||
'#e3f2fd', '#bbdefb', '#90caf9', '#64b5f6', '#42a5f5',
|
|
||||||
'#2196f3', '#1e88e5', '#1976d2', '#1565c0', '#0d47a1',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const grayColors: MantineColorsTuple = [
|
export const grayColors: MantineColorsTuple = [
|
||||||
'#f5f6f7', '#eceff1', '#e0e3e7', '#d1d5db', '#9ca3af',
|
'#f5f6f7',
|
||||||
'#6b7280', '#4b5563', '#374151', '#1f2937', '#111827',
|
'#eceff1',
|
||||||
|
'#e0e3e7',
|
||||||
|
'#d1d5db',
|
||||||
|
'#9ca3af',
|
||||||
|
'#6b7280',
|
||||||
|
'#4b5563',
|
||||||
|
'#374151',
|
||||||
|
'#1f2937',
|
||||||
|
'#111827',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export const densityStyles = {
|
||||||
|
compact: {
|
||||||
|
spacing: { xs: '0.25rem', sm: '0.5rem', md: '0.75rem', lg: '1rem', xl: '1.25rem' },
|
||||||
|
},
|
||||||
|
standard: {
|
||||||
|
spacing: { xs: '0.5rem', sm: '0.75rem', md: '1rem', lg: '1.5rem', xl: '2rem' },
|
||||||
|
},
|
||||||
|
spacious: {
|
||||||
|
spacing: { xs: '0.75rem', sm: '1rem', md: '1.5rem', lg: '2rem', xl: '3rem' },
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user