Skip to content

Commit d768974

Browse files
committed
chore: wip
chore: wip
1 parent a759581 commit d768974

File tree

11 files changed

+872
-89
lines changed

11 files changed

+872
-89
lines changed

README.md

Lines changed: 234 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,249 @@
88

99
# headwind
1010

11-
This is an opinionated TypeScript Starter kit to help kick-start development of your next Bun package.
11+
A blazingly fast, utility-first CSS framework built with Bun. Headwind generates only the CSS you need by scanning your files for utility classes, providing Tailwind CSS-compatible utilities with exceptional performance.
1212

1313
## Features
1414

15-
This Starter Kit comes pre-configured with the following:
16-
17-
- 🛠️ [Powerful Build Process](https://github.com/oven-sh/bun) - via Bun
18-
- 💪🏽 [Fully Typed APIs](https://www.typescriptlang.org/) - via TypeScript
19-
- 📚 [Documentation-ready](https://vitepress.dev/) - via VitePress
20-
-[CLI & Binary](https://www.npmjs.com/package/bunx) - via Bun & CAC
21-
- 🧪 [Built With Testing In Mind](https://bun.sh/docs/cli/test) - pre-configured unit-testing powered by [Bun](https://bun.sh/docs/cli/test)
22-
- 🤖 [Renovate](https://renovatebot.com/) - optimized & automated PR dependency updates
23-
- 🎨 [ESLint](https://eslint.org/) - for code linting _(and formatting)_
24-
- 📦️ [pkg.pr.new](https://pkg.pr.new) - Continuous (Preview) Releases for your libraries
25-
- 🐙 [GitHub Actions](https://github.com/features/actions) - runs your CI _(fixes code style issues, tags releases & creates its changelogs, runs the test suite, etc.)_
15+
- ⚡️ **Blazingly Fast** - Built with Bun for exceptional performance (1000+ utilities in <10ms)
16+
- 🎯 **On-Demand Generation** - Only generates CSS for utilities you actually use
17+
- 🎨 **Tailwind-Compatible** - Familiar utility classes and syntax
18+
- 💪 **Fully Typed** - Complete TypeScript support with type-safe configuration
19+
- 🔧 **Highly Configurable** - Customize theme, colors, spacing, variants, and more
20+
- 📦 **Zero Dependencies** - Minimal footprint, maximum performance
21+
- 🔥 **Hot Reload** - Watch mode for instant rebuilds during development
22+
- 🎭 **Variant Support** - Responsive, state (hover, focus, etc.), dark mode, and custom variants
23+
-**Modern CSS Features** - Grid, Flexbox, animations, transforms, filters, and more
24+
- 🧪 **Thoroughly Tested** - 860+ tests including comprehensive performance benchmarks
25+
- 🚀 **Production Ready** - Minification, preflight CSS, and optimized builds
26+
- ⌨️ **CLI & API** - Use via command line or programmatic API
2627

2728
## Get Started
2829

29-
It's rather simple to get your package development started:
30+
### Installation
3031

3132
```bash
32-
# you may use this GitHub template or the following command:
33-
bunx degit stacksjs/ts-starter my-pkg
34-
cd my-pkg
33+
bun add headwind
34+
# or
35+
npm install headwind
36+
```
37+
38+
### Quick Start
39+
40+
1. **Create a configuration file** (`headwind.config.ts`):
41+
42+
```typescript
43+
import type { HeadwindConfig } from 'headwind'
44+
45+
export default {
46+
content: ['./src/**/*.{html,js,ts,jsx,tsx}'],
47+
output: './dist/styles.css',
48+
minify: true,
49+
} satisfies Partial<HeadwindConfig>
50+
```
51+
52+
2. **Add utility classes to your HTML**:
53+
54+
```html
55+
<div class="flex items-center justify-between p-4 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-600">
56+
<h1 class="text-2xl font-bold">Hello Headwind!</h1>
57+
</div>
58+
```
59+
60+
3. **Build your CSS**:
61+
62+
```bash
63+
# Build once
64+
bunx headwind build
65+
66+
# Build and watch for changes
67+
bunx headwind watch
68+
69+
# Build with options
70+
bunx headwind build --output ./dist/styles.css --minify
71+
```
72+
73+
### Programmatic API
74+
75+
You can also use Headwind programmatically:
76+
77+
```typescript
78+
import { build } from 'headwind'
79+
80+
const result = await build({
81+
content: ['./src/**/*.html'],
82+
output: './dist/styles.css',
83+
minify: true,
84+
})
85+
86+
console.log(`Generated ${result.classes.size} classes in ${result.duration}ms`)
87+
```
88+
89+
## Configuration
90+
91+
Headwind supports extensive configuration options:
92+
93+
```typescript
94+
import type { HeadwindConfig } from 'headwind'
95+
96+
export default {
97+
// Content sources to scan for utility classes
98+
content: ['./src/**/*.{html,js,ts,jsx,tsx}'],
99+
100+
// Output CSS file path
101+
output: './dist/styles.css',
102+
103+
// Minify output CSS
104+
minify: false,
105+
106+
// Enable watch mode
107+
watch: false,
108+
109+
// Enable verbose logging
110+
verbose: false,
35111

36-
bun i # install all deps
37-
bun run build # builds the library for production-ready use
112+
// Theme customization
113+
theme: {
114+
colors: {
115+
primary: '#3b82f6',
116+
secondary: '#10b981',
117+
// ... extend or override default colors
118+
},
119+
spacing: {
120+
// ... customize spacing scale
121+
},
122+
fontSize: {
123+
// ... customize font sizes
124+
},
125+
// ... and more
126+
},
38127

39-
# after you have successfully committed, you may create a "release"
40-
bun run release # automates git commits, versioning, and changelog generations
128+
// Shortcuts (utility aliases)
129+
shortcuts: {
130+
btn: 'px-4 py-2 rounded bg-blue-500 text-white hover:bg-blue-600',
131+
card: 'p-6 bg-white rounded-lg shadow-md',
132+
},
133+
134+
// Custom variants
135+
variants: {
136+
// ... configure breakpoints, states, etc.
137+
},
138+
139+
// Safelist (always include these classes)
140+
safelist: ['bg-red-500', 'text-green-500'],
141+
142+
// Blocklist (never include these classes)
143+
blocklist: ['debug-*'],
144+
145+
// Custom rules
146+
rules: [],
147+
148+
// Preflight CSS (normalize/reset styles)
149+
preflights: [],
150+
151+
// Presets
152+
presets: [],
153+
} satisfies Partial<HeadwindConfig>
41154
```
42155

43-
_Check out the package.json scripts for more commands._
156+
## Available Utilities
157+
158+
Headwind provides a comprehensive set of utility classes compatible with Tailwind CSS:
159+
160+
- **Layout**: display, position, overflow, z-index, etc.
161+
- **Flexbox & Grid**: flex, grid, gap, align, justify, etc.
162+
- **Spacing**: margin, padding with full scale support
163+
- **Sizing**: width, height, min/max sizes
164+
- **Typography**: font family, size, weight, line height, text alignment, etc.
165+
- **Backgrounds**: colors, gradients, images, position, size
166+
- **Borders**: width, color, radius, style
167+
- **Effects**: shadow, opacity, blend modes, filters
168+
- **Transforms**: translate, rotate, scale, skew
169+
- **Transitions & Animations**: duration, timing, delay
170+
- **Interactivity**: cursor, pointer events, user select, scroll behavior
171+
- **Advanced**: mask utilities, backdrop filters, ring utilities
172+
173+
### Variants
174+
175+
- **Responsive**: `sm:`, `md:`, `lg:`, `xl:`, `2xl:`
176+
- **State**: `hover:`, `focus:`, `active:`, `disabled:`, `visited:`, `checked:`
177+
- **Pseudo-elements**: `before:`, `after:`, `placeholder:`, `selection:`
178+
- **Group/Peer**: `group-hover:`, `peer-focus:`
179+
- **Dark mode**: `dark:`
180+
- **Positional**: `first:`, `last:`, `odd:`, `even:`
181+
- **Important**: `!` prefix (e.g., `!text-red-500`)
182+
183+
### Arbitrary Values
184+
185+
Headwind supports arbitrary values for maximum flexibility:
186+
187+
```html
188+
<div class="w-[500px] h-[calc(100vh-4rem)] bg-[#1da1f2] text-[clamp(1rem,5vw,3rem)]">
189+
Custom values!
190+
</div>
191+
```
44192

45193
## Testing
46194

195+
Headwind includes a comprehensive test suite with 860+ tests:
196+
197+
```bash
198+
# Run all tests
199+
bun test
200+
201+
# Run specific test files
202+
bun test test/performance.test.ts
203+
204+
# Run tests in watch mode
205+
bun test --watch
206+
```
207+
208+
### Test Coverage
209+
210+
- **Core Functionality**: Parser, generator, scanner, builder
211+
- **Utilities**: Layout, typography, colors, spacing, grid, flexbox
212+
- **Variants**: Responsive, state, pseudo-elements, combinations
213+
- **Advanced Features**: Shortcuts, custom rules, arbitrary values
214+
- **Performance**: Benchmarks for generation speed and memory efficiency
215+
- **Edge Cases**: Invalid inputs, complex nesting, duplicate handling
216+
217+
## Performance
218+
219+
Headwind is designed for speed. Here are some benchmarks from our test suite:
220+
221+
- **Simple utilities**: ~7ms for 1,000 utilities
222+
- **Complex utilities** (with variants): ~9ms for 1,000 utilities
223+
- **Arbitrary values**: ~3ms for 1,000 utilities
224+
- **CSS output**: ~1ms for 1,000 rules
225+
226+
All benchmarks run on Bun runtime. Your results may vary based on hardware.
227+
228+
## Development
229+
230+
To contribute to Headwind development:
231+
47232
```bash
233+
# Clone the repository
234+
git clone https://github.com/stacksjs/headwind.git
235+
cd headwind
236+
237+
# Install dependencies
238+
bun install
239+
240+
# Run tests
48241
bun test
242+
243+
# Run tests in watch mode
244+
bun test --watch
245+
246+
# Run performance benchmarks
247+
bun test test/performance.test.ts
248+
249+
# Type check
250+
bun run typecheck
251+
252+
# Build the package
253+
bun run build
49254
```
50255

51256
## Changelog
@@ -56,6 +261,14 @@ Please see our [releases](https://github.com/stackjs/headwind/releases) page for
56261

57262
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
58263

264+
We welcome contributions! Whether it's:
265+
266+
- 🐛 Bug reports and fixes
267+
- ✨ New utility classes or features
268+
- 📝 Documentation improvements
269+
- ⚡️ Performance optimizations
270+
- 🧪 Additional test coverage
271+
59272
## Community
60273

61274
For help, discussion about best practices, or any other conversation that would benefit from being searchable:

headwind.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { HeadwindOptions } from './packages/headwind/src/types'
22

3-
const config: HeadwindOptions = {
3+
const config = {
44
verbose: true,
5-
}
5+
} satisfies Partial<HeadwindOptions>
66

7-
export default config
7+
export default config as Partial<HeadwindOptions>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { HeadwindConfig } from './src/types'
22

3-
export default {
3+
const config = {
44
content: ['./example/**/*.html'],
55
output: './example/output.css',
66
minify: false,
77
} satisfies Partial<HeadwindConfig>
8+
9+
export default config as Partial<HeadwindConfig>

packages/headwind/package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "headwind",
33
"type": "module",
44
"version": "0.0.0",
5-
"description": "Like our `ts-starter`, but optimized for monorepos.",
5+
"description": "A blazingly fast, utility-first CSS framework built with Bun. Generates only the CSS you need by scanning your files for utility classes.",
66
"author": "Chris Breuer <[email protected]>",
77
"license": "MIT",
88
"homepage": "https://github.com/stacksjs/headwind#readme",
@@ -14,10 +14,16 @@
1414
"url": "https://github.com/stacksjs/headwind/issues"
1515
},
1616
"keywords": [
17-
"monorepo",
18-
"ts-starter",
17+
"css",
18+
"utility-first",
19+
"tailwind",
20+
"css-framework",
21+
"bun",
22+
"performance",
1923
"headwind",
20-
"template"
24+
"atomic-css",
25+
"typescript",
26+
"on-demand"
2127
],
2228
"exports": {
2329
".": {

0 commit comments

Comments
 (0)