Skip to content

Commit 0acba30

Browse files
authored
fix(typography): scale link underline with font size, include pseudo styling in utility (#410)
This commit: - Scales the link decoration (offset + thickness) with the font size, fixing an issue where no change would be visible when users customize the font size in their browsers - Moves the hover and focus styles that are currently defined outside the `@utility` directive into the utility directive, removing the need to manually add them when using typography utilities with `@apply` Addresses functional review feedback from RISDEV-9450
1 parent 4a6fd1b commit 0acba30

File tree

1 file changed

+58
-33
lines changed

1 file changed

+58
-33
lines changed

src/tailwind/global.css

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,16 @@
277277
font-weight: normal;
278278
line-height: 1.5;
279279
text-decoration: underline;
280-
text-underline-offset: 3px;
280+
text-underline-offset: 0.1875rem;
281+
282+
&:hover {
283+
text-decoration-thickness: 0.1875rem;
284+
}
285+
286+
&:focus-visible {
287+
outline: var(--color-blue-800) solid 4px;
288+
outline-offset: 4px;
289+
}
281290
}
282291

283292
@utility ris-link1-bold {
@@ -286,7 +295,16 @@
286295
font-weight: bold;
287296
line-height: 1.5;
288297
text-decoration: underline;
289-
text-underline-offset: 3px;
298+
text-underline-offset: 0.1875rem;
299+
300+
&:hover {
301+
text-decoration-thickness: 0.1875rem;
302+
}
303+
304+
&:focus-visible {
305+
outline: var(--color-blue-800) solid 4px;
306+
outline-offset: 4px;
307+
}
290308
}
291309

292310
@utility ris-link2-regular {
@@ -295,7 +313,16 @@
295313
font-weight: normal;
296314
line-height: 1.5;
297315
text-decoration: underline;
298-
text-underline-offset: 2px;
316+
text-underline-offset: 0.125rem;
317+
318+
&:hover {
319+
text-decoration-thickness: 0.125rem;
320+
}
321+
322+
&:focus-visible {
323+
outline: var(--color-blue-800) solid 4px;
324+
outline-offset: 4px;
325+
}
299326
}
300327

301328
@utility ris-link2-bold {
@@ -304,7 +331,16 @@
304331
font-weight: bold;
305332
line-height: 1.5;
306333
text-decoration: underline;
307-
text-underline-offset: 2px;
334+
text-underline-offset: 0.125rem;
335+
336+
&:hover {
337+
text-decoration-thickness: 0.125rem;
338+
}
339+
340+
&:focus-visible {
341+
outline: var(--color-blue-800) solid 4px;
342+
outline-offset: 4px;
343+
}
308344
}
309345

310346
@utility ris-link3-regular {
@@ -313,7 +349,16 @@
313349
font-weight: normal;
314350
line-height: 1.5;
315351
text-decoration: underline;
316-
text-underline-offset: 2px;
352+
text-underline-offset: 0.125rem;
353+
354+
&:hover {
355+
text-decoration-thickness: 0.125rem;
356+
}
357+
358+
&:focus-visible {
359+
outline: var(--color-blue-800) solid 4px;
360+
outline-offset: 4px;
361+
}
317362
}
318363

319364
@utility ris-link3-bold {
@@ -322,34 +367,14 @@
322367
font-weight: bold;
323368
line-height: 1.5;
324369
text-decoration: underline;
325-
text-underline-offset: 2px;
326-
}
370+
text-underline-offset: 0.125rem;
327371

328-
/* Utility pseudo-classes */
329-
330-
/*
331-
These styles might be written more concisely using @apply directives.
332-
However, using @apply inside @utility statements silently breaks class name generation
333-
as of Tailwind v4.0.17.
334-
*/
335-
.ris-link1-regular:hover,
336-
.ris-link1-bold:hover {
337-
text-decoration-thickness: 3px;
338-
}
339-
340-
.ris-link2-regular:hover,
341-
.ris-link2-bold:hover,
342-
.ris-link3-regular:hover,
343-
.ris-link3-bold:hover {
344-
text-decoration-thickness: 2px;
345-
}
372+
&:hover {
373+
text-decoration-thickness: 0.125rem;
374+
}
346375

347-
.ris-link1-regular:focus-visible,
348-
.ris-link1-bold:focus-visible,
349-
.ris-link2-regular:focus-visible,
350-
.ris-link2-bold:focus-visible,
351-
.ris-link3-regular:focus-visible,
352-
.ris-link3-bold:focus-visible {
353-
outline: var(--color-blue-800) solid 4px;
354-
outline-offset: 4px;
376+
&:focus-visible {
377+
outline: var(--color-blue-800) solid 4px;
378+
outline-offset: 4px;
379+
}
355380
}

0 commit comments

Comments
 (0)