Skip to content

Commit

Permalink
fix: fixing broken docgen because of forwardRef
Browse files Browse the repository at this point in the history
  • Loading branch information
Powerplex committed Sep 11, 2023
1 parent 75c3262 commit 4fac93f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions documentation/helpers/ArgTypes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tabs, type TabsRootProps } from '@spark-ui/tabs'
import { Tabs, type TabsProps } from '@spark-ui/tabs'
import { ArgTypes as StorybookArgTypes } from '@storybook/blocks'
import { type FC, type ReactNode, useEffect, useState } from 'react'

Expand All @@ -21,7 +21,7 @@ const ComponentDescription = ({ name, children }: { name: string; children: Reac
}

function useTabsOrientation() {
const [tabsOrientation, setTabsOrientation] = useState<TabsRootProps['orientation']>(
const [tabsOrientation, setTabsOrientation] = useState<TabsProps['orientation']>(
window.innerWidth < 640 ? 'horizontal' : 'vertical'
)

Expand Down
4 changes: 2 additions & 2 deletions packages/components/icon-button/src/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Button, ButtonProps } from '@spark-ui/button'
import React from 'react'
import React, { forwardRef } from 'react'

import { iconButtonStyles } from './IconButton.styles'

export interface IconButtonProps extends Omit<ButtonProps, 'loadingText'> {
'aria-label': string
}

export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
(
{
design = 'filled',
Expand Down
4 changes: 2 additions & 2 deletions packages/components/portal/src/Portal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Portal as PortalPrimitive } from '@radix-ui/react-portal'
import type * as Radix from '@radix-ui/react-primitive'
import React, { PropsWithChildren } from 'react'
import React, { forwardRef, type PropsWithChildren } from 'react'

interface PortalProps {
/**
Expand All @@ -11,6 +11,6 @@ interface PortalProps {

type PortalRef = React.ElementRef<typeof Radix.Primitive.div>

export const Portal = React.forwardRef<PortalRef, PropsWithChildren<PortalProps>>((props, ref) => {
export const Portal = forwardRef<PortalRef, PropsWithChildren<PortalProps>>((props, ref) => {
return <PortalPrimitive ref={ref} {...props} />
})
2 changes: 2 additions & 0 deletions packages/components/switch/src/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ export const Switch = forwardRef<HTMLButtonElement, SwitchProps>(
)
}
)

Switch.displayName = 'Switch'
8 changes: 5 additions & 3 deletions packages/components/switch/src/SwitchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Check } from '@spark-ui/icons/dist/icons/Check'
import { Close } from '@spark-ui/icons/dist/icons/Close'
import { Slot } from '@spark-ui/slot'
import { useCombinedState } from '@spark-ui/use-combined-state'
import React, { ReactNode } from 'react'
import React, { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from 'react'

import { styles, type StylesProps, thumbCheckSVGStyles, thumbStyles } from './SwitchInput.styles'

export interface SwitchInputProps
extends StylesProps,
Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'value'> {
Omit<ComponentPropsWithoutRef<'button'>, 'value'> {
/**
* The state of the switch when it is initially rendered. Use when you do not need to control its state.
*/
Expand Down Expand Up @@ -52,7 +52,7 @@ export interface SwitchInputProps
uncheckedIcon?: ReactNode
}

export const SwitchInput = React.forwardRef<HTMLButtonElement, SwitchInputProps>(
export const SwitchInput = forwardRef<HTMLButtonElement, SwitchInputProps>(
(
{
checked,
Expand Down Expand Up @@ -104,3 +104,5 @@ export const SwitchInput = React.forwardRef<HTMLButtonElement, SwitchInputProps>
)
}
)

SwitchInput.displayName = 'SwitchInput'
5 changes: 5 additions & 0 deletions packages/components/tabs/src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export interface TabsProps
asChild?: boolean
}

/**
* @deprecated
*/
export type TabsRootProps = TabsProps

export const Tabs = forwardRef<HTMLDivElement, TabsProps>(
(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/components/tabs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Content.displayName = 'Tabs.Content'

export { type TabsContentProps } from './TabsContent'
export { type TabsListProps } from './TabsList'
export { type TabsProps } from './Tabs'
export { type TabsProps, type TabsRootProps } from './Tabs'
export { type TabsTriggerProps } from './TabsTrigger'

0 comments on commit 4fac93f

Please sign in to comment.