Skip to content

Commit 1db0349

Browse files
committed
chore: wip
1 parent 298a2e7 commit 1db0349

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1298
-1264
lines changed

bun.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"workspaces": {
44
"": {
55
"name": "headwind",
6+
"dependencies": {
7+
"jiti": "^2.6.1",
8+
},
69
"devDependencies": {
710
"@stacksjs/bumpx": "^0.1.84",
811
"@stacksjs/docs": "^0.70.23",
@@ -1279,7 +1282,7 @@
12791282

12801283
"jake": ["[email protected]", "", { "dependencies": { "async": "^3.2.3", "chalk": "^4.0.2", "filelist": "^1.0.4", "minimatch": "^3.1.2" }, "bin": { "jake": "bin/cli.js" } }, "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA=="],
12811284

1282-
"jiti": ["jiti@1.21.7", "", { "bin": { "jiti": "bin/jiti.js" } }, "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A=="],
1285+
"jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="],
12831286

12841287
"js-tokens": ["[email protected]", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
12851288

@@ -2241,6 +2244,8 @@
22412244

22422245
"toml-eslint-parser/eslint-visitor-keys": ["[email protected]", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
22432246

2247+
"unconfig/jiti": ["[email protected]", "", { "bin": { "jiti": "bin/jiti.js" } }, "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A=="],
2248+
22442249
"unplugin-icons/@antfu/install-pkg": ["@antfu/[email protected]", "", { "dependencies": { "package-manager-detector": "^0.2.8", "tinyexec": "^0.3.2" } }, "sha512-xvX6P/lo1B3ej0OsaErAjqgFYzYVcJpamjLAFLYh9vRJngBrMoUG7aVnrGTeqM7yxbyTD5p3F2+0/QUEh8Vzhw=="],
22452250

22462251
"unplugin-icons/local-pkg": ["[email protected]", "", { "dependencies": { "mlly": "^1.7.3", "pkg-types": "^1.3.0" } }, "sha512-bbgPw/wmroJsil/GgL4qjDzs5YLTBMQ99weRsok1XCDccQeehbHA/I1oRvk2NPtr7KGZgT/Y5tPRnAtMqeG2Kg=="],

docs/advanced/custom-rules.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const config = {
3131
// Dynamic rule with pattern matching
3232
[
3333
/^custom-(\w+)$/,
34-
(match) => ({
34+
match => ({
3535
'custom-property': match[1],
3636
}),
3737
],
@@ -47,7 +47,7 @@ Each custom rule is a tuple:
4747

4848
```typescript
4949
type CustomRule = [
50-
RegExp, // Pattern to match
50+
RegExp, // Pattern to match
5151
(match: RegExpMatchArray) => Record<string, string> | undefined
5252
]
5353
```
@@ -108,7 +108,7 @@ const config = {
108108
rules: [
109109
[
110110
/^aspect-(\d+)\/(\d+)$/,
111-
(match) => ({
111+
match => ({
112112
'aspect-ratio': `${match[1]} / ${match[2]}`,
113113
}),
114114
],
@@ -137,10 +137,11 @@ const config = {
137137
}
138138

139139
const color = colors[match[1]]
140-
if (!color) return undefined
140+
if (!color)
141+
return undefined
141142

142143
return {
143-
'color': color,
144+
color,
144145
}
145146
},
146147
],
@@ -169,7 +170,8 @@ const config = {
169170
}
170171

171172
const template = templates[match[1]]
172-
if (!template) return undefined
173+
if (!template)
174+
return undefined
173175

174176
return {
175177
'grid-template-areas': template,
@@ -196,13 +198,13 @@ const config = {
196198
rules: [
197199
[
198200
/^animate-delay-(\d+)$/,
199-
(match) => ({
201+
match => ({
200202
'animation-delay': `${match[1]}ms`,
201203
}),
202204
],
203205
[
204206
/^animate-duration-(\d+)$/,
205-
(match) => ({
207+
match => ({
206208
'animation-duration': `${match[1]}ms`,
207209
}),
208210
],
@@ -228,7 +230,7 @@ const config = {
228230
rules: [
229231
[
230232
/^truncate-(\d+)$/,
231-
(match) => ({
233+
match => ({
232234
'overflow': 'hidden',
233235
'text-overflow': 'ellipsis',
234236
'white-space': 'nowrap',
@@ -296,10 +298,11 @@ const config = {
296298
const spacingKey = match[1]
297299
const spacing = config.theme.spacing[spacingKey]
298300

299-
if (!spacing) return undefined
301+
if (!spacing)
302+
return undefined
300303

301304
return {
302-
'gap': spacing,
305+
gap: spacing,
303306
}
304307
},
305308
],
@@ -337,7 +340,7 @@ const config = {
337340
rules: [
338341
[
339342
/^stack-(\d+)$/,
340-
(match) => ({
343+
match => ({
341344
'> * + *': {
342345
'margin-top': `${match[1] * 0.25}rem`,
343346
},
@@ -404,7 +407,8 @@ const config = {
404407
const fromColor = colors[from]
405408
const toColor = colors[to]
406409

407-
if (!fromColor || !toColor) return undefined
410+
if (!fromColor || !toColor)
411+
return undefined
408412

409413
return {
410414
'background-image': `linear-gradient(to right, ${fromColor}, ${toColor})`,
@@ -438,7 +442,8 @@ const config = {
438442
}
439443

440444
const size = sizes[match[1]]
441-
if (!size) return undefined
445+
if (!size)
446+
return undefined
442447

443448
return {
444449
'font-size': size,
@@ -455,12 +460,12 @@ const config = {
455460

456461
**Good:**
457462
```typescript
458-
/^my-utility-(\d+)$/ // Specific pattern
463+
/^my-utility-(\d+)$/ // Specific pattern
459464
```
460465

461466
**Avoid:**
462467
```typescript
463-
/^my-/ // Too broad, might conflict
468+
/^my-/ // Too broad, might conflict
464469
```
465470

466471
### 2. Validate Input
@@ -498,7 +503,7 @@ const config = {
498503
const validSizes = ['sm', 'md', 'lg']
499504

500505
if (!validSizes.includes(match[1])) {
501-
return undefined // Don't generate CSS
506+
return undefined // Don't generate CSS
502507
}
503508

504509
return { /* ... */ }
@@ -517,7 +522,7 @@ const config = {
517522
// Usage: aspect-16/9, aspect-4/3
518523
[
519524
/^aspect-(\d+)\/(\d+)$/,
520-
(match) => ({
525+
match => ({
521526
'aspect-ratio': `${match[1]} / ${match[2]}`,
522527
}),
523528
],
@@ -565,10 +570,12 @@ Custom rules have minimal performance impact:
565570
2. **Avoid complex logic:**
566571
```typescript
567572
// ✅ Simple check
568-
if (value === 'sm') return { /* ... */ }
573+
if (value === 'sm')
574+
return { /* ... */ }
569575

570576
// ❌ Complex computation
571-
if (expensiveFunction(value)) return { /* ... */ }
577+
if (expensiveFunction(value))
578+
return { /* ... */ }
572579
```
573580

574581
3. **Cache computed values:**
@@ -600,7 +607,7 @@ Custom rules have minimal performance impact:
600607
1. Pattern is correct:
601608
```typescript
602609
// Test pattern
603-
/^my-utility-(\d+)$/.test('my-utility-10') // true
610+
/^my-utility-(\d+)$/.test('my-utility-10') // true
604611
```
605612

606613
2. Class name matches exactly:

docs/advanced/frameworks.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,9 @@ const sizeClasses = {
273273
274274
<template>
275275
<button
276-
:class="[
277-
'rounded font-semibold transition-colors',
276+
class="rounded font-semibold transition-colors" :class="[
278277
variantClasses[variant],
279-
sizeClasses[size]
278+
sizeClasses[size],
280279
]"
281280
>
282281
<slot />
@@ -663,7 +662,7 @@ const config = {
663662

664663
```javascript
665664
// webpack.config.js
666-
const { spawn } = require('child_process')
665+
const { spawn } = require('node:child_process')
667666

668667
module.exports = {
669668
// ... webpack config
@@ -684,7 +683,7 @@ module.exports = {
684683

685684
```javascript
686685
// rollup.config.js
687-
import { spawn } from 'child_process'
686+
import { spawn } from 'node:child_process'
688687

689688
function headwind() {
690689
return {
@@ -706,9 +705,9 @@ export default {
706705
### esbuild
707706

708707
```javascript
708+
import { spawn } from 'node:child_process'
709709
// build.js
710710
import * as esbuild from 'esbuild'
711-
import { spawn } from 'child_process'
712711

713712
// Build CSS first
714713
await new Promise((resolve) => {

docs/advanced/presets.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ A preset is a configuration object that can include theme customization, shortcu
99
```typescript
1010
// Before: Duplicate configuration in each project
1111
// project-a/headwind.config.ts
12+
// After: Share configuration via preset
13+
import { companyPreset } from '@company/headwind-preset'
14+
1215
const config = {
1316
theme: { colors: { primary: '#3b82f6' } },
14-
shortcuts: { 'btn': 'px-4 py-2 rounded' },
17+
shortcuts: { btn: 'px-4 py-2 rounded' },
1518
}
1619

1720
// project-b/headwind.config.ts
1821
const config = {
1922
theme: { colors: { primary: '#3b82f6' } },
20-
shortcuts: { 'btn': 'px-4 py-2 rounded' },
23+
shortcuts: { btn: 'px-4 py-2 rounded' },
2124
}
2225

23-
// After: Share configuration via preset
24-
import { companyPreset } from '@company/headwind-preset'
25-
2626
const config = {
2727
presets: [companyPreset],
2828
}
@@ -115,9 +115,9 @@ import { utilitiesPreset } from './presets/utilities'
115115

116116
const config = {
117117
presets: [
118-
basePreset, // Applied first
118+
basePreset, // Applied first
119119
componentsPreset, // Applied second, overrides base
120-
utilitiesPreset, // Applied last, overrides both
120+
utilitiesPreset, // Applied last, overrides both
121121
],
122122
}
123123
```
@@ -313,14 +313,14 @@ export const utilitiesPreset: Preset = {
313313
(match) => {
314314
const direction = match[1]
315315
const directions: Record<string, string> = {
316-
't': 'to top',
317-
'r': 'to right',
318-
'b': 'to bottom',
319-
'l': 'to left',
320-
'tr': 'to top right',
321-
'br': 'to bottom right',
322-
'bl': 'to bottom left',
323-
'tl': 'to top left',
316+
t: 'to top',
317+
r: 'to right',
318+
b: 'to bottom',
319+
l: 'to left',
320+
tr: 'to top right',
321+
br: 'to bottom right',
322+
bl: 'to bottom left',
323+
tl: 'to top left',
324324
}
325325
return {
326326
'background-image': `linear-gradient(${directions[direction] || 'to right'}, var(--tw-gradient-stops))`,
@@ -356,10 +356,10 @@ export const reactPreset: Preset = {
356356

357357
variants: {
358358
// Enable all variants for React components
359-
hover: true,
360-
focus: true,
361-
active: true,
362-
disabled: true,
359+
'hover': true,
360+
'focus': true,
361+
'active': true,
362+
'disabled': true,
363363
'focus-visible': true,
364364
'focus-within': true,
365365
},
@@ -497,7 +497,7 @@ const config = {
497497
### Preset with Custom Preflight
498498

499499
```typescript
500-
import type { Preset, Preflight } from 'headwind'
500+
import type { Preflight, Preset } from 'headwind'
501501

502502
const customPreflight: Preflight = {
503503
getCSS: () => `
@@ -617,13 +617,13 @@ Use semantic versioning for published presets:
617617
Create multiple focused presets rather than one monolithic preset:
618618

619619
```typescript
620-
// ✅ Good - focused presets
621-
import { themePreset } from './presets/theme'
622620
import { componentPreset } from './presets/components'
623-
import { utilityPreset } from './presets/utilities'
624-
625621
// ❌ Avoid - everything in one preset
626622
import { everythingPreset } from './presets/everything'
623+
// ✅ Good - focused presets
624+
import { themePreset } from './presets/theme'
625+
626+
import { utilityPreset } from './presets/utilities'
627627
```
628628

629629
### 5. Provide Examples
@@ -635,7 +635,7 @@ Include usage examples with your preset:
635635
export const examplePreset: Preset = {
636636
name: 'example',
637637
shortcuts: {
638-
'btn': 'px-4 py-2 rounded',
638+
btn: 'px-4 py-2 rounded',
639639
},
640640
}
641641

@@ -682,8 +682,8 @@ const exampleConfig = {
682682
```typescript
683683
const config = {
684684
presets: [
685-
generalPreset, // Base configuration
686-
specificPreset, // More specific overrides
685+
generalPreset, // Base configuration
686+
specificPreset, // More specific overrides
687687
],
688688
}
689689
```

0 commit comments

Comments
 (0)