preact-component-scss
v2.0.1
Published
A Preact component library with SCSS styling
Maintainers
Readme
Preact Component Library with SCSS
A modern, responsive component library built with Preact, TypeScript, and SCSS. Features dark/light/auto theme switching, comprehensive documentation, and GitHub Pages deployment.
Features
- ⚡ Preact - Fast, lightweight React alternative
- 🎨 SCSS - Modular styling with CSS custom properties
- 🌙 Theme Support - Dark, light, and auto themes with localStorage persistence
- 📱 Responsive - Mobile-first design with fluid typography
- 🧪 Tested - Comprehensive test suite with JUnit reporting
- 📚 Documented - TSDoc generated documentation
- 🚀 CI/CD - GitHub Actions with automated testing and deployment
- 🔄 Version Management - Automatic version checking and bumping with Husky pre-commit hooks
- 📦 NPM Publishing - Automated publishing pipeline with version validation
Installation
npm install preact-component-scssUsage
import { App } from 'preact-component-scss';
import 'preact-component-scss/styles';
function MyApp() {
return <App />;
}Theme Configuration
The library includes a theme provider for easy theme switching:
import { ThemeProvider, useTheme } from 'preact-component-scss';
function App() {
const { theme, setTheme } = useTheme();
return (
<div>
<button onClick={() => setTheme('dark')}>Dark</button>
<button onClick={() => setTheme('light')}>Light</button>
<button onClick={() => setTheme('auto')}>Auto</button>
</div>
);
}Version Management & Publishing
The project includes automated version management to ensure safe publishing:
Pre-commit Hooks
- Husky pre-commit hook automatically runs
npm run version-check - Prevents commits when local version matches published version
- Automatically bumps patch version when needed
Publishing Workflow
# Manual version check (optional)
npm run version-check
# Build library for publishing
npm run build:lib
# Publish to NPM (requires NPM_TOKEN)
npm publishCI/CD Pipeline
- GitHub Actions automatically publishes on main branch pushes
- Version validation prevents publishing duplicate versions
- Automated testing and building before publishing
Development
# Install dependencies (also sets up Husky git hooks)
npm install
# Start development server
npm run dev
# Run tests
npm run test
# Build for production
npm run build
# Generate documentation
npm run docsScripts
npm run dev- Start Vite dev servernpm run build- Build for productionnpm run build:lib- Build library for NPM publishingnpm run test- Run tests with Vitestnpm run test:junit- Run tests with JUnit output for CInpm run test:coverage- Run tests with coverage reportingnpm run test:ui- Run tests with Vitest UInpm run docs- Generate TSDoc documentationnpm run preview- Preview production buildnpm run version-check- Check and bump version if needed before publishing
Project Structure
src/
├── app.tsx # Main demo component
├── index.ts # Library entry point
├── main.tsx # App bootstrap
├── theme-provider.tsx # Theme context provider
├── utils.ts # Utility functions
├── global.d.ts # TypeScript environment variable declarations
├── styles/
│ ├── _variables.scss # CSS custom properties and SCSS variables
│ ├── _mixins.scss # SCSS mixins
│ ├── _base.scss # Global styles
│ ├── _components.scss # Component styles
│ └── main.scss # Main stylesheet
├── components/ # Component library
├── test/
│ └── setup.ts # Test configuration
└── assets/ # Static assets
.husky/
├── pre-commit # Git pre-commit hook for version checking
└── _/ # Husky internal filesContributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Run
npm run testto ensure tests pass - Commit your changes (pre-commit hooks will automatically check versions)
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/prachwal/preact-component-scss.git
cd preact-component-scss
# Install dependencies (this also sets up Husky hooks)
npm install
# Start development
npm run devPre-commit Hooks - Description
The project uses Husky to run automated checks before commits:
- Version validation: Ensures version bumping when needed
- Code quality: Runs tests and linting (when configured)
To bypass hooks for specific commits (use with caution):
git commit --no-verify -m "Your commit message"License
MIT - see LICENSE file for details.
