Files
ipal-kit/src/styles/tailwind.css
T
Radosław SmolińskiandClaude Opus 5.5 d6675d2979 Design tokens: themes on any element, primary-inverse, form template
Follow-ups from the reference site's first visual test:
- data-theme="dark"/"light" switches the tokens on any element (LIGHT_SELECTOR,
  DARK_SELECTOR as selector lists); the base layer colours a themed panel's text
- inverted sections re-map primary / primary-hover / primary-text to the new
  primary-inverse / primary-inverse-text roles; the contrast report checks them
  (inherited roles resolved on the ancestor, as the cascade does)
- ipal-form formClasses.ts on token utilities + buttonClass(); theme.md: one-icon
  ThemeSwitcher pattern (the default two-option toggle stays)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 15:04:54 +01:00

156 lines
5.5 KiB
CSS

/*
* @intecion/ipal-kit/tailwind.css — Tailwind 4 preset for the --ipal-* design tokens
* (docs/design-tokens.md). Import after "tailwindcss" and tokens.css:
*
* @import "tailwindcss";
* @import "@intecion/ipal-kit/fluid-wide.css";
* @import "@intecion/ipal-kit/tokens.css";
* @import "@intecion/ipal-kit/tailwind.css";
* @import "../../design/tokens.css";
*
* `@theme inline` makes every utility read the --ipal-* variable where it is used, so a
* scope that re-maps a token (dark theme, data-surface="inverse") reaches every utility.
* Colours switch with the theme on their own: no dark: variant for colours.
*/
/* dark: follows <ThemeScript> (data-theme on <html>), not the device setting */
@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));
@theme inline {
--color-bg: var(--ipal-bg);
--color-surface: var(--ipal-surface);
--color-surface-muted: var(--ipal-surface-muted);
--color-surface-raised: var(--ipal-surface-raised);
--color-inverse: var(--ipal-surface-inverse);
--color-on-inverse: var(--ipal-text-inverse);
--color-fg: var(--ipal-text);
--color-fg-strong: var(--ipal-text-strong);
--color-fg-muted: var(--ipal-text-muted);
--color-border: var(--ipal-border);
--color-border-strong: var(--ipal-border-strong);
--color-primary: var(--ipal-primary);
--color-primary-hover: var(--ipal-primary-hover);
--color-on-primary: var(--ipal-primary-text);
--color-secondary: var(--ipal-secondary);
--color-secondary-hover: var(--ipal-secondary-hover);
--color-on-secondary: var(--ipal-secondary-text);
--color-accent: var(--ipal-accent);
--color-on-accent: var(--ipal-accent-text);
--color-link: var(--ipal-link);
--color-link-hover: var(--ipal-link-hover);
--color-hover: var(--ipal-hover);
--color-focus: var(--ipal-focus);
--color-overlay: var(--ipal-overlay);
--color-success: var(--ipal-success);
--color-success-surface: var(--ipal-success-surface);
--color-warning: var(--ipal-warning);
--color-warning-surface: var(--ipal-warning-surface);
--color-danger: var(--ipal-danger);
--color-danger-surface: var(--ipal-danger-surface);
--color-info: var(--ipal-info);
--color-info-surface: var(--ipal-info-surface);
--font-sans: var(--ipal-font-body);
--font-body: var(--ipal-font-body);
--font-heading: var(--ipal-font-heading);
--font-mono: var(--ipal-font-mono);
--text-xs: var(--ipal-fs-xs);
--text-sm: var(--ipal-fs-sm);
--text-base: var(--ipal-fs-base);
--text-lg: var(--ipal-fs-lg);
--text-lead: var(--ipal-fs-lg);
--text-lead--line-height: var(--ipal-lh-body);
--text-h4: var(--ipal-fs-h4);
--text-h4--line-height: var(--ipal-lh-heading);
--text-h3: var(--ipal-fs-h3);
--text-h3--line-height: var(--ipal-lh-heading);
--text-h2: var(--ipal-fs-h2);
--text-h2--line-height: var(--ipal-lh-heading);
--text-h1: var(--ipal-fs-h1);
--text-h1--line-height: var(--ipal-lh-heading);
--text-display: var(--ipal-fs-display);
--text-display--line-height: var(--ipal-lh-heading);
--leading-body: var(--ipal-lh-body);
--leading-heading: var(--ipal-lh-heading);
--tracking-heading: var(--ipal-tracking-heading);
--spacing-stack: var(--ipal-space-stack);
--spacing-gap: var(--ipal-space-gap);
--spacing-gutter: var(--ipal-space-gutter);
--spacing-section-sm: var(--ipal-space-section-sm);
--spacing-section: var(--ipal-space-section);
--radius-control: var(--ipal-radius);
--radius-sm: var(--ipal-radius-sm);
--radius-card: var(--ipal-radius-card);
--radius-media: var(--ipal-radius-media);
--shadow-sm: var(--ipal-shadow-sm);
--shadow-md: var(--ipal-shadow-md);
--shadow-lg: var(--ipal-shadow-lg);
--container-container: var(--ipal-container);
--container-container-wide: var(--ipal-container-wide);
--container-narrow: var(--ipal-container-narrow);
--container-measure: var(--ipal-measure);
--ease-out: var(--ipal-ease-out);
--ease-in-out: var(--ipal-ease-in-out);
}
/* Durations and layers have no theme namespace in Tailwind 4: plain utilities. */
@utility duration-fast {
transition-duration: var(--ipal-duration-fast);
}
@utility duration-base {
transition-duration: var(--ipal-duration);
}
@utility duration-slow {
transition-duration: var(--ipal-duration-slow);
}
@utility z-header {
z-index: var(--ipal-z-header);
}
@utility z-overlay {
z-index: var(--ipal-z-overlay);
}
@utility z-toast {
z-index: var(--ipal-z-toast);
}
@layer base {
body {
background-color: var(--ipal-bg);
color: var(--ipal-text);
font-family: var(--ipal-font-body);
font-weight: var(--ipal-fw-body);
line-height: var(--ipal-lh-body);
}
h1, h2, h3, h4, h5, h6 {
color: var(--ipal-text-strong);
font-family: var(--ipal-font-heading);
font-weight: var(--ipal-fw-heading);
letter-spacing: var(--ipal-tracking-heading);
line-height: var(--ipal-lh-heading);
}
/* a scope that re-maps the text roles (data-surface="inverse", a nested data-theme panel) also sets its text colour */
[data-surface],
[data-theme] {
color: var(--ipal-text);
}
:focus-visible {
outline: var(--ipal-focus-width) solid var(--ipal-focus);
outline-offset: var(--ipal-focus-offset);
}
}
/* Smooth colours only at the moment the theme switches (applyTheme sets data-theme-switching). */
[data-theme-switching] *,
[data-theme-switching] *::before,
[data-theme-switching] *::after {
transition-duration: var(--ipal-duration) !important;
transition-property: background-color, border-color, color, fill, stroke !important;
transition-timing-function: var(--ipal-ease-in-out) !important;
}