Last active
March 14, 2023 20:03
-
-
Save codebutler/1478e946ed4bc14be8be62effd17bf03 to your computer and use it in GitHub Desktop.
Storybook dynamic auto-generated icon gallery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IconGallery, IconItem, Meta } from "@storybook/blocks"; | |
import React from "react"; | |
export const icons = import.meta.glob("../shared/icons/*.tsx", { eager: true }); | |
<Meta title="Documentation/Icons" /> | |
# Icons | |
<IconGallery> | |
{ | |
Object.values(icons).map((module) => { | |
const [iconName, IconComponent] = Object.entries(module)[0]; | |
return ( | |
<IconItem name={iconName}> | |
<IconComponent /> | |
</IconItem> | |
); | |
}) | |
} | |
</IconGallery> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment