File tree 3 files changed +111
-3
lines changed
3 files changed +111
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,28 @@ const config: StorybookConfig = {
14
14
} ,
15
15
typescript : {
16
16
reactDocgen : "react-docgen-typescript" ,
17
+ reactDocgenTypescriptOptions : {
18
+ propFilter : ( prop ) => {
19
+ if ( prop . parent ) {
20
+ const fileName = prop . parent . fileName ;
21
+ // Include props from our own code (not in node_modules)
22
+ if ( ! fileName . includes ( "node_modules" ) ) {
23
+ return true ;
24
+ }
25
+ // Include props from react-aria-components and react-aria
26
+ if (
27
+ fileName . includes ( "react-aria-components" ) ||
28
+ fileName . includes ( "react-aria" ) ||
29
+ fileName . includes ( "node_modules/@react-types" )
30
+ ) {
31
+ return true ;
32
+ }
33
+ // Exclude all other props from node_modules
34
+ return false ;
35
+ }
36
+ return true ;
37
+ } ,
38
+ } ,
17
39
} ,
18
40
} ;
19
41
export default config ;
Original file line number Diff line number Diff line change @@ -9,22 +9,33 @@ import KlerosSymbol from "./KlerosSymbol";
9
9
import ButtonIcon from "./ButtonIcon" ;
10
10
11
11
export interface BaseButtonProps {
12
+ /** @default primary */
12
13
variant ?: "primary" | "secondary" | "tertiary" ;
14
+ /**
15
+ * Reduce the paddings on button
16
+ * @default false
17
+ */
13
18
small ?: boolean ;
19
+ /**
20
+ * Indicate if button is in loading state
21
+ * @default false
22
+ */
14
23
isLoading ?: boolean ;
15
24
}
16
25
17
26
export interface ButtonProps
18
27
extends AriaButtonProps ,
19
28
Omit < BaseButtonProps , "$loading" > {
20
29
text : string ;
30
+ /** A React svg element to show as icon on button */
21
31
Icon ?: React . FC < React . SVGAttributes < SVGElement > > ;
32
+ /** A React node element to show as is on button */
22
33
icon ?: React . ReactNode ;
23
34
onClick ?: React . MouseEventHandler < HTMLButtonElement > ;
24
35
className ?: string ;
25
36
}
26
37
27
- const Button : React . FC < ButtonProps > = ( {
38
+ function Button ( {
28
39
text,
29
40
variant,
30
41
Icon,
@@ -34,7 +45,7 @@ const Button: React.FC<ButtonProps> = ({
34
45
className,
35
46
isDisabled,
36
47
...props
37
- } ) => {
48
+ } : ButtonProps ) : React . ReactElement {
38
49
const isPrimary = variant === "primary" || variant === undefined ;
39
50
const isSecondary = variant === "secondary" ;
40
51
const isTertiary = variant === "tertiary" ;
@@ -71,6 +82,6 @@ const Button: React.FC<ButtonProps> = ({
71
82
< ButtonText { ...{ isLoading, isDisabled, variant, text } } />
72
83
</ AriaButton >
73
84
) ;
74
- } ;
85
+ }
75
86
76
87
export default Button ;
Original file line number Diff line number Diff line change
1
+ import type { Meta , StoryObj } from "@storybook/react" ;
2
+
3
+ import { IPreviewArgs } from "./utils" ;
4
+
5
+ import Button from "../lib/button/index" ;
6
+ import Telegram from "../assets/svgs/telegram.svg" ;
7
+
8
+ const meta = {
9
+ component : Button ,
10
+ title : "Button" ,
11
+ tags : [ "autodocs" ] ,
12
+ argTypes : {
13
+ // by default storybook generates an inputType,
14
+ // https://storybook.js.org/docs/essentials/controls#choosing-the-control-type
15
+ variant : {
16
+ options : [ "primary" , "secondary" , "tertiary" ] ,
17
+ control : { type : "radio" } ,
18
+ } ,
19
+ isDisabled : {
20
+ control : "boolean" ,
21
+ } ,
22
+ } ,
23
+ } satisfies Meta < typeof Button > ;
24
+
25
+ export default meta ;
26
+
27
+ type Story = StoryObj < typeof meta > & IPreviewArgs ;
28
+
29
+ export const PrimaryButton : Story = {
30
+ args : {
31
+ variant : "primary" ,
32
+ text : "Primary" ,
33
+ themeUI : "dark" ,
34
+ backgroundUI : "light" ,
35
+ } ,
36
+ } ;
37
+
38
+ export const SecondaryButton : Story = {
39
+ args : {
40
+ variant : "secondary" ,
41
+ text : "Secondary" ,
42
+ themeUI : "dark" ,
43
+ backgroundUI : "light" ,
44
+ } ,
45
+ } ;
46
+
47
+ export const TertiaryButton : Story = {
48
+ args : {
49
+ variant : "tertiary" ,
50
+ text : "Tertiary" ,
51
+ themeUI : "dark" ,
52
+ backgroundUI : "light" ,
53
+ } ,
54
+ } ;
55
+
56
+ export const IconButton : Story = {
57
+ args : {
58
+ variant : "primary" ,
59
+ text : "Telegram" ,
60
+ Icon : Telegram ,
61
+ themeUI : "dark" ,
62
+ backgroundUI : "light" ,
63
+ } ,
64
+ } ;
65
+
66
+ export const LoadingButton : Story = {
67
+ args : {
68
+ variant : "primary" ,
69
+ text : "Loading" ,
70
+ isLoading : true ,
71
+ isDisabled : true ,
72
+ themeUI : "dark" ,
73
+ backgroundUI : "light" ,
74
+ } ,
75
+ } ;
You can’t perform that action at this time.
0 commit comments