Skip to content

Commit

Permalink
Merge pull request #24433 from storybookjs/new-icon-library
Browse files Browse the repository at this point in the history
UI: New icon library
  • Loading branch information
cdedreuille authored Oct 19, 2023
2 parents f03ed59 + b332f40 commit a994219
Show file tree
Hide file tree
Showing 88 changed files with 871 additions and 1,772 deletions.
5 changes: 5 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [Core changes](#core-changes)
- [UI layout state has changed shape](#ui-layout-state-has-changed-shape)
- [New UI and props for Button and IconButton components](#new-ui-and-props-for-button-and-iconbutton-components)
- [Icons is deprecated](#icons-is-deprecated)
- [From version 7.4.0 to 7.5.0](#from-version-740-to-750)
- [`storyStoreV6` and `storiesOf` is deprecated](#storystorev6-and-storiesof-is-deprecated)
- [`storyIndexers` is replaced with `experimental_indexers`](#storyindexers-is-replaced-with-experimental_indexers)
Expand Down Expand Up @@ -339,6 +340,10 @@ For the `Button` component, the following props are now deprecated:

The `IconButton` doesn't have any deprecated props but it now uses the new `Button` component under the hood so all props for `IconButton` will be the same as `Button`.

#### Icons is deprecated

In Storybook 8.0 we are introducing a new icon library available with `@storybook/icons`. We are deprecating the `Icons` component in `@storybook/components` and recommend that addon creators and Storybook maintainers use the new `@storybook/icons` component instead.

## From version 7.4.0 to 7.5.0

#### `storyStoreV6` and `storiesOf` is deprecated
Expand Down
1 change: 1 addition & 0 deletions code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.1",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
Expand Down
11 changes: 5 additions & 6 deletions code/addons/a11y/src/components/A11YPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React, { useCallback, useMemo, useState } from 'react';

import { styled } from '@storybook/theming';

import { ActionBar, Icons, ScrollArea } from '@storybook/components';
import { ActionBar, ScrollArea } from '@storybook/components';
import { SyncIcon, CheckIcon } from '@storybook/icons';

import type { AxeResults } from 'axe-core';
import { useChannel, useParameter, useStorybookState } from '@storybook/manager-api';
Expand All @@ -21,9 +22,7 @@ export enum RuleType {
INCOMPLETION,
}

const Icon = styled(Icons)({
height: 12,
width: 12,
const Icon = styled(SyncIcon)({
marginRight: 4,
});

Expand Down Expand Up @@ -108,7 +107,7 @@ export const A11YPanel: React.FC = () => {
'Rerun tests'
) : (
<>
<Icon icon="check" /> Tests completed
<CheckIcon /> Tests completed
</>
),
onClick: handleManual,
Expand Down Expand Up @@ -164,7 +163,7 @@ export const A11YPanel: React.FC = () => {
)}
{status === 'running' && (
<Centered>
<RotatingIcon icon="sync" /> Please wait while the accessibility scan is running ...
<RotatingIcon size={12} /> Please wait while the accessibility scan is running ...
</Centered>
)}
{(status === 'ready' || status === 'ran') && (
Expand Down
5 changes: 3 additions & 2 deletions code/addons/a11y/src/components/VisionSimulator.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { ReactNode } from 'react';
import React, { useState } from 'react';
import { Global, styled } from '@storybook/theming';
import { Icons, IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';
import { IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';

import { AccessibilityIcon } from '@storybook/icons';
import { Filters } from './ColorFilters';

const iframeId = 'storybook-preview-iframe';
Expand Down Expand Up @@ -144,7 +145,7 @@ export const VisionSimulator = () => {
onDoubleClick={() => setFilter(null)}
>
<IconButton key="filter" active={!!filter} title="Vision simulator">
<Icons icon="accessibility" />
<AccessibilityIcon />
</IconButton>
</WithTooltip>
<Hidden>
Expand Down
1 change: 1 addition & 0 deletions code/addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.1",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions code/addons/backgrounds/src/containers/BackgroundSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import memoize from 'memoizerific';

import { useParameter, useGlobals } from '@storybook/manager-api';
import { logger } from '@storybook/client-logger';
import { Icons, IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';
import { IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';

import { PhotoIcon } from '@storybook/icons';
import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants';
import { ColorIcon } from '../components/ColorIcon';
import type {
Expand Down Expand Up @@ -140,7 +141,7 @@ export const BackgroundSelector: FC = memo(function BackgroundSelector() {
title="Change the background of the preview"
active={selectedBackgroundColor !== 'transparent' || isTooltipVisible}
>
<Icons icon="photo" />
<PhotoIcon />
</IconButton>
</WithTooltip>
</Fragment>
Expand Down
5 changes: 3 additions & 2 deletions code/addons/backgrounds/src/containers/GridSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import type { FC } from 'react';
import React, { memo } from 'react';

import { useGlobals, useParameter } from '@storybook/manager-api';
import { Icons, IconButton } from '@storybook/components';
import { IconButton } from '@storybook/components';

import { GridIcon } from '@storybook/icons';
import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants';

export const GridSelector: FC = memo(function GridSelector() {
Expand All @@ -30,7 +31,7 @@ export const GridSelector: FC = memo(function GridSelector() {
})
}
>
<Icons icon="grid" />
<GridIcon />
</IconButton>
);
});
1 change: 1 addition & 0 deletions code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@storybook/core-common": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.1",
"@storybook/instrumenter": "workspace:*",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions code/addons/interactions/src/components/Interaction.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from 'react';
import { IconButton, Icons, TooltipNote, WithTooltip } from '@storybook/components';
import { IconButton, TooltipNote, WithTooltip } from '@storybook/components';
import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter';
import { styled, typography } from '@storybook/theming';
import { transparentize } from 'polished';

import { ListUnorderedIcon } from '@storybook/icons';
import { MatcherResult } from './MatcherResult';
import { MethodCall } from './MethodCall';
import { StatusIcon } from './StatusIcon';
Expand Down Expand Up @@ -174,7 +175,7 @@ export const Interaction = ({
tooltip={<Note note={`${isCollapsed ? 'Show' : 'Hide'} interactions`} />}
>
<StyledIconButton containsIcon onClick={toggleCollapsed}>
<Icons icon="listunordered" />
<ListUnorderedIcon />
</StyledIconButton>
</WithTooltip>
)}
Expand Down
18 changes: 12 additions & 6 deletions code/addons/interactions/src/components/Subnav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import {
Button,
IconButton,
Icons,
Separator,
P,
TooltipNote,
Expand All @@ -14,6 +13,13 @@ import type { Call, ControlStates } from '@storybook/instrumenter';
import { CallStates } from '@storybook/instrumenter';
import { styled } from '@storybook/theming';

import {
FastForwardIcon,
PlayBackIcon,
PlayNextIcon,
RewindIcon,
SyncIcon,
} from '@storybook/icons';
import { StatusBadge } from './StatusBadge';

import type { Controls } from './InteractionsPanel';
Expand Down Expand Up @@ -135,7 +141,7 @@ export const Subnav: React.FC<SubnavProps> = ({
onClick={controls.start}
disabled={!controlStates.start}
>
<Icons icon="rewind" />
<RewindIcon />
</RewindButton>
</WithTooltip>

Expand All @@ -146,7 +152,7 @@ export const Subnav: React.FC<SubnavProps> = ({
onClick={controls.back}
disabled={!controlStates.back}
>
<Icons icon="playback" />
<PlayBackIcon />
</StyledIconButton>
</WithTooltip>

Expand All @@ -157,7 +163,7 @@ export const Subnav: React.FC<SubnavProps> = ({
onClick={controls.next}
disabled={!controlStates.next}
>
<Icons icon="playnext" />
<PlayNextIcon />
</StyledIconButton>
</WithTooltip>

Expand All @@ -168,13 +174,13 @@ export const Subnav: React.FC<SubnavProps> = ({
onClick={controls.end}
disabled={!controlStates.end}
>
<Icons icon="fastforward" />
<FastForwardIcon />
</StyledIconButton>
</WithTooltip>

<WithTooltip trigger="hover" hasChrome={false} tooltip={<Note note="Rerun" />}>
<RerunButton aria-label="Rerun" containsIcon onClick={controls.rerun}>
<Icons icon="sync" />
<SyncIcon />
</RerunButton>
</WithTooltip>
</Group>
Expand Down
1 change: 1 addition & 0 deletions code/addons/measure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.1",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/types": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions code/addons/measure/src/Tool.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback, useEffect } from 'react';
import { useGlobals, useStorybookApi } from '@storybook/manager-api';
import { Icons, IconButton } from '@storybook/components';
import { IconButton } from '@storybook/components';
import { RulerIcon } from '@storybook/icons';
import { TOOL_ID, ADDON_ID } from './constants';

export const Tool = () => {
Expand Down Expand Up @@ -33,7 +34,7 @@ export const Tool = () => {
title="Enable measure"
onClick={toggleMeasure}
>
<Icons icon="ruler" />
<RulerIcon />
</IconButton>
);
};
1 change: 1 addition & 0 deletions code/addons/outline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.1",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/types": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions code/addons/outline/src/OutlineSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { memo, useCallback, useEffect } from 'react';
import { useGlobals, useStorybookApi } from '@storybook/manager-api';
import { Icons, IconButton } from '@storybook/components';
import { IconButton } from '@storybook/components';
import { OutlineIcon } from '@storybook/icons';
import { ADDON_ID, PARAM_KEY } from './constants';

export const OutlineSelector = memo(function OutlineSelector() {
Expand Down Expand Up @@ -34,7 +35,7 @@ export const OutlineSelector = memo(function OutlineSelector() {
title="Apply outlines to the preview"
onClick={toggleOutline}
>
<Icons icon="outline" />
<OutlineIcon />
</IconButton>
);
});
1 change: 1 addition & 0 deletions code/addons/themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@storybook/client-logger": "workspace:*",
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/icons": "^1.2.1",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions code/addons/themes/src/theme-switcher.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { Fragment, useMemo } from 'react';
import { useAddonState, useChannel, useGlobals, useParameter } from '@storybook/manager-api';
import { styled } from '@storybook/theming';
import { Icons, IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';
import { IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';

import { PaintBrushIcon } from '@storybook/icons';
import type { ThemeAddonState, ThemeParameters } from './constants';
import {
PARAM_KEY,
Expand Down Expand Up @@ -74,7 +75,7 @@ export const ThemeSwitcher = () => {
}}
>
<IconButton key={THEME_SWITCHER_ID} active={!themeOverride} title="Theme">
<Icons icon="paintbrush" />
<PaintBrushIcon />
{label && <IconButtonLabel>{label}</IconButtonLabel>}
</IconButton>
</WithTooltip>
Expand Down
5 changes: 2 additions & 3 deletions code/addons/toolbars/src/components/ToolbarMenuListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type ToolbarMenuListItemProps = {
} & ToolbarItem;

export const ToolbarMenuListItem = ({
left,
right,
title,
value,
Expand All @@ -25,12 +24,12 @@ export const ToolbarMenuListItem = ({
active: currentValue === value,
right,
title,
left,
icon,
onClick,
};

if (icon && !hideIcon) {
Item.left = Icon;
Item.icon = Icon;
}

return Item;
Expand Down
1 change: 1 addition & 0 deletions code/addons/viewport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.1",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
Expand Down
7 changes: 4 additions & 3 deletions code/addons/viewport/src/Tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import memoize from 'memoizerific';

import { styled, Global, type Theme, withTheme } from '@storybook/theming';

import { Icons, IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';
import { IconButton, WithTooltip, TooltipLinkList } from '@storybook/components';

import { useStorybookApi, useParameter, useAddonState } from '@storybook/manager-api';
import { GrowIcon, TransferIcon } from '@storybook/icons';
import { registerShortcuts } from './shortcuts';
import { PARAM_KEY, ADDON_ID } from './constants';
import { MINIMAL_VIEWPORTS } from './defaults';
Expand Down Expand Up @@ -186,7 +187,7 @@ export const ViewportTool: FC = memo(
setState({ ...state, selected: responsiveViewport.id });
}}
>
<Icons icon="grow" />
<GrowIcon />
{styles ? (
<IconButtonLabel>
{isRotated ? `${item.title} (L)` : `${item.title} (P)`}
Expand Down Expand Up @@ -217,7 +218,7 @@ export const ViewportTool: FC = memo(
setState({ ...state, isRotated: !isRotated });
}}
>
<Icons icon="transfer" />
<TransferIcon />
</IconButton>
<ActiveViewportLabel title="Viewport height">
{styles.height.replace('px', '')}
Expand Down
10 changes: 0 additions & 10 deletions code/ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ export const decorators = [
) : (
<Story />
),
/**
* This decorator adds Symbols that the sidebar icons references.
* Any sidebar story that uses the icons must set the parameter withSymbols: true .
*/
(Story, { parameters: { withSymbols } }) => (
<>
{withSymbols && <Symbols icons={['folder', 'component', 'document', 'bookmarkhollow']} />}
<Story />
</>
),
/**
* This decorator renders the stories side-by-side, stacked or default based on the theme switcher in the toolbar
*/
Expand Down
1 change: 1 addition & 0 deletions code/ui/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@storybook/csf": "^0.1.0",
"@storybook/docs-tools": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.1",
"@storybook/manager-api": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@storybook/theming": "workspace:*",
Expand Down
Loading

0 comments on commit a994219

Please sign in to comment.