Skip to content

Commit

Permalink
fix: typescript + paragraph element type
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILLIPS71 committed Apr 20, 2024
1 parent c92ba59 commit 3a8ab8c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
17 changes: 14 additions & 3 deletions packages/react/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ type ComponentType = <T extends React.ElementType = typeof __ELEMENT_TYPE__>(

const Component: ComponentType = React.forwardRef(
<T extends React.ElementType = typeof __ELEMENT_TYPE__>(props: ComponentProps<T>, ref: Polymophic.Ref<T>) => {
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

Expand All @@ -29,11 +40,11 @@ const Component: ComponentType = React.forwardRef(
const component = React.useMemo<ButtonProps>(
() => ({
'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 (
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/divider/Divider.tsx
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<T extends React.ElementType> = Polymophic.ComponentPropsWithRef<T, ComponentOwnProps>

Expand All @@ -20,11 +18,11 @@ const Component: ComponentType = React.forwardRef(
<T extends React.ElementType = typeof __ELEMENT_TYPE__>(props: ComponentProps<T>, ref: Polymophic.Ref<T>) => {
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<TextProps>(
const component = React.useMemo<React.ComponentPropsWithoutRef<typeof __ELEMENT_TYPE__>>(
() => ({
className: slots.paragraph({ className }),
...rest,
Expand Down

0 comments on commit 3a8ab8c

Please sign in to comment.