Skip to content

Commit 4320dd9

Browse files
committed
update instructions for copilot
1 parent 570a781 commit 4320dd9

25 files changed

Lines changed: 1596 additions & 2870 deletions

.github/copilot-instructions.md

Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,57 @@
22
applyTo: "**"
33
---
44

5-
# OUDS Web — AI Agent Instructions
5+
# OUDS Web — Project Context
66

7-
You are working in **OUDS Web** (Orange Unified Design System — Web), a multi-brand design system built as a fork of Bootstrap 5.3.6.
8-
Version: 1.1.0 | Main branch: `ouds/main` | Brands: Orange, Sosh, Orange Compact
7+
**OUDS Web** (Orange Unified Design System — Web) is a multi-brand design system built as a fork of Bootstrap 5.3.6. It serves 3 brands (Orange, Sosh, Orange Compact) from a single codebase where only CSS tokens differ per brand — JavaScript is fully shared.
98

10-
---
11-
12-
## Standards — Apply Always
13-
14-
The following standards define mandatory conventions. Always apply them when writing or reviewing code:
15-
16-
- **[Code Conventions](.packmind/standards/ouds-code-conventions.md)** — HTML/SCSS/JS style rules: `!default` on variables, forbidden direct properties (`border-radius`, `transition`), forbidden values (`border: none`, `lighten()`), token usage, JS no-semicolons, template literals.
17-
18-
- **[Accessibility WCAG 2.2 AAA (with AA fallback)](.packmind/standards/ouds-accessibility-wcag.md)** — Target WCAG 2.2 Level AAA with documented fallback to AA for specific color and UI constraints. Non-negotiable: `@include focus-visible()`, ARIA attributes, `.visually-hidden`, keyboard navigation, 7:1 text contrast (AAA) / 4.5:1 fallback (AA), 44×44px touch targets, RTL support, cognitive accessibility.
19-
20-
- **[Design Token System](.packmind/standards/ouds-design-tokens.md)** — 3-tier hierarchy (raw → semantic → component). Never edit auto-generated files (`_raw.scss`, `_semantic.scss`, `_component.scss`, `_*-custom-props.scss`). Colors via `var(--#{$prefix}color-*)`. New tokens in all 3 brands.
21-
22-
- **[Component Patterns](.packmind/standards/ouds-component-patterns.md)** — CSS custom property declaration at top of class, state overrides via variable overrides, `scss-docs-start/end` markers, `// OUDS mod:` comments, JS BaseComponent pattern.
23-
24-
---
25-
26-
## Commands — Use for Specific Workflows
27-
28-
When the user asks to perform a specific task, load and follow the appropriate command:
29-
30-
- **[ouds-create-component](.packmind/commands/ouds-create-component.md)** — Full step-by-step guide for creating a new SCSS/JS component (SCSS structure, tokens per brand, ARIA, JS boilerplate, tests, docs).
9+
## Quick Reference
3110

32-
- **[ouds-diagnose-error](.packmind/commands/ouds-diagnose-error.md)** — Diagnostic workflow for Stylelint, ESLint, Sass build, CI, token, JS test, and Pa11y errors.
33-
34-
- **[ouds-decision-routing](.packmind/commands/ouds-decision-routing.md)** — 4 decision trees (where to put code, which token, multi-brand updates, testing strategy).
35-
36-
- **[ouds-lookup](.packmind/commands/ouds-lookup.md)** — Quick lookup index: maps any topic to the right standard, command, or skill.
37-
38-
- **[ouds-validate-tokens](.packmind/commands/ouds-validate-tokens.md)** — Read-only audit: cross-brand token presence check and anti-pattern detection for SCSS component files.
11+
| Key | Value |
12+
|---|---|
13+
| Version | 1.1.0 |
14+
| Main branch | `ouds/main` |
15+
| CSS prefix | `--bs-` (via `$prefix`) |
16+
| Build | `npm run dist` |
17+
| Lint | `npm run lint` |
18+
| Tests | `npm run test` |
19+
| Dev servers | `:9001` (orange) · `:9002` (sosh) · `:9003` (orange-compact) |
3920

40-
---
21+
## Critical Constraints
4122

42-
## Skills — Domain Knowledge
23+
These rules are non-negotiable and apply to every contribution:
4324

44-
Load these skills when deep conceptual understanding is needed:
25+
1. **Use tokens, not hardcoded values** — colors, spacing, dimensions all come from the OUDS token system.
26+
2. **Use mixins for `border-radius` and `transition`** — direct CSS properties are forbidden by Stylelint.
27+
3. **Auto-generated token files are read-only** — never edit `_raw.scss`, `_semantic.scss`, `_component.scss`, or `_*-custom-props.scss`. Only `_composite.scss` is hand-editable.
28+
4. **Never commit `dist/`** — build artifacts are generated in CI.
29+
5. **JavaScript lives in `js/src/` only** — never in `packages/<brand>/`.
30+
6. **Colors use CSS custom properties**`var(--#{$prefix}color-*)` enables runtime dark mode switching.
31+
7. **Accessibility is mandatory** — visible `:focus-visible`, ARIA attributes on all interactive elements, `.visually-hidden` for SR content.
4532

46-
- **[ouds-token-strategy](.packmind/skills/ouds-token-strategy.md)** — Full token architecture: pipeline, layer hierarchy, CSS custom property bridge for dark mode, color token dual-track, consumption patterns. Load when asked about tokens, dark mode, or brand differentiation.
33+
## Scoped Instructions
4734

48-
- **[ouds-multi-brand-sync](.packmind/skills/ouds-multi-brand-sync.md)** — 3-brand architecture: what is shared, what differs, when to update all brands, brand entry point pattern, testing multi-brand changes.
35+
Detailed conventions are loaded automatically based on the files you're working on. They live in `.github/instructions/`:
4936

50-
- **[ouds-knowledge-base](.packmind/skills/ouds-knowledge-base.md)** — Full glossary (154 terms), build pipeline, npm scripts reference, CI/CD jobs, release process, and project file map. Load when encountering unfamiliar terms or working on build/infra.
37+
- `scss.instructions.md` — SCSS conventions and patterns
38+
- `javascript.instructions.md` — JS conventions
39+
- `html-accessibility.instructions.md` — HTML structure and WCAG compliance
40+
- `tokens.instructions.md` — Token system rules
41+
- `components.instructions.md` — Component SCSS/JS patterns
42+
- `multi-brand.instructions.md` — Cross-brand synchronization
5143

52-
---
44+
## Workflows
5345

54-
## Critical Constraints (Always Active)
46+
For complex multi-step tasks, follow the dedicated workflow guides:
5547

56-
1. **Never hardcode** colors (`#ff7900`), spacing (`16px`), or dimensions — use OUDS tokens.
57-
2. **Never use `border-radius: X` or `transition: X` directly** — use `@include border-radius()` / `@include transition()`.
58-
3. **Never edit auto-generated token files**: `_raw.scss`, `_semantic.scss`, `_component.scss`, `_*-custom-props.scss` — only `_composite.scss` is editable.
59-
4. **Never commit `dist/`** files — they are build artifacts.
60-
5. **Never put JavaScript** in `packages/<brand>/` — JS is shared via `js/src/`.
61-
6. **Color tokens for dark mode** → always `var(--#{$prefix}color-*)`, never the SCSS variable directly.
62-
7. **Accessibility**: never remove `:focus-visible` styles, always add ARIA attributes to interactive components, never use `display: none` for screen-reader content.
48+
- `workflows/create-component.instructions.md` — Creating a new component
49+
- `workflows/diagnose-errors.instructions.md` — Debugging build/lint/CI errors
50+
- `workflows/validate-tokens.instructions.md` — Auditing token usage
6351

64-
---
52+
## Deep References
6553

66-
## Project Quick Facts
54+
For in-depth architecture knowledge, read the reference docs in `.github/instructions/references/`:
6755

68-
| | |
69-
|---|---|
70-
| CSS prefix | `--bs-` (via `$prefix` in `scss/_config.scss`) |
71-
| Brands | orange, sosh, orange-compact |
72-
| JS components | 15 (all extend `BaseComponent`) |
73-
| Token layers | raw → semantic → composite → component → CSS custom props |
74-
| Build | `npm run dist` (CSS + JS) |
75-
| Lint | `npm run lint` |
76-
| Tests | `npm run test` |
77-
| Dev servers | `:9001` (orange), `:9002` (sosh), `:9003` (orange-compact) |
56+
- `token-architecture.md` — Full token pipeline and layer hierarchy
57+
- `glossary.md` — 154 project-specific terms
58+
- `project-map.md` — File structure, npm scripts, CI/CD jobs
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
name: component-patterns
3+
description: >
4+
SCSS and JavaScript structural patterns for OUDS Web components. Covers CSS custom
5+
property declarations, state management via variable overrides, documentation markers,
6+
icon patterns, and responsive overrides. Applied when working on component files.
7+
applyTo: "scss/_*.scss,scss/forms/_*.scss,js/src/*.js"
8+
---
9+
10+
# Component Patterns
11+
12+
## Core principle
13+
14+
Every component declares CSS custom properties at the top, then consumes them via `var()`. State changes override the *variable*, not the *property*. This creates a single point of truth and enables runtime theming.
15+
16+
---
17+
18+
## SCSS component structure
19+
20+
```scss
21+
// scss/_my-component.scss
22+
23+
// Root-level shared variables (if needed by child components)
24+
#{$ouds-root-selector} {
25+
--#{$prefix}my-component-border-radius: #{$ouds-border-radius-default};
26+
}
27+
28+
.my-component {
29+
// scss-docs-start my-component-css-vars
30+
--#{$prefix}my-component-padding: #{$ouds-my-component-space-padding-block};
31+
--#{$prefix}my-component-color: #{$ouds-color-content-default};
32+
--#{$prefix}my-component-bg: #{$ouds-color-bg-primary};
33+
// scss-docs-end my-component-css-vars
34+
35+
padding: var(--#{$prefix}my-component-padding);
36+
color: var(--#{$prefix}my-component-color);
37+
background-color: var(--#{$prefix}my-component-bg);
38+
@include border-radius(var(--#{$prefix}my-component-border-radius));
39+
@include transition($transition-base);
40+
41+
&:hover {
42+
--#{$prefix}my-component-bg: #{$ouds-color-bg-secondary};
43+
}
44+
45+
&:focus-visible {
46+
@include focus-visible();
47+
}
48+
49+
&:disabled,
50+
&[aria-disabled="true"] {
51+
--#{$prefix}my-component-color: #{$ouds-color-content-disabled};
52+
pointer-events: none;
53+
}
54+
}
55+
56+
// Variants override variables, not properties
57+
.my-component-variant {
58+
--#{$prefix}my-component-bg: #{$ouds-color-surface-brand};
59+
}
60+
```
61+
62+
---
63+
64+
## Key patterns
65+
66+
### State overrides via custom properties
67+
68+
Override the CSS custom property in pseudo-classes/variants — the `var()` references update automatically. This avoids duplicating property declarations.
69+
70+
```scss
71+
// ✓ override the variable
72+
&:hover {
73+
--#{$prefix}chip-bg: #{$ouds-chip-color-bg-unselected-hover};
74+
}
75+
76+
// ✗ re-declaring the property — harder to maintain
77+
&:hover {
78+
background-color: $ouds-chip-color-bg-unselected-hover;
79+
}
80+
```
81+
82+
### Documentation markers
83+
84+
The Astro docs site extracts CSS custom property tables using these markers. Every component's variable block needs them:
85+
86+
```scss
87+
// scss-docs-start badge-css-vars
88+
--#{$prefix}badge-size: #{$value};
89+
// scss-docs-end badge-css-vars
90+
```
91+
92+
### Border-width compensation
93+
94+
Prevent layout shifts when borders change on interaction (e.g., hover adds a thicker border):
95+
96+
```scss
97+
padding: calc(var(--#{$prefix}btn-padding-y) - var(--#{$prefix}btn-border-width))
98+
calc(var(--#{$prefix}btn-padding-x) - var(--#{$prefix}btn-border-width));
99+
```
100+
101+
### Icon pattern (`mask-image`)
102+
103+
Icons use mask-image to inherit color from `currentcolor`:
104+
105+
```scss
106+
&::before {
107+
content: "";
108+
display: inline-block;
109+
background-color: currentcolor;
110+
mask-image: escape-svg(var(--#{$prefix}some-icon));
111+
mask-size: 100%;
112+
mask-repeat: no-repeat;
113+
}
114+
```
115+
116+
### Responsive overrides
117+
118+
Override the custom property at the breakpoint — don't duplicate rulesets:
119+
120+
```scss
121+
//
122+
.component {
123+
--#{$prefix}component-width: #{$mobile-width};
124+
125+
@include media-breakpoint-up(xl) {
126+
--#{$prefix}component-width: #{$desktop-width};
127+
}
128+
}
129+
```
130+
131+
---
132+
133+
## Bootstrap override markers
134+
135+
Every deviation from Bootstrap upstream must be marked for merge visibility:
136+
137+
```scss
138+
display: flex; // OUDS mod: instead of `inline-block`
139+
// OUDS mod: no `@include rfs($btn-font-size, ...)`
140+
141+
// OUDS mod: loading buttons
142+
.btn.loading-indeterminate { ... }
143+
// End mod
144+
```
145+
146+
---
147+
148+
## JavaScript component pattern
149+
150+
See `javascript.instructions.md` for the full BaseComponent structure. Key reminders:
151+
152+
- Extend `BaseComponent`, expose static `NAME` getter
153+
- Use `data-bs-*` attributes for configuration — never inline handlers
154+
- JS lives in `js/src/` only — never in `packages/<brand>/`
155+
- Register in `js/index.esm.js` and `js/index.umd.js`

0 commit comments

Comments
 (0)