Initial commit — direction A4, design tokens, et package @napps/design-system

Direction artistique explorée (A1-A4), audit complet du kit Figma iOS 27
d'Apple pour calibrer les mécaniques du design system (hiérarchie de texte
par opacité, échelle de fills, deux familles de matière), tokens formalisés
dans tokens.css, et première version du package de composants React.
This commit is contained in:
2026-09-16 11:15:30 +02:00
commit 7878054b70
34 changed files with 26516 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+42
View File
@@ -0,0 +1,42 @@
{
"name": "@napps/design-system",
"version": "0.1.0",
"private": false,
"description": "Identité visuelle et bibliothèque de composants nApps — direction A4 (Précision / Vibrance)",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"style": "./dist/index.css",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./tokens.css": "./dist/index.css"
},
"files": [
"dist"
],
"sideEffects": [
"**/*.css"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
},
"devDependencies": {
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"tsup": "^8.0.0",
"typescript": "^5.5.0"
}
}
@@ -0,0 +1,22 @@
import { ButtonHTMLAttributes, forwardRef } from 'react';
export type ButtonVariant = 'primary' | 'secondary';
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: ButtonVariant;
}
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ variant = 'primary', className, ...props }, ref) => {
const variantClass = variant === 'primary' ? 'btn-primary' : 'btn-secondary';
return (
<button
ref={ref}
className={[variantClass, className].filter(Boolean).join(' ')}
{...props}
/>
);
}
);
Button.displayName = 'Button';
@@ -0,0 +1,15 @@
import { HTMLAttributes, ReactNode } from 'react';
export interface IconBadgeProps extends HTMLAttributes<HTMLDivElement> {
tone?: 'neutral' | 'accent';
children: ReactNode;
}
export function IconBadge({ tone = 'neutral', className, children, ...props }: IconBadgeProps) {
const toneClass = tone === 'accent' ? 'icon-badge--accent' : 'icon-badge--neutral';
return (
<div className={['icon-badge', toneClass, className].filter(Boolean).join(' ')} {...props}>
{children}
</div>
);
}
@@ -0,0 +1,19 @@
import { HTMLAttributes, ReactNode } from 'react';
export interface ListRowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
title: ReactNode;
subtitle?: ReactNode;
trailing?: ReactNode;
}
export function ListRow({ title, subtitle, trailing, className, ...props }: ListRowProps) {
return (
<div className={['list-row', className].filter(Boolean).join(' ')} {...props}>
<div style={{ flex: 1, minWidth: 0 }}>
<div className="list-row__title">{title}</div>
{subtitle && <div className="list-row__subtitle">{subtitle}</div>}
</div>
{trailing && <div>{trailing}</div>}
</div>
);
}
@@ -0,0 +1,42 @@
import { useId } from 'react';
export interface SegmentedControlOption {
label: string;
value: string;
}
export interface SegmentedControlProps {
options: SegmentedControlOption[];
value: string;
onChange: (value: string) => void;
'aria-label': string;
}
export function SegmentedControl({ options, value, onChange, ...props }: SegmentedControlProps) {
const name = useId();
return (
<div className="segmented-control" role="radiogroup" aria-label={props['aria-label']}>
{options.map((option) => {
const selected = option.value === value;
return (
<label
key={option.value}
className={['segmented-control__item', selected && 'segmented-control__item--selected']
.filter(Boolean)
.join(' ')}
>
<input
type="radio"
name={name}
value={option.value}
checked={selected}
onChange={() => onChange(option.value)}
style={{ position: 'absolute', opacity: 0, pointerEvents: 'none' }}
/>
{option.label}
</label>
);
})}
</div>
);
}
@@ -0,0 +1,28 @@
import { ElementType, HTMLAttributes, ReactNode } from 'react';
export type SurfaceLevel = 'page' | 'grouped' | 'nested';
export type MaterialVariant = 'control' | 'panel';
export interface SurfaceProps extends HTMLAttributes<HTMLElement> {
level?: SurfaceLevel;
material?: MaterialVariant;
as?: ElementType;
children: ReactNode;
}
/**
* Couche de fond. `level` suit la hiérarchie page → grouped → nested (couleur,
* jamais d'ombre). `material` superpose une des deux recettes de verre —
* "control" pour un élément flottant isolé, "panel" pour une grande surface
* de dialogue — au lieu du niveau de couleur.
*/
export function Surface({ level = 'grouped', material, as: Component = 'div', className, children, ...props }: SurfaceProps) {
const classes = material
? [`material-${material}`]
: [`surface-${level}`];
return (
<Component className={[...classes, className].filter(Boolean).join(' ')} {...props}>
{children}
</Component>
);
}
@@ -0,0 +1,49 @@
import { ElementType, HTMLAttributes, ReactNode } from 'react';
export type TextVariant =
| 'large-title'
| 'title1'
| 'title2'
| 'title3'
| 'headline'
| 'body'
| 'callout'
| 'subheadline'
| 'footnote'
| 'caption1'
| 'caption2';
export type TextColor = 'primary' | 'secondary' | 'tertiary' | 'quaternary';
const defaultElement: Record<TextVariant, ElementType> = {
'large-title': 'h1',
title1: 'h1',
title2: 'h2',
title3: 'h3',
headline: 'h4',
body: 'p',
callout: 'p',
subheadline: 'p',
footnote: 'p',
caption1: 'span',
caption2: 'span',
};
export interface TextProps extends HTMLAttributes<HTMLElement> {
variant?: TextVariant;
color?: TextColor;
as?: ElementType;
children: ReactNode;
}
export function Text({ variant = 'body', color = 'primary', as, className, children, ...props }: TextProps) {
const Component = as ?? defaultElement[variant];
return (
<Component
className={[`text-${variant}`, `text-${color}`, className].filter(Boolean).join(' ')}
{...props}
>
{children}
</Component>
);
}
@@ -0,0 +1,25 @@
import { InputHTMLAttributes, forwardRef } from 'react';
export type TextFieldProps = InputHTMLAttributes<HTMLInputElement>;
export const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
({ className, style, ...props }, ref) => {
return (
<input
ref={ref}
className={['text-field', 'text-body', className].filter(Boolean).join(' ')}
style={{
border: 'none',
outline: 'none',
width: '100%',
background: 'transparent',
color: 'var(--label-primary)',
...style,
}}
{...props}
/>
);
}
);
TextField.displayName = 'TextField';
@@ -0,0 +1,23 @@
export interface ToggleProps {
checked: boolean;
onChange: (checked: boolean) => void;
disabled?: boolean;
'aria-label': string;
}
export function Toggle({ checked, onChange, disabled, ...props }: ToggleProps) {
return (
<button
type="button"
role="switch"
aria-checked={checked}
aria-label={props['aria-label']}
disabled={disabled}
onClick={() => onChange(!checked)}
className={['toggle', checked && 'toggle--on'].filter(Boolean).join(' ')}
style={{ border: 'none', padding: 0, cursor: disabled ? 'default' : 'pointer', opacity: disabled ? 0.5 : 1 }}
>
<span className="toggle__knob" />
</button>
);
}
+25
View File
@@ -0,0 +1,25 @@
import './tokens.css';
export { Button } from './components/Button';
export type { ButtonProps, ButtonVariant } from './components/Button';
export { SegmentedControl } from './components/SegmentedControl';
export type { SegmentedControlProps, SegmentedControlOption } from './components/SegmentedControl';
export { Toggle } from './components/Toggle';
export type { ToggleProps } from './components/Toggle';
export { TextField } from './components/TextField';
export type { TextFieldProps } from './components/TextField';
export { ListRow } from './components/ListRow';
export type { ListRowProps } from './components/ListRow';
export { IconBadge } from './components/IconBadge';
export type { IconBadgeProps } from './components/IconBadge';
export { Text } from './components/Text';
export type { TextProps, TextVariant, TextColor } from './components/Text';
export { Surface } from './components/Surface';
export type { SurfaceProps, SurfaceLevel, MaterialVariant } from './components/Surface';
+261
View File
@@ -0,0 +1,261 @@
/*
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;
/* ===== 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 22px;
font: var(--text-body-weight) var(--text-body-size)/var(--text-body-line) var(--font-family);
letter-spacing: var(--text-body-tracking);
}
/* 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 22px;
font: var(--text-body-weight) var(--text-body-size)/var(--text-body-line) var(--font-family);
letter-spacing: var(--text-body-tracking);
}
/* Segmented control */
.segmented-control {
display: inline-flex;
background: var(--fill-tertiary);
border-radius: var(--radius-pill);
padding: 2px;
gap: 2px;
}
.segmented-control__item {
padding: 3px 12px;
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: 2px; left: 2px;
}
.toggle--on .toggle__knob { left: auto; right: 2px; }
/* List row */
.list-row {
border-top: 1px solid var(--separator);
padding: 0 16px;
min-height: 52px;
display: flex; align-items: center;
}
.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); }
/* Text field */
.text-field {
border-top: 1px solid var(--separator);
padding: 16px;
min-height: 52px;
}
.text-field--placeholder { color: var(--label-tertiary); }
.text-field__cursor { width: 2px; height: 22px; border-radius: 10px; background: var(--napps-accent); }
/* 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); }
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020", "DOM"],
"jsx": "react-jsx",
"module": "ESNext",
"moduleResolution": "Bundler",
"declaration": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist"
},
"include": ["src"]
}
+12
View File
@@ -0,0 +1,12 @@
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
splitting: false,
sourcemap: true,
clean: true,
external: ['react', 'react-dom'],
injectStyle: false,
});