55import type { Meta , StoryObj } from "@storybook/react-vite" ;
66import { storybookLayoutDecorator , StoryLabel } from "@storybook-common" ;
77
8+ import { Buggy , IconNames } from "@blueprintjs/icons" ;
89import { Flex } from "@blueprintjs/labs" ;
910
10- import { Intent } from "../../common" ;
11+ import { Colors , Intent } from "../../common" ;
1112
1213import { Icon , IconSize } from "./icon" ;
1314
@@ -16,28 +17,38 @@ const meta: Meta<typeof Icon> = {
1617 component : Icon ,
1718 decorators : [ storybookLayoutDecorator ] ,
1819 args : {
19- icon : "buggy" ,
20+ icon : IconNames . BUGGY ,
21+ intent : Intent . NONE ,
2022 size : IconSize . STANDARD ,
21- intent : "none" ,
2223 color : undefined ,
24+ title : undefined ,
25+ tagName : "span" ,
26+ autoLoad : true ,
2327 } ,
2428 argTypes : {
29+ icon : {
30+ control : "text" ,
31+ } ,
2532 intent : {
2633 control : "select" ,
2734 options : Object . values ( Intent ) ,
2835 } ,
2936 size : {
30- control : "select" ,
31- options : [ IconSize . STANDARD , IconSize . LARGE ] ,
37+ control : "number" ,
3238 } ,
33- icon : {
39+ color : {
40+ control : "color" ,
41+ } ,
42+ title : {
3443 control : "text" ,
3544 } ,
36- color : {
45+ tagName : {
3746 control : "text" ,
3847 } ,
48+ autoLoad : {
49+ control : "boolean" ,
50+ } ,
3951 className : { table : { disable : true } } ,
40- autoLoad : { table : { disable : true } } ,
4152 svgProps : { table : { disable : true } } ,
4253 } ,
4354} satisfies Meta < typeof Icon > ;
@@ -48,11 +59,7 @@ type Story = StoryObj<typeof meta>;
4859/**
4960 * A basic icon with default styling.
5061 */
51- export const Default : Story = {
52- args : {
53- icon : "buggy" ,
54- } ,
55- } ;
62+ export const Default : Story = { } ;
5663
5764/**
5865 * Use the `intent` prop to apply a semantic color that conveys the purpose or status of the icon.
@@ -80,15 +87,48 @@ export const SizeExample: Story = {
8087 size : { table : { disable : true } } ,
8188 } ,
8289 render : args => (
83- < Flex flexDirection = "column" gap = { 10 } >
84- < Flex flexDirection = "column" gap = { 2 } alignItems = "center" >
85- < StoryLabel title = "standard size - 16px" />
86- < Icon { ...args } size = { IconSize . STANDARD } />
87- </ Flex >
90+ < Flex gap = { 5 } >
91+ < Icon { ...args } size = { IconSize . STANDARD } />
92+ < Icon { ...args } size = { IconSize . LARGE } />
93+ < Icon { ...args } size = { 48 } />
94+ </ Flex >
95+ ) ,
96+ } ;
97+
98+ /**
99+ * Use the `color` prop to override the icon fill with a custom CSS color.
100+ * This takes precedence over `intent`.
101+ */
102+ export const ColorExample : Story = {
103+ name : "Color" ,
104+ render : args => (
105+ < Flex gap = { 4 } alignItems = "center" >
106+ { [ Colors . BLUE3 , Colors . FOREST3 , Colors . GOLD3 , Colors . RED3 , Colors . INDIGO4 ] . map ( color => (
107+ < Flex key = { color } flexDirection = "column" gap = { 1 } alignItems = "center" >
108+ < Icon { ...args } color = { color } />
109+ < StoryLabel title = { color } />
110+ </ Flex >
111+ ) ) }
112+ </ Flex >
113+ ) ,
114+ } ;
88115
89- < Flex flexDirection = "column" gap = { 2 } alignItems = "center" >
90- < StoryLabel title = "large size - 20px" />
91- < Icon { ...args } size = { IconSize . LARGE } />
116+ /**
117+ * The `icon` prop accepts either a string icon name or a React element (typically an icon
118+ * component from `@blueprintjs/icons`). When an element is provided, `<Icon>` clones it and
119+ * merges the parent-provided `className` and intent class onto its root.
120+ */
121+ export const ElementIcon : Story = {
122+ name : "Element icon" ,
123+ render : args => (
124+ < Flex gap = { 4 } alignItems = "center" >
125+ < Flex flexDirection = "column" gap = { 1 } alignItems = "center" >
126+ < Icon { ...args } icon = { IconNames . BUGGY } />
127+ < StoryLabel title = 'icon="buggy"' />
128+ </ Flex >
129+ < Flex flexDirection = "column" gap = { 1 } alignItems = "center" >
130+ < Icon { ...args } icon = { < Buggy size = { args . size } /> } />
131+ < StoryLabel title = "icon={<Buggy />}" />
92132 </ Flex >
93133 </ Flex >
94134 ) ,
@@ -99,7 +139,7 @@ export const SizeExample: Story = {
99139 */
100140export const Playground : Story = {
101141 args : {
102- icon : "buggy" ,
142+ icon : IconNames . BUGGY ,
103143 size : IconSize . STANDARD ,
104144 intent : "none" ,
105145 color : undefined ,
0 commit comments