Skip to content
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
31 changes: 31 additions & 0 deletions src/components/ui/icon/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,37 @@ describe("Icon", () => {
});
});

describe("フォントウェイト / Font Weight", () => {
it("font-medium が常に付与される(weight 500 統一)", () => {
// Given: 基本的なIcon
// en: Given a basic Icon
testContainer.render(<Icon icon="check" />);

// When: aria-hiddenなspan要素を取得
// en: When selecting the aria-hidden span element
const span = testContainer.querySelector("span[aria-hidden='true']");

// Then: 親の font-weight 継承(疑似ボールド)を防ぐ font-medium が付与される
// en: Then font-medium is applied to prevent inherited font-weight (faux bold)
expect(StyleHelpers.hasClass(span, "font-medium")).toBe(true);
});

it("className で font-weight を上書きできる", () => {
// Given: font-bold を className で指定
// en: Given font-bold provided via className
testContainer.render(<Icon icon="check" className="font-bold" />);

// When: aria-hiddenなspan要素を取得
// en: When selecting the aria-hidden span element
const span = testContainer.querySelector("span[aria-hidden='true']");

// Then: tailwind-merge により font-bold が優先される
// en: Then font-bold wins via tailwind-merge
expect(StyleHelpers.hasClass(span, "font-bold")).toBe(true);
expect(StyleHelpers.hasClass(span, "font-medium")).toBe(false);
});
});

describe("HTMLAttributes / Props", () => {
it("id や data 属性、style が反映される", () => {
// Given
Expand Down
10 changes: 9 additions & 1 deletion src/components/ui/icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ export const Icon = React.forwardRef<HTMLSpanElement, IconProps>(
return (
<span
ref={ref}
className={cn(iconTypographyClass, "select-none", className)}
// font-medium: アイコンの weight は 500 で統一。親要素(Button の bold 等)から
// font-weight が継承されると疑似ボールド(faux bold)で太く描画されるため明示する。
// en: Icons are unified at weight 500. Set font-weight explicitly so an inherited
// font-weight (e.g. bold Button labels) does not trigger faux-bold rendering.
className={cn(
iconTypographyClass,
"select-none font-medium",
className
)}
aria-hidden="true"
{...props}
>
Expand Down
Loading