File size: 4,397 Bytes
a289b2a 8f175f6 aa61ac1 33ce28f bcc4b86 a289b2a 33ce28f aa61ac1 33ce28f aa61ac1 1f5bc01 bcc4b86 1f5bc01 bcc4b86 1f5bc01 bcc4b86 33ce28f bcc4b86 33ce28f 1f5bc01 a289b2a 33ce28f 144145d a289b2a 33ce28f a289b2a aa61ac1 bcc4b86 33ce28f a289b2a 33ce28f 1825659 33ce28f a73107f 33ce28f a73107f a289b2a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | import { createTheme, type MantineColorsTuple } from '@mantine/core';
// Patchwise: one graphite accent (colour is for status only). Mantine's primary shade is #1d1d1f in light and #f5f5f7 in dark, so anything Mantine
// paints with the primary colour (progress, steppers, checkboxes) is graphite; the CSS variables in apple.css do the rest.
const trio: MantineColorsTuple = ['#f5f5f7', '#e5e5ea', '#d1d1d6', '#aeaeb2', '#8e8e93', '#636366', '#1d1d1f', '#3a3a3c', '#2c2c2e', '#000000'];
// Neutral ramp for Mantine's "dark" lookups; the real surfaces come from the CSS variables in apple.css.
const dark: MantineColorsTuple = ['#f5f5f7', '#a1a1a6', '#8e8e93', '#6e6e73', '#48484a', '#3a3a3c', '#2a2a2d', '#1c1c1e', '#141416', '#0a0a0b'];
// Every size below reads a design token (tokens.css), so Mantine, Tailwind and the app CSS share one scale. The colour
// ramps above stay as hex: Mantine needs real colours to compute its variants.
const FONT = 'var(--font)';
const t = (k: string) => ({ fontSize: `var(--fs-${k})`, lineHeight: `var(--lh-${k})` });
export const theme = createTheme({
primaryColor: 'trio',
primaryShade: { light: 6, dark: 0 },
// the old colour names alias to the one accent so code that still asks for them keeps working
colors: { trio, dark, accent: trio, ink: trio },
fontFamily: FONT,
fontFamilyMonospace: 'var(--mono)',
headings: {
fontFamily: FONT, fontWeight: 'var(--fw-bold)',
sizes: { h1: t('3xl'), h2: t('2xl'), h3: t('lg'), h4: t('md'), h5: t('base'), h6: t('sm') },
},
fontSizes: { xs: 'var(--fs-xs)', sm: 'var(--fs-sm)', md: 'var(--fs-base)', lg: 'var(--fs-md)', xl: 'var(--fs-lg)' },
lineHeights: { xs: 'var(--lh-xs)', sm: 'var(--lh-sm)', md: 'var(--lh-base)', lg: 'var(--lh-md)', xl: 'var(--lh-lg)' },
spacing: { xs: 'var(--sp-2)', sm: 'var(--sp-3)', md: 'var(--sp-4)', lg: 'var(--sp-6)', xl: 'var(--sp-8)' },
// md = controls, lg = cards and grouped lists, xl = pills (buttons, chips, segmented)
radius: { xs: 'var(--r-sm)', sm: 'var(--r-sm)', md: 'var(--r-md)', lg: 'var(--r-lg)', xl: 'var(--r-pill)' },
defaultRadius: 'md',
// the same breakpoints as Tailwind and DESIGN_SYSTEM.md: 640 / 768 / 1024 / 1280 / 1536
breakpoints: { xs: '40em', sm: '48em', md: '64em', lg: '80em', xl: '96em' },
shadows: { xs: 'none', sm: 'var(--sh-card)', md: 'var(--sh-card)', lg: 'var(--sh-pop)', xl: 'var(--sh-pop)' },
focusRing: 'auto',
components: {
// Secondary by default: each screen marks its one primary action with variant="filled".
Button: { defaultProps: { radius: 'xl', size: 'sm', variant: 'default' } },
ActionIcon: { defaultProps: { radius: 'xl', variant: 'subtle' } },
Card: { defaultProps: { radius: 'lg', shadow: 'sm' } },
Paper: { defaultProps: { radius: 'lg' } },
Badge: { defaultProps: { radius: 'xl', variant: 'light' } },
TextInput: { defaultProps: { radius: 'md', size: 'sm' } },
PasswordInput: { defaultProps: { radius: 'md', size: 'sm' } },
NumberInput: { defaultProps: { radius: 'md', size: 'sm' } },
Select: { defaultProps: { radius: 'md', size: 'sm' } },
MultiSelect: { defaultProps: { radius: 'md', size: 'sm' } },
Textarea: { defaultProps: { radius: 'md', size: 'sm' } },
SegmentedControl: { defaultProps: { radius: 'xl' } },
Tabs: { defaultProps: { radius: 'md' } },
Switch: { defaultProps: { color: 'trio' } }, // "on" is graphite (near-white in dark)
Modal: { defaultProps: { radius: 'var(--r-xl)', centered: true, overlayProps: { backgroundOpacity: 0.28, blur: 0 }, transitionProps: { transition: 'pop', duration: 240 } } },
Menu: { defaultProps: { radius: 'lg', shadow: 'lg', withinPortal: true } },
Tooltip: { defaultProps: { radius: 'sm' } },
Table: { defaultProps: { verticalSpacing: 12, horizontalSpacing: 16, fz: 'sm' } },
// a wide table scrolls sideways: its viewport must be reachable by keyboard to scroll it (WCAG 2.1.1)
TableScrollContainer: { defaultProps: { scrollAreaProps: { viewportProps: { tabIndex: 0 } } } },
Notification: { defaultProps: { radius: 'lg' } },
Drawer: {
defaultProps: { radius: 'lg', overlayProps: { backgroundOpacity: 0.28 } },
styles: { content: { background: 'var(--bg-elev)', color: 'var(--label)' }, header: { background: 'var(--bg-elev)', color: 'var(--label)' } },
},
},
});
|