@dhasdk/simple-ui 0.0.11 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +923 -212
- package/index.d.ts +20 -2
- package/index.js +33 -6
- package/index.mjs +2444 -697
- package/lib/Accordion.d.ts +18 -2
- package/lib/BreadCrumbs.d.ts +9 -0
- package/lib/Button.d.ts +4 -2
- package/lib/CharacterCounter.d.ts +11 -0
- package/lib/DatePicker.d.ts +7 -0
- package/lib/List.d.ts +3 -2
- package/lib/Pill.d.ts +12 -0
- package/lib/SectionHeader.d.ts +9 -0
- package/lib/Select.d.ts +5 -3
- package/lib/SideBarNav.d.ts +17 -0
- package/lib/Skeleton.d.ts +15 -0
- package/lib/Status.d.ts +10 -0
- package/lib/Tabs.d.ts +23 -0
- package/package.json +3 -3
- package/style.css +1 -1
package/README.md
CHANGED
|
@@ -1,68 +1,266 @@
|
|
|
1
1
|
# simple-ui
|
|
2
2
|
|
|
3
|
-
This library was generated with [Nx](https://nx.dev).
|
|
3
|
+
This library was generated with [Nx](https://nx.dev) on React 18.x.
|
|
4
4
|
|
|
5
|
+
## <span style="color: orange;">*This library is under active development and not ready for production use\*</span>
|
|
5
6
|
|
|
6
|
-
##
|
|
7
|
+
## Table of Contents
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- [Installation](#installation-and-setup)
|
|
10
|
+
- [Accordion](#accordion)
|
|
11
|
+
- [Badge](#badge)
|
|
12
|
+
- [BreadCrumbs](#breadcrumbs)
|
|
13
|
+
- [Button](#button)
|
|
14
|
+
- [Card](#card)
|
|
15
|
+
- [CharacterCounter](#charactercounter)
|
|
16
|
+
- [DatePicker](#datepicker)
|
|
17
|
+
- [Input](#input)
|
|
18
|
+
- [List](#list)
|
|
19
|
+
- [Modal](#modal)
|
|
20
|
+
- [Select](#select)
|
|
21
|
+
- [Skeleton](#skeleton)
|
|
22
|
+
- [Status](#status)
|
|
23
|
+
- [Tabs](#tabs)
|
|
24
|
+
- [Toggle](#toggle)
|
|
9
25
|
|
|
10
|
-
##
|
|
26
|
+
## Quick Notes:
|
|
11
27
|
|
|
12
|
-
|
|
28
|
+
- Some of these components use what are called **variants** from the **class-variance-authority** library. This allows pre-defined styles to be set, or 'variants', and those variants to be called by name via a prop when using the specified component. An example is the **Button** component below, and calling it using the 'DHAActive' style variant of that component (example code below).
|
|
13
29
|
|
|
14
|
-
|
|
30
|
+
<!-- I N S T A L L A T I O N ----------------------------------------------------------------------------------- -->
|
|
15
31
|
|
|
16
|
-
|
|
32
|
+
[Back to Main Readme](./README.md)
|
|
17
33
|
|
|
18
|
-
|
|
34
|
+
## Installation and Setup
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
1. From the terminal run the following command:
|
|
21
37
|
|
|
38
|
+
**`npm install @dha-sdk/simple-ui`**
|
|
22
39
|
|
|
40
|
+
2. Open the page that you are going to place the **dha-sdk/simple-ui** component, and do the following:
|
|
41
|
+
|
|
42
|
+
- At the top of the file, import your desired component from **'@dha-sdk'**, i.e. if you are using the **Badge** component, then:
|
|
43
|
+
- **`import { Badge } from '@dhasdk/simple-ui';`**
|
|
44
|
+
- Elsewhere in your file, use the component as documented below
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<!-- A C C O R D I O N ----------------------------------------------------------------------------------- -->
|
|
48
|
+
|
|
49
|
+
## Accordion
|
|
50
|
+
|
|
51
|
+
The **Accordion** and **AccordionParent** components take a number of props, and work together to display a group of Accordions. The AccordionParent component is really only required for two purposes:
|
|
52
|
+
|
|
53
|
+
- Multiple accordions are displayed, and it is desired that only one can be opened at a time. This requires state management between the various accordions listed, and the parent Accordion helps with this.
|
|
54
|
+
|
|
55
|
+
- You have multiple accordions, and there are one or more identical prop values that you would like to pass to each of the Accordion components. Passing these props to the parent component instead, **AccordionParent**, will simplify **Accordion** component usage. These various props that are specified on the AccordionParent level will be automatically passed down to the children Accordion components.
|
|
56
|
+
|
|
57
|
+
A **ref** can also be created and assigned to the Accordion component, and the component will point the reference to the outer html DIV.
|
|
58
|
+
|
|
59
|
+
Separately below is the Props listing both the **AccordionParent** and **Accordion** components. All of the props listed for Accordion can be passed as values to the AccordionParent, and they will be safely passed to the child Accordion components so that they do not have to be individually specified.
|
|
60
|
+
|
|
61
|
+
Finally, if Accordion props are specified inside the parent component, those values can be overridden on an individual basis by specifying alternate values for the individual Accordion component you wish to indepentently control.
|
|
62
|
+
|
|
63
|
+
### Props for AccordionParent
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Optional | Default | Description |
|
|
66
|
+
| ----------- | -------- | -------- | -------- | -------------------------------------------- |
|
|
67
|
+
| children | ReactNode | No | undefined | This is intended to contain the child **Accordion** components |
|
|
68
|
+
| chevron | boolean | Yes | undefined | If true, displays chevron icons for open/closed status, otherwise displays plus and minus icons. |
|
|
69
|
+
| iconAccordionOpened & iconAccordionClosed | ReactNode | Yes | N/A | custom icons to display for opened and closed state. See usage example above for a demonstration. |
|
|
70
|
+
| childHeadingClassName | string | Yes | CSS classes to apply to the child Accordion component headings. These can be overridden on an individual basis using the same prop on the Accordion component. |
|
|
71
|
+
| childContentClassName | string | No | N/A | CSS classes to apply to the child Accordion component content body. These can be overridden on an individual basis using the same prop on the Accordion component. |
|
|
72
|
+
| className | string | Yes | undefined | CSS classes applied to the container div for the **AccordionParent** component. |
|
|
73
|
+
| ...props | string | No | | takes additional props that are not specifically defined in the component, i.e. aria-label |
|
|
74
|
+
| rounded | boolean | Yes | false | This boolean value indicates whether to display rounded corners or not. By using this prop vs custom classes, only the top of the heading is rounded in an opened state, and only the bottom of the content block is rounded also. |
|
|
75
|
+
| singleOpen | boolean | Yes | false | This boolean value directs the accordion to allow only one opened child content body at a time. Setting a value of false will allow multiple to be opened at once. |
|
|
76
|
+
| variant | string | Yes | 'default' | currently unused |
|
|
77
|
+
|
|
78
|
+
### Props for Accordion
|
|
79
|
+
|
|
80
|
+
| Prop | Type | Optional | Default | Description |
|
|
81
|
+
| ----------- | -------- | -------- | -------- | -------------------------------------------- |
|
|
82
|
+
| children | ReactNode | No | undefined | This contains the body of the **Accordion** content. |
|
|
83
|
+
| chevron | boolean | Yes | undefined | If true, displays chevron icons for open/closed status, otherwise displays plus and minus icons. |
|
|
84
|
+
| iconAccordionOpened & iconAccordionClosed | ReactNode | Yes | N/A | custom icons to display for opened and closed state. See usage example above for a demonstration. |
|
|
85
|
+
| childHeadingClassName | string | Yes | CSS classes to apply to the child Accordion component headings. These can be overridden on an individual basis using the same prop on the Accordion component. |
|
|
86
|
+
| childContentClassName | string | No | N/A | CSS classes to apply to the child Accordion component content body. These can be overridden on an individual basis using the same prop on the Accordion component. |
|
|
87
|
+
| className | string | Yes | undefined | CSS classes applied to the container div for the **Accordion** component. |
|
|
88
|
+
| ...props | string | No | | takes additional props that are not specifically defined in the component, i.e. aria-label |
|
|
89
|
+
| rounded | boolean | Yes | false | This boolean value indicates whether to display rounded corners or not. By using this prop vs custom classes, only the top of the heading is rounded in an opened state, and only the bottom of the content block is rounded also. |
|
|
90
|
+
| singleOpen | boolean | Yes | false | This boolean value directs the accordion to allow only one opened child content body at a time. Setting a value of false will allow multiple to be opened at once. |
|
|
91
|
+
| variant | string | Yes | 'default' | currently unused |
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Example Usage
|
|
96
|
+
|
|
97
|
+
```jsx
|
|
98
|
+
<AccordionParent
|
|
99
|
+
childHeadingClassName='bg-white'
|
|
100
|
+
childContentClassName='bg-white'>
|
|
101
|
+
<Accordion label='First Example'>
|
|
102
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed ...
|
|
103
|
+
</Accordion>
|
|
104
|
+
<Accordion label='Second Example'>
|
|
105
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed ...
|
|
106
|
+
</Accordion>
|
|
107
|
+
<Accordion label='Third Example'>
|
|
108
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed ...
|
|
109
|
+
</Accordion>
|
|
110
|
+
</AccordionParent>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Dependencies
|
|
114
|
+
|
|
115
|
+
**_none_**
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
[Top of Page](#table-of-contents)
|
|
119
|
+
|
|
120
|
+
<!-- E N D A C C O R D I O N -->
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
<!-- B A D G E ----------------------------------------------------------------------------------- -->
|
|
23
124
|
|
|
24
125
|
## Badge
|
|
25
126
|
|
|
26
|
-
The **badge** component takes three
|
|
127
|
+
The **badge** component takes three required props, **variant**, **subVariant**, and **child** content.
|
|
128
|
+
|
|
129
|
+
Optional props are **className**, **svgClasses**, **imagePath**, **imageAlt**, and **imageClasses**.
|
|
130
|
+
|
|
131
|
+
As with the button component, this component also takes additional html attributes that when included are passed to the parent div.
|
|
27
132
|
|
|
28
|
-
|
|
133
|
+
This div is also styled using the tailwind **`twMerge()`** utility, so custom classes can be added via the classNames prop as well.
|
|
29
134
|
|
|
30
135
|
### Props
|
|
31
136
|
|
|
32
137
|
| Prop | Type | Optional | Default | Description |
|
|
33
138
|
| ----------- | -------- | -------- | -------- | -------------------------------------------- |
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
| className | string | Yes | See **(
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
139
|
+
| children | ReactNode | No | | html and content that becomes the body of the Badge. |
|
|
140
|
+
| subVariant | string | No | See **(1)** below | The predefined variant of Badge to display. |
|
|
141
|
+
| variant | string | No | See **(1)** below | The predefined variant of Badge to display. UX designed variants are **go**, **hazard**, and **warning** |
|
|
142
|
+
| className | string | Yes | See **(2)** below | Alternate CSS classnames to apply to the Badge component.twMerge is used to apply these styles, so they reliably overwrite existing styles |
|
|
143
|
+
| imageAlt | string | See Comment | undefined | When an imagePath is specified, please specify an imageAlt that can be used for accessibility purposes. |
|
|
144
|
+
| imageClasses | string | Yes | undefined | Alternate CSS classes that are applied to the image for variant type media. |
|
|
145
|
+
| imagePath | string | See Comment | undefined | When variant is of type "media", an imagePath has to be specified that the component can load and display. |
|
|
146
|
+
| svgClasses | string | Yes | (2) below | alternate classes to apply style to the svg icons used in the Badge component for type icon. Applied using twMerge, and will reliabily overwrite any default CSS classes. |
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
1. Variants --> subVariants
|
|
150
|
+
- default --> default, gray, red, yellow, green, blue
|
|
151
|
+
- warning **UX Variant** --> half, full
|
|
152
|
+
- hazard **UX Variant** --> half, full,
|
|
153
|
+
- go **UX Variant** --> half, full
|
|
154
|
+
- icon --> default, gray, red, yellow, green, blue
|
|
155
|
+
- media --> default, gray, green
|
|
43
156
|
|
|
157
|
+
2. classNames per variant default
|
|
158
|
+
- default --> **`mx-2 inline-flex items-center rounded-md bg-gray-500/10 px-2 py-1 text-xs font-medium text-gray-700 ring-1 ring-inset ring-gray-400/20`**
|
|
159
|
+
- icon --> **`inline-flex items-center gap-x-1.5 rounded-full bg-gray-500 px-2 py-1 text-xs font-medium text-gray-700`**
|
|
160
|
+
- media --> **`w-[250px] mx-2 border-l-8 border-black grid grid-cols-6 rounded-md bg-gray-400/10 pr-2 text-xs font-medium text-gray-400 ring-1 ring-inset ring-gray-400/20 overflow-hidden`**
|
|
44
161
|
|
|
45
|
-
**(1)** default values applied are **`flex flex-nowrap box-border rounded-md border-t-[1px] border-r-[1px] border-b-[1px] border-dha-mc-secondary-border border-l-[1em] border-l-dha-mc-true-blue bg-white
|
|
46
|
-
drop-shadow-md w-[90vw] lg:max-w-[25em] mx-auto py-1 min-h-20 items-center`**
|
|
47
162
|
|
|
48
163
|
|
|
49
164
|
### Example Usage
|
|
50
165
|
|
|
166
|
+
Default Variant
|
|
167
|
+
|
|
168
|
+
```jsx
|
|
169
|
+
<Badge ref={ref}
|
|
170
|
+
variant="default"
|
|
171
|
+
subVariant="blue"
|
|
172
|
+
aria-label="appropriate aria label here">
|
|
173
|
+
Badge!
|
|
174
|
+
</Badge>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
icon Variant
|
|
178
|
+
|
|
51
179
|
```jsx
|
|
52
|
-
<Badge
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
>
|
|
58
|
-
Fill out the patient information form to ensure appropriate care can be provided.
|
|
59
|
-
</Badge>
|
|
180
|
+
<Badge ref={ref}
|
|
181
|
+
variant="icon"
|
|
182
|
+
subVariant="blue"
|
|
183
|
+
aria-label="appropriate aria label here">
|
|
184
|
+
Badge!
|
|
185
|
+
</Badge>
|
|
60
186
|
```
|
|
187
|
+
media Variant
|
|
188
|
+
|
|
189
|
+
```jsx
|
|
190
|
+
<Badge ref={ref} variant="media"
|
|
191
|
+
subVariant="blue"
|
|
192
|
+
imagePath="/src/assets/Doctor.png"
|
|
193
|
+
aria-label="health professional icon">
|
|
194
|
+
<h5 className='text-sm font-bold my-2'>Flu Season!</h5>
|
|
195
|
+
<p className="mb-2">Don't be caught unprepared. </p>
|
|
196
|
+
</Badge>
|
|
197
|
+
```
|
|
198
|
+
go Variant
|
|
199
|
+
|
|
200
|
+
```jsx
|
|
201
|
+
<Badge
|
|
202
|
+
className="text-left "
|
|
203
|
+
variant='go'
|
|
204
|
+
subVariant='full
|
|
205
|
+
>Lorem ipsum dolor sit amet, consectetur adipiscing
|
|
206
|
+
elit, sed do eiusmod tempor incididunt ut labore
|
|
207
|
+
et dolore magna aliqua</Badge>
|
|
208
|
+
```
|
|
209
|
+
|
|
61
210
|
|
|
62
211
|
### Dependencies
|
|
63
212
|
|
|
64
213
|
**_none_**
|
|
65
214
|
|
|
215
|
+
[Top of Page](#table-of-contents)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
<!-- B R E A D C R U M B S ------------------------------------------------------------------------------ -->
|
|
219
|
+
|
|
220
|
+
## BreadCrumbs
|
|
221
|
+
|
|
222
|
+
BreadCrumbs allow users to quickly and easily see their current location in an app or sites heirarchy, as well as quickly navigate to previous levels, enabling quick navigation back to those sections.
|
|
223
|
+
|
|
224
|
+
The BreadCrumbs component takes in various props (`className`, `containerClassName`, `variant`, `auto`, and `separator`), in addition to any other html attributes a normal NAV element would use.
|
|
225
|
+
|
|
226
|
+
A `ref` can also be created and assigned to the button component, and the component will point the reference to the html nav element.
|
|
227
|
+
|
|
228
|
+
The `className` prop takes a list of alternate CSS classes the developer would like applied to the component. These are applied using the tailwind `twMerge` function, and will safely overwrite any conflicting classes ensuring proper styling. These classes are applied to the individual links.
|
|
229
|
+
|
|
230
|
+
The `containerClassName` takes a list of css classes that are applied to the enclosing `nav` element.
|
|
231
|
+
|
|
232
|
+
Finally, the `separator` prop is a string value that represents the separator used between bread crumbs. The default value is a greater than sign, >.
|
|
233
|
+
|
|
234
|
+
Full list of props below
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
### Props
|
|
238
|
+
|
|
239
|
+
| Prop | Type | Optional | Default | Description |
|
|
240
|
+
| ----------- | -------- | -------- | -------- | -------------------------------------------- |
|
|
241
|
+
| className | string | Yes | | This is used to apply user supplied styling to the `Link` components. Note that words are capitalized using CSS, and can be made using the prop. |
|
|
242
|
+
| containerClassName | string | Yes | | This is used to apply user supplied styling to the container `nav` element. |
|
|
243
|
+
| ...props | string | Yes | undefined | takes additional props that are not specifically defined in the component, i.e. aria-label |
|
|
244
|
+
| separator | string | Yes | > | A string separator value to place between the separate breadcrumbs. The default value is '>' |
|
|
245
|
+
| variant | string | Yes | | Allows the user to enter a pre-defined variant that includes its own pre-defined styling. |
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
### Example Usage
|
|
250
|
+
|
|
251
|
+
Default Variant
|
|
252
|
+
|
|
253
|
+
```jsx
|
|
254
|
+
<BreadCrumbs />
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
### Dependencies
|
|
259
|
+
|
|
260
|
+
**_none_**
|
|
261
|
+
|
|
262
|
+
[Top of Page](#table-of-contents)
|
|
263
|
+
|
|
66
264
|
<!-- B U T T O N ------------------------------------------------------------------------------ -->
|
|
67
265
|
|
|
68
266
|
## Button
|
|
@@ -75,84 +273,225 @@ A reference can also be created and passed to the button component, and the comp
|
|
|
75
273
|
|
|
76
274
|
| Prop | Type | Optional | Default | Description |
|
|
77
275
|
| ----------- | -------- | -------- | -------- | ----------- |
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
276
|
+
| children | ReactNode | Yes | | Content to display in the Button, overrides 'label' if both are present. |
|
|
277
|
+
| className | string | Yes | **(1) below** | Class names to style component |
|
|
278
|
+
| label | string | Yes | | Display text for button. If 'children' is present, that is used instead |
|
|
279
|
+
| onClick | () => void | Yes | | A click handler for the Button |
|
|
280
|
+
| ...props | string | Yes | undefined | additional props that are not specifically defined in the component, i.e. aria-label |
|
|
281
|
+
| type | string | Yes | 'button' | specifies the button type, and is one of 'button', 'submit', or 'reset' |
|
|
282
|
+
| variant | string | Yes | 'default' | CSS Button variant, available variants are 'default', 'filled', 'outline', and 'transparent' |
|
|
283
|
+
|
|
82
284
|
|
|
83
285
|
|
|
84
286
|
**(1) classname defaults**
|
|
85
|
-
- inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50
|
|
86
287
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
-
|
|
288
|
+
- Base CSS Classes
|
|
289
|
+
|
|
290
|
+
- **`inline-flex items-center justify-center whitespace-nowrap rounded-md ring-offset-background transition-colors focus-visible:outline-none font-[`Arial`] disabled:pointer-events-none text-sm md:text-base lg:text-lg disabled:opacity-50 px-6 py-[12px] md:py-[14px] lg:py-[16px]`**
|
|
291
|
+
|
|
292
|
+
- Additional Classes per variant
|
|
293
|
+
- 'default' - **`rounded-md bg-gray-200 hover:bg-slate-400 text-black text-lg hover:text-white hover:border-slate-600 disabled:bg-dha-mc-bottom-nav-background disabled:text-dha-mc-checkbox-inactive disabled:border-dha-mc-secondary-border disabled:border-2 py-0 md:py-0 lg:py-0 h-[48px] mt-1`**
|
|
294
|
+
- 'filled' - **`rounded-md bg-[#092068] hover:bg-[#0c2c8e] text-white text-lg hover:text-white focus:shadow-[0px_0px_0px_3px_rgba(251,137,241,1.00)] active:bg-[#092068]/80 disabled:bg-[#e4e4e5] disabled:text-[#939194] disabled:border-[#e4e4e5] disabled:border-2 lg:h-14`**
|
|
295
|
+
- 'outline' - **`rounded-md border-[#092068] bg-white border-2 text-[#092068] text-lg disabled:border-dha-mc-secondary-border disabled:text-[#939194] hover:bg-[#d1dbfb] active:bg-[#9fc5f0] focus:shadow-[0px_0px_0px_3px_rgba(251,137,241,1.00)] lg:h-14`**
|
|
296
|
+
- 'transparent' - **`rounded-md text-lg text-[#092068] hover:bg-[#d1dbfb] active:bg-[#9fc5f0] focus:shadow-[0px_0px_0px_3px_rgba(251,137,241,1.00)] disabled:text-[#939194] w-[157px] md:w-[163px] lg:w-[169px] h-12 md:h-[52px] lg:h-14`**
|
|
96
297
|
|
|
97
298
|
|
|
98
299
|
### Example Usage
|
|
99
300
|
|
|
301
|
+
Basic example
|
|
302
|
+
|
|
303
|
+
```jsx
|
|
304
|
+
<Button ref={ref} variant="MedCard"
|
|
305
|
+
onClick={console.log('Clicked!')}
|
|
306
|
+
label='Click Me!' />
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Using an alternate varint, className, and aria-label
|
|
310
|
+
|
|
100
311
|
```jsx
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
312
|
+
|
|
313
|
+
<Button ref={ref} variant="MedCard"
|
|
314
|
+
onClick={console.log('Clicked!')}
|
|
315
|
+
className='px-10 py-6'
|
|
316
|
+
aria-label='Show example pop-up'
|
|
317
|
+
>
|
|
318
|
+
Click Me!</Button>
|
|
104
319
|
```
|
|
105
320
|
|
|
321
|
+
|
|
106
322
|
### Dependencies
|
|
107
323
|
|
|
108
324
|
**_none_**
|
|
109
325
|
|
|
110
|
-
<!-- C A R D
|
|
326
|
+
<!-- C A R D -------------------------------------------------------------------------------- -->
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
[Top of Page](#table-of-contents)
|
|
111
330
|
|
|
112
331
|
## Card
|
|
113
332
|
|
|
114
|
-
|
|
333
|
+
Cards contain content or information on a specific topic, often with a relevant image.
|
|
334
|
+
|
|
335
|
+
The **Card** component as built takes in various props (variant, variantStyle, imagePath, imageClassname, imageInset, alt, ariaLabel, and children), in addition to any other html attributes a normal html button would use, for example an **`aria-label`** tag.
|
|
336
|
+
|
|
337
|
+
A **`ref`** can also be created and assigned to the **Card** component, and the component will point the reference to the outer html DIV.
|
|
338
|
+
|
|
339
|
+
The **className** prop takes a list of alternate CSS classes the developer would like applied to the component. These are applied using the tailwind **`twMerge`** function, and will safely overwrite any conflicting classes ensuring proper styling.
|
|
340
|
+
|
|
341
|
+
Full list of props below
|
|
342
|
+
|
|
343
|
+
### Props
|
|
344
|
+
|
|
345
|
+
| Prop | Type | Optional | Default | Description |
|
|
346
|
+
| ----------- | -------- | -------- | -------- | ----------- |
|
|
347
|
+
| alt | string | No | | Alt tag to use inside the image displayed inside the Card component. |
|
|
348
|
+
| children | ReactNode | No | | Content to display in the Card aside from the image |
|
|
349
|
+
| ariaLabel | string | Yes | 'card component' | This is the aria-label applied to the parentDIV element in the Card component. |
|
|
350
|
+
| className | string | Yes | (1) below | Class names to style component |
|
|
351
|
+
| imageInset | string | Yes | | A boolean value indicating whether the image inside the card should be inset or not. See above for functional examples. |
|
|
352
|
+
| imageClassName | string | Yes | | CSS Classes to apply to the **img** element inside the Card component. These classes are applied using **`twMerge()`** and will safely override any conflicting tailwind css classes. |
|
|
353
|
+
| ...props | string | Yes | undefined | additional props that are not specifically defined in the component, i.e. aria-label |
|
|
354
|
+
| variant | string | Yes | 'default' | valid Card variant choices are 'default', 'imageLeft', 'imageBottom', and 'imageRight'. The default variant has its image on the top of the Card. |
|
|
355
|
+
| variantStyle | string | Yes | 'default' | Optoins are 'default' and 'outline' |
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
**(1) classnames for different variants**
|
|
359
|
+
|
|
360
|
+
- default --> **`flex flex-col w-64 max-w-64`**
|
|
361
|
+
- imageBottom --> **`flex flex-col-reverse w-64 mx-w-64`**
|
|
362
|
+
- imageLeft --> **`flex flex-row h-auto max-w-lg min-w-96`**
|
|
363
|
+
- imageRight --> **`flex flex-row-reverse h-auto max-w-lg min-w-96`**
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
### Example Usage
|
|
367
|
+
|
|
368
|
+
Basic example
|
|
369
|
+
|
|
370
|
+
```jsx
|
|
371
|
+
<Card
|
|
372
|
+
imagePath={imagePath}>
|
|
373
|
+
<h1 className="text-lg font-bold">Flu Season</h1>
|
|
374
|
+
<p>Flu season is approaching, and flu vaccines are
|
|
375
|
+
available now.</p>
|
|
376
|
+
</Card>
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Using an alternate varint, custom css, etc.
|
|
380
|
+
|
|
381
|
+
```jsx
|
|
382
|
+
<Card variant='imageLeft'
|
|
383
|
+
imagePath={imagePath}
|
|
384
|
+
imageClassname="rounded-lg"
|
|
385
|
+
variantStyle="outline"
|
|
386
|
+
alt="Doctor wearing face mask"
|
|
387
|
+
imageInset>
|
|
388
|
+
<h1 className="text-lg font-bold">Flu Season</h1>
|
|
389
|
+
<p>Flu season is approaching, and flu vaccines are
|
|
390
|
+
available now.</p>
|
|
391
|
+
</Card>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Dependencies
|
|
395
|
+
|
|
396
|
+
**_none_**
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
<!-- C H A R A C T E R C O U N T E R -------------------------------------------------------- -->
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
[Top of Page](#table-of-contents)
|
|
403
|
+
|
|
404
|
+
## CharacterCounter
|
|
115
405
|
|
|
116
|
-
|
|
406
|
+
The **CharacterCounter** component is one that you use to wrap an Input or TextArea component or element to inform a user of the number of characters they have typed. If the user goes over the specified limit the message style (further styling can be specified via the prop **overLimitMessageClassName**) and message will change to inform the visitor of this.
|
|
117
407
|
|
|
118
|
-
The
|
|
408
|
+
The **CharacterCounter** component takes two required prop values, **children**, and **maxCharacters**, and informs the user of the number of characters they have typed or the number of characters they are over the limit for an Input or TextArea component.
|
|
119
409
|
|
|
120
|
-
|
|
410
|
+
The children prop will be an **input** or **textArea** element, wrapped by CharacterCounter, and is what CharacterCounter will monitor.
|
|
121
411
|
|
|
122
|
-
|
|
412
|
+
Full list of props below
|
|
123
413
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
133
|
-
|
|
|
134
|
-
|
|
|
135
|
-
|
|
414
|
+
### Props
|
|
415
|
+
|
|
416
|
+
| Prop | Type | Optional | Default | Description |
|
|
417
|
+
| ----------- | -------- | -------- | -------- | ----------- |
|
|
418
|
+
| children | ReactNode | No | | the child Input or TextArea component |
|
|
419
|
+
| maxCharacters | number | No | | the number of characters allowed by CharacterCounter prior to it changing the displayed message and warning the user they are over the limit. |
|
|
420
|
+
| className | string | Yes | (1) below | This is used to apply user supplied styling to the CharacterCounter div element. |
|
|
421
|
+
| messageClassName | string | Yes | | CSS classes to apply to the message text prior to the user exceeding the specified limit |
|
|
422
|
+
| overLimitMessageClassName | string | Yes | | CSS classes to apply to the message text after the user has exceeded the specified limit. |
|
|
423
|
+
| altRemainingMessageText | string | Yes | 'remaining' | A string value containing an alternate message to display to the user as they type. If the user has typed 5 characters and is not over the limit, the default reads "5 remaining". |
|
|
424
|
+
| altOverageMessageText | string | Yes | 'characters too many' | A string value containing an alternate message to display to the user they have exceeded the specified limit. If the user has typed 15 characters and is over the limit, the default reads "5 characters too many" in red text (with dfeault overLimitMessageClassName). |
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
### Example Usage
|
|
428
|
+
|
|
429
|
+
Basic example
|
|
430
|
+
|
|
431
|
+
```jsx
|
|
432
|
+
<CharacterCounter
|
|
433
|
+
maxCharacters={15}>
|
|
434
|
+
<Input size={10} />
|
|
435
|
+
</CharacterCounter>
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
Using an altOverageMessageText and altRemainingMessageText
|
|
439
|
+
|
|
440
|
+
```jsx
|
|
441
|
+
<CharacterCounter
|
|
442
|
+
maxCharacters={15}
|
|
443
|
+
altOverageMessageText="CHARACTERS OVER THE LIMIT!"
|
|
444
|
+
altRemainingMessageText="characters remaining, use them wisely!">
|
|
445
|
+
<Input size={10} />
|
|
446
|
+
</CharacterCounter>
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Dependencies
|
|
450
|
+
|
|
451
|
+
**_none_**
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
[Top of Page](#table-of-contents)
|
|
136
455
|
|
|
137
|
-
---
|
|
138
456
|
|
|
139
|
-
|
|
457
|
+
<!-- D A T E P I C K E R ------------------------------------------------------------------------------- -->
|
|
458
|
+
|
|
459
|
+
## DatePicker
|
|
460
|
+
|
|
461
|
+
DatePicker is an input that can be set typing or clicking on the day of the week displayed.
|
|
462
|
+
|
|
463
|
+
The DatePicker component as built takes in various props (id, label, value, onChange)
|
|
464
|
+
|
|
465
|
+
### Props
|
|
466
|
+
|
|
467
|
+
| Prop | Type | Optional | Default | Description |
|
|
468
|
+
| ----------- | -------- | -------- | -------- | -------------------------------------------- |
|
|
469
|
+
| id | string | No | | An ID to differentiate/target the component. |
|
|
470
|
+
| label | string | No | | A label for the component |
|
|
471
|
+
| value | string | No | | The date the component is currently set to. |
|
|
472
|
+
| onChange | (date: string) => void \| null | No | | Handler function to be fed to the component, executed when the date changes |
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
### Example Usage
|
|
476
|
+
|
|
477
|
+
Default Variant
|
|
478
|
+
|
|
479
|
+
```jsx
|
|
480
|
+
import dayjs from "dayjs";
|
|
481
|
+
const [displayDate, setDisplayDate] = useState('');
|
|
482
|
+
|
|
483
|
+
<DatePicker id={""} label={""}
|
|
484
|
+
value={dayjs().startOf("day").format("MM-DD-YYYY")}
|
|
485
|
+
onChange={setDisplayDate}/>
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
### Dependencies
|
|
490
|
+
|
|
491
|
+
**dayjs**
|
|
492
|
+
|
|
493
|
+
[Top of Page](#table-of-contents)
|
|
140
494
|
|
|
141
|
-
1. **default:**
|
|
142
|
-
```css
|
|
143
|
-
flex flex-col w-64 max-w-64
|
|
144
|
-
```
|
|
145
|
-
2. **imageBottom:**
|
|
146
|
-
```css
|
|
147
|
-
flex flex-col-reverse w-64 mx-w-64
|
|
148
|
-
3. **imageLeft:**
|
|
149
|
-
```css
|
|
150
|
-
flex flex-row h-auto max-w-lg min-w-96
|
|
151
|
-
```
|
|
152
|
-
4. **imageRight:**
|
|
153
|
-
```css
|
|
154
|
-
flex flex-row-reverse h-auto max-w-lg min-w-96
|
|
155
|
-
```
|
|
156
495
|
|
|
157
496
|
|
|
158
497
|
<!-- I N P U T ------------------------------------------------------------------------------ -->
|
|
@@ -168,15 +507,20 @@ A reference can also be created and passed to the input component, and the compo
|
|
|
168
507
|
| Prop | Type | Optional | Default | Description |
|
|
169
508
|
| ----------- | -------- | -------- | -------- | ----------- |
|
|
170
509
|
| className | string | Yes | **(1) below** | pass any css class names to add/change styling
|
|
171
|
-
| labelClassName | string | Yes | **(2) below** | pass any css class names to add/change styling for the input label |
|
|
172
510
|
| label | string | Yes | '' | string value of label, blank for no label |
|
|
173
|
-
|
|
|
174
|
-
|
|
|
511
|
+
| labelBaseColor | string | Yes | | Use if the page or input color is not white, this will help to blend the label background to the surrounding area |
|
|
512
|
+
| labelClassName | string | Yes | **(2) below** | pass any css class names to add/change styling for the input label |
|
|
513
|
+
| placeHolder | string | Yes | Yes | | sets the placeholder text inside the input element |
|
|
514
|
+
| ...props | string | Yes | | takes additional props that are not specifically defined in the component, i.e. aria-label |
|
|
515
|
+
| required | boolean | Yes | | if specified, a red asterisk is prepended to the label, and the required attribute is set to true |
|
|
516
|
+
| textShadow | boolean | Yes | false | indicates whether a drop shadow should be applied or not to the label text, and if used, utilizes the **labelBaseColor** above. |
|
|
517
|
+
| variant | string | Yes | | The predefined variant of Badge to display. Current options are 'default', 'MedCard', 'Outline', and 'nonHover' |
|
|
175
518
|
|
|
176
|
-
**(1)** **`'arial rounded-sm border-2 border-[#c6c6c6] p-1 ps-2 mx-2
|
|
177
|
-
bg-white hover:outline-[#c6c6c6] focus:outline-[#0256ab] active:outline-[#0256ab]`**
|
|
178
519
|
|
|
179
|
-
**(
|
|
520
|
+
**(1)** Default classes are different for each variant, but the base classes are **`h-10 px-4 py-2 arial rounded-sm border-2 border-[#c6c6c6] p-1 ps-2 mx-2 bg-white hover:outline-[#c6c6c6] focus:outline-[#0256ab] active:outline-[#0256ab]`**
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
**(2)** Default classes for the label are **`absolute ms-5 -translate-y-1/2 px-2 text-[0.8em] w-auto h-auto`**
|
|
180
524
|
|
|
181
525
|
### Additional Properties & Attributes
|
|
182
526
|
|
|
@@ -187,7 +531,11 @@ This component as mentioned also takes any other property or attribute that a no
|
|
|
187
531
|
#### Simple version
|
|
188
532
|
|
|
189
533
|
```jsx
|
|
190
|
-
<Input
|
|
534
|
+
<Input
|
|
535
|
+
label="Default Input"
|
|
536
|
+
placeholder="placeholder text here"
|
|
537
|
+
labelBaseColor="#f5f5f5"
|
|
538
|
+
/>
|
|
191
539
|
```
|
|
192
540
|
|
|
193
541
|
#### More complex
|
|
@@ -210,6 +558,9 @@ This component as mentioned also takes any other property or attribute that a no
|
|
|
210
558
|
|
|
211
559
|
**_none_**
|
|
212
560
|
|
|
561
|
+
|
|
562
|
+
[Top of Page](#table-of-contents)
|
|
563
|
+
|
|
213
564
|
<!-- L I S T ----------------------------------------------------------------------------------- -->
|
|
214
565
|
|
|
215
566
|
## List
|
|
@@ -221,12 +572,12 @@ The **List** component is a component that creates a list of items, ordered or u
|
|
|
221
572
|
| Prop | Type | Optional | Default | Description |
|
|
222
573
|
| ----------- | -------- | -------- | -------- | ----------- |
|
|
223
574
|
| items | ListItemProps[] | Yes | undefined | takes an array of objects of type ListItemProps, anything can be fed to the children prop of the objects in the array |
|
|
575
|
+
| header | string | Yes | undefined | takes in a string of text to be displayed above the list of items |
|
|
224
576
|
| children | React.ReactNode | Yes | undefined | this allows the component to receive any number of react components as children |
|
|
225
577
|
| className | string | Yes | undefined | takes additional classnames to add/change styling |
|
|
226
578
|
| withDividers | boolean | Yes | false | if true, this prop will display a divider to separate each item within the list |
|
|
227
579
|
| dividerColorClass | string | Yes | undefined | this prop is used to change the color of dividers when used, for example 'red-400' |
|
|
228
|
-
| itemClassName | string | Yes | undefined | takes additional classnames to add/change styling of the items within the list |
|
|
229
|
-
| variant | string | Yes | undefined | variants can be used to change the theme of the component, for example DHA MedCard |
|
|
580
|
+
| itemClassName | string | Yes | undefined | takes additional classnames to add/change styling of the items within the list |
|
|
230
581
|
| isDecimal | boolean | Yes | false | if true, this prop will change the component to be ordered as a decimal list, placing a number next toe each item |
|
|
231
582
|
| isDisc | boolean | Yes | false | if true, this prob will change the list to be unordered, placing bullet points next to each item |
|
|
232
583
|
|
|
@@ -276,194 +627,554 @@ Usage can be viewed inside the storybook app (**`npm run storybook`**), and exam
|
|
|
276
627
|
</List>
|
|
277
628
|
```
|
|
278
629
|
|
|
630
|
+
<!-- M O D A L --------------------------------------------------------------------------- -->
|
|
631
|
+
|
|
279
632
|
|
|
280
|
-
|
|
281
|
-
-->
|
|
633
|
+
[Top of Page](#table-of-contents)
|
|
282
634
|
|
|
283
635
|
## Modal
|
|
284
636
|
|
|
285
|
-
The Modal component
|
|
637
|
+
The **Modal** component is intended to be a re-usable component that developers can include in an app that provides alert dialog functionality to users.
|
|
286
638
|
|
|
287
|
-
|
|
639
|
+
The Modal component takes four required props, **isOpen**, **onClose**, **title**, and **child** content.
|
|
288
640
|
|
|
289
|
-
|
|
641
|
+
Optional props are **className**, **clickOutsideCloses**, **displayClosingX**, **closeButtonText**,**continueButton**, **continueButtonText**, and **continueButtonHandler**.
|
|
290
642
|
|
|
291
|
-
|
|
643
|
+
As with the Button component, this component can also take additional html attributes that when included are passed to the parent div.
|
|
292
644
|
|
|
293
|
-
|
|
645
|
+
This div is also styled using the tailwind **`twMerge()`** utility, and is used to apply custom css classes via the className prop.
|
|
294
646
|
|
|
295
|
-
|
|
296
|
-
|-------------------------|-----------------|----------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
297
|
-
| `children` | ReactNode | No | | This prop takes children content, i.e., HTML and content that becomes the body of the Modal. |
|
|
298
|
-
| `isOpen` | boolean | No | | Indicates whether the Modal is displayed or not. This value also controls the `overflow: hidden` CSS property and enables/disables keyboard listeners for accessibility. |
|
|
299
|
-
| `onClose` | () => void | No | | This is the close handler for the Modal component. |
|
|
300
|
-
| `title` | string | No | | This is the title to display in the Modal component. |
|
|
301
|
-
| `className` | string | Yes | See (1) below | Alternate CSS class names to apply to the Modal component. `twMerge` is used to apply these classes, so they reliably overwrite existing styles. |
|
|
302
|
-
| `clickOutsideCloses` | boolean | Yes | `false` | When `true`, any mouse click outside of the Modal will close the Modal component. |
|
|
303
|
-
| `displayClosingX` | boolean | Yes | `true` | When `true`, an "x" icon is displayed in the upper right of the Modal component that, when clicked, will close the component. |
|
|
304
|
-
| `closeButtonText` | string | Yes | `'Close'` | The string value to display in the `Close` button. |
|
|
305
|
-
| `continueButton` | boolean | Yes | `false` | When `true`, a "Continue" button is displayed in the Modal along with a "Close" button. |
|
|
306
|
-
| `continueButtonText` | string | Yes | `'Continue'` | The string value to display in the `Continue` button. |
|
|
307
|
-
| `continueButtonHandler` | () => void | Yes | | The function handler to execute when the `Continue` button is clicked. |
|
|
647
|
+
Full list of props below
|
|
308
648
|
|
|
309
|
-
|
|
649
|
+
### Props
|
|
310
650
|
|
|
311
|
-
|
|
651
|
+
| Prop | Type | Optional | Default | Description |
|
|
652
|
+
| ----------- | -------- | -------- | -------- | ----------- |
|
|
653
|
+
| children | ReactNode | No | | This prop takes children content, i.e. html and content that becomes the body of the Modal. |
|
|
654
|
+
| isOpen | boolean | No | | indicates whether the Modal is displayed or not. This value also controls the overflow: hidden css property, as well as enabling/disabling keyboard event listeners for accessibility purposes. |
|
|
655
|
+
| onClose | () => void() | No | | This is the close handler for the Modal component. |
|
|
656
|
+
| title | string | No | | This is the title to display in the Modal component. |
|
|
657
|
+
| className | string | Yes | | Alternate CSS classnames to apply to the Modal component. twMerge is used to apply these classes, so they reliably overwrite existing styles. |
|
|
658
|
+
| clickOutsideCloses | boolean | Yes | | When true, any mouse click outside of the Modal will close the Modal component. |
|
|
659
|
+
| displayClosingX | boolean | Yes | | When true, an 'x' icon is displayed in the upper right of the Modal component that when clicked will close the component. |
|
|
660
|
+
| closeButtonText | string | Yes | | The string value to display in the Close button |
|
|
661
|
+
| continueButton | boolean | Yes | | When true, a 'Continue' button is displayed in the Modal along with a 'Close' button |
|
|
662
|
+
| continueButtonText | string | Yes | | The string value to display in the Continue button |
|
|
663
|
+
| continueButtonHandler | () => void | Yes | | The function handler to execute when the Continue button is clicked. |
|
|
312
664
|
|
|
313
|
-
1. **`default`**:
|
|
314
|
-
```css
|
|
315
|
-
bg-white rounded-lg shadow-lg w-full max-w-lg p-6 focus:outline-none
|
|
316
|
-
```
|
|
317
665
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
666
|
+
### Example Usage
|
|
667
|
+
|
|
668
|
+
Basic Modal
|
|
669
|
+
|
|
670
|
+
```jsx
|
|
671
|
+
<Modal
|
|
672
|
+
isOpen={isOpen}
|
|
673
|
+
onClose={() => setIsOpen(false)}
|
|
674
|
+
title="Test Modal"
|
|
675
|
+
clickOutsideCloses
|
|
676
|
+
>
|
|
677
|
+
<p>This is a Modal dialog that can be used for many varying
|
|
678
|
+
purposes, from informational messages to taking user input,
|
|
679
|
+
ideal for required quick tasks on a page.
|
|
680
|
+
</p>
|
|
681
|
+
</Modal>
|
|
682
|
+
```
|
|
322
683
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
```
|
|
684
|
+
### Dependencies
|
|
685
|
+
|
|
686
|
+
**_none_**
|
|
327
687
|
|
|
328
688
|
|
|
689
|
+
[Top of Page](#table-of-contents)
|
|
690
|
+
|
|
329
691
|
|
|
330
692
|
<!-- S E L E C T ---------------------------------------------------------------------------- -->
|
|
331
693
|
|
|
332
694
|
## Select
|
|
333
695
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
696
|
+
The **Select** component or drop-down allow a user to make a single selection from multiple choices while preserving space on the form. Our Select component comes with several variants: default, fill, and outline.
|
|
697
|
+
|
|
698
|
+
The **Select** component takes two required props (**options** and **setSelectedOption**) as well as four optional props (**className**, **error**, **label**, **optionsLabel**, and **variant**), in addition to any other html attributes a normal html element would use, for example an aria-tag.
|
|
699
|
+
|
|
700
|
+
Full list of props below
|
|
701
|
+
|
|
702
|
+
### Props
|
|
703
|
+
|
|
704
|
+
| Prop | Type | Optional | Default | Description |
|
|
705
|
+
| ----------- | -------- | -------- | -------- | ----------- |
|
|
706
|
+
| className | string | Yes | (1) below | a group of alternate css classes that can be specified by the developer for use in the input element. |
|
|
707
|
+
| disabled | boolean | Yes | undefined | if true the Select component is placed in a disabled state |
|
|
708
|
+
| error | boolean | Yes | false | if true a red border is applied to the outside of the select component indicating an error state. |
|
|
709
|
+
| label | string | Yes | undefined | text used as the label for the input, i.e. 'Border Color' above |
|
|
710
|
+
| options | {{name: ..., value:...}, ...} | Yes | undefined | options is an array of objects, each with a **name** and an optional **value** property. If value is not present, name is used in the handler function. |
|
|
711
|
+
| optionsLabel | string | Yes | undefined | appears as the label in the Select component, i.e. 'Choose a Color' above. Note, this is not the label above the component. |
|
|
712
|
+
| setSelectedOption | (string) => void | Yes | undefined | calls the function passed in as **`setSelectedOption`** with the selected **value** if present, otherwise with **name** |
|
|
713
|
+
| variant | string | Yes | undefined | The predefined variant of Select to display. Current options are 'default', 'MedCard', 'Outline', and 'nonHover' |
|
|
714
|
+
| width | string | Yes | | This prop is intended to like **`className`** take in css class name values. These are
|
|
715
|
+
intended though to only take class names relevant to the component width, as they will be applied to both the **button**
|
|
716
|
+
and the **drop down** elements of the **`Select`** component. For instance, the **`width`** prop is a good way to ensure that
|
|
717
|
+
the button and drop down are of the same width. Note the default classes below, i.e. widths specified on various break points. |
|
|
718
|
+
|
|
719
|
+
1. Base CSS Classes
|
|
720
|
+
|
|
721
|
+
- **`outline-none outline-offset-0 flex justify-between items-center w-[292px] md:w-[343px] lg:w-[600px] h-14 border focus:outline-4 focus:outline-[#fa89f1] shadow-sm px-4 py-2 bg-white text-lg font-medium text-gray-700 hover:bg-gray-50 border-[#b3b3b3]`**
|
|
722
|
+
|
|
723
|
+
Separate Variant Styles
|
|
724
|
+
|
|
725
|
+
- default:
|
|
726
|
+
- **`hover:bg-gray-200 text-black hover:border-gray-400 disabled:bg-dha-mc-bottom-nav-background disabled:text-dha-mc-checkbox-inactive h-12 mt-1 disabled:border-dha-mc-secondary-border disabled:border-2`**
|
|
727
|
+
- fill:
|
|
728
|
+
- **`hover:bg-[#0c2c8e] text-base text-white bg-[#092068] hover:border-gray-400 disabled:bg-dha-mc-bottom-nav-background disabled:text-dha-mc-checkbox-inactive h-12 mt-1 disabled:border-dha-mc-secondary-border disabled:border-2 py-3 pl-[15px] pr-[9px]`**
|
|
729
|
+
- outline:
|
|
730
|
+
- **`border-dha-mc-true-blue bg-white border-2 text-dha-mc-true-blue disabled:border-dha-mc-secondary-border disabled:text-dha-mc-checkbox-inactive`**
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
### Example Usage
|
|
734
|
+
|
|
735
|
+
```jsx
|
|
736
|
+
<Select
|
|
737
|
+
label='Border Color'
|
|
738
|
+
optionsLabel='Choose a Color'
|
|
739
|
+
variant='MedCard'
|
|
740
|
+
options={[
|
|
741
|
+
{name: 'gray', value: 'border-gray-500'},
|
|
742
|
+
{name: 'Blue', value: 'border-blue-500'}
|
|
743
|
+
]}
|
|
744
|
+
setSelectedOption={setSelectedBorder} />
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
### Dependencies
|
|
750
|
+
|
|
751
|
+
**_none_**
|
|
752
|
+
|
|
753
|
+
[Top of Page](#table-of-contents)
|
|
754
|
+
|
|
755
|
+
<!-- S I D E B A R N A V ---------------------------------------------------------------------------- -->
|
|
756
|
+
|
|
757
|
+
## SideBarNav
|
|
758
|
+
|
|
759
|
+
The **SideBarNav** component provides a navigation component that slides in from the side of the display when activated. It includes an application logo, the application name, a list of links, and the version number of the application displayed at the bottom of the navbar.
|
|
339
760
|
|
|
340
|
-
|
|
761
|
+
Future versions should include search functionality.
|
|
341
762
|
|
|
342
|
-
|
|
763
|
+
version: string;
|
|
764
|
+
appName: string;
|
|
765
|
+
menuItems: ListItemProps[];
|
|
343
766
|
|
|
344
|
-
|
|
767
|
+
Full list of props below
|
|
768
|
+
|
|
769
|
+
### Props
|
|
770
|
+
|
|
771
|
+
| Prop | Type | Optional | Default | Description |
|
|
772
|
+
| ----------- | -------- | -------- | -------- | ----------- |
|
|
773
|
+
| appName | string | No | undefined | The application name to dispilay |
|
|
774
|
+
| className | string | Yes | (1) below | a group of alternate css classes that can be specified by the developer and applied to the outer **`div`** element. |
|
|
775
|
+
| clickOutsideCloses | boolean | Yes | **`false`** | clicking or tapping elsewhere on the application will close the SideBarNav |
|
|
776
|
+
| image | string | No | undefined | string path to the application logo to display |
|
|
777
|
+
| imageClassname | string | Yes | (2) below | a group of alternate classes that can be specified for the logo image, and applied to the **`img`** element |
|
|
778
|
+
| menu | boolean | Yes | false | when **`true`**, the default in-component hamburger menu is displayed and used to display or hide the SideBarNav |
|
|
779
|
+
| menuClassName | string | Yes | (3) below | alternate css classes to apply to the **`button`** element that makes up the hamburger menu |
|
|
780
|
+
| menuItems | ListItemProps[] | No | undefined, see (4) below | The menu items to display |
|
|
781
|
+
| version | string | No | undefined | The version number to display |
|
|
345
782
|
|
|
346
|
-
If no width value is specified then the component will determine its own best width, though most likely the Select component and the drop-down width will be different.
|
|
347
783
|
|
|
348
|
-
|
|
784
|
+
1. Default Classes outer **`div`**
|
|
785
|
+
|
|
786
|
+
- w/o menu **`relative w-56 h-screen flex flex-col px-4 pb-4 pt-10 bg-white overflow-y-auto`**
|
|
787
|
+
- w/ menu, include also **`fixed z-20 right-0 top-0 translate-x-full transition-transform duration-300`**
|
|
788
|
+
|
|
789
|
+
2. Default classes applied to **`img`** - **`border border-[#bbbabc] w-16 h-16 bg-[#eeeeef] ring-1`**
|
|
790
|
+
|
|
791
|
+
3. Default classes applied to **`button`** - **`size-8 mb-4`**
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
### Example Usage
|
|
795
|
+
|
|
796
|
+
```jsx
|
|
797
|
+
import doctor from '../../assets/Doctor.png';
|
|
798
|
+
// ...
|
|
799
|
+
|
|
800
|
+
const menuItems = [
|
|
801
|
+
{
|
|
802
|
+
children: <>
|
|
803
|
+
<img className='max-h-[2em] max-w-[2em] pr-1 inline' src={arrowRight} alt='home link icon' />
|
|
804
|
+
<p className='inline hover:underline'>Accordion</p>
|
|
805
|
+
</>,
|
|
806
|
+
target: '/accordion'
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
children: <>
|
|
810
|
+
<img className='max-h-[2em] max-w-[2em] pr-1 inline' src={arrowRight} alt='home link icon' />
|
|
811
|
+
<p className='inline hover:underline'>Badge</p>
|
|
812
|
+
</>,
|
|
813
|
+
target: '/badge'
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
children: <>
|
|
817
|
+
<img className='max-h-[2em] max-w-[2em] pr-1 inline' src={arrowRight} alt='home link icon' />
|
|
818
|
+
<p className='inline hover:underline'>Breadcrumbs</p>
|
|
819
|
+
</>,
|
|
820
|
+
target: '/libraries/simple-ui/bread-crumbs-page'
|
|
821
|
+
},
|
|
822
|
+
....
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// in the return JSX
|
|
826
|
+
<SideBarNav
|
|
827
|
+
appName='A.C.M.E. Tools'
|
|
828
|
+
version="0.0.0"
|
|
829
|
+
menuItems={menuItems}
|
|
830
|
+
image={doctor}
|
|
831
|
+
clickOutsideCloses
|
|
832
|
+
menu
|
|
833
|
+
className='bg-slate-200 border border-slate-400 rounded-l-md h-full'
|
|
834
|
+
/>
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
### Dependencies
|
|
840
|
+
|
|
841
|
+
**_none_**
|
|
842
|
+
|
|
843
|
+
[Top of Page](#table-of-contents)
|
|
844
|
+
|
|
845
|
+
<!-- S K E L E T O N ---------------------------------------------------------------------------- -->
|
|
846
|
+
|
|
847
|
+
## Skeleton
|
|
848
|
+
|
|
849
|
+
A Skeleton is used as a placeholder, showing a basic graphic representation of a page or resource while content is loading.
|
|
850
|
+
|
|
851
|
+
The `Skeleton` component serves as a container for the Skeleton content, which consists of SkelCircle, SkelLine, SkelSection, and SkelRow. Skeleton takes two optional prop values, className and variant.
|
|
852
|
+
|
|
853
|
+
Note that the `Skeleton` component uses `Flexbox`, and you can in theory use your own custom elements inside it, or change the layout on child components with this in mind.
|
|
854
|
+
|
|
855
|
+
The nested components inside of Skeleton are `SkelCircle`, `SkelLine`, `SkelSection`, and `SkelRow`. These small components serve to display shaded shapes that represent larger content on the page representation.
|
|
856
|
+
|
|
857
|
+
When using the `className` prop on one of the internal props inside the `Skeleton` component to alter style or size, as the container uses flexbox, note the usage examples above. For instance, to make a bar partially expand across the line, you can for example use `className="grow-0 basis-2/12"`.
|
|
858
|
+
|
|
859
|
+
- `SkelCircle` - a small circle (i.e. a badge or icon)
|
|
860
|
+
- `SkelLine` - a line (i.e. text or content)
|
|
861
|
+
- `SkelSection` - a larger section on a page, or paragraph
|
|
862
|
+
- `SkelRow` - non graphical, used to force following items to a new row after using inline variants above. Usually not required.
|
|
863
|
+
|
|
864
|
+
Full list of props below
|
|
865
|
+
|
|
866
|
+
### Props for Skeleton
|
|
867
|
+
|
|
868
|
+
| Prop | Type | Optional | Default | Description |
|
|
869
|
+
| ----------- | -------- | -------- | -------- | ----------- |
|
|
870
|
+
| className | string | Yes | | This is used to apply user supplied styling to the `Skeleton` component. |
|
|
871
|
+
| variant | string | Yes | | Allows the user to enter a pre-defined variant that includes its own pre-defined styling |
|
|
872
|
+
|
|
873
|
+
### Props for SkelCircle & SkelLine components
|
|
349
874
|
|
|
350
|
-
|
|
875
|
+
| Prop | Type | Optional | Default | Description |
|
|
876
|
+
| ----------- | -------- | -------- | -------- | ----------- |
|
|
877
|
+
| className | string | Yes | | This is used to apply user supplied styling to the `SkelCircle` and `SkelLine` components. |
|
|
878
|
+
| inline | boolean | Yes | false | if specified or true this component will be layed out inline. The `className` prop can be used to set a width, and if desired, additional inline components can be placed on the same line inside the Skeleton. |
|
|
351
879
|
|
|
352
|
-
### Props
|
|
880
|
+
### Props for SkelCircle & SkelLine components
|
|
353
881
|
|
|
354
882
|
| Prop | Type | Optional | Default | Description |
|
|
355
883
|
| ----------- | -------- | -------- | -------- | ----------- |
|
|
356
|
-
| className | string | Yes |
|
|
884
|
+
| className | string | Yes | | This is used to apply user supplied styling to the `SkelSection` and `SkelRow` components. |
|
|
885
|
+
|
|
886
|
+
Tailwind CSS Classes used for Skeleton components
|
|
887
|
+
|
|
888
|
+
- Skeleton
|
|
889
|
+
- **`flex flex-row flex-wrap animate-pulse h-48 w-56 pt-2`**
|
|
890
|
+
- SkelCircle & SkelLine
|
|
891
|
+
- **`rounded-lg bg-slate-300 h-6 inline-block mx-2 my-1 grow`**
|
|
892
|
+
- SkelSection
|
|
893
|
+
- **`rounded-lg bg-slate-300 grow h-24 my-1 mx-2`**
|
|
894
|
+
- SkelRow
|
|
895
|
+
- **`basis-full h-0`**
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
### Example Usage
|
|
899
|
+
|
|
900
|
+
Usage example for Example 1 below
|
|
901
|
+
|
|
902
|
+
```jsx
|
|
903
|
+
import { Skeleton, SkelCircle, SkelLine, SkelRow, SkelSection } from '@dhasdk/simple-ui'
|
|
904
|
+
// ...
|
|
905
|
+
<Skeleton>
|
|
906
|
+
<SkelCircle inline /><SkelLine inline />
|
|
907
|
+
<SkelLine />
|
|
908
|
+
<SkelSection />
|
|
909
|
+
</Skeleton>
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
Usage example for Example 2 below
|
|
913
|
+
|
|
914
|
+
```jsx
|
|
915
|
+
import { Skeleton, SkelCircle, SkelLine, SkelRow, SkelSection } from '@dhasdk/simple-ui'
|
|
916
|
+
// ...
|
|
917
|
+
<Skeleton>
|
|
918
|
+
<SkelLine className="grow-0 basis-2/12" inline />
|
|
919
|
+
<SkelLine className="grow-0 basis-2/12" inline />
|
|
920
|
+
<SkelLine />
|
|
921
|
+
<SkelSection />
|
|
922
|
+
</Skeleton>
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
### Dependencies
|
|
926
|
+
|
|
927
|
+
**_none_**
|
|
928
|
+
|
|
929
|
+
[Top of Page](#table-of-contents)
|
|
357
930
|
|
|
358
|
-
|
|
931
|
+
|
|
932
|
+
<!-- S T A T U S ---------------------------------------------------------------------------- -->
|
|
933
|
+
|
|
934
|
+
## Status
|
|
935
|
+
|
|
936
|
+
The `Status` component comes with three default variants, and the ability for the developer to create their own. Status is used to display in a small graphical format the status of content or a short message, accompanied by an icon - similar to a Badge.
|
|
937
|
+
|
|
938
|
+
This component takes five optional props that allow for customization and/or the use of pre-defined variants. The three predefined variants, specified via the `variant` prop, are `available`, `inProgress`, and `notAvailable`. If `variant` is left blank, `available` is used.
|
|
939
|
+
|
|
940
|
+
To create a custom iteration of Status, leave `variant` blank and utilize a combination of the remaining props. The `Status` component consists of three separate div elements, one serving as a container, and then one each for the image/icon and child data.
|
|
941
|
+
|
|
942
|
+
The `className` prop can be used to add alternate styling to the outer div, i.e. `border-blue-700 bg-blue-200`. Likewise, the `imageClasses` prop can be used to provide alternate styling to the div containing the image, and the `childClasses` prop can provide alternate styling for the child div that contains the text, i.e. `text-blue-700`
|
|
943
|
+
|
|
944
|
+
`image` and `children` are the final two props, and are both of type `ReactNode`.
|
|
945
|
+
|
|
946
|
+
Full list of props below
|
|
947
|
+
|
|
948
|
+
### Props
|
|
359
949
|
|
|
360
950
|
| Prop | Type | Optional | Default | Description |
|
|
361
951
|
| ----------- | -------- | -------- | -------- | ----------- |
|
|
362
|
-
|
|
|
363
|
-
|
|
|
364
|
-
|
|
|
952
|
+
| children | string | No | | This prop takes children content, i.e. html and content that becomes the body of the Status. |
|
|
953
|
+
| variant | string | No | 'available' | The predefined variant of Status to display. Predefined variants are `available`, `inProgress`, and `notAvailable` |
|
|
954
|
+
| className | string | Yes | (1) below | Alternate CSS classnames to apply to the Status component. `twMerge` is used to apply these styles, so they reliably overwrite existing styles. |
|
|
955
|
+
| childClasses | string | Yes | (2) below | This prop takes in alternate classes to apply style to the `div` that contains the child content. |
|
|
956
|
+
| image | ReactNode | Yes | | This prop takes type `ReactNode`, and is used to display a custom user supplied image. See usage examples above for more. |
|
|
957
|
+
| imageClasses | string | Yes | (3) below | Alternate CSS classes that are applied to the div containing the childe div that contains the Status component image. |
|
|
958
|
+
|
|
959
|
+
1. className
|
|
960
|
+
|
|
961
|
+
**`h-[45px] px-4 py-3 bg-green-50 rounded-[100px] border border-green-700 justify-center items-center gap-2 inline-flex`**
|
|
962
|
+
|
|
963
|
+
2. childClasses
|
|
964
|
+
|
|
965
|
+
**`text-green-900 text-lg font-normal font-['Arial']`**
|
|
966
|
+
|
|
967
|
+
3. imageClasses
|
|
968
|
+
|
|
969
|
+
**`w-5 h-5 relative overflow-hidden`**
|
|
970
|
+
|
|
971
|
+
### Example Usage
|
|
972
|
+
|
|
973
|
+
Available variant
|
|
974
|
+
|
|
975
|
+
```jsx
|
|
976
|
+
<Status
|
|
977
|
+
className='me-4'>
|
|
978
|
+
Available</Status>
|
|
979
|
+
```
|
|
980
|
+
|
|
981
|
+
inProgress variant
|
|
982
|
+
|
|
983
|
+
```jsx
|
|
984
|
+
<Status
|
|
985
|
+
className='me-4'
|
|
986
|
+
variant='inProgress'>
|
|
987
|
+
In Progress</Status>
|
|
988
|
+
```
|
|
989
|
+
|
|
990
|
+
notAvailable variant
|
|
991
|
+
|
|
992
|
+
```jsx
|
|
993
|
+
<Status
|
|
994
|
+
className='me-4'
|
|
995
|
+
variant='inProgress'>
|
|
996
|
+
In Progress</Status>
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
Custom variant
|
|
1000
|
+
|
|
1001
|
+
```jsx
|
|
1002
|
+
<Status
|
|
1003
|
+
image={ <img src={tune}
|
|
1004
|
+
alt='information' /> }
|
|
1005
|
+
className='border-blue-700 bg-blue-200'
|
|
1006
|
+
childClasses='text-blue-700'
|
|
1007
|
+
>
|
|
1008
|
+
Custom
|
|
1009
|
+
</Status>
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
### Dependencies
|
|
1013
|
+
|
|
1014
|
+
**_none_**
|
|
1015
|
+
|
|
1016
|
+
[Top of Page](#table-of-contents)
|
|
1017
|
+
|
|
1018
|
+
<!-- T A B S --------------------------------------------------------------------------------- -->
|
|
1019
|
+
|
|
1020
|
+
## Tabs
|
|
365
1021
|
|
|
366
|
-
|
|
1022
|
+
Tabs component lets the user split the UI into independent pieces, and view each piece in isolation.
|
|
1023
|
+
|
|
1024
|
+
This component has one required prop, **tabs**, which contains the content of the various tabs as type ReactNode. Optional props are **className**, **containerClassName**, and **variant**.
|
|
1025
|
+
|
|
1026
|
+
Full list of props below
|
|
1027
|
+
|
|
1028
|
+
### Props
|
|
367
1029
|
|
|
368
1030
|
| Prop | Type | Optional | Default | Description |
|
|
369
1031
|
| ----------- | -------- | -------- | -------- | ----------- |
|
|
370
|
-
|
|
|
1032
|
+
| className | string | Yes | undefined | |
|
|
1033
|
+
| containerClassName | string | Yes | undefined | |
|
|
1034
|
+
| tabs | {id: string; label: string; content: ReactNode;}[] | Yes | undefined | An array of |
|
|
1035
|
+
| variant | string | Yes | 'default' | The predefined variant of Tabs to display. Current options are 'default', 'outline', and 'filled' |
|
|
371
1036
|
|
|
372
1037
|
### Example Usage
|
|
373
1038
|
|
|
374
|
-
|
|
375
|
-
<summary><span style="color: green;">Click to view example source code</span></summary>
|
|
1039
|
+
Tabs - very simple example
|
|
376
1040
|
|
|
377
1041
|
```jsx
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
SelectLabel,
|
|
383
|
-
SelectValue,
|
|
384
|
-
SelectContent,
|
|
385
|
-
SelectItem,
|
|
386
|
-
ComponentWidthProvider,
|
|
387
|
-
SelectScrollDownButton,
|
|
388
|
-
SelectScrollUpButton,
|
|
389
|
-
} from '../components/ui/select';
|
|
390
|
-
|
|
391
|
-
<ComponentWidthProvider>
|
|
392
|
-
<Select
|
|
393
|
-
widthClass="w-[180px]"
|
|
394
|
-
onValueChange={(value) => console.log('Clicked! Value: ', value)}
|
|
395
|
-
name="TestSelect"
|
|
396
|
-
>
|
|
397
|
-
<SelectTrigger className="">
|
|
398
|
-
<SelectValue placeholder="Theme" />
|
|
399
|
-
</SelectTrigger>
|
|
400
|
-
<SelectContent>
|
|
401
|
-
<SelectGroup>
|
|
402
|
-
<SelectLabel>Words</SelectLabel>
|
|
403
|
-
<SelectItem value="light">Light</SelectItem>
|
|
404
|
-
<SelectItem value="dark">Dark</SelectItem>
|
|
405
|
-
<SelectItem value="system">System</SelectItem>
|
|
406
|
-
</SelectGroup>
|
|
407
|
-
<SelectGroup>
|
|
408
|
-
<SelectLabel>Numbers</SelectLabel>
|
|
409
|
-
<SelectItem value="1">One</SelectItem>
|
|
410
|
-
<SelectItem value="2">Two</SelectItem>
|
|
411
|
-
<SelectItem value="3">Three</SelectItem>
|
|
412
|
-
<SelectItem value="4">Four</SelectItem>
|
|
413
|
-
<SelectItem value="5">Five</SelectItem>
|
|
414
|
-
<SelectItem value="42">Answer to Life</SelectItem>
|
|
415
|
-
</SelectGroup>
|
|
416
|
-
<SelectGroup>
|
|
417
|
-
<SelectLabel>Colors</SelectLabel>
|
|
418
|
-
<SelectItem value="red">Red</SelectItem>
|
|
419
|
-
<SelectItem value="yellow">Yellow</SelectItem>
|
|
420
|
-
<SelectItem value="blue">Blue</SelectItem>
|
|
421
|
-
<SelectItem value="brown">Brown</SelectItem>
|
|
422
|
-
<SelectItem value="green">Green</SelectItem>
|
|
423
|
-
<SelectItem value="orange">Orange</SelectItem>
|
|
424
|
-
<SelectItem value="purple">Purple</SelectItem>
|
|
425
|
-
</SelectGroup>
|
|
426
|
-
</SelectContent>
|
|
427
|
-
</Select>
|
|
428
|
-
</ComponentWidthProvider>;
|
|
1042
|
+
<Tabs tabs={[
|
|
1043
|
+
{id: 'tab1', label: 'Tab 1', content: <p>I am a tab!</p>},
|
|
1044
|
+
{id: 'tab2', label: 'Tab 2', content: <p>I am a 2nd tab!</p>}
|
|
1045
|
+
]} />
|
|
429
1046
|
```
|
|
430
1047
|
|
|
431
|
-
|
|
1048
|
+
Tabs - more complicated example
|
|
1049
|
+
|
|
1050
|
+
```jsx
|
|
1051
|
+
|
|
1052
|
+
const TabsContent1 = () => {
|
|
1053
|
+
return(
|
|
1054
|
+
<>
|
|
1055
|
+
<p>Test Data 1</p>
|
|
1056
|
+
<ul className="list-disc mt-2 ms-4">
|
|
1057
|
+
<li>Seattle</li>
|
|
1058
|
+
<li>Tacoma</li>
|
|
1059
|
+
<li>Olympia</li>
|
|
1060
|
+
<li>Bellevue</li>
|
|
1061
|
+
<li>Redmond</li>
|
|
1062
|
+
</ul>
|
|
1063
|
+
</>
|
|
1064
|
+
)
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
const TabsContent2 = () => {
|
|
1068
|
+
return(
|
|
1069
|
+
<>
|
|
1070
|
+
<p>Test Data 2</p>
|
|
1071
|
+
<ul className="list-disc mt-2 ms-4">
|
|
1072
|
+
<li>Tokyo - Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
|
|
1073
|
+
<li>Paris - Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
|
|
1074
|
+
<li>London - Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
|
|
1075
|
+
<li>Sydney - Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
|
|
1076
|
+
<li>Honolulu - Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
|
|
1077
|
+
</ul>
|
|
1078
|
+
</>
|
|
1079
|
+
)
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
const tabExample = [
|
|
1083
|
+
{
|
|
1084
|
+
id: 'tab1',
|
|
1085
|
+
label: 'Tab 1',
|
|
1086
|
+
content: <TabsContent1/>,
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
id: 'tab2',
|
|
1090
|
+
label: 'Tab 2',
|
|
1091
|
+
content: <TabsContent2/>,
|
|
1092
|
+
}
|
|
1093
|
+
]
|
|
1094
|
+
// ...
|
|
1095
|
+
return {
|
|
1096
|
+
...
|
|
1097
|
+
<Tabs tabs={tabExample} />
|
|
1098
|
+
...
|
|
1099
|
+
}
|
|
1100
|
+
```
|
|
432
1101
|
|
|
433
1102
|
### Dependencies
|
|
434
1103
|
|
|
435
|
-
|
|
1104
|
+
**_none_**
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
[Top of Page](#table-of-contents)
|
|
436
1109
|
|
|
437
1110
|
<!-- T O G G L E -------------------------------------------------------------------- -->
|
|
438
1111
|
|
|
439
1112
|
## Toggle
|
|
440
1113
|
|
|
441
|
-
|
|
1114
|
+
A Toggle is an element that allows the user to make a choice between two mutually exclusive states. Our Toggle comes with several variants: default, outlined, and text.
|
|
442
1115
|
|
|
443
|
-
The
|
|
1116
|
+
The Toggle component takes a "variant" prop used to indicate pre-defined styles, an optional click handler, and various other optional props described below and uses those to display a Toggle button. The variant prop currently takes one of four values, those possible values currently being 'default', 'Outline', 'nonHover', and 'MedCard'.
|
|
1117
|
+
|
|
1118
|
+
As with the button component, Toggle takes any other additional html attributes and passes them to the parent **`<button>`** tag. This div is styled using the tailwind twMerge() utility, so custom classes can be added via the classNames prop as and applied as well.
|
|
444
1119
|
|
|
445
1120
|
### Props
|
|
446
1121
|
|
|
447
1122
|
| Prop | Type | Optional | Default | Description |
|
|
448
1123
|
| ----------- | -------- | -------- | -------- | ----------- |
|
|
449
|
-
| className | string | Yes |
|
|
450
|
-
|
|
|
451
|
-
|
|
|
1124
|
+
| className | string | Yes | (1) below | alternate css classes to add/change styling of button element inside component |
|
|
1125
|
+
| classNameButton | string | Yes | (1) below | alternate css classes to add/change styling of div used inside button/toggle |
|
|
1126
|
+
| defaultChecked | boolean | Yes | **`false`** | sets default state as checked or unchecked state when first displayed |
|
|
1127
|
+
| disabled | boolean | Yes | **`false`** | sets disabled state of Toggle component |
|
|
1128
|
+
| onCheckedChange | (checked: boolean) => void | Yes | undefined | callback function that is called with the new value of `checked` whenever it changes. To capture the correct state, it is recommended that you use an arrow function here. |
|
|
452
1129
|
| ...props | string | Yes | undefined | takes additional props that are not specifically defined in the component, i.e. **`aria-label`** |
|
|
453
1130
|
| ref | string | Yes | undefined | ref is exposed as a prop, and can be assigned and used on this component as normal |
|
|
454
|
-
|
|
1131
|
+
| variant | string | Yes | 'default' | The predefined variant of Badge to display. Options are: 'default', 'Outline', 'nonHover', and 'MedCard'. |
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
(1) Base CSS Classes
|
|
1135
|
+
- w-16 h-8 flex items-center p-1 rounded-full cursor-pointer transition-colors duration-300
|
|
1136
|
+
Toggle portion Base CSS Classes
|
|
1137
|
+
- bg-white w-6 h-6 rounded-full shadow-md transform transition-transform duration-300
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
Separate Variant Styles
|
|
1141
|
+
|
|
1142
|
+
- default:
|
|
1143
|
+
- classes: 'bg-gray-300 hover:bg-gray-400'
|
|
1144
|
+
- toggledClasses: 'bg-[#092068] hover:bg-blue-700'
|
|
1145
|
+
- buttonClasses: 'translate-x-0'
|
|
1146
|
+
- toggledButtonClasses: 'translate-x-8'
|
|
1147
|
+
- Outline:
|
|
1148
|
+
- classes: 'bg-slate-200 border-2 border-blue-700 hover:bg-slate-300'
|
|
1149
|
+
- toggledClasses: 'bg-blue-500 border-2 border-blue-700 hover:bg-blue-400'
|
|
1150
|
+
- buttonClasses: 'translate-x-0'
|
|
1151
|
+
- toggledButtonClasses: 'translate-x-8'
|
|
1152
|
+
- nonHover:
|
|
1153
|
+
- classes: 'bg-gray-300'
|
|
1154
|
+
- toggledClasses: 'bg-[#092068]'
|
|
1155
|
+
- buttonClasses: 'translate-x-0'
|
|
1156
|
+
- toggledButtonClasses: 'translate-x-8'
|
|
1157
|
+
- MedCard:
|
|
1158
|
+
- classes: 'bg-[#E3EBF3] border-2 border-[#0256AB]'
|
|
1159
|
+
- toggledClasses: 'bg-[#0256AB] border-2 border-[#0256AB]'
|
|
1160
|
+
- buttonClasses: 'translate-x-0'
|
|
1161
|
+
- toggledButtonClasses: 'translate-x-8'
|
|
455
1162
|
|
|
456
1163
|
### Example Usage
|
|
457
1164
|
|
|
458
|
-
Usage can be viewed inside the storybook app (**`npm run storybook`**), and an example is below. The following logs the checked state value (true or false) to the console when toggled.
|
|
459
|
-
|
|
460
1165
|
```jsx
|
|
461
|
-
<Toggle
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
1166
|
+
<Toggle
|
|
1167
|
+
onCheckedChange={(checked: boolean) => {
|
|
1168
|
+
setColor(checked ?
|
|
1169
|
+
'border-green-500' : 'border-gray-400');
|
|
1170
|
+
console.log(checked);}
|
|
1171
|
+
}
|
|
1172
|
+
variant={badgeVariant} />
|
|
465
1173
|
```
|
|
466
1174
|
|
|
467
1175
|
### Dependencies
|
|
468
1176
|
|
|
469
|
-
|
|
1177
|
+
**_none_**
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
[Top of Page](#table-of-contents)
|