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(): Optional next link config via props. #31

Merged
merged 2 commits into from
Oct 7, 2024
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
11 changes: 6 additions & 5 deletions src/custom/docs/components/triplecard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Card, CardTitle, CardSubtitle } from './Card'
import NextImage from 'next/image'
import NextLink from 'next/link'
import { z } from 'zod'
import { ComponentProps } from 'react'

Expand All @@ -20,9 +21,9 @@ const cardSchema = z.array(
}))


const regularLink = (props: ComponentProps<'a'>) => <a {...props}></a>

export const TripleCard = (props: {cards: z.infer<typeof cardSchema>, imageComponent: typeof NextImage | typeof regularLink }) => {
const RegularLink = (props: ComponentProps<'a'>) => <a {...props}></a>
const RegularImage = (props: ComponentProps<'img'>) => <img {...props}></img>
export const TripleCard = (props: {cards: z.infer<typeof cardSchema>, imageComponent: typeof NextImage | typeof RegularImage, linkComponent: typeof NextLink | typeof RegularLink }) => {

return (
<section className="shadow-lg rounded-xl grid grid-cols-1 items-stretch md:grid-cols-3 ">
Expand Down Expand Up @@ -65,12 +66,12 @@ export const TripleCard = (props: {cards: z.infer<typeof cardSchema>, imageCompo
return (
<li key={link.title}>

<a
<props.linkComponent
className="font-semibold tracking-tight text-blue-600 dark:text-blue-300"
href={link.link}
>
{link.title}
</a>
</props.linkComponent>
<div className="my-2"></div>
<div className="text-muted-foreground text-xs leading-4">
{link.description}
Expand Down
2 changes: 1 addition & 1 deletion stories/custom/docs-tripleCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import { DocsTripleCard } from "src";


export function DocsTripleCardDemo() {
return <DocsTripleCard cards={tripleCardProps} imageComponent={(props: ComponentProps<'a'>) => <a {...props}></a>} />;
return <DocsTripleCard cards={tripleCardProps} linkComponent={(props: ComponentProps<'a'>) => <a {...props}></a>} imageComponent={(props: ComponentProps<'img'>) => <img {...props}></img>} />;
}

const meta: Meta<typeof DocsTripleCardDemo> = {
Expand Down