Skip to content

Commit f62592e

Browse files
chore(.github): add copilot-instructions.md (#641)
1 parent bfc8775 commit f62592e

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/copilot-instructions.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copilot Instructions for freeCodeCamp UI
2+
3+
## Overview
4+
5+
This is the freeCodeCamp UI component library, built with React and Tailwind CSS. It provides accessible, reusable components for use in freeCodeCamp and other projects. The codebase is designed for easy customization and theming.
6+
7+
## Architecture & Patterns
8+
9+
- All components are in `src/`, each in its own folder (e.g., `src/col/`, `src/button/`).
10+
- Each component folder typically contains:
11+
- `*.tsx`: Component implementation
12+
- `*.stories.tsx`: Storybook stories
13+
- `*.test.tsx`: Jest tests
14+
- `types.ts`: TypeScript types for props
15+
- Components are exported via `src/index.ts`.
16+
- Styles are managed with Tailwind CSS. The main stylesheet is `src/base.css`, built to `dist/base.css`.
17+
- Theming is handled by the `getThemingClass` util.
18+
19+
## Developer Workflows
20+
21+
- **Install dependencies:** `pnpm install`
22+
- **Run Storybook:** `pnpm run storybook` (see components in isolation)
23+
- **Run tests:** `pnpm test` (Jest, Testing Library)
24+
- **Lint:** `pnpm lint`
25+
- **Typecheck:** `pnpm typecheck`
26+
- **Build:** `pnpm run build` (runs clean, CSS build, JS build)
27+
- **Generate new component:** `pnpm run gen-component`
28+
- **Start development:** `pnpm start` (parallel dev:css, dev:js, storybook)
29+
30+
## Testing
31+
32+
- Tests use Jest and React Testing Library.
33+
- CSS imports are stubbed in tests via `__mocks__/styleMock.ts`.
34+
- Use the `should` style for assertions.
35+
36+
## Conventions
37+
38+
- Use only pnpm for package management (`npx only-allow pnpm` enforced).
39+
- All props and types for components are defined in `types.ts` in each component folder.
40+
- Use Tailwind utility classes for layout and spacing. For RTL support, prefer logical properties (e.g., `ms-*` for margin-start).
41+
- Storybook stories are in `*.stories.tsx` files.
42+
- Accessibility is a priority: use semantic HTML and ARIA attributes as needed.
43+
44+
## CI/CD
45+
46+
- GitHub Actions run lint, test, typecheck, and build on PRs and pushes to main.
47+
- Storybook is deployed via GitHub Actions (`.github/workflows/storybook-deploy.yml`).
48+
49+
## Key Files & Directories
50+
51+
- `src/`: All components
52+
- `src/index.ts`: Component exports
53+
- `src/base.css`: Main stylesheet
54+
- `package.json`: Scripts and dependencies
55+
- `.github/workflows/`: CI/CD pipelines
56+
- `README.md`: Basic usage and setup
57+
58+
## Example: Adding a New Component
59+
60+
1. Run `pnpm run gen-component` to scaffold.
61+
2. Implement in `src/[component]/[component].tsx`.
62+
3. Add types in `src/[component]/types.ts`.
63+
4. Write tests in `src/[component]/[component].test.tsx`.
64+
5. Add Storybook stories in `src/[component]/[component].stories.tsx`.
65+
6. Export from `src/index.ts`.
66+
67+
## Integration Points
68+
69+
- Peer dependencies: React 16/17/18, ReactDOM
70+
- External: FontAwesome, HeadlessUI, Radix UI, PrismJS
71+
72+
## PR and Commit Convention
73+
74+
- PR title and commit messages MUST follow Conventional Commits (https://www.conventionalcommits.org/).
75+
- The PR title should describe what the change does. Use the conventional-commit prefix as the PR title prefix, for example:
76+
- `feat(col): add support for all 12 grid columns`
77+
- `refactor(button): simplify disabled state logic`
78+
- For commits, use the commit body to explain why the change was made and any important implementation notes.
79+
- PR descriptions should be concise: what changed, why, and any migration steps or risk notes. Reference related issues using `#<issue-number>`.

0 commit comments

Comments
 (0)