import React, { useState } from 'react' import { type Meta, type StoryObj } from '@storybook/react' import classnames from 'classnames' import { Button } from '~components/Button' import { InlineNotification } from '~components/Notification' import { TableCard, TableContainer, TableHeader, TableHeaderRowCell, TableRow, TableRowCell, } from '~components/Table' import { Text } from '~components/Text' import { ToggleSwitchField } from '~components/ToggleSwitch' import { Tag } from '~components/__next__/Tag' import { StickerSheet } from '~storybook/components/StickerSheet' import { iconMap } from '../../../codemods/upgradeIconV1/getNewIconPropsFromOldIconName' import { iconDefaultSet } from '../constants' import { Icon } from '../index' import imgInterfaceDont from './assets/interface-dont.png' import imgTooltipDont from './assets/tooltip-dont.png' import styles from './Icon.docs.module.css' const meta = { title: 'Components/Icon', component: Icon, args: { name: 'star', isPresentational: true, }, argTypes: { name: { type: 'string' }, alt: { description: 'Set this value when `isPresentational={false}`', }, }, } satisfies Meta export default meta type Story = StoryObj export const Playground: Story = { render: (args) => { if (args.isPresentational) return return }, } export const Filled: Story = { args: { isFilled: true }, } export const MirrorInRTL: Story = { render: (args) => (
), parameters: { docs: { source: { code: `
`, }, }, }, } export const Color: Story = { render: (args) => (
), } export const Size: Story = { render: (args) => (
), } export const MeaningfulIcon: Story = { render: (args) => ( }> Meaningful icons can be helpful ), args: { isPresentational: false, alt: 'Info:', name: 'info', isFilled: true }, } export const PresentationalIcon: Story = { render: (args) => ( ), args: { isPresentational: true, name: 'add' }, } const IconSetButton = ({ iconName, isFilled, }: { iconName: string isFilled: boolean }): JSX.Element => { const [copied, setCopied] = useState(false) const handleCopy = (): void => { const snippet = isFilled ? `` : `` navigator.clipboard.writeText(snippet) setCopied(true) setTimeout(() => setCopied(false), 1000) } return (
  • ) } export const DefaultIconSet: Story = { render: () => { const [isFilled, setIsFilled] = useState(false) return (
    setIsFilled(!isFilled)} />
      {iconDefaultSet.map((iconName) => ( ))}
    ) }, } export const ConsistentDo: Story = { render: () => ( Edit ), } export const FilledUnfilledDo: Story = { render: () => (
    Default state
    Selected
    ), } export const OpticalSizeDo: Story = { render: () => (
    20/20
    24/24
    40/40
    48/48
    ), } export const OpticalSizeDont: Story = { render: () => (
    20/48
    24/40
    40/24
    48/20
    ), } export const AlignmentDo: Story = { render: () => ( Symbol baseline set lower in relation to symbol. ), } export const AlignmentDont: Story = { render: () => ( Both symbol and text set on same baseline. ), } export const ContrastDo: Story = { render: () => (
    ), } export const ContrastDont: Story = { render: () => (
    ), } export const ColorPurposefulDo: Story = { render: () => ( <> Success Error ), } export const DistinguishDo: Story = { render: () => (
    Default state
    Selected
    ), } export const DistinguishDont: Story = { render: () => (
    Default state
    Selected
    ), } export const InterfaceDont: Story = { render: () => ( Example of a bad interface ), } export const ImportantInformationDo: Story = { render: () => ( John Johnson Michelle Summer ), } export const ImportantInformationDont: Story = { render: () => ( John Johnson Michelle Summer ), parameters: { a11y: { disable: true }, // accessible label fix to be addressed in a separate PR }, } const InteractiveIcon = (props: Record): JSX.Element => ( ) export const InteractiveStatesDo: Story = { render: () => (
    Base Hover Focus
    ), parameters: { pseudo: { hover: '[data-sb-pseudo-styles="hover"]', focus: '[data-sb-pseudo-styles="focus"]', focusVisible: '[data-sb-pseudo-styles="focus"]', }, }, } export const TooltipDont: Story = { render: () => ( Example of a bad use of a tooltip on an icon ), } export const IconTableComparison: Story = { render: () => { return ( {Array.from(iconMap).map(([key, value]) => ( {key} {value?.name ?? 'N/A'} {value?.isFilled ? 'true' : value?.name ? 'false' : 'N/A'} ))} ) }, }