refactor: migrate Abbr to Tailwind (#19242)

This commit is contained in:
ケイラ
2025-08-07 15:27:49 -06:00
committed by GitHub
parent 5225c5671d
commit d1e64affd6
2 changed files with 11 additions and 15 deletions
+4 -11
View File
@@ -25,10 +25,10 @@ export const InlinedShorthand: Story = {
},
decorators: [
(Story) => (
<p css={{ maxWidth: "40em" }}>
<p className="max-w-2xl">
The physical pain of getting bonked on the head with a cartoon mallet
lasts precisely 593{" "}
<span css={styles.underlined}>
<span className="underline decoration-dotted">
<Story />
</span>
. The emotional turmoil and complete embarrassment lasts forever.
@@ -45,7 +45,7 @@ export const Acronym: Story = {
},
decorators: [
(Story) => (
<span css={styles.underlined}>
<span className="underline decoration-dotted">
<Story />
</span>
),
@@ -60,16 +60,9 @@ export const Initialism: Story = {
},
decorators: [
(Story) => (
<span css={styles.underlined}>
<span className="underline decoration-dotted">
<Story />
</span>
),
],
};
const styles = {
// Just here to make the abbreviated part more obvious in the component library
underlined: {
textDecoration: "underline dotted",
},
};
+7 -4
View File
@@ -1,4 +1,5 @@
import type { FC, HTMLAttributes } from "react";
import { cn } from "utils/cn";
export type Pronunciation = "shorthand" | "acronym" | "initialism";
@@ -29,10 +30,12 @@ export const Abbr: FC<AbbrProps> = ({
// always have to supplement with aria-label
title={title}
aria-label={getAccessibleLabel(children, title, pronunciation)}
css={{
textDecoration: "inherit",
letterSpacing: children === children.toUpperCase() ? "0.02em" : "0",
}}
className={cn(
"decoration-inherit",
children === children.toUpperCase()
? "tracking-wide"
: "tracking-normal",
)}
{...delegatedProps}
>
<span aria-hidden>{children}</span>