Skip to content

Commit ccbda14

Browse files
authored
ci(.github): add repo and react-icons instructions to help automate assets/ updates (#887)
* chore: update package lock after release * ci: add copilot instruction files with special one for react-icons * ci: add copilot workflow * chore: update codeowners
1 parent 557be19 commit ccbda14

File tree

5 files changed

+185
-5
lines changed

5 files changed

+185
-5
lines changed

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/.github/ISSUE_TEMPLATE/01-react-icons-bug-report.yml @microsoft/cxe-prg
22
/.github/ISSUE_TEMPLATE/02-react-icons-feature-request.yml @microsoft/cxe-prg
3+
/.github/react-icons.instructions.md @microsoft/cxe-prg
4+
/.github/workflows/copilot-setup-steps.yml @microsoft/cxe-prg
5+
/.github/workflows/pr.yml @microsoft/cxe-prg @spencer-nelson
36

47
## packages
58
packages/icon-app @microsoft/cxe-prg
@@ -14,6 +17,8 @@ packages/react-native-icons @praveen970
1417
android/ @praveen970
1518
flutter/ @nickromano
1619
ios/ @nickromano
20+
package-lock.json @microsoft/cxe-prg
21+
package.json @microsoft/cxe-prg
1722

1823
## Assets
1924
assets/ @spencer-nelson @willchavez

.github/copilot-instructions.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# AI Assistant Project Guide: Fluent UI System Icons
2+
3+
Purpose: Enable rapid, correct contributions across multi-platform icon packages (web React, React Native, SVG assets/sprites, Android, iOS, Flutter) generated from a single `assets/` source.
4+
5+
## Core Architecture
6+
- Targeted package instructions: see `./react-icons.instructions.md` (auto-applies when working inside `packages/react-icons`).
7+
- Source of truth: Raw SVG design assets in `assets/` (folder names = icon groups). Each icon has metadata (directionality handled via RTL processing scripts) and fixed primary fill `#212121` (validation enforced in CI).
8+
- Generated outputs per platform:
9+
- React web: `@fluentui/react-icons` → JSX components + optional font implementation. Build pipeline: asset -> optimized SVG (`intermediate/`) -> component TS in `src/` -> compiled output in `lib/` (ESM) & `lib-cjs/` (CJS) + `fonts/` bundle + merged `metadata.json`.
10+
- React Native: Similar SVG -> `intermediate/` -> RN components in `src/`; styling more limited (no Griffel styling utilities).
11+
- Plain SVG package: `@fluentui/svg-icons` emits optimized renamed raw SVGs in `packages/svg-icons/icons/` following `[name]_[size]_[style].svg`.
12+
- Sprites: `@fluentui/svg-sprites` converts single SVGs to per-icon sprite files: `<icon>.sprite.svg` for on-demand `<use href="/sprites/{id}.sprite.svg#id" />` consumption.
13+
- Fonts: Generated via `importer/generateFont.js` (Regular/Filled/Light/Resizable) feeding React font condition and Flutter/iOS/Android.
14+
- Native (Android/iOS/Flutter): Produced by `importer` deployment scripts (`deploy:android`, `deploy:ios`, `deploy:flutter`) which transform assets into vector drawables / PDF assets / Dart classes.
15+
16+
## Key Workflows (Local)
17+
- Install deps (root + packages): `npm ci` at repo root (Yarn/PNPM NOT configured; uses npm workspaces).
18+
- React icons build (full): `cd packages/react-icons && npm run build` (runs font + svg generation + JS emission). Quick validation only: `npm run build:verify` (Vitest metadata checks).
19+
- React Native icons build: `cd packages/react-native-icons && npm run build`.
20+
- SVG raw assets: `cd packages/svg-icons && npm run build`.
21+
- Sprites: `cd packages/svg-sprites && npm run build`.
22+
- Importer operations (multi-platform generation & version bumps): `cd importer && npm run deploy:android|deploy:ios|deploy:fonts`.
23+
- Clean React icons intermediates: `npm run clean` in each package (removes generated `lib*` and `intermediate/`). Avoid manual deletion to keep scripts deterministic.
24+
25+
## CI Expectations / Pitfalls
26+
- PR validation (`.github/workflows/pr.yml`) enforces: (1) asset folder names not ending with space; (2) all non-color SVGs include `fill="#212121"` (except `*_color.svg` which are skipped). Maintain fill when editing SVGs; use scripts (`optimize`, `unfill`) instead of hand-edits.
27+
- React build job runs `lint`, full `build`, and `build:verify`; keep TypeScript version constraints (TS ~4.1) when adding language features.
28+
- iOS/Android build jobs rely on importer output; ensure importer scripts still produce expected file layout when modifying generation logic.
29+
30+
## Conventions & Patterns
31+
- Icon naming (React / RN): `AccessTimeFilled` (state suffix) and sized variants `AccessTime24Filled`. General (resizable) variant without size preferred for flexible UI.
32+
- Plain SVG file naming: lowercase + underscores from original asset folder; pattern: `mail_24_filled.svg`.
33+
- Sprite consumption id pattern: `{name}_{size}_{style}` (mirrors SVG file stem) reused inside `#symbol` id.
34+
- Directionality: `rtlMetadata.js` generates `intermediate/rtl.json`; keep this in sync when adding new directional icons. Metadata merging occurs via `convert:merge-metadata`.
35+
- Fonts: Four iconType variants (Regular/Filled/Light/Resizable). New styles require updating font generation pipeline (all `generate:font-*` scripts and metadata merge).
36+
- Export map (`packages/react-icons/package.json` `exports`) uses conditional `fluentIconFont`; when adjusting build output paths, update both `lib` and `lib-cjs` mappings consistently.
37+
- React styling: Components accept `primaryFill`, `className`; compound icon pattern uses `bundleIcon(Filled, Regular)` plus `iconFilledClassName` / `iconRegularClassName` for state toggling.
38+
39+
## Typical Change Flow (Add / Update Icons)
40+
1. Add raw SVG(s) to appropriate new/existing folder in `assets/` (ensure fill `#212121`).
41+
2. If direction-specific, set metadata / ensure RTL logic recognizes (inspect or extend `rtlMetadata.js`).
42+
3. Run relevant package builds (e.g., `packages/react-icons` build) to regenerate components and fonts.
43+
4. Run `npm run build:verify` in React icons to confirm metadata & generation integrity.
44+
5. Commit generated outputs (generated code is tracked—do not manually edit `lib/` outputs; edit sources or generation scripts instead).
45+
6. Let CI validate fills & builds.
46+
47+
## When Modifying Generators
48+
- Prefer changes inside `importer/` scripts (e.g., `generate.js`, `generateFont.js`) to altering per-package build steps; keep script flags consistent (`--source`, `--dest`, `--extension`, `--target`, `--iconType`).
49+
- After script changes, rebuild at least one consumer package to ensure no path/flag regressions.
50+
51+
## Platform-Specific Notes
52+
- React Native: Limited styling (no Griffel). Avoid introducing DOM-specific props.
53+
- iOS: Enum-based access (`UIImage(fluent: .appStore24Filled)`); asset stripping tool in `ios/remove-unused-fluent-icons` must still find & parse asset names—keep naming stable.
54+
- Android: Vector drawable tint placeholder replaced (`@color/fluent_default_icon_tint`) during finalize step; avoid hardcoding other colors.
55+
- Flutter: Icon classes generated from font codepoint JSON; if glyph sets change, regenerate fonts first then Flutter classes.
56+
57+
## Safe Extensions / Additions
58+
- New icon style variant: add generation script, extend metadata merge, update exports if needed.
59+
- New distribution format (e.g., consolidated sprite index): create new package under `packages/` and reuse `importer/generate.js` with new flags.
60+
61+
## Avoid
62+
- Manual edits to generated `lib/`, `lib-cjs/`, `icons/`, `sprites/` files.
63+
- Upgrading TypeScript/Babel broadly without verifying downstream package constraints & CI.
64+
- Introducing SVG fills other than `#212121` (unless *_color.svg purposefully multi-colored).
65+
66+
## Quick Validation Checklist Before PR
67+
- Builds succeed for changed packages.
68+
- No asset directories with trailing spaces.
69+
- All new SVGs pass fill rule.
70+
- React icons `build:verify` passes.
71+
- Metadata (`metadata.json`) updated if generation logic changed.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
applyTo: 'packages/react-icons'
3+
---
4+
5+
# AI Assistant Project Guide: react-icons
6+
Focus: Generation & maintenance of `@fluentui/react-icons` (web React package) from shared `assets/` SVG source.
7+
8+
## Directory Anatomy (package scope)
9+
- `assets/` (root repo): canonical SVG sources (must keep `fill="#212121"`).
10+
- `packages/react-icons/intermediate/`: transient optimized SVG + `rtl.json` (never commit manually; produced by scripts).
11+
- `packages/react-icons/src/`: generated TypeScript icon components + font helpers.
12+
- `packages/react-icons/src/fonts/`: generated font wrapper exports (from codepoint JSON + font TTFs).
13+
- `packages/react-icons/src/utils/fonts/`: raw generation staging (codepoint JSON lives here pre-build).
14+
- `packages/react-icons/tmp/`: transient metadata fragments (`metadata-svg.json`, `metadata-font.json`).
15+
- `packages/react-icons/lib/` & `lib-cjs/`: compiled outputs (ESM/CJS) — committed but NEVER hand‑edit.
16+
17+
## Build Pipeline (expanded)
18+
Full `npm run build` executes, in order:
19+
1. `generate:assets-to-svg` → copy raw SVGs into `intermediate/` (React target naming).
20+
2. `generate:font-*` (parallel) → build four font variants (Regular / Filled / Light / Resizable) into `src/utils/fonts`.
21+
3. `generate:rtl` → produce `intermediate/rtl.json` (directional metadata) via `rtlMetadata.js`.
22+
4. `optimize` → SVGO pass (precision=2) over `intermediate/`.
23+
5. `unfill` → strips explicit `fill="none"` etc so `primaryFill` prop can apply.
24+
6. `convert:svg` → emit per-icon component TS files & SVG metadata JSON.
25+
7. `convert:fonts` → emit font-based component wrappers & font metadata JSON.
26+
8. `convert:merge-metadata` → merge SVG + font metadata → `metadata.json` (public contract consumed by tests/fonts).
27+
9. `build:js` → TypeScript compile + Babel transform into `lib/` & `lib-cjs/`.
28+
29+
Fast checks: `npm run build:verify` (Vitest) validates metadata integrity without regenerating assets if already built.
30+
31+
## Icon Component Conventions
32+
- General (resizable) component: `AccessTimeFilled` / `AccessTimeRegular` (default `1em`, scale via `fontSize`, `height/width`).
33+
- Sized variant: `AccessTime24Filled` (pixel-perfect at that size). Prefer general unless a fixed size is mandated.
34+
- Bundle pattern: `const AccessTime = bundleIcon(AccessTimeFilled, AccessTimeRegular)`; toggle via CSS using `iconFilledClassName` / `iconRegularClassName`.
35+
- Props: `className`, `primaryFill` (overrides default color), standard SVG passthrough (aria, etc.).
36+
37+
## Conditional Font Implementation
38+
- Consumers opt into font path via `resolve.conditionNames` including `"fluentIconFont"` (see package `exports`). Ensure any path changes update ALL export condition blocks (`lib` & `lib-cjs`).
39+
- Font glyph subsets can be auto‑reduced with `@fluentui/react-icons-font-subsetting-webpack-plugin`.
40+
41+
## Typical Change Flow (Add / Update Icons)
42+
1. Add SVG(s) under appropriate group folder in root `assets/` (validate fill color; skip `_color.svg` rule only if multi-colored).
43+
2. If direction-specific asset (LTR/RTL differ), confirm `rtlMetadata.js` covers filename; extend script if new pattern.
44+
3. Run `npm run build` in `packages/react-icons` (or root then `cd` in) to regenerate components + metadata.
45+
4. Run `npm run build:verify` (should succeed; failing usually means duplicate/missing metadata keys after script changes).
46+
5. Commit: added SVG(s) + updated generated outputs (`src/`, `metadata.json`). Avoid partial commits that exclude metadata.
47+
6. Open PR; CI will enforce fill + lint + build.
48+
49+
## Adding / Adjusting Font Variants
50+
- Add new variant by extending `importer/generateFont.js` and adding a `generate:font-<Variant>` script + include in `generate:font` concurrently block.
51+
- Update merge step (`convert:merge-metadata`) if metadata shape changes (keep existing fields stable for consumers).
52+
53+
## Debug & Troubleshooting
54+
- Missing component after build: ensure SVG filename begins with `ic_fluent_` pattern in generated intermediate (run `generate:assets-to-svg` and inspect).
55+
- Wrong direction in RTL: verify entry in `intermediate/rtl.json`; re-run `generate:rtl`.
56+
- Font glyph absent: check corresponding codepoint JSON in `src/utils/fonts`; if missing, regenerate fonts (`generate:font-*`).
57+
- Build is slow during iteration: run only early stages (`npm run generate:assets-to-svg && npm run optimize && npm run convert:svg`) while editing converter scripts, then full build before commit.
58+
59+
## Tests & Lint
60+
- `npm run lint` (ESLint with Griffel rules) — keep TS language features compatible with TS `~4.1.0`.
61+
- `npm run build:verify` (Vitest) — do NOT delete/rename metadata keys without updating test expectations.
62+
63+
## Do / Avoid
64+
Do: Modify generator scripts or assets; re-run full build; commit all related outputs.
65+
Avoid: Manually editing anything inside `lib*/`, `src/fonts/` or generated icon TS files; upgrading TypeScript without cross‑package validation; adding hardcoded colors.
66+
67+
## Quick PR Self-Check
68+
- Added icons have correct fill & naming.
69+
- `build` + `build:verify` pass locally.
70+
- No stray edits to compiled output unrelated to your change (run `git diff --name-only` to inspect).
71+
72+
If anything remains ambiguous, annotate PR with a question so docs & scripts can be refined.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'Copilot Setup Steps'
2+
# Refer: https://docs.github.com/en/enterprise-cloud@latest/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent#preinstalling-tools-or-dependencies-in-copilots-environment
3+
4+
# Allow testing of the setup steps from your repository's "Actions" tab.
5+
on: workflow_dispatch
6+
7+
jobs:
8+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
9+
copilot-setup-steps:
10+
runs-on: ubuntu-latest
11+
12+
# Set the permissions to the lowest permissions possible needed for your steps.
13+
# Copilot will be given its own token for its operations.
14+
permissions:
15+
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
16+
contents: read
17+
18+
# You can define any steps you want, and they will run before the agent starts.
19+
# If you do not check out your code, Copilot will do this for you.
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
cache: 'yarn'
30+
node-version: '20'
31+
32+
- run: npm ci

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)