File size: 4,344 Bytes
af1bee9 153376e af1bee9 589f639 af1bee9 0d811c3 af1bee9 0d811c3 af1bee9 0d811c3 af1bee9 0d811c3 af1bee9 | 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';
// Astra: Mantine's primary is the CES blue of the logo (#0F467C) (checkboxes, switches, progress, steppers); filled
// buttons take the deeper blue and its gradient from tokens.css (--mantine-primary-color-filled, --accent-grad).
const trio: MantineColorsTuple = ['#e8f1fb', '#cfe1f6', '#a3c5ee', '#73a5e3', '#4a89d8', '#2a6fc0', '#1d5aa3', '#164a87', '#0f467c', '#0b2a4f'];
// 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: 5, dark: 5 },
// 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 and buttons, lg = cards and grouped lists, xl = pills (badges, chips)
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: 'md', size: 'sm', variant: 'default' } },
ActionIcon: { defaultProps: { radius: 'md', 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: 'md' } },
Tabs: { defaultProps: { radius: 'md' } },
Switch: { defaultProps: { color: 'trio' } }, // "on" is the indigo accent
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)' } },
},
},
});
|