Thank you for your interest in contributing to Shift CSS! This document provides guidelines and information for contributors.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Development Workflow
- Code Style
- Commit Messages
- Pull Request Process
- Testing
- Release Process
- Getting Help
By participating in this project, you agree to maintain a respectful and inclusive environment. We expect all contributors to:
- Use welcoming and inclusive language
- Be respectful of differing viewpoints and experiences
- Gracefully accept constructive criticism
- Focus on what is best for the community
- Show empathy towards other community members
- Bun v1.0 or higher
- Node.js v20 or higher (for compatibility)
- A modern browser for testing (Chrome 131+, Firefox 133+, or Safari 18+)
# Clone the repository
git clone https://github.com/auswm85/shift-css.git
cd shift-css
# Install dependencies
bun install
# Build the framework
bun run build
# Start development mode
bun run devbun installThis installs dependencies for both the core package and documentation site.
# Full build (tokens + CSS bundle)
bun run build
# Generate tokens only
cd packages/core && bun run build:tokens
# Development with watch mode
bun run dev
# Build documentation site
bun run docs:build# Start docs dev server (includes live framework preview)
bun run docs:devThe documentation site at http://localhost:4321 serves as the primary development environment, showcasing all components and utilities.
shift-css/
├── packages/
│ └── core/ # @shift-css/core package
│ ├── src/
│ │ ├── index.css # Layer orchestration entry
│ │ ├── base/
│ │ │ └── reset.css # Browser reset, fluid typography
│ │ ├── tokens/
│ │ │ └── tokens.css # Generated CSS custom properties
│ │ ├── components/
│ │ │ ├── surface.css # Surface component
│ │ │ ├── button.css # Button component
│ │ │ ├── card.css # Card component
│ │ │ └── input.css # Input component
│ │ └── utils/
│ │ ├── layout.css # Flex, grid, container
│ │ ├── spacing.css # Margin, padding, gap
│ │ ├── typography.css
│ │ ├── flex.css
│ │ └── visibility.css
│ ├── tokens/ # Token definitions (JSON)
│ │ ├── colors.json # Color scales and hues
│ │ ├── semantic.json # Light/dark mappings
│ │ └── spacing.json # Spacing and radius
│ ├── scripts/
│ │ ├── generate-colors.ts # Token generator
│ │ ├── build.ts # CSS bundler
│ │ └── utils.ts # Helper functions
│ ├── tests/
│ │ ├── e2e/ # Playwright tests
│ │ ├── utils.test.ts # Unit tests
│ │ └── generator.test.ts
│ └── dist/ # Built output
├── apps/
│ └── docs/ # Astro documentation site
├── .changeset/ # Changeset files
├── biome.json # Linter/formatter config
└── package.json # Root workspace config
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fixBranch naming conventions:
feature/- New features or componentsfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Test additions or modifications
- Create the CSS file in
packages/core/src/components/ - Import it in
packages/core/src/index.css - Add documentation in
apps/docs/src/content/docs/components/ - Add visual tests in
packages/core/tests/e2e/ - Update the README if needed
- Edit the appropriate JSON file in
packages/core/tokens/ - Run
bun run build:tokensto regenerate CSS - Verify changes in the documentation site
- Update visual regression snapshots if needed
- Create or modify CSS in
packages/core/src/utils/ - Follow the existing naming pattern (
s-prefix) - Add documentation in
apps/docs/src/content/docs/utilities/
# Run all tests
bun run test
# Specific test suites
bun run test:unit # Unit tests
bun run test:e2e # E2E tests
bun run test:visual # Visual regression
bun run test:a11y # Accessibility
bun run test:contrast # Color contrast# Check for issues
bun run lint
# Auto-fix issues
bun run lint:fix
# Format code
bun run formatFor any user-facing changes, create a changeset:
bun run changesetFollow the prompts to:
- Select the package(s) affected
- Choose the version bump type (patch/minor/major)
- Write a description of your changes
-
Components: Use attribute selectors with
s-prefix[s-btn] { } [s-btn="primary"] { }
-
Utilities: Use class selectors with
s-prefix.s-flex { } .s-m-4 { }
-
Internal properties: Use
--_prefix for component-scoped variables[s-btn] { --_btn-bg: var(--s-primary-600); }
All CSS must be wrapped in appropriate layers:
@layer shift.core {
/* Component styles */
}
@layer shift.utils {
/* Utility styles */
}Always use design tokens instead of hardcoded values:
/* Good */
padding: var(--s-space-4);
color: var(--s-text-primary);
border-radius: var(--s-radius-md);
/* Avoid */
padding: 1rem;
color: #333;
border-radius: 6px;For cutting-edge features, provide fallbacks:
[s-component] {
/* Fallback first */
color: var(--s-text-primary);
/* Enhancement */
@supports (color: contrast-color(black)) {
color: contrast-color(var(--_bg));
}
}- Use strict TypeScript
- Prefer
constoverlet - Use meaningful variable names
- Add JSDoc comments for public functions
- Use descriptive names
- Group related tokens
- Document the purpose of each scale
- Maintain consistent structure
We follow Conventional Commits:
type(scope): description
[optional body]
[optional footer]
feat: New featurefix: Bug fixdocs: Documentation changesstyle: CSS/formatting changes (no logic change)refactor: Code refactoringtest: Test additions or modificationschore: Build process or tooling changesperf: Performance improvements
feat(button): add outline variant
fix(surface): correct auto-contrast calculation for dark backgrounds
docs(readme): add customization examples
style(tokens): reorganize color scale comments
refactor(build): simplify token generation pipeline
test(visual): add snapshot tests for card component
chore(deps): update lightning-css to v1.28
- Ensure all tests pass:
bun run test - Lint your code:
bun run lint - Update documentation if needed
- Create a changeset for user-facing changes
- Update snapshots if visual changes are intentional:
bun run test:update-snapshots
Follow the commit message format:
feat(component): add new feature description
Include:
- Summary: What does this PR do?
- Motivation: Why is this change needed?
- Changes: List of specific changes
- Testing: How was this tested?
- Screenshots: For visual changes
- A maintainer will review your PR
- Address any requested changes
- Once approved, a maintainer will merge
- Your changes will be included in the next release
packages/core/tests/
├── e2e/
│ ├── accessibility.a11y.ts # WCAG compliance
│ ├── contrast.contrast.ts # Color contrast
│ ├── components.visual.ts # Component visuals
│ └── fixtures/ # Test HTML files
├── utils.test.ts # Utility functions
└── generator.test.ts # Token generation
# All tests
bun run test
# Unit tests only
bun run test:unit
# Visual regression (Chrome)
bun run test:visual
# All visual tests (Chrome, Firefox, Mobile)
bun run test:visual:all
# Accessibility tests
bun run test:a11y
# Contrast validation
bun run test:contrast
# Update snapshots
bun run test:update-snapshotstest("component renders correctly", async ({ page }) => {
await page.goto("/fixtures/component.html");
await expect(page.locator("[s-component]")).toHaveScreenshot();
});test("component is accessible", async ({ page }) => {
await page.goto("/fixtures/component.html");
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations).toEqual([]);
});- All new components must have visual regression tests
- All interactive components must have accessibility tests
- Contrast tests for any new color combinations
- Unit tests for utility functions
Releases are managed through Changesets.
-
Merge changesets: PRs with changesets are merged to
main -
Version packages:
bun run version
This consumes changesets and updates package versions.
-
Review changes: Check
CHANGELOG.mdand version bumps -
Publish:
bun run release
This builds and publishes to npm.
- Patch (0.0.X): Bug fixes, documentation
- Minor (0.X.0): New features, components, utilities
- Major (X.0.0): Breaking changes
- Questions: Open a Discussion
- Bugs: Open an Issue
- Security: Report via GitHub Security Advisories
Thank you for contributing to Shift CSS!