From c92ba595400602d9ee1012905721b3611a024fb3 Mon Sep 17 00:00:00 2001 From: Jordan Phillips Date: Sat, 20 Apr 2024 16:37:02 +1000 Subject: [PATCH 1/2] feat: add menu stories --- .../src/components/menu/Menu.stories.tsx | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 packages/react/src/components/menu/Menu.stories.tsx diff --git a/packages/react/src/components/menu/Menu.stories.tsx b/packages/react/src/components/menu/Menu.stories.tsx new file mode 100644 index 0000000..0cba0a8 --- /dev/null +++ b/packages/react/src/components/menu/Menu.stories.tsx @@ -0,0 +1,47 @@ +import type { MenuProps } from '@/components/menu' +import type { Meta, StoryFn } from '@storybook/react' + +import { menu } from '@giantnodes/theme' + +import { Button } from '@/components/button' +import { Menu } from '@/components/menu' + +const Component: Meta = { + title: 'Components/Menu', + component: Menu, + argTypes: { + size: { + control: { type: 'select' }, + }, + status: { + control: { type: 'select' }, + }, + variant: { + control: { type: 'select' }, + }, + }, +} + +const defaultProps = { + ...menu.defaultVariants, +} + +export const Default: StoryFn = (args: MenuProps) => ( + + + + + + First + Second + Third + + + +) + +Default.args = { + ...defaultProps, +} + +export default Component From 3a8ab8c62369c3a1381d6825984200685b3c44ce Mon Sep 17 00:00:00 2001 From: Jordan Phillips Date: Sat, 20 Apr 2024 16:37:35 +1000 Subject: [PATCH 2/2] fix: typescript + paragraph element type --- packages/react/src/components/button/Button.tsx | 17 ++++++++++++++--- .../react/src/components/divider/Divider.tsx | 3 ++- .../typography/TypographyParagraph.tsx | 8 +++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/react/src/components/button/Button.tsx b/packages/react/src/components/button/Button.tsx index 208d434..829ec40 100644 --- a/packages/react/src/components/button/Button.tsx +++ b/packages/react/src/components/button/Button.tsx @@ -20,7 +20,18 @@ type ComponentType = ( const Component: ComponentType = React.forwardRef( (props: ComponentProps, ref: Polymophic.Ref) => { - const { as, children, isLoading = false, isDisabled = false, color, shape, size, variant, ...rest } = props + const { + as, + children, + className, + isLoading = false, + isDisabled = false, + color, + shape, + size, + variant, + ...rest + } = props const Element = as ?? Button @@ -29,11 +40,11 @@ const Component: ComponentType = React.forwardRef( const component = React.useMemo( () => ({ 'data-loading': isLoading, - className: slots.button(), + className: slots.button({ className: className?.toString() }), isDisabled: isLoading || isDisabled, ...rest, }), - [isDisabled, isLoading, rest, slots] + [className, isDisabled, isLoading, rest, slots] ) return ( diff --git a/packages/react/src/components/divider/Divider.tsx b/packages/react/src/components/divider/Divider.tsx index ccd77f5..c875f3d 100644 --- a/packages/react/src/components/divider/Divider.tsx +++ b/packages/react/src/components/divider/Divider.tsx @@ -1,11 +1,12 @@ import type * as Polymophic from '@/utilities/polymorphic' +import type { DividerVariantProps } from '@giantnodes/theme' import { divider } from '@giantnodes/theme' import React from 'react' const __ELEMENT_TYPE__ = 'hr' -type ComponentOwnProps = { +type ComponentOwnProps = DividerVariantProps & { icon: React.ReactNode } diff --git a/packages/react/src/components/typography/TypographyParagraph.tsx b/packages/react/src/components/typography/TypographyParagraph.tsx index 52319b2..e1b3ad7 100644 --- a/packages/react/src/components/typography/TypographyParagraph.tsx +++ b/packages/react/src/components/typography/TypographyParagraph.tsx @@ -1,14 +1,12 @@ import type * as Polymophic from '@/utilities/polymorphic' import type { TypographyVariantProps } from '@giantnodes/theme' -import type { TextProps } from 'react-aria-components' import { typography } from '@giantnodes/theme' import React from 'react' -import { Text } from 'react-aria-components' const __ELEMENT_TYPE__ = 'p' -type ComponentOwnProps = TextProps & TypographyVariantProps +type ComponentOwnProps = TypographyVariantProps type ComponentProps = Polymophic.ComponentPropsWithRef @@ -20,11 +18,11 @@ const Component: ComponentType = React.forwardRef( (props: ComponentProps, ref: Polymophic.Ref) => { const { as, children, className, variant, ...rest } = props - const Element = as ?? Text + const Element = as ?? __ELEMENT_TYPE__ const slots = React.useMemo(() => typography({ variant }), [variant]) - const component = React.useMemo( + const component = React.useMemo>( () => ({ className: slots.paragraph({ className }), ...rest,