File tree Expand file tree Collapse file tree 3 files changed +111
-3
lines changed
Expand file tree Collapse file tree 3 files changed +111
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,28 @@ const config: StorybookConfig = {
1414 } ,
1515 typescript : {
1616 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+ } ,
1739 } ,
1840} ;
1941export default config ;
Original file line number Diff line number Diff line change @@ -9,22 +9,33 @@ import KlerosSymbol from "./KlerosSymbol";
99import ButtonIcon from "./ButtonIcon" ;
1010
1111export interface BaseButtonProps {
12+ /** @default primary */
1213 variant ?: "primary" | "secondary" | "tertiary" ;
14+ /**
15+ * Reduce the paddings on button
16+ * @default false
17+ */
1318 small ?: boolean ;
19+ /**
20+ * Indicate if button is in loading state
21+ * @default false
22+ */
1423 isLoading ?: boolean ;
1524}
1625
1726export interface ButtonProps
1827 extends AriaButtonProps ,
1928 Omit < BaseButtonProps , "$loading" > {
2029 text : string ;
30+ /** A React svg element to show as icon on button */
2131 Icon ?: React . FC < React . SVGAttributes < SVGElement > > ;
32+ /** A React node element to show as is on button */
2233 icon ?: React . ReactNode ;
2334 onClick ?: React . MouseEventHandler < HTMLButtonElement > ;
2435 className ?: string ;
2536}
2637
27- const Button : React . FC < ButtonProps > = ( {
38+ function Button ( {
2839 text,
2940 variant,
3041 Icon,
@@ -34,7 +45,7 @@ const Button: React.FC<ButtonProps> = ({
3445 className,
3546 isDisabled,
3647 ...props
37- } ) => {
48+ } : ButtonProps ) : React . ReactElement {
3849 const isPrimary = variant === "primary" || variant === undefined ;
3950 const isSecondary = variant === "secondary" ;
4051 const isTertiary = variant === "tertiary" ;
@@ -71,6 +82,6 @@ const Button: React.FC<ButtonProps> = ({
7182 < ButtonText { ...{ isLoading, isDisabled, variant, text } } />
7283 </ AriaButton >
7384 ) ;
74- } ;
85+ }
7586
7687export 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