Thank you for your interest in contributing to APG Patterns Examples! This document provides guidelines and instructions for contributing to this project.
- Code of Conduct
- Getting Started
- Development Setup
- Development Workflow
- Coding Standards
- Component Guidelines
- Testing
- Pull Request Process
- Commit Message Guidelines
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please read CODE_OF_CONDUCT.md before contributing.
- Node.js 20 or higher
- npm (comes with Node.js)
- Git
- Basic understanding of:
- WAI-ARIA and accessibility principles
- At least one of: React, Vue, Svelte, or Astro
- TypeScript
- Tailwind CSS
- WAI-ARIA Authoring Practices Guide (APG)
- WCAG 2.1 Guidelines
- Project Documentation - Internal development guide
- Coding Rules - TypeScript and code style requirements
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/apg-patterns-examples.git cd apg-patterns-examples -
Add upstream remote:
git remote add upstream https://github.com/masuP9/apg-patterns-examples.git
-
Install dependencies:
npm install
-
Start development server:
npm run dev # The port is derived from the worktree path (Astro prints the exact URL), # and the site is served under the base path, e.g. # http://localhost:<port>/apg-patterns-examples/
# Update your local main branch
git checkout main
git pull upstream main
# Create a feature branch
git checkout -b feature/your-feature-namefeature/pattern-name- New pattern implementationfix/issue-description- Bug fixesdocs/description- Documentation updatesrefactor/description- Code refactoringtest/description- Test additions or modifications
- Make your changes in the feature branch
- Test your changes thoroughly
- Run linting and formatting:
For faster iteration, you can run individual checks:
npm run lint # Runs all checks in parallel (ESLint, TypeScript, Astro) npm run formatnpm run lint:eslint # ESLint only npm run lint:types # TypeScript type check only npm run lint:astro # Astro check only
- Ensure all tests pass:
npm run test
git fetch upstream
git rebase upstream/main- Follow the Coding Rules document
- Use TypeScript with strict type checking
- Minimize use of type assertions (
as) - Prefer type guards and proper type definitions
- Write self-documenting code with clear variable names
- Add comments only where logic isn't self-evident
We use Prettier for most files and @takazudo/mdx-formatter for MDX files (.prettierignore excludes *.mdx). Both run in parallel via npm-run-all2:
# Format all files (Prettier + mdx-formatter in parallel)
npm run format
# Check formatting
npm run format:check
# MDX only
npm run format:mdx
npm run format:mdx:checkFormatting Rules:
- Semicolons: Required
- Quotes: Single quotes (double in JSX attributes)
- Indentation: 2 spaces
- Trailing commas: ES5
- Line width: 100 characters
- Tailwind CSS class ordering: Automatic
See CODING_RULES.md for detailed TypeScript requirements, especially:
- Type assertion restrictions
- Type guard patterns
- DOM API handling
- Safe access helpers
All components MUST:
- Follow APG Patterns: Implement the exact ARIA roles, states, and properties specified in WAI-ARIA APG
- Keyboard Navigation: Support all required keyboard interactions
- Screen Reader Support: Provide appropriate labels and announcements
- Focus Management: Handle focus correctly (visible indicators, logical order)
- High Contrast Mode: Work correctly in Windows High Contrast Mode
- Reduced Motion: Respect
prefers-reduced-motionpreference
When implementing a pattern, ensure:
- All four frameworks (React, Vue, Svelte, Astro) have the same functionality
- Component APIs are consistent across frameworks
- All implementations pass the same accessibility tests
- Documentation is complete for each framework
Each pattern should include:
src/patterns/{pattern}/
├── meta.ts # Pattern metadata (single source of truth)
├── DemoSection.react.astro # React demo
├── DemoSection.vue.astro # Vue demo
├── DemoSection.svelte.astro # Svelte demo
├── DemoSection.web-component.astro # Astro Web Component demo
├── {pattern}-demo-data.ts # Shared demo data (optional)
├── TestingDocs.astro # Test documentation
├── {Pattern}.tsx # React implementation
├── {Pattern}.vue # Vue implementation
├── {Pattern}.svelte # Svelte implementation
├── {Pattern}.astro # Astro/Web Components implementation
├── {Pattern}.test.tsx # React tests
├── {Pattern}.test.vue.ts # Vue tests
├── {Pattern}.test.svelte.ts # Svelte tests
└── {pattern}.md # AI assistant reference (llm.md)
src/content/accessibility-docs/{pattern}/
├── en.mdx # Accessibility docs (English)
└── ja.mdx # Accessibility docs (Japanese)
-
Accessibility docs (
src/content/accessibility-docs/{pattern}/en.mdx,ja.mdx): Include sections for:- Native HTML Considerations (if applicable)
- WAI-ARIA Roles
- WAI-ARIA States/Properties
- Keyboard Support
-
meta.ts: Pattern metadata including title, description, TOC, resources, and per-framework API docs (see
src/lib/pattern-meta-types.tsfor thePatternMetatype) -
llm.md: AI-friendly reference (see .internal/llm-md-template.md)
# Run all tests
npm run test
# Run tests in watch mode
npm run test:ui
# Run tests with coverage
npm run test:coverage
# Run tests for CI
npm run test:ciAll components must have tests for:
-
ARIA Compliance:
- Correct roles
- Required states and properties
- Dynamic state updates
-
Keyboard Navigation:
- All required key handlers
- Focus management
- Tab order
-
User Interactions:
- Click/tap events
- State changes
- Event callbacks
-
Accessibility:
jest-axeautomated checks- Screen reader announcements (where applicable)
See the Testing Strategy page for detailed testing guidelines (source: src/testing-strategy/content.mdx).
- ✅ All tests pass (
npm run test) - ✅ Linting passes (
npm run lint) - ✅ Code is formatted (
npm run format) - ✅ Documentation is updated
- ✅ Commits follow our commit message guidelines
-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub
-
Fill out the PR template with:
- Description of changes
- Related issue number (if applicable)
- Screenshots/GIFs (for UI changes)
- Testing checklist
-
Wait for review: A maintainer will review your PR and may request changes
-
Address feedback: Make requested changes and push updates
-
Merge: Once approved, a maintainer will merge your PR
PRs will be reviewed for:
- ✅ APG compliance and accessibility
- ✅ Code quality and adherence to standards
- ✅ Test coverage
- ✅ Documentation completeness
- ✅ Framework parity (all 4 frameworks work identically)
- ✅ No breaking changes (unless discussed)
We follow Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Code style changes (formatting, no logic change)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
feat(accordion): implement accordion pattern for all frameworks
- Add React, Vue, Svelte, and Astro implementations
- Include keyboard navigation (Arrow keys, Home, End)
- Add comprehensive accessibility tests
- Document ARIA roles and properties
Closes #42
fix(tabs): correct focus management on tab deletion
When a selected tab is deleted, focus now moves to the
adjacent tab instead of losing focus.
Fixes #128
docs(contributing): add component guidelines section
Use the pattern name or area of change:
accordion,tabs,dialog, etc. - For pattern-specific changesci- CI/CD changesdeps- Dependency updatesa11y- Cross-cutting accessibility improvements
- General questions: Open a Discussion
- Bug reports: Open an Issue
- Feature requests: Open an Issue with the
enhancementlabel
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to make the web more accessible! 🎉