import type { Meta, StoryFn } from "@storybook/vue3"; import { ICON_SIZE } from "@/types/evcc"; // Auto-discover all MaterialIcon components const iconModules = import.meta.glob("./*.vue", { eager: true }); const iconComponents: Record = {}; const iconNames: string[] = []; Object.keys(iconModules).forEach((path) => { const iconName = path.replace("./", "").replace(".vue", ""); iconComponents[iconName] = (iconModules[path] as any).default; iconNames.push(iconName); }); // Sort icon names alphabetically iconNames.sort(); export default { title: "MaterialIcon/MaterialIcon", argTypes: { size: { control: "select", options: Object.values(ICON_SIZE), defaultValue: ICON_SIZE.L, }, }, } as Meta; // Template for a single icon const SingleIconTemplate: StoryFn = (args) => ({ components: iconComponents, setup() { return { args, iconNames }; }, template: `
`, }); // Single icon story (controllable via Storybook controls) export const SingleIcon = SingleIconTemplate.bind({}); SingleIcon.args = { iconName: iconNames[0], size: ICON_SIZE.L, }; SingleIcon.argTypes = { iconName: { control: "select", options: iconNames, }, }; // All icons in a simple grid export const AllIcons = () => ({ components: iconComponents, setup() { return { iconNames }; }, template: `
{{ iconName }}
`, }); // Color variations story - table format with all icons export const ColorVariations = () => ({ components: iconComponents, setup() { return { iconNames }; }, template: `
Icon Name Default Primary Danger Warning
{{ iconName }}
`, }); // Size variations story - all icons export const SizeVariations = () => ({ components: iconComponents, setup() { const sizes = Object.values(ICON_SIZE); return { iconNames, sizes }; }, template: `

{{ iconName }}

{{ size }}
`, });