Files
design-system/tokens.css
T
nathanduquet dc74b1b97b v0.1.3 — états d'interaction, tailles compactes, tokens d'espacement, ColorPicker
Corrige 4 lacunes remontées par l'usage réel (app Cars), applicables à toutes
les apps consommant le design system :

- Hover/pressé/focus-visible sur Button, Select, Checkbox, Radio, Toggle,
  TabBar item, et ListRow (rendue en <button> avec onClick, focus clavier
  correct). Couleurs dérivées des tokens existants (color-mix, filter),
  aucune nouvelle valeur brute — pas de vérification dark distincte requise.
- Prop size="compact" sur Button/Select/TextField (~34px, recette du Search
  Field audité) en plus de size="regular" (comportement historique
  inchangé, zéro régression pour les apps déjà en prod).
- Échelle --space-1 (2px) à --space-8 (48px), dérivée des valeurs exactes
  du kit audité (space-4=14px, space-6=20px), composants existants migrés
  dessus.
- ColorPicker (18e composant) : déclencheur rond, palette fermée ou input
  natif selon la prop options.

package.json racine et packages/design-system/package.json synchronisés en
0.1.3.
2026-09-18 19:04:48 +02:00

544 lines
22 KiB
CSS
Executable File

/*
nApps — Design Tokens (v1)
Direction retenue : A4 — Précision / Vibrance
Source : audit du kit Figma "iOS and iPadOS 27 (Community)" — voir figma-kit-audit.md
Principe : les MÉCANIQUES (hiérarchie par opacité, échelle de fills, deux familles de
matière) sont reprises du vrai système Apple. Les VALEURS de marque (accent, typographie,
rayons) restent propres à nApps — jamais de copie de SF Pro / SF Symbols / bleu système.
*/
:root {
/* ===== Accent — propre à nApps, jamais le bleu système Apple (#0088FF) ===== */
--napps-accent: #0B6CFF;
--napps-success: #1FA968;
--napps-warning: #D68C1B;
--napps-error: #E6483D;
/* ===== Labels — hiérarchie par OPACITÉ du noir, pas par des gris séparés =====
Découverte de l'audit : Apple encode primary/secondary/tertiary en assombrissant
un seul noir, jamais avec une palette de gris. Un token qui s'adapte à n'importe
quel fond au lieu d'une variante par contexte. */
--label-primary: rgba(0, 0, 0, 1);
--label-secondary: rgba(0, 0, 0, 0.6);
--label-tertiary: rgba(0, 0, 0, 0.3);
--label-quaternary: rgba(0, 0, 0, 0.18);
/* ===== Fills — fonds de contrôle translucides, 3 paliers d'opacité =====
primary > secondary > tertiary : plus une surface est "au premier plan"
(un bouton qu'on presse), plus l'opacité est haute. */
--fill-primary: rgba(0, 0, 0, 0.2);
--fill-secondary: rgba(0, 0, 0, 0.16);
--fill-tertiary: rgba(0, 0, 0, 0.12);
--separator: rgba(0, 0, 0, 0.1);
/* ===== Surfaces — hiérarchie de fond par couleur, PAS par ombre =====
page → groupée → imbriquée. Jamais d'ombre pour distinguer les niveaux. */
--bg-page: #F5F6F9;
--bg-grouped: #FFFFFF;
--bg-nested: #EDEFF3;
/* ===== Rayons ===== */
--radius-pill: 999px;
--radius-card: 16px;
--radius-card-lg: 20px;
--radius-sheet-top: 24px;
--radius-sheet-bottom: 32px;
/* ===== Cible tactile minimale ===== */
--tap-target-min: 44px;
--control-height-compact: 34px;
/* ===== Espacement — dérivé des valeurs réellement observées dans le kit
audité, pas d'une grille 4pt appliquée mécaniquement. --space-4 (14px)
vient exactement du padding de l'Action Sheet/Alert card ; --space-5
(16px) du padding des List Row/Text Field/Toolbar ; --space-6 (20px)
du padding horizontal du bouton Bordered-Prominent Large. --space-7/8
étendent la base à 6 crans demandée pour couvrir les grands espacements
déjà en usage (Empty State). Théorique et sans dépendance au thème —
aucune valeur dark distincte n'est nécessaire ici. */
--space-1: 2px;
--space-2: 4px;
--space-3: 8px;
--space-4: 14px;
--space-5: 16px;
--space-6: 20px;
--space-7: 24px;
--space-8: 48px;
/* ===== Typographie — échelle réelle (points Apple), police nApps (Manrope) =====
Taille/graisse/interligne/tracking vérifiés sur le kit — la hiérarchie se fait
autant par le POIDS que par la taille (Headline et Body partagent 17pt). */
--font-family: 'Manrope', sans-serif;
--text-large-title-size: 34px; --text-large-title-line: 41px; --text-large-title-weight: 800; --text-large-title-tracking: -0.02em;
--text-title1-size: 28px; --text-title1-line: 34px; --text-title1-weight: 700;
--text-title2-size: 22px; --text-title2-line: 28px; --text-title2-weight: 700;
--text-title3-size: 20px; --text-title3-line: 25px; --text-title3-weight: 600;
--text-headline-size: 17px; --text-headline-line: 22px; --text-headline-weight: 700; --text-headline-tracking: -0.43px;
--text-body-size: 17px; --text-body-line: 22px; --text-body-weight: 400; --text-body-tracking: -0.43px;
--text-callout-size: 16px; --text-callout-line: 21px; --text-callout-weight: 400;
--text-subheadline-size: 15px; --text-subheadline-line: 20px; --text-subheadline-weight: 400;
--text-footnote-size: 13px; --text-footnote-line: 18px; --text-footnote-weight: 400;
--text-caption1-size: 12px; --text-caption1-line: 16px; --text-caption1-weight: 400;
--text-caption2-size: 11px; --text-caption2-line: 13px; --text-caption2-weight: 400;
}
/* ============================================================
DARK MODE — les tokens ne sont jamais une simple inversion.
Découverte de l'audit : fills/secondary passe de 16% à 32% en
dark (pas juste "même valeur sur fond sombre") ; les surfaces
s'ÉCLAIRCISSENT en montant (page < groupée < imbriquée), à
l'inverse du light. Chaque token dark est vérifié, pas déduit.
============================================================ */
:root[data-theme="dark"] {
--napps-accent: #4C93FF;
--napps-success: #43C283;
--napps-warning: #E8AC52;
--napps-error: #F17B70;
--label-primary: rgba(255, 255, 255, 1);
--label-secondary: rgba(255, 255, 255, 0.6);
--label-tertiary: rgba(255, 255, 255, 0.3);
--label-quaternary: rgba(255, 255, 255, 0.18);
--fill-primary: rgba(255, 255, 255, 0.24);
--fill-secondary: rgba(255, 255, 255, 0.32);
--fill-tertiary: rgba(255, 255, 255, 0.16);
--separator: rgba(255, 255, 255, 0.12);
--bg-page: #15171C;
--bg-grouped: #1D1F26;
--bg-nested: #262930;
}
/* ============================================================
MATÉRIAUX — DEUX familles seulement (pas une par composant) :
1. "control" — bouton flottant, barre d'outils, capsule isolée
2. "panel" — grande surface de dialogue (feuille, menu contextuel)
============================================================ */
.material-control {
background: rgba(255, 255, 255, 0.55);
backdrop-filter: blur(46px) saturate(1.6);
-webkit-backdrop-filter: blur(46px) saturate(1.6);
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.6),
inset 0 -1px 0 rgba(0, 0, 0, 0.04),
0 8px 15px rgba(0, 0, 0, 0.02);
}
:root[data-theme="dark"] .material-control {
background: rgba(38, 41, 48, 0.5);
backdrop-filter: blur(46px) saturate(1.4);
-webkit-backdrop-filter: blur(46px) saturate(1.4);
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.06),
inset 0 -1px 0 rgba(0, 0, 0, 0.3),
0 8px 15px rgba(0, 0, 0, 0.35);
}
.material-panel {
background: rgba(255, 255, 255, 0.85);
backdrop-filter: blur(30px);
-webkit-backdrop-filter: blur(30px);
box-shadow: 0 8px 48px rgba(0, 0, 0, 0.25);
}
:root[data-theme="dark"] .material-panel {
background: rgba(20, 20, 20, 0.85);
backdrop-filter: blur(30px);
-webkit-backdrop-filter: blur(30px);
box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5);
}
/* ============================================================
COMPOSANTS de référence — construits uniquement à partir des
tokens ci-dessus. Aucune valeur ad hoc.
============================================================ */
/* Bouton primaire (= Bordered-Prominent d'Apple) */
.btn-primary {
background: var(--napps-accent);
color: #FFFFFF;
border: none;
border-radius: var(--radius-pill);
min-height: var(--tap-target-min);
padding: 0 var(--space-6);
font: var(--text-body-weight) var(--text-body-size)/var(--text-body-line) var(--font-family);
letter-spacing: var(--text-body-tracking);
}
.btn-primary--compact {
min-height: var(--control-height-compact);
padding: 0 var(--space-4);
font-size: var(--text-subheadline-size);
}
/* Bouton secondaire discret (= Bordered d'Apple — PAS un contour) */
.btn-secondary {
background: var(--fill-tertiary);
color: var(--napps-accent);
border: none;
border-radius: var(--radius-pill);
min-height: var(--tap-target-min);
padding: 0 var(--space-6);
font: var(--text-body-weight) var(--text-body-size)/var(--text-body-line) var(--font-family);
letter-spacing: var(--text-body-tracking);
}
.btn-secondary--compact {
min-height: var(--control-height-compact);
padding: 0 var(--space-4);
font-size: var(--text-subheadline-size);
}
/* Segmented control */
.segmented-control {
display: inline-flex;
background: var(--fill-tertiary);
border-radius: var(--radius-pill);
padding: var(--space-1);
gap: var(--space-1);
}
.segmented-control__item {
padding: 3px var(--space-4);
border-radius: var(--radius-pill);
font-size: 13.3px;
font-weight: 510;
color: var(--label-primary);
min-height: 28px;
display: flex;
align-items: center;
}
.segmented-control__item--selected {
background: var(--bg-grouped);
font-weight: 600;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
/* Toggle */
.toggle {
width: 64px;
height: 28px;
border-radius: var(--radius-pill);
background: var(--label-tertiary);
position: relative;
}
.toggle--on { background: var(--napps-success); }
.toggle__knob {
width: 24px; height: 24px;
border-radius: var(--radius-pill);
background: #FFFFFF;
position: absolute; top: var(--space-1); left: var(--space-1);
}
.toggle--on .toggle__knob { left: auto; right: var(--space-1); }
/* List row */
.list-row {
border-top: 1px solid var(--separator);
padding: 0 var(--space-5);
min-height: 52px;
display: flex; align-items: center;
width: 100%;
text-align: left;
background: none;
font-family: inherit;
}
.list-row__title { font-size: var(--text-body-size); color: var(--label-primary); }
.list-row__subtitle { font-size: var(--text-subheadline-size); color: var(--label-secondary); }
.list-row--interactive { cursor: pointer; }
/* Text field */
.text-field {
border: none;
border-top: 1px solid var(--separator);
outline: none;
width: 100%;
background: transparent;
color: var(--label-primary);
padding: var(--space-5);
min-height: 52px;
}
.text-field--placeholder { color: var(--label-tertiary); }
.text-field__cursor { width: 2px; height: 22px; border-radius: 10px; background: var(--napps-accent); }
.text-field--compact {
border-top: none;
background: var(--fill-secondary);
border-radius: var(--radius-pill);
min-height: var(--control-height-compact);
padding: 0 var(--space-4);
}
/* Empty state — badge circulaire réutilisable (Activity View + Empty State du kit) */
.icon-badge {
width: 50px; height: 50px;
border-radius: var(--radius-pill);
display: flex; align-items: center; justify-content: center;
}
.icon-badge--neutral { background: var(--fill-tertiary); color: var(--label-primary); }
.icon-badge--accent { background: color-mix(in srgb, var(--napps-accent) 15%, transparent); color: var(--napps-accent); }
/* ============================================================
SURFACES — hiérarchie de fond, jamais d'ombre pour distinguer
les niveaux (voir "Couches de couleur" dans les planches A4).
============================================================ */
.surface-page { background: var(--bg-page); }
.surface-grouped { background: var(--bg-grouped); border-radius: var(--radius-card); }
.surface-nested { background: var(--bg-nested); border-radius: calc(var(--radius-card) - 4px); }
/* ============================================================
TYPOGRAPHIE — une classe par échelon. La hiérarchie se lit
dans le POIDS autant que dans la taille (headline == body en
taille, 17px, seul le poids change).
============================================================ */
.text-large-title { font: var(--text-large-title-weight) var(--text-large-title-size)/var(--text-large-title-line) var(--font-family); letter-spacing: var(--text-large-title-tracking); margin: 0; }
.text-title1 { font: var(--text-title1-weight) var(--text-title1-size)/var(--text-title1-line) var(--font-family); margin: 0; }
.text-title2 { font: var(--text-title2-weight) var(--text-title2-size)/var(--text-title2-line) var(--font-family); margin: 0; }
.text-title3 { font: var(--text-title3-weight) var(--text-title3-size)/var(--text-title3-line) var(--font-family); margin: 0; }
.text-headline { font: var(--text-headline-weight) var(--text-headline-size)/var(--text-headline-line) var(--font-family); letter-spacing: var(--text-headline-tracking); margin: 0; }
.text-body { font: var(--text-body-weight) var(--text-body-size)/var(--text-body-line) var(--font-family); letter-spacing: var(--text-body-tracking); margin: 0; }
.text-callout { font: var(--text-callout-weight) var(--text-callout-size)/var(--text-callout-line) var(--font-family); margin: 0; }
.text-subheadline { font: var(--text-subheadline-weight) var(--text-subheadline-size)/var(--text-subheadline-line) var(--font-family); margin: 0; }
.text-footnote { font: var(--text-footnote-weight) var(--text-footnote-size)/var(--text-footnote-line) var(--font-family); margin: 0; }
.text-caption1 { font: var(--text-caption1-weight) var(--text-caption1-size)/var(--text-caption1-line) var(--font-family); margin: 0; }
.text-caption2 { font: var(--text-caption2-weight) var(--text-caption2-size)/var(--text-caption2-line) var(--font-family); margin: 0; }
.text-primary { color: var(--label-primary); }
.text-secondary { color: var(--label-secondary); }
.text-tertiary { color: var(--label-tertiary); }
.text-quaternary { color: var(--label-quaternary); }
/* ============================================================
CARD — surface groupée standard, contenu libre.
============================================================ */
.card {
background: var(--bg-grouped);
border-radius: var(--radius-card-lg);
padding: var(--space-5);
}
/* ============================================================
BADGE — pastille de statut, jamais seul signal (toujours du texte).
============================================================ */
.badge {
display: inline-flex;
align-items: center;
gap: var(--space-2);
padding: 3px var(--space-3);
border-radius: 8px;
font-size: var(--text-caption1-size);
font-weight: 600;
white-space: nowrap;
}
.badge--neutral { background: var(--fill-tertiary); color: var(--label-primary); }
.badge--accent { background: color-mix(in srgb, var(--napps-accent) 12%, transparent); color: var(--napps-accent); }
.badge--success { background: color-mix(in srgb, var(--napps-success) 15%, transparent); color: var(--napps-success); }
.badge--warning { background: color-mix(in srgb, var(--napps-warning) 15%, transparent); color: var(--napps-warning); }
.badge--error { background: color-mix(in srgb, var(--napps-error) 15%, transparent); color: var(--napps-error); }
/* ============================================================
FORMULAIRES AVANCÉS — checkbox, radio, select.
Même échelle de fill que le reste (fill-tertiary au repos).
============================================================ */
.checkbox, .radio {
width: 22px; height: 22px;
flex-shrink: 0;
display: inline-flex; align-items: center; justify-content: center;
border: none; cursor: pointer; padding: 0;
background: var(--fill-tertiary);
color: transparent;
}
.checkbox { border-radius: 6px; }
.radio { border-radius: var(--radius-pill); }
.checkbox--checked, .radio--checked { background: var(--napps-accent); color: #FFFFFF; }
.checkbox:disabled, .radio:disabled { opacity: 0.5; cursor: default; }
.select-wrapper { position: relative; }
.select {
appearance: none; -webkit-appearance: none;
width: 100%;
border: none;
border-top: 1px solid var(--separator);
background: transparent;
padding: var(--space-5) 32px var(--space-5) 0;
font: var(--text-body-weight) var(--text-body-size)/var(--text-body-line) var(--font-family);
color: var(--label-primary);
cursor: pointer;
}
.select-chevron {
position: absolute; right: var(--space-2); top: 50%; transform: translateY(-50%);
pointer-events: none;
color: var(--label-tertiary);
font-size: 12px;
}
/* Compacte — reprend la recette du Search Field du kit audité (fond
fill-secondary en pilule) plutôt que la ligne à hairline du regular,
adaptée aux barres de filtres / actions inline de liste. */
.select--compact {
border-top: none;
background: var(--fill-secondary);
border-radius: var(--radius-pill);
min-height: var(--control-height-compact);
padding: 0 var(--space-6) 0 var(--space-4);
}
.select-wrapper--compact .select-chevron { right: var(--space-3); }
/* ============================================================
FEEDBACK — spinner, empty state, dialog (verre de panneau).
============================================================ */
.spinner {
border-radius: var(--radius-pill);
border: 2px solid var(--fill-tertiary);
border-top-color: var(--label-secondary);
animation: napps-spin 0.7s linear infinite;
display: inline-block;
}
.spinner--small { width: 14px; height: 14px; border-width: 2px; }
.spinner--regular { width: 20px; height: 20px; border-width: 2px; }
.spinner--large { width: 35px; height: 35px; border-width: 3px; }
@keyframes napps-spin { to { transform: rotate(360deg); } }
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: var(--space-4);
padding: var(--space-8) var(--space-7);
}
.dialog-overlay {
position: fixed; inset: 0;
background: rgba(0, 0, 0, 0.4);
display: flex; align-items: center; justify-content: center;
padding: var(--space-6);
z-index: 1000;
}
.dialog {
width: 100%; max-width: 270px;
border-radius: 20px;
padding: var(--space-4);
display: flex; flex-direction: column; gap: var(--space-4);
text-align: center;
}
.dialog__title { font: var(--text-headline-weight) var(--text-headline-size)/var(--text-headline-line) var(--font-family); color: var(--label-primary); margin: 0; }
.dialog__message { font: var(--text-body-weight) var(--text-body-size)/var(--text-body-line) var(--font-family); color: var(--label-primary); margin: 0; }
.dialog__actions { display: flex; flex-direction: column; gap: var(--space-3); }
.dialog__action {
border: none;
border-radius: var(--radius-pill);
min-height: var(--tap-target-min);
font: 600 var(--text-body-size)/var(--text-body-line) var(--font-family);
cursor: pointer;
}
.dialog__action--default { background: var(--napps-accent); color: #FFFFFF; }
.dialog__action--cancel { background: var(--fill-secondary); color: var(--label-primary); }
.dialog__action--destructive { background: var(--fill-secondary); color: var(--napps-error); }
/* ============================================================
NAVIGATION — tab bar flottante et toolbar, toutes deux en
"verre de contrôle" (.material-control), jamais en aplat.
============================================================ */
.tab-bar { display: inline-flex; gap: var(--space-2); padding: 6px; }
.tab-bar__item {
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
min-width: 56px; min-height: var(--tap-target-min);
border-radius: var(--radius-pill);
font-size: var(--text-caption2-size);
font-weight: 600;
color: var(--label-secondary);
background: none; border: none; cursor: pointer;
}
.tab-bar__item--active { color: var(--napps-accent); }
.toolbar {
display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
padding: 0 6px 0 var(--space-5);
min-height: 52px;
border-radius: var(--radius-pill);
}
.toolbar__title { font: var(--text-headline-weight) var(--text-headline-size)/var(--text-headline-line) var(--font-family); color: var(--label-primary); }
.toolbar__actions { display: flex; align-items: center; gap: var(--space-2); }
/* ============================================================
ÉTATS D'INTERACTION — hover (pointeur uniquement, jamais collé
au tactile), pressé (discret, pas d'animation voyante), focus
clavier visible (focus-visible seulement, jamais au clic souris).
Limité strictement aux contrôles qui en manquaient : btn-primary,
btn-secondary, select, checkbox, radio, toggle, tab-bar__item,
list-row (variante --interactive). Toutes les couleurs viennent de
tokens déjà vérifiés indépendamment en dark — aucune nouvelle
valeur de couleur brute n'est introduite ici.
============================================================ */
:where(.btn-primary, .btn-secondary, .select, .checkbox, .radio, .toggle, .tab-bar__item, .list-row--interactive) {
transition: opacity 120ms ease, transform 120ms ease, background-color 120ms ease, filter 120ms ease;
}
@media (hover: hover) {
.btn-primary:hover { background: color-mix(in srgb, var(--napps-accent) 88%, black); }
.btn-secondary:hover { background: var(--fill-secondary); }
.select:hover { background: var(--fill-tertiary); }
.checkbox:not(.checkbox--checked):hover:not(:disabled),
.radio:not(.radio--checked):hover:not(:disabled) { background: var(--fill-secondary); }
.checkbox--checked:hover:not(:disabled),
.radio--checked:hover:not(:disabled) { background: color-mix(in srgb, var(--napps-accent) 88%, black); }
.toggle:hover { filter: brightness(0.96); }
.tab-bar__item:hover:not(.tab-bar__item--active) { color: var(--label-primary); }
.list-row--interactive:hover { background: var(--fill-tertiary); }
}
.btn-primary:active,
.btn-secondary:active,
.select:active,
.checkbox:active:not(:disabled),
.radio:active:not(:disabled),
.toggle:active,
.tab-bar__item:active,
.list-row--interactive:active {
opacity: 0.7;
transform: scale(0.97);
}
:where(.btn-primary, .btn-secondary, .select, .checkbox, .radio, .toggle, .tab-bar__item, .list-row--interactive):focus-visible {
outline: 2px solid var(--napps-accent);
outline-offset: 2px;
}
/* ============================================================
COLOR PICKER — sélecteur rond, même logique que icon-badge mais
dédié à afficher/choisir une couleur arbitraire (catégorie,
étiquette, tag). L'anneau vient de tokens de surface déjà
vérifiés en dark (bg-grouped, separator), pas de nouvelle valeur.
============================================================ */
.color-picker { display: inline-flex; gap: var(--space-3); flex-wrap: wrap; }
.color-swatch {
position: relative;
width: 28px; height: 28px;
border-radius: var(--radius-pill);
border: 2px solid var(--bg-grouped);
box-shadow: 0 0 0 1px var(--separator);
padding: 0;
cursor: pointer;
flex-shrink: 0;
display: inline-flex;
align-items: center;
justify-content: center;
}
.color-swatch--selected {
box-shadow: 0 0 0 2px var(--bg-grouped), 0 0 0 4px var(--napps-accent);
}
.color-swatch:focus-visible {
outline: 2px solid var(--napps-accent);
outline-offset: 2px;
}
.color-swatch__check {
color: #FFFFFF;
filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));
}
.color-picker__input {
position: absolute; inset: 0;
opacity: 0;
cursor: pointer;
border: none;
padding: 0;
width: 100%;
height: 100%;
}