1
- import React from ' react' ;
2
- import { Meta , Story } from ' @storybook/react/types-6-0' ;
3
- import { Button , ButtonProps } from ' ../lib/components/Button' ;
4
- import * as Yup from ' yup' ;
1
+ import React from " react" ;
2
+ import { Meta , Story } from " @storybook/react/types-6-0" ;
3
+ import { Button , ButtonProps } from " ../src/ lib/components/Button" ;
4
+ import * as Yup from " yup" ;
5
5
6
- import {
7
- FluidButtonSizes ,
8
- FluidButtonWeights ,
9
- } from '../lib/components/FluidUI/FluidTheme' ;
6
+ import { FluidButtonSizes , FluidButtonWeights } from "../src/lib/components/FluidUI/FluidTheme" ;
10
7
import {
11
8
ComboBox ,
12
9
Form ,
13
10
Input ,
11
+ Menu ,
14
12
SubmitButton ,
15
13
SubmitButtonRef ,
16
14
Switch ,
17
15
Textarea ,
18
- } from '../lib/components/Form' ;
19
- import { HiInformationCircle } from 'react-icons/hi' ;
20
- import { states } from '../lib/helpers/data' ;
21
- import { useRef , useState } from '@storybook/addons' ;
16
+ } from "../src/lib/components/Form" ;
17
+ import { HiChevronDown , HiDotsVertical , HiInformationCircle , HiPencil , HiTrash } from "react-icons/hi" ;
18
+ import { states } from "../src/lib/helpers/data" ;
19
+ import { useRef , useState } from "@storybook/addons" ;
20
+ import AppMenu from "../src/lib/components/Form/AppMenu" ;
22
21
23
22
export default {
24
- title : ' Components/Form' ,
23
+ title : " Components/Form" ,
25
24
component : Button ,
26
25
args : {
27
- weight : ' normal' as keyof FluidButtonWeights ,
28
- size : 'md' as keyof FluidButtonSizes ,
26
+ weight : " normal" as keyof FluidButtonWeights ,
27
+ size : "md" as keyof FluidButtonSizes ,
29
28
disabled : false ,
30
29
} ,
31
30
} as Meta ;
32
31
33
- interface StoryButtonProps extends Omit < ButtonProps , ' color' > { }
32
+ interface StoryButtonProps extends Omit < ButtonProps , " color" > { }
34
33
35
34
const Template : Story < StoryButtonProps > = args => {
36
- const submitBtnRef = useRef < HTMLButtonElement > ( null ) ;
37
- const [ isSubmitted , setIsSubmitted ] = useState ( null ) ;
35
+ const submitBtnRef = useRef < HTMLButtonElement | null > ( null ) ;
36
+ const [ isSubmitted , setIsSubmitted ] = useState < any > ( null ) ;
38
37
const initialValues = {
39
- name : '' ,
40
- email : '' ,
41
- message : '' ,
42
- state : ' California' ,
38
+ name : "" ,
39
+ email : "" ,
40
+ message : "" ,
41
+ state : " California" ,
43
42
saveResponse : false ,
44
43
} ;
45
44
const validationSchema = Yup . object ( ) . shape ( {
46
- name : Yup . string ( ) . required ( ' Name is required' ) ,
45
+ name : Yup . string ( ) . required ( " Name is required" ) ,
47
46
email : Yup . string ( )
48
- . email ( ' Invalid email address' )
49
- . required ( ' Email is required' ) ,
47
+ . email ( " Invalid email address" )
48
+ . required ( " Email is required" ) ,
50
49
message : Yup . string ( ) . optional ( ) ,
51
- state : Yup . string ( ) . required ( ' State is required' ) ,
52
- saveResponse : Yup . boolean ( ) . required ( ' Save response is required' ) ,
50
+ state : Yup . string ( ) . required ( " State is required" ) ,
51
+ saveResponse : Yup . boolean ( ) . required ( " Save response is required" ) ,
53
52
} ) ;
54
- console . log ( ' submitBtnRef' , submitBtnRef ) ;
53
+ console . log ( " submitBtnRef" , submitBtnRef ) ;
55
54
return (
56
55
< >
57
- < div className = "w-4/5 max-w-lg mx-auto p-4 bg-white dark:bg-stone-900 shadow-lg shadow-gray-400/20 dark:shadow-black/30 rounded-xl" >
56
+ < div className = "w-4/5 max-w-lg mx-auto mt-12 p-4 bg-white dark:bg-stone-900 shadow-lg shadow-gray-400/20 dark:shadow-black/30 rounded-xl" >
58
57
< Form
59
58
initialValues = { initialValues }
60
59
validationSchema = { validationSchema }
@@ -71,16 +70,50 @@ const Template: Story<StoryButtonProps> = args => {
71
70
< h1 > Thank you for your submission!</ h1 >
72
71
</ div >
73
72
) }
74
- < h2 className = "text-xl font-semibold pb-4 text-gray-700 dark:text-gray-200" >
75
- Contact Us
76
- </ h2 >
73
+ < h2 className = "text-xl font-semibold pb-4 text-gray-700 dark:text-gray-200" > Contact Us</ h2 >
74
+ < div className = "relative flex justify-between mb-4" >
75
+ < div />
76
+ < Menu
77
+ label = { "Actions" }
78
+ icon = {
79
+ < HiChevronDown
80
+ className = "-mr-1 ml-1 h-5 w-5 flex-shrink-0 text-gray-400 group-hover:text-gray-500 dark:text-gray-400 dark:group-hover:text-gray-50"
81
+ aria-hidden = "true"
82
+ />
83
+ }
84
+ header = {
85
+ < p className = "truncate py-3 px-3.5" >
86
+ < span className = "mb-0.5 block text-xs text-gray-500 dark:text-gray-400" > Signed in as</ span >
87
+ < span className = "font-semibold text-gray-700 dark:text-gray-300" > Guest user</ span >
88
+ </ p >
89
+ }
90
+ buttonClassName = "!ring-offset-2 ring-offset-gray-50 dark:ring-offset-gray-800 rounded-md"
91
+ menus = { [
92
+ {
93
+ label : "Edit" ,
94
+ icon : HiPencil ,
95
+ role : "info" ,
96
+ onClick : ( ) => console . log ( "edit" ) ,
97
+ } ,
98
+ {
99
+ role : "separator" ,
100
+ } ,
101
+ {
102
+ label : "Delete" ,
103
+ role : "destructive" ,
104
+ icon : HiTrash ,
105
+ onClick : ( ) => console . log ( "delete" ) ,
106
+ } ,
107
+ ] }
108
+ />
109
+ </ div >
77
110
< Input name = "name" label = "Name" type = "text" />
78
111
< Input name = "email" label = "Email" type = "email" />
79
112
< Textarea
80
113
name = "message"
81
114
label = "Message"
82
115
description = { {
83
- text : ' Please be as detailed as possible.' ,
116
+ text : " Please be as detailed as possible." ,
84
117
icon : HiInformationCircle ,
85
118
} }
86
119
/>
@@ -91,12 +124,7 @@ const Template: Story<StoryButtonProps> = args => {
91
124
</ Form >
92
125
</ div >
93
126
< div >
94
- < Button
95
- onClick = { ( ) => submitBtnRef . current ?. click ( ) }
96
- shape = "pill"
97
- weight = "outline"
98
- color = "green"
99
- >
127
+ < Button onClick = { ( ) => submitBtnRef . current ?. click ( ) } shape = "pill" weight = "outline" color = "green" >
100
128
Submit Button Ref
101
129
</ Button >
102
130
</ div >
0 commit comments