Skip to content

Commit

Permalink
refactor(card-list): migrate from js to tsx
Browse files Browse the repository at this point in the history
the card list components has been migrated to typescript
react component. For a given card list item, if the image is provided,
then the alt props must be passed as GastbyImage requires the alt props

Refs: ethereum#6392
  • Loading branch information
Mousticke committed Jun 4, 2022
1 parent ef581e2 commit d9b74c4
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/components/CardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,27 @@ const Image = styled(GatsbyImage)`
margin-top: 4px;
`

export interface ICardListItem {
type ForbidOptional<T = {}> = {
[P in keyof T]?: never
}

type OptionalCardImageProp = {
image: string
alt: string
}

type CardImage = ForbidOptional<OptionalCardImageProp>

export type CardListItem = {
title: string
description: string
description?: string
caption?: string
link: string
image?: string
alt?: string
id: string | number
}
link?: string
id?: string | number
} & (OptionalCardImageProp | CardImage)

export interface IProps {
content: Array<ICardListItem>
content: Array<CardListItem>
className?: string
clickHandler?: (idx: string | number) => void
}
Expand Down

0 comments on commit d9b74c4

Please sign in to comment.