+ {(['ltr', 'rtl'] as const).map((dir) => (
+
+ {(['sm', 'md', 'lg'] as const).map((size) => (
+
+
+ {dir.toUpperCase()} {size}
+
+
+
+
+ ))}
+
+ ))}
+
+ )
+};
+
/** The sm, md and lg presets: 12.8, 16 (--icon-size) and 22.4px. */
export const Sizes: Story = {
args: { name: 'radio' },
diff --git a/packages/ui/src/atoms/icon/Icon.test.tsx b/packages/ui/src/atoms/icon/Icon.test.tsx
index 5408d6d7..4043d0de 100644
--- a/packages/ui/src/atoms/icon/Icon.test.tsx
+++ b/packages/ui/src/atoms/icon/Icon.test.tsx
@@ -2,13 +2,64 @@ import { readdirSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { render, renderHook, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { describe, expect, it } from 'vitest';
+import { describe, expect, expectTypeOf, it } from 'vitest';
+import type { IconName as PublicIconName, IconProps as PublicIconProps } from '../../index';
import { Icon } from './Icon';
-import { Gallery } from './Icon.stories';
+import { Directions, Gallery } from './Icon.stories';
import { iconPaths } from './icon-paths';
import type { IconName, IconSize } from './types';
import { useIcon } from './useIcon';
+const expectedNames = [
+ 'github',
+ 'youtube',
+ 'twitch',
+ 'x',
+ 'linkedin',
+ 'instagram',
+ 'search',
+ 'arrow-left',
+ 'arrow-right',
+ 'arrow-up-right',
+ 'arrow-down',
+ 'play',
+ 'users',
+ 'menu',
+ 'radio',
+ 'terminal',
+ 'hammer',
+ 'compass',
+ 'alert',
+ 'close',
+ 'user',
+ 'bookmark',
+ 'bell',
+ 'settings',
+ 'log-out',
+ 'chevron-down',
+ 'calendar',
+ 'inbox',
+ 'lightbulb',
+ 'shuffle',
+ 'pause',
+ 'pencil',
+ 'send',
+ 'grip',
+ 'upload',
+ 'flask',
+ 'plug',
+ 'bot',
+ 'trash',
+ 'copy',
+ 'check',
+ 'minus',
+ 'plus',
+ 'circle-alert',
+ 'circle-check',
+ 'info',
+ 'download',
+ 'external-link'
+] as const satisfies readonly PublicIconName[];
const names = Object.keys(iconPaths) as IconName[];
const sizes: [IconSize, string][] = [
['sm', 'size-4'],
@@ -17,6 +68,11 @@ const sizes: [IconSize, string][] = [
];
const glyphElements = new Set(['path', 'circle', 'rect', 'line', 'polyline', 'polygon']);
const newGlyphs = [
+ {
+ name: 'arrow-left',
+ label: 'Go back',
+ paths: ['M19 12h-14', 'm12 5-7 7 7 7']
+ },
{
name: 'download',
label: 'Download',
@@ -38,28 +94,69 @@ const svgOf = (container: HTMLElement) => {
};
describe('Icon glyph set', () => {
- it('ships exactly 47 names, including both additions and the existing status glyphs', () => {
- expect(names).toHaveLength(47);
- expect(new Set(names).size).toBe(47);
+ it('ships exactly the prior 47 names plus arrow-left through the public type and glyph set', () => {
+ expect(expectedNames).toHaveLength(48);
+ expect(new Set(expectedNames).size).toBe(48);
+ expect(names).toHaveLength(48);
+ expect(new Set(names).size).toBe(48);
+ expect([...names].sort()).toEqual([...expectedNames].sort());
expect(names).not.toContain('external');
- for (const name of [
- 'check',
- 'minus',
- 'plus',
- 'chevron-down',
- 'grip',
- 'flask',
- 'trash',
- 'circle-alert',
- 'circle-check',
- 'info',
- 'download',
- 'external-link'
- ] as const) {
- expect(names).toContain(name);
+ expectTypeOf