Skip to content

Commit

Permalink
feat(stories): add controls and type exports for card
Browse files Browse the repository at this point in the history
  • Loading branch information
JoltCode committed Nov 13, 2023
1 parent cc127d4 commit f49784a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
42 changes: 34 additions & 8 deletions src/card/Card.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
import { Card } from "./Card.js";
import {Card, CardProps} from "./Card.js";
import {Story} from "@ladle/react";

export const CardStory = () => (
export const CardStory: Story<CardProps & {
title: string,
body: string,
footer: string,
}> = (props) => (
<Card>
<Card.CardTitle>Card Title</Card.CardTitle>
<Card.CardTitle>{props.title}</Card.CardTitle>
<Card.CardBody>
lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam,
voluptatum. lorem ipsum dolor sit amet consectetur adipisicing elit.
Quisquam, voluptatum. lorem ipsum dolor sit amet consectetur adipisicing
elit. Quisquam, voluptatum.
{props.body}
</Card.CardBody>
<Card.CardFooter>Card Footer</Card.CardFooter>
<Card.CardFooter>{props.footer}</Card.CardFooter>
</Card>
);

CardStory.argTypes = {
title: {
control: {
type: "text",
},
defaultValue: "Card Title",
},
body: {
control: {
type: "text",
},
defaultValue: "lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam,\n" +
"voluptatum. lorem ipsum dolor sit amet consectetur adipisicing elit.\n" +
"Quisquam, voluptatum. lorem ipsum dolor sit amet consectetur adipisicing\n" +
"elit. Quisquam, voluptatum.",
},
footer: {
control: {
type: "text",
},
defaultValue: "Card Footer",
},
}
6 changes: 3 additions & 3 deletions src/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const Card = (props: CardProps) => {
);
};

interface CardTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {}
export interface CardTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {}
const CardTitle = (props: CardTitleProps) => {
const { className, ...rest } = props;

Expand All @@ -28,7 +28,7 @@ const CardTitle = (props: CardTitleProps) => {

Card.CardTitle = CardTitle;

interface CardBodyProps extends React.HTMLAttributes<HTMLDivElement> {}
export interface CardBodyProps extends React.HTMLAttributes<HTMLDivElement> {}
const CardBody = (props: CardBodyProps) => {
const { className, ...rest } = props;

Expand All @@ -41,7 +41,7 @@ const CardBody = (props: CardBodyProps) => {

Card.CardBody = CardBody;

interface CardFooterProps extends React.HTMLAttributes<HTMLDivElement> {}
export interface CardFooterProps extends React.HTMLAttributes<HTMLDivElement> {}
const CardFooter = (props: CardFooterProps) => {
const { className, ...rest } = props;

Expand Down

0 comments on commit f49784a

Please sign in to comment.