Skip to content

Commit 97bd74b

Browse files
authored
chore: add additional stories to storybook (#11524)
add stories for ActiveUserChart, CopyableValue, and CopyButton
1 parent 8a48485 commit 97bd74b

File tree

5 files changed

+83
-16
lines changed

5 files changed

+83
-16
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { ActiveUserChart } from "./ActiveUserChart";
3+
4+
const meta: Meta<typeof ActiveUserChart> = {
5+
title: "components/ActiveUserChart",
6+
component: ActiveUserChart,
7+
args: {
8+
data: [
9+
{ date: "1/1/2024", amount: 5 },
10+
{ date: "1/2/2024", amount: 6 },
11+
{ date: "1/3/2024", amount: 7 },
12+
{ date: "1/4/2024", amount: 8 },
13+
{ date: "1/5/2024", amount: 9 },
14+
{ date: "1/6/2024", amount: 10 },
15+
{ date: "1/7/2024", amount: 11 },
16+
],
17+
interval: "day",
18+
},
19+
};
20+
21+
export default meta;
22+
type Story = StoryObj<typeof ActiveUserChart>;
23+
24+
export const Example: Story = {};
25+
26+
export const UserLimit: Story = {
27+
args: {
28+
userLimit: 10,
29+
},
30+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { CopyButton } from "./CopyButton";
3+
4+
const meta: Meta<typeof CopyButton> = {
5+
title: "components/CopyButton",
6+
component: CopyButton,
7+
args: {
8+
children: "Get secret",
9+
text: "cool secret",
10+
},
11+
};
12+
13+
export default meta;
14+
type Story = StoryObj<typeof CopyButton>;
15+
16+
const Example: Story = {};
17+
18+
export { Example as CopyButton };

site/src/components/CopyButton/CopyButton.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,7 @@ export const CopyButton: FC<CopyButtonProps> = ({
3636
<Tooltip title={tooltipTitle} placement="top">
3737
<div css={[{ display: "flex" }, wrapperStyles]}>
3838
<IconButton
39-
css={[
40-
(theme) => css`
41-
border-radius: 8px;
42-
padding: 8px;
43-
min-width: 32px;
44-
45-
&:hover {
46-
background: ${theme.palette.background.paper};
47-
}
48-
`,
49-
buttonStyles,
50-
]}
39+
css={[styles.button, buttonStyles]}
5140
onClick={copyToClipboard}
5241
size="small"
5342
aria-label={Language.ariaLabel}
@@ -66,6 +55,15 @@ export const CopyButton: FC<CopyButtonProps> = ({
6655
};
6756

6857
const styles = {
58+
button: (theme) => css`
59+
border-radius: 8px;
60+
padding: 8px;
61+
min-width: 32px;
62+
63+
&:hover {
64+
background: ${theme.palette.background.paper};
65+
}
66+
`,
6967
copyIcon: css`
7068
width: 20px;
7169
height: 20px;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { CopyableValue } from "./CopyableValue";
3+
4+
const meta: Meta<typeof CopyableValue> = {
5+
title: "components/CopyableValue",
6+
component: CopyableValue,
7+
args: {
8+
children: <button>Get secret</button>,
9+
value: "cool secret",
10+
},
11+
};
12+
13+
export default meta;
14+
type Story = StoryObj<typeof CopyableValue>;
15+
16+
const Example: Story = {};
17+
18+
export { Example as CopyableValue };

site/src/components/CopyableValue/CopyableValue.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Tooltip, { type TooltipProps } from "@mui/material/Tooltip";
2+
import { type FC, type HTMLAttributes } from "react";
23
import { useClickable } from "hooks/useClickable";
34
import { useClipboard } from "hooks/useClipboard";
4-
import { type FC, type HTMLProps } from "react";
55

6-
interface CopyableValueProps extends HTMLProps<HTMLDivElement> {
6+
interface CopyableValueProps extends HTMLAttributes<HTMLSpanElement> {
77
value: string;
88
placement?: TooltipProps["placement"];
99
PopperProps?: TooltipProps["PopperProps"];
@@ -13,7 +13,8 @@ export const CopyableValue: FC<CopyableValueProps> = ({
1313
value,
1414
placement = "bottom-start",
1515
PopperProps,
16-
...props
16+
children,
17+
...attrs
1718
}) => {
1819
const { isCopied, copy } = useClipboard(value);
1920
const clickableProps = useClickable<HTMLSpanElement>(copy);
@@ -24,7 +25,9 @@ export const CopyableValue: FC<CopyableValueProps> = ({
2425
placement={placement}
2526
PopperProps={PopperProps}
2627
>
27-
<span {...props} {...clickableProps} css={{ cursor: "pointer" }} />
28+
<span {...attrs} {...clickableProps} css={{ cursor: "pointer" }}>
29+
{children}
30+
</span>
2831
</Tooltip>
2932
);
3033
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy