Skip to content

Commit 7cbee34

Browse files
committed
chore: wip
1 parent b71e60f commit 7cbee34

22 files changed

Lines changed: 2208 additions & 1698 deletions

packages/headwind/src/parser.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ export function parseClass(className: string): ParsedClass {
3333
const utility = parts[parts.length - 1]
3434
const variants = parts.slice(0, -1)
3535

36+
// Check for full utility names that should not be split (display utilities)
37+
const fullUtilityNames = [
38+
'inline-block',
39+
'inline-flex',
40+
'inline-grid',
41+
]
42+
if (fullUtilityNames.includes(utility)) {
43+
return {
44+
raw: className,
45+
variants,
46+
utility,
47+
value: undefined,
48+
important,
49+
arbitrary: false,
50+
}
51+
}
52+
3653
// Check for arbitrary values: w-[100px] or bg-[#ff0000]
3754
const arbitraryMatch = utility.match(/^([a-z-]+?)-\[(.+?)\]$/)
3855
if (arbitraryMatch) {

packages/headwind/src/rules-effects.ts

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,36 @@ export const borderStyleRule: UtilityRule = (parsed) => {
9999
}
100100

101101
export const outlineRule: UtilityRule = (parsed, config) => {
102-
if (parsed.utility === 'outline') {
103-
if (!parsed.value) {
104-
return { 'outline-width': '1px' }
105-
}
106-
const widths: Record<string, string> = {
102+
// Outline offset
103+
if (parsed.utility === 'outline-offset' && parsed.value) {
104+
const offsets: Record<string, string> = {
107105
0: '0px',
108106
1: '1px',
109107
2: '2px',
110108
4: '4px',
111109
8: '8px',
112110
}
113-
return { 'outline-width': widths[parsed.value] || parsed.value }
111+
return { 'outline-offset': offsets[parsed.value] || parsed.value }
112+
}
113+
114+
// Outline styles
115+
const outlineStyles: Record<string, string> = {
116+
'outline-none': 'none',
117+
'outline-solid': 'solid',
118+
'outline-dashed': 'dashed',
119+
'outline-dotted': 'dotted',
120+
'outline-double': 'double',
121+
}
122+
if (parsed.raw.startsWith('outline-') && outlineStyles[parsed.raw]) {
123+
return { 'outline-style': outlineStyles[parsed.raw] }
114124
}
115125

116-
// Outline colors
117-
if (parsed.utility === 'outline' && parsed.value) {
126+
if (parsed.utility === 'outline') {
127+
if (!parsed.value) {
128+
return { 'outline-width': '1px' }
129+
}
130+
131+
// Check for colors first (e.g., outline-blue-500)
118132
const parts = parsed.value.split('-')
119133
if (parts.length === 2) {
120134
const [colorName, shade] = parts
@@ -123,34 +137,27 @@ export const outlineRule: UtilityRule = (parsed, config) => {
123137
return { 'outline-color': colorValue[shade] }
124138
}
125139
}
126-
// Direct color
140+
141+
// Direct color (e.g., outline-black)
127142
const directColor = config.theme.colors[parsed.value]
128143
if (typeof directColor === 'string') {
129144
return { 'outline-color': directColor }
130145
}
131-
}
132146

133-
// Outline offset
134-
if (parsed.utility === 'outline-offset' && parsed.value) {
135-
const offsets: Record<string, string> = {
147+
// Check for width values
148+
const widths: Record<string, string> = {
136149
0: '0px',
137150
1: '1px',
138151
2: '2px',
139152
4: '4px',
140153
8: '8px',
141154
}
142-
return { 'outline-offset': offsets[parsed.value] || parsed.value }
143-
}
155+
if (widths[parsed.value]) {
156+
return { 'outline-width': widths[parsed.value] }
157+
}
144158

145-
const outlineStyles: Record<string, string> = {
146-
'outline-none': 'none',
147-
'outline-solid': 'solid',
148-
'outline-dashed': 'dashed',
149-
'outline-dotted': 'dotted',
150-
'outline-double': 'double',
151-
}
152-
if (parsed.raw.startsWith('outline-') && outlineStyles[parsed.raw]) {
153-
return { 'outline-style': outlineStyles[parsed.raw] }
159+
// Fallback to raw value as width
160+
return { 'outline-width': parsed.value }
154161
}
155162
}
156163

packages/headwind/src/rules-layout.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,17 @@ export const insetRule: UtilityRule = (parsed, config) => {
169169
if (!props || !parsed.value)
170170
return undefined
171171

172-
const value = config.theme.spacing[parsed.value] || parsed.value
172+
// Handle negative values
173+
let value: string
174+
if (parsed.value.startsWith('-')) {
175+
const positiveValue = parsed.value.slice(1)
176+
const spacing = config.theme.spacing[positiveValue]
177+
value = spacing ? `-${spacing}` : parsed.value
178+
}
179+
else {
180+
value = config.theme.spacing[parsed.value] || parsed.value
181+
}
182+
173183
const result: Record<string, string> = {}
174184
for (const prop of props) {
175185
result[prop] = value

0 commit comments

Comments
 (0)