Skip to content
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

Automatically add new icons to the icons story in Storybook #3873

Merged
merged 2 commits into from
May 12, 2023
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
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ If you have added any icon (custom or from codicon), you will have to run
`yarn svgr` or `yarn install` to ensure the icon is now available in the
codebase.

You should also add any added icon to `webview/src/stories/Icons.stories.tsx`.

To use an icon, import it from `webview/src/shared/components/icons` (from the
index file, not the file itself) and use it with the `<Icon />` component
filling its `icon` prop with your imported icon.
124 changes: 20 additions & 104 deletions webview/src/stories/Icons.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,8 @@ import { IconWrapper } from './components/IconWrapper'
import { IconsWrapper } from './components/IconsWrapper'
import { DISABLE_CHROMATIC_SNAPSHOTS } from './util'
import { Icon } from '../shared/components/Icon'
import {
Add,
Check,
ChevronDown,
ChevronRight,
Clock,
Close,
Copy,
ArrowDown,
Ellipsis,
Error,
Filter,
GitCommit,
GitMerge,
GraphLine,
GraphScatter,
Gripper,
ListFilter,
PassFilled,
Pinned,
Refresh,
SortPrecedence,
StarEmpty,
StarFull,
Trash,
ArrowUp
} from '../shared/components/icons'

import * as Icons from '../shared/components/icons'

export default {
args: {
Expand All @@ -44,83 +19,24 @@ export default {

const Template: StoryFn = () => {
return (
<IconsWrapper>
<IconWrapper name="Add">
<Icon icon={Add} />
</IconWrapper>
<IconWrapper name="Check">
<Icon icon={Check} />
</IconWrapper>
<IconWrapper name="ChevronDown">
<Icon icon={ChevronDown} />
</IconWrapper>
<IconWrapper name="ChevronRight">
<Icon icon={ChevronRight} />
</IconWrapper>
<IconWrapper name="Clock">
<Icon icon={Clock} />
</IconWrapper>
<IconWrapper name="Close">
<Icon icon={Close} />
</IconWrapper>
<IconWrapper name="Copy">
<Icon icon={Copy} />
</IconWrapper>
<IconWrapper name="Ellipsis">
<Icon icon={Ellipsis} />
</IconWrapper>
<IconWrapper name="ArrowDown">
<Icon icon={ArrowDown} />
</IconWrapper>
<IconWrapper name="Error">
<Icon icon={Error} />
</IconWrapper>
<IconWrapper name="Filter">
<Icon icon={Filter} />
</IconWrapper>
<IconWrapper name="GitCommit">
<Icon icon={GitCommit} />
</IconWrapper>
<IconWrapper name="GitMerge">
<Icon icon={GitMerge} />
</IconWrapper>
<IconWrapper name="GraphLine">
<Icon icon={GraphLine} />
</IconWrapper>
<IconWrapper name="GraphScatter">
<Icon icon={GraphScatter} />
</IconWrapper>
<IconWrapper name="Gripper">
<Icon icon={Gripper} />
</IconWrapper>
<IconWrapper name="ListFilter">
<Icon icon={ListFilter} />
</IconWrapper>
<IconWrapper name="PassFilled">
<Icon icon={PassFilled} />
</IconWrapper>
<IconWrapper name="Pinned">
<Icon icon={Pinned} />
</IconWrapper>
<IconWrapper name="Refresh">
<Icon icon={Refresh} />
</IconWrapper>
<IconWrapper name="SortPrecedence">
<Icon icon={SortPrecedence} />
</IconWrapper>
<IconWrapper name="StarEmpty">
<Icon icon={StarEmpty} />
</IconWrapper>
<IconWrapper name="StarFull">
<Icon icon={StarFull} />
</IconWrapper>
<IconWrapper name="Trash">
<Icon icon={Trash} />
</IconWrapper>
<IconWrapper name="ArrowUp">
<Icon icon={ArrowUp} />
</IconWrapper>
</IconsWrapper>
<>
<IconsWrapper>
{Object.values(Icons).map(IconComponent => (
<IconWrapper key={IconComponent.name} name={IconComponent.name}>
<Icon icon={IconComponent} />
</IconWrapper>
))}
</IconsWrapper>
<p>
<a href="https://microsoft.github.io/vscode-codicons/dist/codicon.html">
Other icons that can be added
</a>
</p>
<p>
Copy the icon name, add it to `codicons` constant in
`webview/icons/generate.mjs` and run `yarn svgr`.
</p>
</>
)
}

Expand Down