Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Clean up redundant subcomponent types #894

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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