Skip to content

refactor: migrate Abbr to Tailwind #19242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions site/src/components/Abbr/Abbr.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -45,7 +45,7 @@ export const Acronym: Story = {
},
decorators: [
(Story) => (
<span css={styles.underlined}>
<span className="underline decoration-dotted">
<Story />
</span>
),
Expand All @@ -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",
},
};
11 changes: 7 additions & 4 deletions site/src/components/Abbr/Abbr.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { FC, HTMLAttributes } from "react";
import { cn } from "utils/cn";

export type Pronunciation = "shorthand" | "acronym" | "initialism";

Expand Down Expand Up @@ -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>
Expand Down
Loading