From 676ef6b1f659a9cea8f36f096346a1f31ffae950 Mon Sep 17 00:00:00 2001 From: jmfrancois Date: Wed, 27 Sep 2023 15:01:31 +0200 Subject: [PATCH] fix: Icons --- .../design-system/src/stories/icons/Icons.tsx | 115 ++++++++++-------- 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/packages/design-system/src/stories/icons/Icons.tsx b/packages/design-system/src/stories/icons/Icons.tsx index ee436a2be22..e363c88e0c6 100644 --- a/packages/design-system/src/stories/icons/Icons.tsx +++ b/packages/design-system/src/stories/icons/Icons.tsx @@ -1,23 +1,25 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, ReactNode } from 'react'; import type { ChangeEvent, FormEvent } from 'react'; +// eslint-disable-next-line import/no-extraneous-dependencies import { IconGallery, IconItem } from '@storybook/blocks'; -import { Form, Icon, IconsProvider } from '../../'; +import { StackHorizontal, Form, Icon, IconsProvider } from '../../'; type TemplateProps = { name: string; size: number; transform: string; - border: boolean; - filter: boolean; - useCurrentColor: boolean; + border?: boolean; + filter?: boolean; + useCurrentColor?: boolean; }; type AllIconsTemplateProps = { children: (props: TemplateProps) => React.ReactNode; + docs?: boolean; }; -export const AllIconsTemplate = ({ children }: AllIconsTemplateProps) => { +export const AllIconsTemplate = ({ children, docs }: AllIconsTemplateProps) => { const [icons, setIds] = useState<(string | null)[]>([]); const [query, setQuery] = useState(''); const [size, setSize] = useState(2); @@ -45,13 +47,19 @@ export const AllIconsTemplate = ({ children }: AllIconsTemplateProps) => { const onChangeTransform = (event: ChangeEvent) => { setTransform(event.currentTarget.value); }; + const Wrapper = (props: { children: ReactNode }) => { + if (docs) { + return {props.children}; + } + return
{props.children}
; + }; return ( <>
- -
- + + + @@ -69,23 +77,14 @@ export const AllIconsTemplate = ({ children }: AllIconsTemplateProps) => { -
- setUseCurrentColor(!useCurrentColor)} - checked={!!useCurrentColor} - /> - ) => - setCurrentColor(event.currentTarget.value) - } - value={currentColor} - disabled={!useCurrentColor} - name="color" - /> -
+
+ + setUseCurrentColor(!useCurrentColor)} + checked={!!useCurrentColor} + /> { onChange={() => setFilter(!filter)} checked={!!filter} /> -
+ + {useCurrentColor ? ( + ) => + setCurrentColor(event.currentTarget.value) + } + value={currentColor} + name="color" + /> + ) : null}
- {icons - .filter(iconName => iconName && iconName.includes(query)) - .map( - iconName => - iconName && - children({ name: iconName, size, transform, useCurrentColor, border, filter }), - )} + + {icons + .filter(iconName => iconName && iconName.includes(query)) + .map( + iconName => + iconName && + children({ name: iconName, size, transform, useCurrentColor, border, filter }), + )} +
); @@ -115,24 +126,22 @@ export const AllIconsTemplate = ({ children }: AllIconsTemplateProps) => { export const AllIconsDocs = () => { return ( - - - {({ name, size, transform, border, filter, useCurrentColor }) => ( - - - - )} - - + + {({ name, size, transform, border, filter, useCurrentColor }) => ( + + + + )} + ); };