@helpwave/hightide 0.0.9 → 0.0.12
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 +1 -1
- package/dist/coloring/shading.d.ts +2 -0
- package/dist/coloring/shading.js +40 -0
- package/dist/coloring/types.d.ts +11 -0
- package/dist/coloring/types.js +1 -0
- package/dist/components/Avatar.d.ts +14 -0
- package/dist/components/Avatar.js +35 -0
- package/dist/components/AvatarGroup.d.ts +10 -0
- package/dist/components/AvatarGroup.js +13 -0
- package/dist/components/BreadCrumb.d.ts +16 -0
- package/dist/components/BreadCrumb.js +12 -0
- package/dist/components/Button.d.ts +41 -0
- package/dist/components/Button.js +84 -0
- package/dist/components/ChipList.d.ts +21 -0
- package/dist/components/ChipList.js +38 -0
- package/dist/components/Circle.d.ts +6 -0
- package/dist/components/Circle.js +10 -0
- package/dist/components/ErrorComponent.d.ts +13 -0
- package/dist/components/ErrorComponent.js +19 -0
- package/dist/components/Expandable.d.ts +30 -0
- package/dist/components/Expandable.js +16 -0
- package/dist/components/HelpwaveBadge.d.ts +11 -0
- package/dist/components/HelpwaveBadge.js +14 -0
- package/dist/components/HideableContentSection.d.ts +10 -0
- package/dist/components/HideableContentSection.js +15 -0
- package/dist/components/InputGroup.d.ts +13 -0
- package/dist/components/InputGroup.js +33 -0
- package/dist/components/LoadingAndErrorComponent.d.ts +17 -0
- package/dist/components/LoadingAndErrorComponent.js +25 -0
- package/dist/components/LoadingAnimation.d.ts +13 -0
- package/dist/components/LoadingAnimation.js +19 -0
- package/dist/components/LoadingButton.d.ts +6 -0
- package/dist/components/LoadingButton.js +10 -0
- package/dist/components/MarkdownInterpreter.d.ts +25 -0
- package/dist/components/MarkdownInterpreter.js +190 -0
- package/dist/components/Pagination.d.ts +14 -0
- package/dist/components/Pagination.js +25 -0
- package/dist/components/Profile.d.ts +28 -0
- package/dist/components/Profile.js +45 -0
- package/dist/components/ProgressIndicator.d.ts +21 -0
- package/dist/components/ProgressIndicator.js +24 -0
- package/dist/components/Ring.d.ts +31 -0
- package/dist/components/Ring.js +113 -0
- package/dist/components/SearchableList.d.ts +18 -0
- package/dist/components/SearchableList.js +27 -0
- package/dist/components/SortButton.d.ts +10 -0
- package/dist/components/SortButton.js +9 -0
- package/dist/components/Span.js +1 -0
- package/dist/components/StepperBar.d.ts +23 -0
- package/dist/components/StepperBar.js +47 -0
- package/dist/components/Table.d.ts +87 -0
- package/dist/components/Table.js +187 -0
- package/dist/components/TechRadar.d.ts +36 -0
- package/dist/components/TechRadar.js +191 -0
- package/dist/components/TextImage.d.ts +20 -0
- package/dist/components/TextImage.js +31 -0
- package/dist/components/TimeDisplay.d.ts +30 -0
- package/dist/components/TimeDisplay.js +83 -0
- package/dist/components/Tooltip.d.ts +34 -0
- package/dist/components/Tooltip.js +38 -0
- package/dist/components/VerticalDivider.d.ts +11 -0
- package/dist/components/VerticalDivider.js +7 -0
- package/dist/components/date/DatePicker.d.ts +26 -0
- package/dist/components/date/DatePicker.js +58 -0
- package/dist/components/date/DayPicker.d.ts +16 -0
- package/dist/components/date/DayPicker.js +37 -0
- package/dist/components/date/TimePicker.d.ts +12 -0
- package/dist/components/date/TimePicker.js +79 -0
- package/dist/components/date/YearMonthPicker.d.ts +11 -0
- package/dist/components/date/YearMonthPicker.js +59 -0
- package/dist/components/examples/InputGroupExample.d.ts +6 -0
- package/dist/components/examples/InputGroupExample.js +21 -0
- package/dist/components/examples/MultiSelectExample.d.ts +7 -0
- package/dist/components/examples/MultiSelectExample.js +27 -0
- package/dist/components/examples/SearchableSelectExample.d.ts +6 -0
- package/dist/components/examples/SearchableSelectExample.js +17 -0
- package/dist/components/examples/SelectExample.d.ts +4 -0
- package/dist/components/examples/SelectExample.js +15 -0
- package/dist/components/examples/StackingModals.d.ts +4 -0
- package/dist/components/examples/StackingModals.js +15 -0
- package/dist/components/examples/TableExample.d.ts +9 -0
- package/dist/components/examples/TableExample.js +92 -0
- package/dist/components/examples/TextareaExample.d.ts +6 -0
- package/dist/components/examples/TextareaExample.js +10 -0
- package/dist/components/examples/TileExample.d.ts +9 -0
- package/dist/components/examples/TileExample.js +9 -0
- package/dist/components/examples/Title.js +1 -0
- package/dist/components/examples/date/DateTimePickerExample.d.ts +10 -0
- package/dist/components/examples/date/DateTimePickerExample.js +21 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.js +13 -0
- package/dist/components/examples/properties/DatePropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/DatePropertyExample.js +23 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.js +16 -0
- package/dist/components/examples/properties/NumberPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/NumberPropertyExample.js +13 -0
- package/dist/components/examples/properties/SelectPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/SelectPropertyExample.js +18 -0
- package/dist/components/examples/properties/TextPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/TextPropertyExample.js +13 -0
- package/dist/components/icons/Helpwave.d.ts +10 -0
- package/dist/components/icons/Helpwave.js +20 -0
- package/dist/components/icons/Tag.d.ts +10 -0
- package/dist/components/icons/Tag.js +12 -0
- package/dist/components/layout/Carousel.d.ts +22 -0
- package/dist/components/layout/Carousel.js +233 -0
- package/dist/components/layout/DividerInserter.d.ts +11 -0
- package/dist/components/layout/DividerInserter.js +20 -0
- package/dist/components/layout/FAQSection.d.ts +23 -0
- package/dist/components/layout/FAQSection.js +14 -0
- package/dist/components/layout/Tile.d.ts +34 -0
- package/dist/components/layout/Tile.js +18 -0
- package/dist/components/modals/ConfirmDialog.d.ts +34 -0
- package/dist/components/modals/ConfirmDialog.js +31 -0
- package/dist/components/modals/DiscardChangesDialog.d.ts +19 -0
- package/dist/components/modals/DiscardChangesDialog.js +24 -0
- package/dist/components/modals/InputModal.d.ts +9 -0
- package/dist/components/modals/InputModal.js +9 -0
- package/dist/components/modals/LanguageModal.d.ts +17 -0
- package/dist/components/modals/LanguageModal.js +35 -0
- package/dist/components/modals/Modal.d.ts +38 -0
- package/dist/components/modals/Modal.js +57 -0
- package/dist/components/modals/ModalRegister.d.ts +11 -0
- package/dist/components/modals/ModalRegister.js +28 -0
- package/dist/components/properties/CheckboxProperty.d.ts +15 -0
- package/dist/components/properties/CheckboxProperty.js +27 -0
- package/dist/components/properties/DateProperty.d.ts +11 -0
- package/dist/components/properties/DateProperty.js +22 -0
- package/dist/components/properties/MultiSelectProperty.d.ts +12 -0
- package/dist/components/properties/MultiSelectProperty.js +33 -0
- package/dist/components/properties/NumberProperty.d.ts +16 -0
- package/dist/components/properties/NumberProperty.js +42 -0
- package/dist/components/properties/PropertyBase.d.ts +23 -0
- package/dist/components/properties/PropertyBase.js +27 -0
- package/dist/components/properties/SelectProperty.d.ts +12 -0
- package/dist/components/properties/SelectProperty.js +22 -0
- package/dist/components/properties/TextProperty.d.ts +15 -0
- package/dist/components/properties/TextProperty.js +37 -0
- package/dist/components/user-input/Checkbox.d.ts +37 -0
- package/dist/components/user-input/Checkbox.js +63 -0
- package/dist/components/user-input/DateAndTimePicker.d.ts +39 -0
- package/dist/components/user-input/DateAndTimePicker.js +65 -0
- package/dist/components/user-input/Input.d.ts +61 -0
- package/dist/components/user-input/Input.js +61 -0
- package/dist/components/user-input/Label.d.ts +12 -0
- package/dist/components/user-input/Label.js +12 -0
- package/dist/components/user-input/Menu.d.ts +21 -0
- package/dist/components/user-input/Menu.js +26 -0
- package/dist/components/user-input/MultiSelect.d.ts +39 -0
- package/dist/components/user-input/MultiSelect.js +57 -0
- package/dist/components/user-input/ScrollPicker.d.ts +11 -0
- package/dist/components/user-input/ScrollPicker.js +151 -0
- package/dist/components/user-input/SearchableSelect.d.ts +8 -0
- package/dist/components/user-input/SearchableSelect.js +14 -0
- package/dist/components/user-input/Select.d.ts +32 -0
- package/dist/components/user-input/Select.js +48 -0
- package/dist/components/user-input/Textarea.d.ts +20 -0
- package/dist/components/user-input/Textarea.js +33 -0
- package/dist/components/user-input/ToggleableInput.d.ts +32 -0
- package/dist/components/user-input/ToggleableInput.js +40 -0
- package/dist/css/globals.css +2450 -0
- package/dist/hooks/useHoverState.d.ts +40 -0
- package/dist/hooks/useHoverState.js +46 -0
- package/dist/hooks/useLanguage.d.ts +17 -0
- package/dist/hooks/useLanguage.js +51 -0
- package/dist/hooks/useLocalStorage.d.ts +4 -0
- package/dist/hooks/useLocalStorage.js +24 -0
- package/dist/hooks/useOutsideClick.d.ts +2 -0
- package/dist/hooks/useOutsideClick.js +22 -0
- package/dist/hooks/useSaveDelay.d.ts +5 -0
- package/dist/hooks/useSaveDelay.js +41 -0
- package/dist/hooks/useTheme.d.ts +16 -0
- package/dist/hooks/useTheme.js +32 -0
- package/dist/hooks/useTranslation.d.ts +24 -0
- package/dist/hooks/useTranslation.js +11 -0
- package/dist/util/array.d.ts +23 -0
- package/dist/util/array.js +103 -0
- package/{util/builder.ts → dist/util/builder.d.ts} +1 -4
- package/dist/util/builder.js +9 -0
- package/dist/util/date.d.ts +28 -0
- package/dist/util/date.js +133 -0
- package/dist/util/easeFunctions.d.ts +9 -0
- package/dist/util/easeFunctions.js +30 -0
- package/dist/util/emailValidation.d.ts +1 -0
- package/dist/util/emailValidation.js +3 -0
- package/dist/util/loopingArray.d.ts +23 -0
- package/dist/util/loopingArray.js +67 -0
- package/dist/util/math.d.ts +1 -0
- package/dist/util/math.js +3 -0
- package/dist/util/news.d.ts +98 -0
- package/dist/util/news.js +27 -0
- package/dist/util/noop.d.ts +1 -0
- package/dist/util/noop.js +1 -0
- package/{util/simpleSearch.ts → dist/util/simpleSearch.d.ts} +4 -21
- package/dist/util/simpleSearch.js +62 -0
- package/dist/util/storage.d.ts +15 -0
- package/dist/util/storage.js +32 -0
- package/dist/util/types.d.ts +1 -0
- package/dist/util/types.js +1 -0
- package/package.json +7 -8
- package/coloring/shading.ts +0 -46
- package/coloring/types.ts +0 -13
- package/components/Avatar.tsx +0 -58
- package/components/AvatarGroup.tsx +0 -48
- package/components/BreadCrumb.tsx +0 -35
- package/components/Button.tsx +0 -236
- package/components/ChipList.tsx +0 -89
- package/components/Circle.tsx +0 -27
- package/components/ErrorComponent.tsx +0 -40
- package/components/Expandable.tsx +0 -61
- package/components/HelpwaveBadge.tsx +0 -35
- package/components/HideableContentSection.tsx +0 -43
- package/components/InputGroup.tsx +0 -72
- package/components/LoadingAndErrorComponent.tsx +0 -47
- package/components/LoadingAnimation.tsx +0 -40
- package/components/LoadingButton.tsx +0 -27
- package/components/MarkdownInterpreter.tsx +0 -278
- package/components/Pagination.tsx +0 -65
- package/components/Profile.tsx +0 -124
- package/components/ProgressIndicator.tsx +0 -58
- package/components/Ring.tsx +0 -286
- package/components/SearchableList.tsx +0 -69
- package/components/SortButton.tsx +0 -33
- package/components/StepperBar.tsx +0 -124
- package/components/Table.tsx +0 -330
- package/components/TechRadar.tsx +0 -247
- package/components/TextImage.tsx +0 -86
- package/components/TimeDisplay.tsx +0 -121
- package/components/Tooltip.tsx +0 -92
- package/components/VerticalDivider.tsx +0 -51
- package/components/date/DatePicker.tsx +0 -164
- package/components/date/DayPicker.tsx +0 -95
- package/components/date/TimePicker.tsx +0 -167
- package/components/date/YearMonthPicker.tsx +0 -130
- package/components/examples/InputGroupExample.tsx +0 -58
- package/components/examples/MultiSelectExample.tsx +0 -57
- package/components/examples/SearchableSelectExample.tsx +0 -34
- package/components/examples/SelectExample.tsx +0 -28
- package/components/examples/StackingModals.tsx +0 -54
- package/components/examples/TableExample.tsx +0 -159
- package/components/examples/TextareaExample.tsx +0 -23
- package/components/examples/TileExample.tsx +0 -25
- package/components/examples/date/DateTimePickerExample.tsx +0 -53
- package/components/examples/properties/CheckboxPropertyExample.tsx +0 -29
- package/components/examples/properties/DatePropertyExample.tsx +0 -44
- package/components/examples/properties/MultiSelectPropertyExample.tsx +0 -39
- package/components/examples/properties/NumberPropertyExample.tsx +0 -28
- package/components/examples/properties/SelectPropertyExample.tsx +0 -39
- package/components/examples/properties/TextPropertyExample.tsx +0 -30
- package/components/icons/Helpwave.tsx +0 -51
- package/components/icons/Tag.tsx +0 -29
- package/components/layout/Carousel.tsx +0 -396
- package/components/layout/DividerInserter.tsx +0 -37
- package/components/layout/FAQSection.tsx +0 -57
- package/components/layout/Tile.tsx +0 -67
- package/components/modals/ConfirmDialog.tsx +0 -105
- package/components/modals/DiscardChangesDialog.tsx +0 -71
- package/components/modals/InputModal.tsx +0 -26
- package/components/modals/LanguageModal.tsx +0 -76
- package/components/modals/Modal.tsx +0 -149
- package/components/modals/ModalRegister.tsx +0 -45
- package/components/properties/CheckboxProperty.tsx +0 -62
- package/components/properties/DateProperty.tsx +0 -58
- package/components/properties/MultiSelectProperty.tsx +0 -82
- package/components/properties/NumberProperty.tsx +0 -86
- package/components/properties/PropertyBase.tsx +0 -84
- package/components/properties/SelectProperty.tsx +0 -67
- package/components/properties/TextProperty.tsx +0 -81
- package/components/user-input/Checkbox.tsx +0 -139
- package/components/user-input/DateAndTimePicker.tsx +0 -156
- package/components/user-input/Input.tsx +0 -192
- package/components/user-input/Label.tsx +0 -32
- package/components/user-input/Menu.tsx +0 -75
- package/components/user-input/MultiSelect.tsx +0 -158
- package/components/user-input/ScrollPicker.tsx +0 -240
- package/components/user-input/SearchableSelect.tsx +0 -36
- package/components/user-input/Select.tsx +0 -132
- package/components/user-input/Textarea.tsx +0 -86
- package/components/user-input/ToggleableInput.tsx +0 -115
- package/globals.css +0 -488
- package/hooks/useHoverState.ts +0 -88
- package/hooks/useLanguage.tsx +0 -78
- package/hooks/useLocalStorage.tsx +0 -33
- package/hooks/useOutsideClick.ts +0 -25
- package/hooks/useSaveDelay.ts +0 -46
- package/hooks/useTheme.tsx +0 -57
- package/hooks/useTranslation.ts +0 -43
- package/index.ts +0 -0
- package/util/array.ts +0 -115
- package/util/date.ts +0 -180
- package/util/easeFunctions.ts +0 -37
- package/util/emailValidation.ts +0 -3
- package/util/loopingArray.ts +0 -94
- package/util/math.ts +0 -3
- package/util/news.ts +0 -43
- package/util/noop.ts +0 -1
- package/util/storage.ts +0 -37
- package/util/types.ts +0 -4
- /package/{components/Span.tsx → dist/components/Span.d.ts} +0 -0
- /package/{components/examples/Title.tsx → dist/components/examples/Title.d.ts} +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import Link from 'next/link'
|
|
2
|
-
import clsx from 'clsx'
|
|
3
|
-
|
|
4
|
-
export type Crumb = {
|
|
5
|
-
display: string,
|
|
6
|
-
link: string,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type BreadCrumbProps = {
|
|
10
|
-
crumbs: Crumb[],
|
|
11
|
-
linkClassName?: string,
|
|
12
|
-
containerClassName?: string,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A component for showing a hierarchical link structure with an independent link on each element
|
|
17
|
-
*
|
|
18
|
-
* e.g. Organizations/Ward/<id>
|
|
19
|
-
*/
|
|
20
|
-
export const BreadCrumb = ({ crumbs, linkClassName, containerClassName }: BreadCrumbProps) => {
|
|
21
|
-
const color = 'text-description'
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div className={clsx('row', containerClassName)}>
|
|
25
|
-
{crumbs.map((crumb, index) => (
|
|
26
|
-
<div key={index}>
|
|
27
|
-
<Link href={crumb.link} className={clsx(linkClassName, { [`${color} hover:brightness-60`]: index !== crumbs.length - 1 })}>
|
|
28
|
-
{crumb.display}
|
|
29
|
-
</Link>
|
|
30
|
-
{index !== crumbs.length - 1 && <span className={clsx(`px-1`, color)}>/</span>}
|
|
31
|
-
</div>
|
|
32
|
-
))}
|
|
33
|
-
</div>
|
|
34
|
-
)
|
|
35
|
-
}
|
package/components/Button.tsx
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren, ButtonHTMLAttributes, ReactNode } from 'react'
|
|
2
|
-
import clsx from 'clsx'
|
|
3
|
-
|
|
4
|
-
export type SolidButtonColor = 'primary' | 'secondary' | 'tertiary' | 'positive' | 'warning'| 'negative'
|
|
5
|
-
export type OutlineButtonColor = 'primary'
|
|
6
|
-
export type TextButtonColor = 'negative' | 'neutral'
|
|
7
|
-
|
|
8
|
-
type ButtonSizes = 'small' | 'medium' | 'large'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The shard properties between all button types
|
|
12
|
-
*/
|
|
13
|
-
export type ButtonProps = PropsWithChildren<{
|
|
14
|
-
/**
|
|
15
|
-
* @default 'medium'
|
|
16
|
-
*/
|
|
17
|
-
size?: ButtonSizes,
|
|
18
|
-
}> & ButtonHTMLAttributes<Element>
|
|
19
|
-
|
|
20
|
-
export const ButtonSizePaddings: Record<ButtonSizes, string> = {
|
|
21
|
-
small: 'btn-sm',
|
|
22
|
-
medium: 'btn-md',
|
|
23
|
-
large: 'btn-lg'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type ButtonWithIconsProps = ButtonProps & {
|
|
27
|
-
startIcon?: ReactNode,
|
|
28
|
-
endIcon?: ReactNode,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type SolidButtonProps = ButtonWithIconsProps & {
|
|
32
|
-
color?: SolidButtonColor,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type OutlineButtonProps = ButtonWithIconsProps & {
|
|
36
|
-
color?: OutlineButtonColor,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type TextButtonProps = ButtonWithIconsProps & {
|
|
40
|
-
color?: TextButtonColor,
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A button with a solid background and different sizes
|
|
45
|
-
*/
|
|
46
|
-
const SolidButton = ({
|
|
47
|
-
children,
|
|
48
|
-
disabled = false,
|
|
49
|
-
color = 'primary',
|
|
50
|
-
size = 'medium',
|
|
51
|
-
startIcon,
|
|
52
|
-
endIcon,
|
|
53
|
-
onClick,
|
|
54
|
-
className,
|
|
55
|
-
...restProps
|
|
56
|
-
}: SolidButtonProps) => {
|
|
57
|
-
const colorClasses = {
|
|
58
|
-
primary: 'bg-button-solid-primary-background text-button-solid-primary-text',
|
|
59
|
-
secondary: 'bg-button-solid-secondary-background text-button-solid-secondary-text',
|
|
60
|
-
tertiary: 'bg-button-solid-tertiary-background text-button-solid-tertiary-text',
|
|
61
|
-
positive: 'bg-button-solid-positive-background text-button-solid-positive-text',
|
|
62
|
-
warning: 'bg-button-solid-warning-background text-button-solid-warning-text',
|
|
63
|
-
negative: 'bg-button-solid-negative-background text-button-solid-negative-text',
|
|
64
|
-
}[color]
|
|
65
|
-
|
|
66
|
-
const iconColorClasses = {
|
|
67
|
-
primary: 'text-button-solid-primary-icon',
|
|
68
|
-
secondary: 'text-button-solid-secondary-icon',
|
|
69
|
-
tertiary: 'text-button-solid-tertiary-icon',
|
|
70
|
-
positive: 'text-button-solid-positive-icon',
|
|
71
|
-
warning: 'text-button-solid-warning-icon',
|
|
72
|
-
negative: 'text-button-solid-negative-icon',
|
|
73
|
-
}[color]
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<button
|
|
77
|
-
onClick={disabled ? undefined : onClick}
|
|
78
|
-
disabled={disabled || onClick === undefined}
|
|
79
|
-
className={clsx(
|
|
80
|
-
className,
|
|
81
|
-
{
|
|
82
|
-
'text-disabled-text bg-disabled-background': disabled,
|
|
83
|
-
[clsx(colorClasses, 'hover:brightness-90')]: !disabled
|
|
84
|
-
},
|
|
85
|
-
ButtonSizePaddings[size]
|
|
86
|
-
)}
|
|
87
|
-
{...restProps}
|
|
88
|
-
>
|
|
89
|
-
{startIcon && (
|
|
90
|
-
<span
|
|
91
|
-
className={clsx({
|
|
92
|
-
[iconColorClasses]: !disabled,
|
|
93
|
-
[`text-disabled-icon`]: disabled
|
|
94
|
-
})}
|
|
95
|
-
>
|
|
96
|
-
{startIcon}
|
|
97
|
-
</span>
|
|
98
|
-
)}
|
|
99
|
-
{children}
|
|
100
|
-
{endIcon && (
|
|
101
|
-
<span
|
|
102
|
-
className={clsx({
|
|
103
|
-
[iconColorClasses]: !disabled,
|
|
104
|
-
[`text-disabled-icon`]: disabled
|
|
105
|
-
})}
|
|
106
|
-
>
|
|
107
|
-
{endIcon}
|
|
108
|
-
</span>
|
|
109
|
-
)}
|
|
110
|
-
</button>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* A button with an outline border and different sizes
|
|
116
|
-
*/
|
|
117
|
-
const OutlineButton = ({
|
|
118
|
-
children,
|
|
119
|
-
disabled = false,
|
|
120
|
-
color = 'primary',
|
|
121
|
-
size = 'medium',
|
|
122
|
-
startIcon,
|
|
123
|
-
endIcon,
|
|
124
|
-
onClick,
|
|
125
|
-
className,
|
|
126
|
-
...restProps
|
|
127
|
-
}: OutlineButtonProps) => {
|
|
128
|
-
const colorClasses = {
|
|
129
|
-
primary: 'bg-transparent border-2 border-button-outline-primary-text text-button-outline-primary-text',
|
|
130
|
-
}[color]
|
|
131
|
-
|
|
132
|
-
const iconColorClasses = {
|
|
133
|
-
primary: 'text-button-outline-primary-icon',
|
|
134
|
-
}[color]
|
|
135
|
-
return (
|
|
136
|
-
<button
|
|
137
|
-
onClick={disabled ? undefined : onClick}
|
|
138
|
-
disabled={disabled || onClick === undefined}
|
|
139
|
-
className={clsx(
|
|
140
|
-
className, {
|
|
141
|
-
'text-disabled-text border-disabled-outline)': disabled,
|
|
142
|
-
[clsx(colorClasses, 'hover:brightness-80')]: !disabled,
|
|
143
|
-
},
|
|
144
|
-
ButtonSizePaddings[size]
|
|
145
|
-
)}
|
|
146
|
-
{...restProps}
|
|
147
|
-
>
|
|
148
|
-
{startIcon && (
|
|
149
|
-
<span
|
|
150
|
-
className={clsx({
|
|
151
|
-
[iconColorClasses]: !disabled,
|
|
152
|
-
[`text-disabled-icon`]: disabled
|
|
153
|
-
})}
|
|
154
|
-
>
|
|
155
|
-
{startIcon}
|
|
156
|
-
</span>
|
|
157
|
-
)}
|
|
158
|
-
{children}
|
|
159
|
-
{endIcon && (
|
|
160
|
-
<span
|
|
161
|
-
className={clsx({
|
|
162
|
-
[iconColorClasses]: !disabled,
|
|
163
|
-
[`text-disabled-icon`]: disabled
|
|
164
|
-
})}
|
|
165
|
-
>
|
|
166
|
-
{endIcon}
|
|
167
|
-
</span>
|
|
168
|
-
)}
|
|
169
|
-
</button>
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* A text that is a button that can have different sizes
|
|
175
|
-
*/
|
|
176
|
-
const TextButton = ({
|
|
177
|
-
children,
|
|
178
|
-
disabled = false,
|
|
179
|
-
color = 'neutral',
|
|
180
|
-
size = 'medium',
|
|
181
|
-
startIcon,
|
|
182
|
-
endIcon,
|
|
183
|
-
onClick,
|
|
184
|
-
className,
|
|
185
|
-
...restProps
|
|
186
|
-
}: TextButtonProps) => {
|
|
187
|
-
const colorClasses = {
|
|
188
|
-
negative: 'bg-transparent text-button-text-negative-text',
|
|
189
|
-
neutral: 'bg-transparent text-button-text-neutral-text',
|
|
190
|
-
}[color]
|
|
191
|
-
|
|
192
|
-
const iconColorClasses = {
|
|
193
|
-
negative: 'text-button-text-negative-icon',
|
|
194
|
-
neutral: 'text-button-text-neutral-icon',
|
|
195
|
-
}[color]
|
|
196
|
-
return (
|
|
197
|
-
<button
|
|
198
|
-
onClick={disabled ? undefined : onClick}
|
|
199
|
-
disabled={disabled || onClick === undefined}
|
|
200
|
-
className={clsx(
|
|
201
|
-
className, {
|
|
202
|
-
'text-disabled-text': disabled,
|
|
203
|
-
[clsx(colorClasses, 'hover:bg-button-text-hover-background rounded-full')]: !disabled,
|
|
204
|
-
},
|
|
205
|
-
ButtonSizePaddings[size]
|
|
206
|
-
)}
|
|
207
|
-
{...restProps}
|
|
208
|
-
>
|
|
209
|
-
{startIcon && (
|
|
210
|
-
<span
|
|
211
|
-
className={clsx({
|
|
212
|
-
[iconColorClasses]: !disabled,
|
|
213
|
-
[`text-disabled-icon`]: disabled
|
|
214
|
-
})}
|
|
215
|
-
>
|
|
216
|
-
{startIcon}
|
|
217
|
-
</span>
|
|
218
|
-
)}
|
|
219
|
-
{children}
|
|
220
|
-
{endIcon && (
|
|
221
|
-
<span
|
|
222
|
-
className={clsx({
|
|
223
|
-
[iconColorClasses]: !disabled,
|
|
224
|
-
[`text-disabled-icon`]: disabled
|
|
225
|
-
})}
|
|
226
|
-
>
|
|
227
|
-
{endIcon}
|
|
228
|
-
</span>
|
|
229
|
-
)}
|
|
230
|
-
</button>
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// TODO Icon button
|
|
235
|
-
|
|
236
|
-
export { SolidButton, OutlineButton, TextButton }
|
package/components/ChipList.tsx
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type { HTMLProps, PropsWithChildren, ReactNode } from 'react'
|
|
2
|
-
import clsx from 'clsx'
|
|
3
|
-
|
|
4
|
-
export type ChipColor = 'default' | 'dark'| 'red' | 'yellow' | 'green' | 'blue' | 'pink'
|
|
5
|
-
type ChipVariant = 'normal' | 'fullyRounded'
|
|
6
|
-
|
|
7
|
-
export type ChipProps = HTMLProps<HTMLDivElement> & PropsWithChildren<{
|
|
8
|
-
color?: ChipColor,
|
|
9
|
-
variant?: ChipVariant,
|
|
10
|
-
trailingIcon?: ReactNode,
|
|
11
|
-
}>
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A component for displaying a single chip
|
|
15
|
-
*/
|
|
16
|
-
export const Chip = ({
|
|
17
|
-
children,
|
|
18
|
-
trailingIcon,
|
|
19
|
-
color = 'default',
|
|
20
|
-
variant = 'normal',
|
|
21
|
-
className = '',
|
|
22
|
-
...restProps
|
|
23
|
-
}: ChipProps) => {
|
|
24
|
-
const colorMapping: string = {
|
|
25
|
-
default: 'text-tag-default-text bg-tag-default-background',
|
|
26
|
-
dark: 'text-tag-dark-text bg-tag-dark-background',
|
|
27
|
-
red: 'text-tag-red-text bg-tag-red-background',
|
|
28
|
-
yellow: 'text-tag-yellow-text bg-tag-yellow-background',
|
|
29
|
-
green: 'text-tag-green-text bg-tag-green-background',
|
|
30
|
-
blue: 'text-tag-blue-text bg-tag-blue-background',
|
|
31
|
-
pink: 'text-tag-pink-text bg-tag-pink-background',
|
|
32
|
-
}[color]
|
|
33
|
-
|
|
34
|
-
const colorMappingIcon: string = {
|
|
35
|
-
default: 'text-tag-default-icon',
|
|
36
|
-
dark: 'text-tag-dark-icon',
|
|
37
|
-
red: 'text-tag-red-icon',
|
|
38
|
-
yellow: 'text-tag-yellow-icon',
|
|
39
|
-
green: 'text-tag-green-icon',
|
|
40
|
-
blue: 'text-tag-blue-icon',
|
|
41
|
-
pink: 'text-tag-pink-icon',
|
|
42
|
-
}[color]
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div
|
|
46
|
-
{...restProps}
|
|
47
|
-
className={clsx(
|
|
48
|
-
`row w-fit px-2 py-1`,
|
|
49
|
-
colorMapping,
|
|
50
|
-
{
|
|
51
|
-
'rounded-md': variant === 'normal',
|
|
52
|
-
'rounded-full': variant === 'fullyRounded',
|
|
53
|
-
},
|
|
54
|
-
className
|
|
55
|
-
)}
|
|
56
|
-
>
|
|
57
|
-
{children}
|
|
58
|
-
{trailingIcon && (<span className={colorMappingIcon}>{trailingIcon}</span>)}
|
|
59
|
-
</div>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export type ChipListProps = {
|
|
64
|
-
list: ChipProps[],
|
|
65
|
-
className?: string,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A component for displaying a list of chips
|
|
70
|
-
*/
|
|
71
|
-
export const ChipList = ({
|
|
72
|
-
list,
|
|
73
|
-
className = ''
|
|
74
|
-
}: ChipListProps) => {
|
|
75
|
-
return (
|
|
76
|
-
<div className={clsx('flex flex-wrap gap-x-4 gap-y-2', className)}>
|
|
77
|
-
{list.map((value, index) => (
|
|
78
|
-
<Chip
|
|
79
|
-
key={index}
|
|
80
|
-
{...value}
|
|
81
|
-
color={value.color ?? 'dark'}
|
|
82
|
-
variant={value.variant ?? 'normal'}
|
|
83
|
-
>
|
|
84
|
-
{value.children}
|
|
85
|
-
</Chip>
|
|
86
|
-
))}
|
|
87
|
-
</div>
|
|
88
|
-
)
|
|
89
|
-
}
|
package/components/Circle.tsx
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes } from 'react'
|
|
2
|
-
import clsx from 'clsx'
|
|
3
|
-
|
|
4
|
-
export type CircleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'color'> & {
|
|
5
|
-
radius: number,
|
|
6
|
-
className?: string,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const Circle = ({
|
|
10
|
-
radius = 20,
|
|
11
|
-
className = 'bg-primary',
|
|
12
|
-
style,
|
|
13
|
-
...restProps
|
|
14
|
-
}: CircleProps) => {
|
|
15
|
-
const size = radius * 2
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
className={clsx(`rounded-full`, className)}
|
|
19
|
-
style={{
|
|
20
|
-
width: `${size}px`,
|
|
21
|
-
height: `${size}px`,
|
|
22
|
-
...style,
|
|
23
|
-
}}
|
|
24
|
-
{...restProps}
|
|
25
|
-
/>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { AlertOctagon } from 'lucide-react'
|
|
2
|
-
import type { Languages } from '../hooks/useLanguage'
|
|
3
|
-
import type { PropsForTranslation } from '../hooks/useTranslation'
|
|
4
|
-
import { useTranslation } from '../hooks/useTranslation'
|
|
5
|
-
import clsx from 'clsx'
|
|
6
|
-
|
|
7
|
-
type ErrorComponentTranslation = {
|
|
8
|
-
errorOccurred: string,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const defaultErrorComponentTranslation: Record<Languages, ErrorComponentTranslation> = {
|
|
12
|
-
en: {
|
|
13
|
-
errorOccurred: 'An error occurred'
|
|
14
|
-
},
|
|
15
|
-
de: {
|
|
16
|
-
errorOccurred: 'Ein Fehler ist aufgetreten'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type ErrorComponentProps = {
|
|
21
|
-
errorText?: string,
|
|
22
|
-
classname?: string,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The Component to show when an error occurred
|
|
27
|
-
*/
|
|
28
|
-
export const ErrorComponent = ({
|
|
29
|
-
overwriteTranslation,
|
|
30
|
-
errorText,
|
|
31
|
-
classname
|
|
32
|
-
}: PropsForTranslation<ErrorComponentTranslation, ErrorComponentProps>) => {
|
|
33
|
-
const translation = useTranslation(defaultErrorComponentTranslation, overwriteTranslation)
|
|
34
|
-
return (
|
|
35
|
-
<div className={clsx('col items-center justify-center gap-y-4 w-full h-24', classname)}>
|
|
36
|
-
<AlertOctagon size={64} className="text-warning"/>
|
|
37
|
-
{errorText ?? `${translation.errorOccurred} :(`}
|
|
38
|
-
</div>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren, ReactNode } from 'react'
|
|
2
|
-
import { forwardRef, useState } from 'react'
|
|
3
|
-
import { ChevronDown, ChevronUp } from 'lucide-react'
|
|
4
|
-
import clsx from 'clsx'
|
|
5
|
-
|
|
6
|
-
type IconBuilder = (expanded: boolean) => ReactNode
|
|
7
|
-
|
|
8
|
-
export type ExpandableProps = PropsWithChildren<{
|
|
9
|
-
label: ReactNode,
|
|
10
|
-
icon?: IconBuilder,
|
|
11
|
-
initialExpansion?: boolean,
|
|
12
|
-
/**
|
|
13
|
-
* Whether the expansion should only happen when the header is clicked or on the entire component
|
|
14
|
-
*/
|
|
15
|
-
clickOnlyOnHeader?: boolean,
|
|
16
|
-
className?: string,
|
|
17
|
-
headerClassName?: string,
|
|
18
|
-
}>
|
|
19
|
-
|
|
20
|
-
const DefaultIcon: IconBuilder = (expanded) => expanded ?
|
|
21
|
-
(<ChevronUp size={16} className="min-w-[16px]"/>)
|
|
22
|
-
: (<ChevronDown size={16} className="min-w-[16px]"/>)
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A Component for showing and hiding content
|
|
26
|
-
*/
|
|
27
|
-
export const Expandable = forwardRef<HTMLDivElement, ExpandableProps>(({
|
|
28
|
-
children,
|
|
29
|
-
label,
|
|
30
|
-
icon,
|
|
31
|
-
initialExpansion = false,
|
|
32
|
-
clickOnlyOnHeader = true,
|
|
33
|
-
className = '',
|
|
34
|
-
headerClassName = ''
|
|
35
|
-
}, ref) => {
|
|
36
|
-
const [isExpanded, setIsExpanded] = useState(initialExpansion)
|
|
37
|
-
icon ??= DefaultIcon
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
ref={ref}
|
|
42
|
-
className={clsx('col bg-surface text-on-surface group rounded-lg shadow-sm', { 'cursor-pointer': !clickOnlyOnHeader }, className)}
|
|
43
|
-
onClick={() => !clickOnlyOnHeader && setIsExpanded(!isExpanded)}
|
|
44
|
-
>
|
|
45
|
-
<button
|
|
46
|
-
className={clsx('btn-md rounded-lg justify-between items-center bg-surface text-on-surface', { 'group-hover:brightness-95': !isExpanded }, headerClassName)}
|
|
47
|
-
onClick={() => clickOnlyOnHeader && setIsExpanded(!isExpanded)}
|
|
48
|
-
>
|
|
49
|
-
{label}
|
|
50
|
-
{icon(isExpanded)}
|
|
51
|
-
</button>
|
|
52
|
-
{isExpanded && (
|
|
53
|
-
<div className="col">
|
|
54
|
-
{children}
|
|
55
|
-
</div>
|
|
56
|
-
)}
|
|
57
|
-
</div>
|
|
58
|
-
)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
Expandable.displayName = 'Expandable'
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx'
|
|
2
|
-
import { Helpwave } from './icons/Helpwave'
|
|
3
|
-
import { Tile } from './layout/Tile'
|
|
4
|
-
|
|
5
|
-
type Size = 'small' | 'large'
|
|
6
|
-
|
|
7
|
-
export type HelpwaveBadgeProps = {
|
|
8
|
-
size?: Size,
|
|
9
|
-
title?: string,
|
|
10
|
-
className?: string,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A Badge with the helpwave logo and the helpwave name
|
|
15
|
-
*/
|
|
16
|
-
export const HelpwaveBadge = ({
|
|
17
|
-
size = 'small',
|
|
18
|
-
title = 'helpwave',
|
|
19
|
-
className = ''
|
|
20
|
-
}: HelpwaveBadgeProps) => {
|
|
21
|
-
const iconSize: number = size === 'small' ? 24 : 64
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Tile
|
|
25
|
-
prefix={(<Helpwave size={iconSize} />)}
|
|
26
|
-
title={{ value: title, className: size === 'small' ? 'textstyle-title-lg text-base' : 'textstyle-title-xl' }}
|
|
27
|
-
className={clsx(
|
|
28
|
-
{
|
|
29
|
-
'px-2 py-1 rounded-md': size === 'small',
|
|
30
|
-
'px-4 py-1 rounded-md': size === 'large',
|
|
31
|
-
}, className
|
|
32
|
-
)}
|
|
33
|
-
/>
|
|
34
|
-
)
|
|
35
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useState, type PropsWithChildren, type ReactNode } from 'react'
|
|
2
|
-
import { ChevronDown, ChevronUp } from 'lucide-react'
|
|
3
|
-
import clsx from 'clsx'
|
|
4
|
-
|
|
5
|
-
export type HideableContentSectionProps = PropsWithChildren & {
|
|
6
|
-
initiallyOpen?: boolean,
|
|
7
|
-
disabled: boolean,
|
|
8
|
-
header: ReactNode,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* A Component to hide and show
|
|
13
|
-
*/
|
|
14
|
-
export const HideableContentSection = ({
|
|
15
|
-
initiallyOpen = true,
|
|
16
|
-
disabled,
|
|
17
|
-
children,
|
|
18
|
-
header
|
|
19
|
-
}: HideableContentSectionProps) => {
|
|
20
|
-
const [open, setOpen] = useState(initiallyOpen)
|
|
21
|
-
return (
|
|
22
|
-
<div className="col">
|
|
23
|
-
<div
|
|
24
|
-
className={clsx('row justify-between items-center', { 'cursor-pointer': !disabled })}
|
|
25
|
-
onClick={() => {
|
|
26
|
-
if (!disabled) {
|
|
27
|
-
setOpen(!open)
|
|
28
|
-
}
|
|
29
|
-
}}
|
|
30
|
-
>
|
|
31
|
-
<div>
|
|
32
|
-
{header}
|
|
33
|
-
</div>
|
|
34
|
-
{!disabled && (open ? <ChevronUp/> : <ChevronDown/>)}
|
|
35
|
-
</div>
|
|
36
|
-
{open && (
|
|
37
|
-
<div>
|
|
38
|
-
{children}
|
|
39
|
-
</div>
|
|
40
|
-
)}
|
|
41
|
-
</div>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
import { ChevronDown, ChevronUp } from 'lucide-react'
|
|
4
|
-
import clsx from 'clsx'
|
|
5
|
-
import { noop } from '../util/noop'
|
|
6
|
-
|
|
7
|
-
export type InputGroupProps = PropsWithChildren<{
|
|
8
|
-
title: string,
|
|
9
|
-
expanded?: boolean,
|
|
10
|
-
isExpandable?: boolean,
|
|
11
|
-
disabled?: boolean,
|
|
12
|
-
onChange?: (value: boolean) => void,
|
|
13
|
-
className?: string,
|
|
14
|
-
}>
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A Component for layouting inputs in an expandable group
|
|
18
|
-
*/
|
|
19
|
-
export const InputGroup = ({
|
|
20
|
-
children,
|
|
21
|
-
title,
|
|
22
|
-
expanded = true,
|
|
23
|
-
isExpandable = true,
|
|
24
|
-
disabled = false,
|
|
25
|
-
onChange = noop,
|
|
26
|
-
className = '',
|
|
27
|
-
}: InputGroupProps) => {
|
|
28
|
-
const [isExpanded, setIsExpanded] = useState<boolean>(expanded)
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
setIsExpanded(expanded)
|
|
32
|
-
}, [expanded])
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className={clsx('col gap-y-4 p-4 bg-white rounded-xl', className)}>
|
|
36
|
-
<div
|
|
37
|
-
className={clsx('row justify-between items-center', {
|
|
38
|
-
'cursor-pointer': isExpandable && !disabled,
|
|
39
|
-
'cursor-not-allowed': disabled,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
'text-primary': !disabled,
|
|
43
|
-
'text-primary/40': disabled
|
|
44
|
-
})}
|
|
45
|
-
onClick={() => {
|
|
46
|
-
if (!isExpandable) {
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
const updatedIsExpanded = !isExpanded
|
|
50
|
-
onChange(updatedIsExpanded)
|
|
51
|
-
setIsExpanded(updatedIsExpanded)
|
|
52
|
-
}}
|
|
53
|
-
>
|
|
54
|
-
<span className="textstyle-title-md">{title}</span>
|
|
55
|
-
<div className={clsx('rounded-full text-white w-6 h-6', {
|
|
56
|
-
'bg-primary': (isExpandable && !disabled) || expanded,
|
|
57
|
-
'bg-primary/40': disabled,
|
|
58
|
-
})}>
|
|
59
|
-
{isExpanded
|
|
60
|
-
? <ChevronUp className="-translate-y-[1px]" size={24}/>
|
|
61
|
-
: <ChevronDown className="translate-y-[1px]" size={24}/>
|
|
62
|
-
}
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
{isExpanded && (
|
|
66
|
-
<div className="col gap-y-2 h-full">
|
|
67
|
-
{children}
|
|
68
|
-
</div>
|
|
69
|
-
)}
|
|
70
|
-
</div>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
import type { LoadingAnimationProps } from './LoadingAnimation'
|
|
4
|
-
import type { ErrorComponentProps } from './ErrorComponent'
|
|
5
|
-
import { LoadingAnimation } from './LoadingAnimation'
|
|
6
|
-
import { ErrorComponent } from './ErrorComponent'
|
|
7
|
-
|
|
8
|
-
export type LoadingAndErrorComponentProps = PropsWithChildren<{
|
|
9
|
-
isLoading?: boolean,
|
|
10
|
-
hasError?: boolean,
|
|
11
|
-
loadingProps?: LoadingAnimationProps,
|
|
12
|
-
errorProps?: ErrorComponentProps,
|
|
13
|
-
/**
|
|
14
|
-
* in milliseconds
|
|
15
|
-
*/
|
|
16
|
-
minimumLoadingDuration?: number,
|
|
17
|
-
}>
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A Component that shows the Error and Loading animation, when appropriate and the children otherwise
|
|
21
|
-
*/
|
|
22
|
-
export const LoadingAndErrorComponent = ({
|
|
23
|
-
children,
|
|
24
|
-
isLoading = false,
|
|
25
|
-
hasError = false,
|
|
26
|
-
errorProps,
|
|
27
|
-
loadingProps,
|
|
28
|
-
minimumLoadingDuration
|
|
29
|
-
}: LoadingAndErrorComponentProps) => {
|
|
30
|
-
const [isInMinimumLoading, setIsInMinimumLoading] = useState(false)
|
|
31
|
-
const [hasUsedMinimumLoading, setHasUsedMinimumLoading] = useState(false)
|
|
32
|
-
if (minimumLoadingDuration && !isInMinimumLoading && !hasUsedMinimumLoading) {
|
|
33
|
-
setIsInMinimumLoading(true)
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
setIsInMinimumLoading(false)
|
|
36
|
-
setHasUsedMinimumLoading(true)
|
|
37
|
-
}, minimumLoadingDuration)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (isLoading || (minimumLoadingDuration && isInMinimumLoading)) {
|
|
41
|
-
return <LoadingAnimation {...loadingProps}/>
|
|
42
|
-
}
|
|
43
|
-
if (hasError) {
|
|
44
|
-
return <ErrorComponent {...errorProps}/>
|
|
45
|
-
}
|
|
46
|
-
return children
|
|
47
|
-
}
|