Skip to content

Commit 0547ef5

Browse files
committed
chore: wip
1 parent 56b34ea commit 0547ef5

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

packages/headwind/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"exports": {
2929
".": {
3030
"types": "./dist/index.d.ts",
31-
"import": "./dist/src/index.js"
31+
"import": "./dist/index.js"
3232
},
3333
"./*": {
3434
"import": "./dist/*"

packages/headwind/src/parser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,13 @@ function parseClassImpl(className: string): ParsedClass {
10551055
// Handle compound utilities with specific prefixes
10561056
// grid-cols-3, grid-rows-2, translate-x-4, etc.
10571057
const compoundPrefixes = [
1058+
// Border side utilities (border-t-0, border-r-2, etc.)
1059+
'border-t',
1060+
'border-r',
1061+
'border-b',
1062+
'border-l',
1063+
'border-x',
1064+
'border-y',
10581065
'grid-cols',
10591066
'grid-rows',
10601067
'grid-flow',

packages/headwind/src/rules.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,40 @@ export const borderWidthRule: UtilityRule = (parsed) => {
592592
}
593593
}
594594

595+
// Border side width utilities (border-t-0, border-r-2, border-x-4, etc.)
596+
export const borderSideWidthRule: UtilityRule = (parsed) => {
597+
const sideUtilities: Record<string, string | string[]> = {
598+
'border-t': 'border-top-width',
599+
'border-r': 'border-right-width',
600+
'border-b': 'border-bottom-width',
601+
'border-l': 'border-left-width',
602+
'border-x': ['border-left-width', 'border-right-width'],
603+
'border-y': ['border-top-width', 'border-bottom-width'],
604+
}
605+
606+
const prop = sideUtilities[parsed.utility]
607+
if (!prop)
608+
return undefined
609+
610+
// Width values: 0, 2, 4, 8 (or default to 1px if no value)
611+
const widthMap: Record<string, string> = {
612+
0: '0px',
613+
2: '2px',
614+
4: '4px',
615+
8: '8px',
616+
}
617+
618+
const width = parsed.value ? widthMap[parsed.value] : '1px'
619+
if (!width)
620+
return undefined
621+
622+
if (Array.isArray(prop)) {
623+
return prop.reduce((acc, p) => ({ ...acc, [p]: width }), {} as Record<string, string>)
624+
}
625+
626+
return { [prop]: width }
627+
}
628+
595629
export const borderRadiusRule: UtilityRule = (parsed, config) => {
596630
if (parsed.utility === 'rounded') {
597631
const value = parsed.value ? config.theme.borderRadius[parsed.value] : config.theme.borderRadius.DEFAULT
@@ -661,7 +695,8 @@ export const builtInRules: UtilityRule[] = [
661695
// Forms utilities
662696
...formsRules,
663697

664-
// Border rules
698+
// Border rules (specific side rules first)
699+
borderSideWidthRule,
665700
borderWidthRule,
666701
borderRadiusRule,
667702

0 commit comments

Comments
 (0)