|
| 1 | +# Instructure UI - Claude Code Documentation |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +InstUI is a React component library and design system. **Lerna 8 monorepo** with 100+ packages. |
| 6 | + |
| 7 | +**Key Resources:** |
| 8 | +- Website: https://instructure.design |
| 9 | +- AI docs: https://instructure.design/llms.txt |
| 10 | +- Component docs: https://instructure.design/markdowns/[ComponentName].md |
| 11 | + - Example: https://instructure.design/markdowns/Alert.md |
| 12 | + - Example: https://instructure.design/markdowns/Button.md |
| 13 | + |
| 14 | +**Tech Stack:** Node.js >=22, npm, React 18.3.1+, TypeScript 5.8.3, Emotion (CSS-in-JS), Vitest, Cypress, Chromatic |
| 15 | + |
| 16 | +## Repository Structure |
| 17 | + |
| 18 | +``` |
| 19 | +/packages # 100+ packages |
| 20 | + /ui-* # Component packages (ui-button, ui-select, etc.) |
| 21 | + /canvas-theme # Theme packages |
| 22 | + /__docs__ # Documentation app |
| 23 | +/docs # Documentation source files |
| 24 | +/regression-test # Visual & a11y testing (Next.js 15 app) |
| 25 | +/cypress # Component tests |
| 26 | +/scripts # Build scripts |
| 27 | +``` |
| 28 | + |
| 29 | +**Important file locations:** |
| 30 | +- Component source: `/packages/ui-*/src/` |
| 31 | +- Component tests: Co-located with components |
| 32 | +- Theme types: `/packages/shared-types/src/ComponentThemeVariables.ts` |
| 33 | +- Visual/a11y tests: `/regression-test/` |
| 34 | +- Testing docs: `/docs/testing/testing-overview.md` |
| 35 | + |
| 36 | +## Quick Start |
| 37 | + |
| 38 | +```bash |
| 39 | +npm run bootstrap # First time setup (clean, build icons, compile, generate tokens) |
| 40 | +npm run dev # Start dev server at http://localhost:9090 |
| 41 | +``` |
| 42 | + |
| 43 | +Most changes hot-reload automatically when dev server is running. |
| 44 | + |
| 45 | +## Essential Commands |
| 46 | + |
| 47 | +```bash |
| 48 | +# Development |
| 49 | +npm run dev # Dev server (http://localhost:9090) |
| 50 | +npm run build:types # Build TypeScript declarations |
| 51 | + |
| 52 | +# Testing |
| 53 | +npm run test:vitest # Unit tests |
| 54 | +npm run cy:component # Cypress component tests |
| 55 | + |
| 56 | +# Linting |
| 57 | +npm run lint:fix # Auto-fix linting issues |
| 58 | +npm run ts:check # TypeScript references check |
| 59 | + |
| 60 | +# Troubleshooting |
| 61 | +npm run clean && npm run bootstrap # Fix build issues |
| 62 | +npm run clean-node && npm install # Nuclear option (removes all node_modules) |
| 63 | +``` |
| 64 | + |
| 65 | +## Code Style |
| 66 | + |
| 67 | +**IMPORTANT: Always use functional components with React hooks for new code.** |
| 68 | + |
| 69 | +- ✅ Functional components with hooks (useState, useEffect, etc.) |
| 70 | +- ❌ No class components for new code (legacy codebase has them) |
| 71 | +- ❌ **Never hardcode text** - all user-facing text must come from props (for i18n) |
| 72 | +- ✅ Support accessibility (WCAG 2.1 AA), RTL languages |
| 73 | +- ✅ Use TypeScript for all new code |
| 74 | +- ✅ Use Emotion for styling (CSS-in-JS) |
| 75 | + |
| 76 | +## Finding Component Information |
| 77 | + |
| 78 | +**To find available components and their packages:** |
| 79 | +- Check `/packages/__docs__/src/components.ts` - lists all components with their package locations |
| 80 | + |
| 81 | +**Each component has two READMEs:** |
| 82 | + |
| 83 | +1. **Component README**: `/packages/[package]/src/[Component]/README.md` ⭐ |
| 84 | + - Usage examples and guidelines |
| 85 | + - **Check this first** - it has the detailed information |
| 86 | + |
| 87 | +2. **Package README**: `/packages/[package]/README.md` |
| 88 | + - Package overview, installation, exports |
| 89 | + |
| 90 | +**For complete API details:** |
| 91 | +- Props: Check `props.ts` files in component source |
| 92 | +- Theme variables: Check `theme.ts` files in component source |
| 93 | + |
| 94 | +## Component Development Workflow |
| 95 | + |
| 96 | +1. Find component in `/packages/ui-[name]/src/[Component]/` |
| 97 | +2. Check Component README for API details |
| 98 | +3. Make changes (functional components only) |
| 99 | +4. Run tests: `npm run test:vitest` |
| 100 | +5. Update both README files if needed |
| 101 | +6. Use `/commit` to create commit |
| 102 | + |
| 103 | +## Breaking Changes |
| 104 | + |
| 105 | +**IMPORTANT: Avoid breaking changes unless explicitly requested by the user.** |
| 106 | + |
| 107 | +A change is **breaking** if it requires consumers to modify their code: |
| 108 | + |
| 109 | +**Breaking changes (avoid):** |
| 110 | +- ❌ Removing or renaming a prop |
| 111 | +- ❌ Changing a prop's type or behavior |
| 112 | +- ❌ Removing or renaming a component |
| 113 | +- ❌ Changing default values that affect behavior |
| 114 | +- ❌ Removing or renaming theme variables |
| 115 | +- ❌ Removing exported utilities or functions |
| 116 | + |
| 117 | +**Not breaking changes (preferred):** |
| 118 | +- ✅ Adding new optional props |
| 119 | +- ✅ Adding new components |
| 120 | +- ✅ Bug fixes that restore intended behavior |
| 121 | +- ✅ Internal refactoring without API changes |
| 122 | +- ✅ Adding new theme variables |
| 123 | +- ✅ Deprecating features with warnings (without removing) |
| 124 | +- ✅ Documentation updates |
| 125 | + |
| 126 | +When a breaking change is explicitly requested, document it clearly in the commit message with `BREAKING CHANGE:` in the body. |
| 127 | + |
| 128 | +## Testing Requirements |
| 129 | + |
| 130 | +All components **MUST**: |
| 131 | +1. Have unit tests (Vitest + React Testing Library in `*.test.tsx`) |
| 132 | +2. Have visual regression tests in `/regression-test` |
| 133 | +3. Pass accessibility audits (WCAG 2.1 AA) |
| 134 | +4. Support RTL languages |
| 135 | + |
| 136 | +### Running Tests |
| 137 | + |
| 138 | +```bash |
| 139 | +npm run test:vitest # Unit tests |
| 140 | +npm run cy:component # Cypress tests |
| 141 | + |
| 142 | +# Visual regression tests (in regression-test directory) |
| 143 | +cd regression-test |
| 144 | +npm run dev # Start at localhost:3000 |
| 145 | +npm run cypress-chrome # Run with GUI |
| 146 | +``` |
| 147 | + |
| 148 | +### Adding Visual Regression Test |
| 149 | + |
| 150 | +1. Create test page: `/regression-test/src/app/[component-name]/page.tsx` |
| 151 | +2. Add Cypress test: `/regression-test/cypress/e2e/spec.cy.ts` |
| 152 | + |
| 153 | +See `/regression-test/README.md` for detailed instructions. |
| 154 | + |
| 155 | +## Writing Documentation |
| 156 | + |
| 157 | +InstUI uses custom markdown with special code blocks for interactive examples. |
| 158 | + |
| 159 | +**Code block types:** |
| 160 | +- `type: code` - Syntax highlighting only |
| 161 | +- `type: embed` - Rendered component only |
| 162 | +- `type: example` - Interactive (rendered + editable) ⭐ Most common |
| 163 | + |
| 164 | +**IMPORTANT:** |
| 165 | +- Always write functional component examples with hooks |
| 166 | +- All InstUI components are available without imports in examples |
| 167 | + |
| 168 | +See `/docs/contributor-docs/writing-docs.md` for complete guidelines and syntax. |
| 169 | + |
| 170 | +## Naming Conventions |
| 171 | + |
| 172 | +- **Packages**: `ui-[component-name]` (kebab-case) |
| 173 | +- **Components**: PascalCase (Button, Select) |
| 174 | +- **Props**: camelCase with prefixes (onClick, isDisabled) |
| 175 | +- **Theme variables**: camelCase |
| 176 | + |
| 177 | +## Committing & PRs |
| 178 | + |
| 179 | +Use `/commit` and `/pr` slash commands - they follow InstUI conventions automatically. |
| 180 | + |
| 181 | +**Branch naming:** Create feature branches from `master` |
| 182 | + |
| 183 | +**PR merging:** PRs are typically squashed when merged |
0 commit comments