File tree 5 files changed +83
-16
lines changed
5 files changed +83
-16
lines changed Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change
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 } ;
Original file line number Diff line number Diff line change @@ -36,18 +36,7 @@ export const CopyButton: FC<CopyButtonProps> = ({
36
36
< Tooltip title = { tooltipTitle } placement = "top" >
37
37
< div css = { [ { display : "flex" } , wrapperStyles ] } >
38
38
< 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 ] }
51
40
onClick = { copyToClipboard }
52
41
size = "small"
53
42
aria-label = { Language . ariaLabel }
@@ -66,6 +55,15 @@ export const CopyButton: FC<CopyButtonProps> = ({
66
55
} ;
67
56
68
57
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
+ ` ,
69
67
copyIcon : css `
70
68
width : 20px ;
71
69
height : 20px ;
Original file line number Diff line number Diff line change
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 } ;
Original file line number Diff line number Diff line change 1
1
import Tooltip , { type TooltipProps } from "@mui/material/Tooltip" ;
2
+ import { type FC , type HTMLAttributes } from "react" ;
2
3
import { useClickable } from "hooks/useClickable" ;
3
4
import { useClipboard } from "hooks/useClipboard" ;
4
- import { type FC , type HTMLProps } from "react" ;
5
5
6
- interface CopyableValueProps extends HTMLProps < HTMLDivElement > {
6
+ interface CopyableValueProps extends HTMLAttributes < HTMLSpanElement > {
7
7
value : string ;
8
8
placement ?: TooltipProps [ "placement" ] ;
9
9
PopperProps ?: TooltipProps [ "PopperProps" ] ;
@@ -13,7 +13,8 @@ export const CopyableValue: FC<CopyableValueProps> = ({
13
13
value,
14
14
placement = "bottom-start" ,
15
15
PopperProps,
16
- ...props
16
+ children,
17
+ ...attrs
17
18
} ) => {
18
19
const { isCopied, copy } = useClipboard ( value ) ;
19
20
const clickableProps = useClickable < HTMLSpanElement > ( copy ) ;
@@ -24,7 +25,9 @@ export const CopyableValue: FC<CopyableValueProps> = ({
24
25
placement = { placement }
25
26
PopperProps = { PopperProps }
26
27
>
27
- < span { ...props } { ...clickableProps } css = { { cursor : "pointer" } } />
28
+ < span { ...attrs } { ...clickableProps } css = { { cursor : "pointer" } } >
29
+ { children }
30
+ </ span >
28
31
</ Tooltip >
29
32
) ;
30
33
} ;
You can’t perform that action at this time.
0 commit comments