-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83c4654
commit 068258b
Showing
12 changed files
with
244 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { ChartCard } from "./ChartCard"; | ||
|
||
/** | ||
* The `ChartCard` component is a flexible card layout designed to display chart-related information. | ||
* It features a title, description, and a content area where charts or other visualizations can be placed. | ||
* This component can be used as a container for any kind of data representation, making it a versatile | ||
* choice for dashboards or analytics pages. | ||
*/ | ||
const meta = { | ||
component: ChartCard, | ||
tags: ["autodocs"], | ||
title: "Components/Charts/Chart Card", | ||
} satisfies Meta<typeof ChartCard>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = { | ||
args: { | ||
children: "Chart Content", | ||
description: | ||
"Compare your average times (HH:MM:SS) across different race distances", | ||
title: "Average Time By Distance", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { ChartCard } from "./ChartCard"; | ||
import { ComponentProps } from "react"; | ||
|
||
describe("ChartCard", () => { | ||
const defaultProps: ComponentProps<typeof ChartCard> = { | ||
children: "chart children", | ||
description: "chart description", | ||
title: "chart title", | ||
}; | ||
|
||
test("should render with default props", () => { | ||
render(<ChartCard {...defaultProps} />); | ||
|
||
expect(screen.getByText(defaultProps.description)).toBeInTheDocument(); | ||
expect(screen.getByText(defaultProps.title)).toBeInTheDocument(); | ||
expect(screen.getByText("chart children")).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card"; | ||
import { PropsWithChildren, ReactNode } from "react"; | ||
|
||
interface IProps { | ||
/** | ||
* The content of the card, often used to display charts, tables, or other visual elements. | ||
*/ | ||
children: ReactNode; | ||
/** | ||
* A brief explanation or context for the chart or data. | ||
*/ | ||
description: string; | ||
/** | ||
* The main heading of the card, typically used to describe the chart or data displayed. | ||
*/ | ||
title: string; | ||
} | ||
|
||
export const ChartCard = (props: PropsWithChildren<IProps>) => { | ||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>{props.title}</CardTitle> | ||
<CardDescription>{props.description}</CardDescription> | ||
</CardHeader> | ||
<CardContent>{props.children}</CardContent> | ||
</Card> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.