Skip to content

Commit

Permalink
Clean up redundant subcomponent types
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Dec 6, 2023
1 parent 1f23792 commit 31b565a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 28 deletions.
9 changes: 2 additions & 7 deletions packages/react/src/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ForwardRefExoticComponent,
HTMLAttributes,
PropsWithChildren,
ReactNode,
RefAttributes,
useImperativeHandle,
useRef,
Expand All @@ -20,16 +19,12 @@ import { AccordionSection } from './AccordionSection'
import useFocusWithArrows from './useFocusWithArrows'
import { HeadingLevel } from '../Heading/Heading'

export interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
children?: ReactNode
export interface AccordionProps extends PropsWithChildren<HTMLAttributes<HTMLDivElement>> {
headingLevel: HeadingLevel
section?: boolean
}

export interface AccordionComponent
extends ForwardRefExoticComponent<
PropsWithChildren<HTMLAttributes<HTMLDivElement>> & RefAttributes<HTMLDivElement> & AccordionProps
> {
export interface AccordionComponent extends ForwardRefExoticComponent<AccordionProps & RefAttributes<HTMLDivElement>> {
Section: typeof AccordionSection
}

Expand Down
21 changes: 10 additions & 11 deletions packages/react/src/Breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ import {
RefAttributes,
} from 'react'

interface BreadcrumbComponent
extends ForwardRefExoticComponent<PropsWithChildren<HTMLAttributes<HTMLElement>> & RefAttributes<HTMLElement>> {
type BreadcrumbProps = PropsWithChildren<HTMLAttributes<HTMLElement>>

interface BreadcrumbComponent extends ForwardRefExoticComponent<BreadcrumbProps & RefAttributes<HTMLElement>> {
Item: typeof BreadcrumbItem
}

export const Breadcrumb = forwardRef(
({ children, ...restProps }: PropsWithChildren<HTMLAttributes<HTMLElement>>, ref: ForwardedRef<HTMLElement>) => {
return (
<nav {...restProps} className="amsterdam-breadcrumb" ref={ref}>
<ol className="amsterdam-breadcrumb__list">{children}</ol>
</nav>
)
},
) as BreadcrumbComponent
export const Breadcrumb = forwardRef(({ children, ...restProps }: BreadcrumbProps, ref: ForwardedRef<HTMLElement>) => {
return (
<nav {...restProps} className="amsterdam-breadcrumb" ref={ref}>
<ol className="amsterdam-breadcrumb__list">{children}</ol>
</nav>
)
}) as BreadcrumbComponent

Breadcrumb.displayName = 'Breadcrumb'

Expand Down
5 changes: 1 addition & 4 deletions packages/react/src/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ CardLink.displayName = 'CardLink'

export interface CardProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {}

export interface CardComponent
extends ForwardRefExoticComponent<
PropsWithChildren<HTMLAttributes<HTMLElement>> & RefAttributes<HTMLElement> & CardProps
> {
export interface CardComponent extends ForwardRefExoticComponent<CardProps & RefAttributes<HTMLElement>> {
HeadingGroup: typeof CardHeadingGroup
Link: typeof CardLink
}
Expand Down
10 changes: 4 additions & 6 deletions packages/react/src/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ export const FooterBottom = forwardRef(

FooterBottom.displayName = 'FooterBottom'

interface FooterComponent
extends ForwardRefExoticComponent<PropsWithChildren<HTMLAttributes<HTMLElement>> & RefAttributes<HTMLElement>> {
type FooterProps = PropsWithChildren<HTMLAttributes<HTMLElement>>

interface FooterComponent extends ForwardRefExoticComponent<FooterProps & RefAttributes<HTMLElement>> {
Top: typeof FooterTop
Bottom: typeof FooterBottom
}

export const Footer = forwardRef(
(
{ children, className, ...restProps }: PropsWithChildren<HTMLAttributes<HTMLElement>>,
ref: ForwardedRef<HTMLElement>,
) => (
({ children, className, ...restProps }: FooterProps, ref: ForwardedRef<HTMLElement>) => (
<footer {...restProps} ref={ref} className={clsx('amsterdam-footer', className)}>
{children}
</footer>
Expand Down

0 comments on commit 31b565a

Please sign in to comment.