Skip to content

Commit

Permalink
card
Browse files Browse the repository at this point in the history
  • Loading branch information
nlkluth committed Nov 7, 2023
1 parent 6f5e283 commit 33a1433
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/nextjs/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as React from "react";
import { SanityImageSource } from "@sanity/image-url/lib/types/types";
import Link, { LinkProps } from "next/link";
import { Image } from "./Image";
import { Card as BaseCard } from "shared-ui";

export interface CardProps {
title: string;
price?: number;
subTitle?: string;
to: LinkProps["href"];
className?: string;
imageProps: {
src: SanityImageSource;
alt: string;
containerClassName?: string;
};
}

export const Card = ({
to,
subTitle,
title,
price,
imageProps: { containerClassName, ...imageProps },
className = "",
}: CardProps) => {
return (
<BaseCard
title={title}
subTitle={subTitle}
to={to.toString()}
price={price}
className={className}
imageContainerClass={containerClassName}
Link={Link}
>
<Image layout="fill" src={imageProps.src} alt={imageProps.alt} objectFit="cover" objectPosition="center" />
</BaseCard>
);
};
1 change: 1 addition & 0 deletions packages/shared-ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from "./components/Price";
export * from "./components/QuantityInput";
export * from './components/ProductSort';
export * from './components/Pagination';
export * from './components/Card';

export * from "./components/sanity";
export * from "./components/cart";
Expand Down

0 comments on commit 33a1433

Please sign in to comment.