@@ -105,7 +105,7 @@ export const listStyleTypeRule: UtilityRule = (parsed) => {
105105 }
106106}
107107
108- export const textDecorationRule : UtilityRule = ( parsed ) => {
108+ export const textDecorationRule : UtilityRule = ( parsed , config ) => {
109109 const decorations : Record < string , string > = {
110110 underline : 'underline' ,
111111 overline : 'overline' ,
@@ -124,12 +124,63 @@ export const textDecorationRule: UtilityRule = (parsed) => {
124124 dashed : 'dashed' ,
125125 wavy : 'wavy' ,
126126 }
127- return { 'text-decoration-style' : styles [ parsed . value ] || parsed . value }
127+
128+ // Check if it's a style
129+ if ( styles [ parsed . value ] ) {
130+ return { 'text-decoration-style' : styles [ parsed . value ] }
131+ }
132+
133+ // Check if it's a thickness
134+ const thicknesses : Record < string , string > = {
135+ auto : 'auto' ,
136+ from : 'from-font' ,
137+ 0 : '0px' ,
138+ 1 : '1px' ,
139+ 2 : '2px' ,
140+ 4 : '4px' ,
141+ 8 : '8px' ,
142+ }
143+ if ( thicknesses [ parsed . value ] ) {
144+ return { 'text-decoration-thickness' : thicknesses [ parsed . value ] }
145+ }
146+
147+ // Otherwise treat it as a color: decoration-blue-500
148+ const parts = parsed . value . split ( '-' )
149+ if ( parts . length === 2 ) {
150+ const [ colorName , shade ] = parts
151+ const colorValue = config . theme . colors [ colorName ]
152+ if ( typeof colorValue === 'object' && colorValue [ shade ] ) {
153+ return { 'text-decoration-color' : colorValue [ shade ] }
154+ }
155+ }
156+
157+ // Direct color
158+ const directColor = config . theme . colors [ parsed . value ]
159+ if ( typeof directColor === 'string' ) {
160+ return { 'text-decoration-color' : directColor }
161+ }
162+
163+ // Fallback
164+ return { 'text-decoration-color' : parsed . value }
128165 }
129166
130167 return undefined
131168}
132169
170+ export const underlineOffsetRule : UtilityRule = ( parsed ) => {
171+ if ( parsed . utility === 'underline-offset' && parsed . value ) {
172+ const offsets : Record < string , string > = {
173+ auto : 'auto' ,
174+ 0 : '0px' ,
175+ 1 : '1px' ,
176+ 2 : '2px' ,
177+ 4 : '4px' ,
178+ 8 : '8px' ,
179+ }
180+ return { 'text-underline-offset' : offsets [ parsed . value ] || parsed . value }
181+ }
182+ }
183+
133184export const textTransformRule : UtilityRule = ( parsed ) => {
134185 const transforms : Record < string , string > = {
135186 uppercase : 'uppercase' ,
@@ -232,18 +283,47 @@ export const contentRule: UtilityRule = (parsed) => {
232283 }
233284}
234285
286+ export const lineHeightRule : UtilityRule = ( parsed , config ) => {
287+ if ( parsed . utility === 'leading' ) {
288+ if ( ! parsed . value ) {
289+ return undefined
290+ }
291+
292+ const lineHeights : Record < string , string > = {
293+ none : '1' ,
294+ tight : '1.25' ,
295+ snug : '1.375' ,
296+ normal : '1.5' ,
297+ relaxed : '1.625' ,
298+ loose : '2' ,
299+ 3 : '.75rem' ,
300+ 4 : '1rem' ,
301+ 5 : '1.25rem' ,
302+ 6 : '1.5rem' ,
303+ 7 : '1.75rem' ,
304+ 8 : '2rem' ,
305+ 9 : '2.25rem' ,
306+ 10 : '2.5rem' ,
307+ }
308+
309+ return { 'line-height' : lineHeights [ parsed . value ] || parsed . value }
310+ }
311+ }
312+
235313export const typographyRules : UtilityRule [ ] = [
236314 fontFamilyRule ,
237315 fontSmoothingRule ,
238316 fontStyleRule ,
239317 fontStretchRule ,
240318 fontVariantNumericRule ,
241319 letterSpacingRule ,
320+ lineHeightRule ,
242321 lineClampRule ,
243322 listStyleImageRule ,
244323 listStylePositionRule ,
245324 listStyleTypeRule ,
246325 textDecorationRule ,
326+ underlineOffsetRule ,
247327 textTransformRule ,
248328 textOverflowRule ,
249329 textWrapRule ,
0 commit comments