@navikt/ds-react 0.19.25 → 1.0.0-rc.3
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 +43 -0
- package/_docs.json +364 -520
- package/cjs/accordion/Accordion.js +2 -2
- package/cjs/accordion/AccordionContent.js +5 -9
- package/cjs/accordion/AccordionHeader.js +5 -10
- package/cjs/accordion/AccordionItem.js +3 -7
- package/cjs/alert/Alert.js +2 -2
- package/cjs/button/Button.js +9 -7
- package/cjs/{speech-bubble → chat}/Bubble.js +7 -4
- package/cjs/{speech-bubble/SpeechBubble.js → chat/Chat.js} +11 -10
- package/cjs/{menu → chat}/index.js +3 -3
- package/cjs/chat/package.json +6 -0
- package/cjs/form/ConfirmationPanel.js +3 -3
- package/cjs/form/Fieldset/Fieldset.js +6 -6
- package/cjs/form/Select.js +6 -6
- package/cjs/form/Switch.js +4 -4
- package/cjs/form/TextField.js +6 -6
- package/cjs/form/Textarea.js +14 -14
- package/cjs/form/checkbox/Checkbox.js +3 -3
- package/cjs/form/checkbox/CheckboxGroup.js +2 -2
- package/cjs/form/error-summary/ErrorSummary.js +3 -3
- package/cjs/form/error-summary/ErrorSummaryItem.js +2 -2
- package/cjs/form/radio/Radio.js +2 -2
- package/cjs/form/radio/RadioGroup.js +2 -2
- package/cjs/form/search/Search.js +6 -7
- package/cjs/form/search/SearchButton.js +2 -4
- package/cjs/form/useFormField.js +2 -2
- package/cjs/grid/Cell.js +2 -2
- package/cjs/grid/ContentContainer.js +2 -2
- package/cjs/grid/Grid.js +2 -2
- package/cjs/guide-panel/Guide.js +3 -3
- package/cjs/guide-panel/GuidePanel.js +2 -2
- package/cjs/help-text/HelpText.js +5 -5
- package/cjs/index.js +1 -6
- package/cjs/link/Link.js +2 -2
- package/cjs/link-panel/LinkPanel.js +2 -2
- package/cjs/link-panel/LinkPanelDescription.js +2 -2
- package/cjs/link-panel/LinkPanelTitle.js +2 -2
- package/cjs/loader/Loader.js +2 -2
- package/cjs/modal/Modal.js +5 -7
- package/cjs/modal/ModalContent.js +2 -2
- package/cjs/pagination/Pagination.js +18 -23
- package/cjs/{menu/MenuItem.js → pagination/PaginationItem.js} +5 -4
- package/cjs/panel/Panel.js +2 -2
- package/cjs/popover/Popover.js +55 -45
- package/cjs/popover/PopoverContent.js +2 -2
- package/cjs/read-more/ReadMore.js +7 -11
- package/cjs/stepper/Step.js +2 -2
- package/cjs/stepper/Stepper.js +3 -3
- package/cjs/table/Body.js +2 -2
- package/cjs/table/DataCell.js +2 -2
- package/cjs/table/ExpandableRow.js +9 -12
- package/cjs/table/Header.js +2 -2
- package/cjs/table/HeaderCell.js +2 -2
- package/cjs/table/Row.js +2 -2
- package/cjs/table/Table.js +2 -2
- package/cjs/tabs/Tab.js +4 -4
- package/cjs/tabs/TabList.js +8 -7
- package/cjs/tabs/TabPanel.js +2 -2
- package/cjs/tabs/Tabs.js +5 -3
- package/cjs/tag/Tag.js +2 -2
- package/cjs/toggle-group/ToggleGroup.js +5 -5
- package/cjs/toggle-group/ToggleItem.js +2 -2
- package/cjs/tooltip/Tooltip.js +45 -92
- package/cjs/typography/BodyLong.js +2 -2
- package/cjs/typography/BodyShort.js +2 -2
- package/cjs/typography/Detail.js +2 -2
- package/cjs/typography/ErrorMessage.js +2 -2
- package/cjs/typography/Heading.js +2 -2
- package/cjs/typography/Ingress.js +2 -2
- package/cjs/typography/Label.js +2 -2
- package/cjs/util/AnimateHeight.js +204 -0
- package/cjs/util/TextareaAutoSize.js +174 -0
- package/cjs/util/debounce.js +18 -0
- package/cjs/util/index.js +14 -1
- package/cjs/util/mergeRefs.js +16 -0
- package/cjs/util/useId.js +60 -17
- package/esm/accordion/Accordion.js +1 -1
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionContent.d.ts +0 -2
- package/esm/accordion/AccordionContent.js +5 -9
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +5 -10
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.d.ts +0 -8
- package/esm/accordion/AccordionItem.js +2 -6
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/alert/Alert.d.ts +1 -1
- package/esm/alert/Alert.js +1 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.d.ts +10 -1
- package/esm/button/Button.js +10 -8
- package/esm/button/Button.js.map +1 -1
- package/esm/{speech-bubble → chat}/Bubble.d.ts +7 -3
- package/esm/{speech-bubble → chat}/Bubble.js +7 -4
- package/esm/chat/Bubble.js.map +1 -0
- package/esm/chat/Chat.d.ts +38 -0
- package/esm/chat/Chat.js +28 -0
- package/esm/chat/Chat.js.map +1 -0
- package/esm/chat/index.d.ts +1 -0
- package/esm/chat/index.js +2 -0
- package/esm/chat/index.js.map +1 -0
- package/esm/form/ConfirmationPanel.d.ts +1 -1
- package/esm/form/ConfirmationPanel.js +3 -3
- package/esm/form/ConfirmationPanel.js.map +1 -1
- package/esm/form/Fieldset/Fieldset.js +1 -1
- package/esm/form/Fieldset/Fieldset.js.map +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/Switch.js +1 -1
- package/esm/form/Switch.js.map +1 -1
- package/esm/form/TextField.js +1 -1
- package/esm/form/TextField.js.map +1 -1
- package/esm/form/Textarea.js +6 -6
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +1 -1
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +1 -1
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.js +3 -3
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.js +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
- package/esm/form/radio/Radio.js +1 -1
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.js +1 -1
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/search/Search.js +4 -5
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.d.ts +1 -1
- package/esm/form/search/SearchButton.js +2 -4
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/form/useFormField.js +1 -1
- package/esm/form/useFormField.js.map +1 -1
- package/esm/grid/Cell.js +1 -1
- package/esm/grid/Cell.js.map +1 -1
- package/esm/grid/ContentContainer.js +1 -1
- package/esm/grid/ContentContainer.js.map +1 -1
- package/esm/grid/Grid.js +1 -1
- package/esm/grid/Grid.js.map +1 -1
- package/esm/guide-panel/Guide.js +1 -1
- package/esm/guide-panel/Guide.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +1 -1
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/help-text/HelpText.d.ts +1 -2
- package/esm/help-text/HelpText.js +7 -7
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/index.d.ts +1 -5
- package/esm/index.js +1 -6
- package/esm/index.js.map +1 -1
- package/esm/link/Link.js +1 -1
- package/esm/link/Link.js.map +1 -1
- package/esm/link-panel/LinkPanel.js +1 -1
- package/esm/link-panel/LinkPanel.js.map +1 -1
- package/esm/link-panel/LinkPanelDescription.js +1 -1
- package/esm/link-panel/LinkPanelDescription.js.map +1 -1
- package/esm/link-panel/LinkPanelTitle.js +1 -1
- package/esm/link-panel/LinkPanelTitle.js.map +1 -1
- package/esm/loader/Loader.js +1 -1
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.js +5 -7
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalContent.js +1 -1
- package/esm/modal/ModalContent.js.map +1 -1
- package/esm/pagination/Pagination.d.ts +12 -3
- package/esm/pagination/Pagination.js +17 -22
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.d.ts +22 -0
- package/esm/{menu/MenuItem.js → pagination/PaginationItem.js} +6 -5
- package/esm/pagination/PaginationItem.js.map +1 -0
- package/esm/pagination/index.d.ts +1 -2
- package/esm/pagination/index.js.map +1 -1
- package/esm/panel/Panel.js +1 -1
- package/esm/panel/Panel.js.map +1 -1
- package/esm/popover/Popover.d.ts +2 -3
- package/esm/popover/Popover.js +56 -46
- package/esm/popover/Popover.js.map +1 -1
- package/esm/popover/PopoverContent.js +1 -1
- package/esm/popover/PopoverContent.js.map +1 -1
- package/esm/read-more/ReadMore.d.ts +0 -5
- package/esm/read-more/ReadMore.js +7 -11
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/stepper/Step.js +1 -1
- package/esm/stepper/Step.js.map +1 -1
- package/esm/stepper/Stepper.js +1 -1
- package/esm/stepper/Stepper.js.map +1 -1
- package/esm/table/Body.js +1 -1
- package/esm/table/Body.js.map +1 -1
- package/esm/table/DataCell.js +1 -1
- package/esm/table/DataCell.js.map +1 -1
- package/esm/table/ExpandableRow.js +7 -10
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/Header.js +1 -1
- package/esm/table/Header.js.map +1 -1
- package/esm/table/HeaderCell.js +1 -1
- package/esm/table/HeaderCell.js.map +1 -1
- package/esm/table/Row.js +1 -1
- package/esm/table/Row.js.map +1 -1
- package/esm/table/Table.js +1 -1
- package/esm/table/Table.js.map +1 -1
- package/esm/tabs/Tab.d.ts +0 -5
- package/esm/tabs/Tab.js +5 -5
- package/esm/tabs/Tab.js.map +1 -1
- package/esm/tabs/TabList.d.ts +0 -4
- package/esm/tabs/TabList.js +7 -6
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/TabPanel.js +1 -1
- package/esm/tabs/TabPanel.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +12 -0
- package/esm/tabs/Tabs.js +4 -2
- package/esm/tabs/Tabs.js.map +1 -1
- package/esm/tag/Tag.js +1 -1
- package/esm/tag/Tag.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +3 -3
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/toggle-group/ToggleItem.js +1 -1
- package/esm/toggle-group/ToggleItem.js.map +1 -1
- package/esm/tooltip/Tooltip.js +44 -91
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/BodyLong.js +1 -1
- package/esm/typography/BodyLong.js.map +1 -1
- package/esm/typography/BodyShort.js +1 -1
- package/esm/typography/BodyShort.js.map +1 -1
- package/esm/typography/Detail.js +1 -1
- package/esm/typography/Detail.js.map +1 -1
- package/esm/typography/ErrorMessage.js +1 -1
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/typography/Heading.js +1 -1
- package/esm/typography/Heading.js.map +1 -1
- package/esm/typography/Ingress.js +1 -1
- package/esm/typography/Ingress.js.map +1 -1
- package/esm/typography/Label.js +1 -1
- package/esm/typography/Label.js.map +1 -1
- package/esm/util/AnimateHeight.d.ts +10 -0
- package/esm/util/AnimateHeight.js +180 -0
- package/esm/util/AnimateHeight.js.map +1 -0
- package/esm/util/TextareaAutoSize.d.ts +14 -0
- package/esm/util/TextareaAutoSize.js +150 -0
- package/esm/util/TextareaAutoSize.js.map +1 -0
- package/esm/util/debounce.d.ts +4 -0
- package/esm/util/debounce.js +16 -0
- package/esm/util/debounce.js.map +1 -0
- package/esm/util/index.d.ts +4 -0
- package/esm/util/index.js +9 -1
- package/esm/util/index.js.map +1 -1
- package/esm/util/mergeRefs.d.ts +2 -0
- package/esm/util/mergeRefs.js +14 -0
- package/esm/util/mergeRefs.js.map +1 -0
- package/esm/util/useId.d.ts +7 -3
- package/esm/util/useId.js +36 -16
- package/esm/util/useId.js.map +1 -1
- package/package.json +13 -15
- package/src/accordion/Accordion.tsx +1 -1
- package/src/accordion/AccordionContent.tsx +13 -19
- package/src/accordion/AccordionHeader.tsx +11 -18
- package/src/accordion/AccordionItem.tsx +2 -23
- package/src/accordion/accordion.stories.tsx +30 -31
- package/src/alert/Alert.tsx +2 -2
- package/src/alert/alert.stories.tsx +7 -0
- package/src/button/Button.tsx +39 -14
- package/src/button/button.stories.tsx +55 -28
- package/src/chat/Bubble.tsx +52 -0
- package/src/chat/Chat.tsx +96 -0
- package/src/chat/chat.stories.tsx +202 -0
- package/src/chat/index.ts +1 -0
- package/src/form/ConfirmationPanel.tsx +9 -4
- package/src/form/Fieldset/Fieldset.tsx +1 -1
- package/src/form/Select.tsx +1 -1
- package/src/form/Switch.tsx +1 -1
- package/src/form/TextField.tsx +1 -1
- package/src/form/Textarea.tsx +6 -6
- package/src/form/checkbox/Checkbox.test.tsx +20 -17
- package/src/form/checkbox/Checkbox.tsx +1 -1
- package/src/form/checkbox/CheckboxGroup.tsx +1 -1
- package/src/form/error-summary/ErrorSummary.tsx +3 -3
- package/src/form/error-summary/ErrorSummaryItem.tsx +1 -1
- package/src/form/radio/Radio.tsx +1 -1
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/form/search/Search.tsx +11 -4
- package/src/form/search/SearchButton.tsx +8 -4
- package/src/form/useFormField.ts +1 -1
- package/src/grid/Cell.tsx +1 -1
- package/src/grid/ContentContainer.tsx +1 -1
- package/src/grid/Grid.tsx +1 -1
- package/src/grid/grid.stories.tsx +68 -0
- package/src/guide-panel/Guide.tsx +1 -1
- package/src/guide-panel/GuidePanel.tsx +1 -1
- package/src/help-text/HelpText.tsx +22 -8
- package/src/help-text/help-text.stories.tsx +12 -16
- package/src/index.ts +1 -7
- package/src/link/Link.tsx +1 -1
- package/src/link-panel/LinkPanel.tsx +1 -1
- package/src/link-panel/LinkPanelDescription.tsx +1 -1
- package/src/link-panel/LinkPanelTitle.tsx +1 -1
- package/src/loader/Loader.tsx +1 -1
- package/src/modal/Modal.tsx +6 -8
- package/src/modal/ModalContent.tsx +1 -1
- package/src/pagination/Pagination.tsx +87 -72
- package/src/pagination/PaginationItem.tsx +56 -0
- package/src/pagination/index.ts +1 -2
- package/src/pagination/pagination.stories.tsx +90 -16
- package/src/panel/Panel.tsx +1 -1
- package/src/popover/Popover.test.tsx +143 -0
- package/src/popover/Popover.tsx +107 -73
- package/src/popover/PopoverContent.tsx +1 -1
- package/src/popover/popover.stories.tsx +22 -27
- package/src/read-more/ReadMore.tsx +19 -30
- package/src/read-more/readmore.stories.tsx +3 -10
- package/src/stepper/Step.tsx +1 -1
- package/src/stepper/Stepper.tsx +1 -1
- package/src/table/Body.tsx +1 -1
- package/src/table/DataCell.tsx +1 -1
- package/src/table/ExpandableRow.tsx +12 -13
- package/src/table/Header.tsx +1 -1
- package/src/table/HeaderCell.tsx +1 -1
- package/src/table/Row.tsx +1 -1
- package/src/table/Table.tsx +1 -1
- package/src/tabs/Tab.tsx +6 -19
- package/src/tabs/TabList.tsx +14 -9
- package/src/tabs/TabPanel.tsx +1 -1
- package/src/tabs/Tabs.stories.tsx +94 -117
- package/src/tabs/Tabs.tsx +17 -1
- package/src/tag/Tag.tsx +1 -1
- package/src/toggle-group/ToggleGroup.tsx +3 -3
- package/src/toggle-group/ToggleItem.tsx +1 -1
- package/src/tooltip/Tooltip.test.tsx +167 -0
- package/src/tooltip/Tooltip.tsx +106 -173
- package/src/tooltip/tooltip.stories.tsx +15 -1
- package/src/typography/BodyLong.tsx +1 -1
- package/src/typography/BodyShort.tsx +1 -1
- package/src/typography/Detail.tsx +1 -1
- package/src/typography/ErrorMessage.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/src/typography/Ingress.tsx +1 -1
- package/src/typography/Label.tsx +1 -1
- package/src/util/AnimateHeight.tsx +240 -0
- package/src/util/TextareaAutoSize.tsx +224 -0
- package/src/util/debounce.ts +17 -0
- package/src/util/index.ts +14 -2
- package/src/util/mergeRefs.tsx +14 -0
- package/src/util/useId.ts +37 -20
- package/cjs/card/MicroCard.js +0 -47
- package/cjs/card/index.js +0 -8
- package/cjs/card/package.json +0 -6
- package/cjs/menu/Menu.js +0 -53
- package/cjs/menu/MenuCollapse.js +0 -65
- package/cjs/menu/MenuItems.js +0 -23
- package/cjs/menu/package.json +0 -6
- package/cjs/page-header/PageHeader.js +0 -51
- package/cjs/page-header/index.js +0 -8
- package/cjs/page-header/package.json +0 -6
- package/cjs/speech-bubble/index.js +0 -8
- package/cjs/speech-bubble/package.json +0 -6
- package/cjs/step-indicator/Step.js +0 -67
- package/cjs/step-indicator/StepIndicator.js +0 -80
- package/cjs/step-indicator/index.js +0 -8
- package/cjs/step-indicator/package.json +0 -6
- package/esm/card/MicroCard.d.ts +0 -10
- package/esm/card/MicroCard.js +0 -19
- package/esm/card/MicroCard.js.map +0 -1
- package/esm/card/index.d.ts +0 -2
- package/esm/card/index.js +0 -2
- package/esm/card/index.js.map +0 -1
- package/esm/menu/Menu.d.ts +0 -12
- package/esm/menu/Menu.js +0 -25
- package/esm/menu/Menu.js.map +0 -1
- package/esm/menu/MenuCollapse.d.ts +0 -12
- package/esm/menu/MenuCollapse.js +0 -37
- package/esm/menu/MenuCollapse.js.map +0 -1
- package/esm/menu/MenuItem.d.ts +0 -13
- package/esm/menu/MenuItem.js.map +0 -1
- package/esm/menu/MenuItems.d.ts +0 -6
- package/esm/menu/MenuItems.js +0 -19
- package/esm/menu/MenuItems.js.map +0 -1
- package/esm/menu/index.d.ts +0 -3
- package/esm/menu/index.js +0 -2
- package/esm/menu/index.js.map +0 -1
- package/esm/page-header/PageHeader.d.ts +0 -27
- package/esm/page-header/PageHeader.js +0 -24
- package/esm/page-header/PageHeader.js.map +0 -1
- package/esm/page-header/index.d.ts +0 -2
- package/esm/page-header/index.js +0 -2
- package/esm/page-header/index.js.map +0 -1
- package/esm/speech-bubble/Bubble.js.map +0 -1
- package/esm/speech-bubble/SpeechBubble.d.ts +0 -34
- package/esm/speech-bubble/SpeechBubble.js +0 -27
- package/esm/speech-bubble/SpeechBubble.js.map +0 -1
- package/esm/speech-bubble/index.d.ts +0 -1
- package/esm/speech-bubble/index.js +0 -2
- package/esm/speech-bubble/index.js.map +0 -1
- package/esm/step-indicator/Step.d.ts +0 -23
- package/esm/step-indicator/Step.js +0 -39
- package/esm/step-indicator/Step.js.map +0 -1
- package/esm/step-indicator/StepIndicator.d.ts +0 -41
- package/esm/step-indicator/StepIndicator.js +0 -52
- package/esm/step-indicator/StepIndicator.js.map +0 -1
- package/esm/step-indicator/index.d.ts +0 -1
- package/esm/step-indicator/index.js +0 -2
- package/esm/step-indicator/index.js.map +0 -1
- package/src/card/MicroCard.tsx +0 -32
- package/src/card/index.ts +0 -2
- package/src/card/stories/card.stories.mdx +0 -26
- package/src/card/stories/card.stories.tsx +0 -16
- package/src/grid/stories/grid.stories.mdx +0 -79
- package/src/grid/stories/grid.stories.tsx +0 -51
- package/src/grid/stories/styles.css +0 -21
- package/src/menu/Menu.tsx +0 -36
- package/src/menu/MenuCollapse.tsx +0 -80
- package/src/menu/MenuItem.tsx +0 -39
- package/src/menu/MenuItems.tsx +0 -21
- package/src/menu/index.ts +0 -3
- package/src/menu/stories/menu.stories.mdx +0 -93
- package/src/menu/stories/menu.stories.tsx +0 -139
- package/src/page-header/PageHeader.tsx +0 -72
- package/src/page-header/index.ts +0 -2
- package/src/page-header/stories/header.stories.mdx +0 -81
- package/src/page-header/stories/header.stories.tsx +0 -61
- package/src/page-header/stories/pictogram.tsx +0 -14
- package/src/speech-bubble/Bubble.tsx +0 -48
- package/src/speech-bubble/SpeechBubble.tsx +0 -93
- package/src/speech-bubble/index.ts +0 -1
- package/src/speech-bubble/stories/illustration.tsx +0 -66
- package/src/speech-bubble/stories/speechbubble.stories.mdx +0 -184
- package/src/speech-bubble/stories/speechbubble.stories.tsx +0 -104
- package/src/step-indicator/Step.tsx +0 -81
- package/src/step-indicator/StepIndicator.tsx +0 -148
- package/src/step-indicator/index.ts +0 -1
- package/src/step-indicator/stories/Example.tsx +0 -23
- package/src/step-indicator/stories/step-indicator.stories.mdx +0 -122
- package/src/step-indicator/stories/step-indicator.stories.tsx +0 -104
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, HTMLAttributes } from "react";
|
|
2
|
-
import cl from "classnames";
|
|
3
|
-
import Bubble, { BubbleType } from "./Bubble";
|
|
4
|
-
|
|
5
|
-
export interface SpeechBubbleProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
-
/**
|
|
7
|
-
* Children of type <SpeechBubble.Bubble />
|
|
8
|
-
*/
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Top text for personalia and date
|
|
12
|
-
*/
|
|
13
|
-
topText?: React.ReactNode;
|
|
14
|
-
/**
|
|
15
|
-
* Illustration for messenger. Regular text for initials works to
|
|
16
|
-
*/
|
|
17
|
-
illustration: React.ReactNode;
|
|
18
|
-
/**
|
|
19
|
-
* Background color on bubbles
|
|
20
|
-
*/
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Background color for illustration
|
|
24
|
-
*/
|
|
25
|
-
illustrationBgColor?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Positions illustration and Speechbubbles
|
|
28
|
-
* @default "left"
|
|
29
|
-
*/
|
|
30
|
-
position?: "left" | "right";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface SpeechBubbleComponent
|
|
34
|
-
extends React.ForwardRefExoticComponent<
|
|
35
|
-
SpeechBubbleProps & React.RefAttributes<HTMLDivElement>
|
|
36
|
-
> {
|
|
37
|
-
Bubble: BubbleType;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const SpeechBubble = forwardRef<HTMLDivElement, SpeechBubbleProps>(
|
|
41
|
-
(
|
|
42
|
-
{
|
|
43
|
-
children,
|
|
44
|
-
className,
|
|
45
|
-
topText,
|
|
46
|
-
illustration,
|
|
47
|
-
position = "left",
|
|
48
|
-
illustrationBgColor,
|
|
49
|
-
backgroundColor,
|
|
50
|
-
...rest
|
|
51
|
-
},
|
|
52
|
-
ref
|
|
53
|
-
) => {
|
|
54
|
-
return (
|
|
55
|
-
<div
|
|
56
|
-
ref={ref}
|
|
57
|
-
className={cl(
|
|
58
|
-
"navds-speechbubble",
|
|
59
|
-
className,
|
|
60
|
-
`navds-speechbubble--${position}`,
|
|
61
|
-
"navds-body-long"
|
|
62
|
-
)}
|
|
63
|
-
{...rest}
|
|
64
|
-
>
|
|
65
|
-
<div
|
|
66
|
-
className="navds-speechbubble__illustration"
|
|
67
|
-
style={{ backgroundColor: illustrationBgColor }}
|
|
68
|
-
>
|
|
69
|
-
{illustration}
|
|
70
|
-
</div>
|
|
71
|
-
<ol className="navds-speechbubble__bubble-list">
|
|
72
|
-
{React.Children.map(children, (child, i) => {
|
|
73
|
-
if (React.isValidElement(child)) {
|
|
74
|
-
return (
|
|
75
|
-
<li>
|
|
76
|
-
{React.cloneElement(child, {
|
|
77
|
-
topText: topText && i === 0 ? topText : undefined,
|
|
78
|
-
backgroundColor,
|
|
79
|
-
...child.props,
|
|
80
|
-
})}
|
|
81
|
-
</li>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
})}
|
|
85
|
-
</ol>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
) as SpeechBubbleComponent;
|
|
90
|
-
|
|
91
|
-
SpeechBubble.Bubble = Bubble;
|
|
92
|
-
|
|
93
|
-
export default SpeechBubble;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as SpeechBubble, SpeechBubbleProps } from "./SpeechBubble";
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export const Illustration = () => (
|
|
3
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 93">
|
|
4
|
-
<path
|
|
5
|
-
fill="#e7e5e2"
|
|
6
|
-
d="M14 50.7C15 52.3 17.9 81 26.5 81S39 51.8 39 50.3c-13.2-7.6-25 .4-25 .4z"
|
|
7
|
-
/>
|
|
8
|
-
<path
|
|
9
|
-
fill="#5c4378"
|
|
10
|
-
d="M38.7 50.2c6 2.9 15.3 10.9 15.3 18.3V93H0V68.5c0-7.1 8.5-14.8 14.5-18-.3.2-.5.3-.5.3 1 1.7 3.8 9.2 12.4 9.2C35 60 39 51.9 39 50.4c-.1-.1-.2-.2-.3-.2z"
|
|
11
|
-
/>
|
|
12
|
-
<path
|
|
13
|
-
fill="#d2242a"
|
|
14
|
-
d="M46.7 76H31.2c-.7 0-1.3-.6-1.2-1.3v-8.5c0-.7.6-1.3 1.3-1.3h15.5c.7 0 1.3.6 1.3 1.3v8.5c-.1.7-.7 1.3-1.4 1.3"
|
|
15
|
-
/>
|
|
16
|
-
<path
|
|
17
|
-
fill="#fff"
|
|
18
|
-
d="M42.9 71c0 2.1-1.7 3.8-3.8 3.8-2.1 0-3.8-1.7-3.8-3.8s1.7-3.8 3.8-3.8c2.1 0 3.8 1.7 3.8 3.8m-8.7 1.7h-.7l.8-1.9h.7l-.8 1.9zm9.3 0H43l.8-1.9h.5l-.8 1.9zm1.2 0h-.2l.8-1.9h.2l-.8 1.9z"
|
|
19
|
-
/>
|
|
20
|
-
<path
|
|
21
|
-
fill="#c52d35"
|
|
22
|
-
d="M36.2 72.7h.6s.1 0 .1-.1v-1.8s0-.1-.1-.1h-.6s-.1 0-.1.1l-.2.6v.1h.2l.1 1.2c0-.1 0 0 0 0"
|
|
23
|
-
/>
|
|
24
|
-
<path
|
|
25
|
-
fill="#c52d35"
|
|
26
|
-
d="M37.5 72.7h.6s.1 0 .1-.1v-1.8s0-.1-.1-.1h-.9s-.1 0-.1.1l-.2.6-.1.1h.5c.1 0 .2.1.2.2v1c-.1-.1-.1 0 0 0m2.6-1.9h-.6s-.1 0-.1.1v1.8s0 .1.1.1h.6s.1 0 .1-.1l.2-.6V72h-.2l-.1-1.2"
|
|
27
|
-
/>
|
|
28
|
-
<path
|
|
29
|
-
fill="#c52d35"
|
|
30
|
-
d="M37.7 72.7h.4s.1 0 .1-.1l.2-.6v-.1h-.2c0 .1-.5.8-.5.8zm3.9-1.9h.7s.1 0 0 .1l-.7 1.8H41l.6-1.9"
|
|
31
|
-
/>
|
|
32
|
-
<path
|
|
33
|
-
fill="#c52d35"
|
|
34
|
-
d="M40.8 70.8h-1c-.1 0 .3.1.3.1l.7 1.7s0 .1.1.1h.6l-.7-1.9m-1.3.6v.4s-.1-.4-.3-.4c-.3 0-.3.2-.3.3 0 .1.1.3.2.3h.5l-.3.7H39c-.2 0-.9-.3-.9-.9 0-.6.5-1 .9-1 .2-.1.5.2.5.6 0-.1 0-.1 0 0z"
|
|
35
|
-
/>
|
|
36
|
-
<path
|
|
37
|
-
fill="#5a1f57"
|
|
38
|
-
d="M39.9 66.7h-1.6c-.1 0-.2-.1-.2-.2v-.3c0-.1.1-.2.2-.2h1.6c.1 0 .2.1.2.2v.3c0 .2-.1.2-.2.2"
|
|
39
|
-
/>
|
|
40
|
-
<path fill="#c2b5cf" d="M38.7 66.5h.9V64h-.9v2.5z" />
|
|
41
|
-
<path
|
|
42
|
-
fill="#e7e5e2"
|
|
43
|
-
d="M47.2 35.3C44.7 45.6 36.6 53.1 27 53.1S9.3 45.6 6.8 35.3c-.2.1-.5.1-.8.1-1.1 0-2-.8-2-1.7v-7c0-1 .9-1.7 2-1.7h.2C7.7 13.1 16.4 4 27 4c10.6 0 19.3 9.1 20.8 21h.2c1.1 0 2 .8 2 1.7v7c0 1-.9 1.7-2 1.7-.3 0-.5 0-.8-.1z"
|
|
44
|
-
/>
|
|
45
|
-
<path
|
|
46
|
-
fill="#635e59"
|
|
47
|
-
d="M19 27.6c-1.4.1-1.9-2-1.4-3.4.1-.3.6-1.5 1.4-1.5.8 0 1.2.7 1.3.8.6 1.4.3 4-1.3 4.1m16.2 0c1.4.1 1.9-2 1.4-3.4-.1-.3-.6-1.5-1.4-1.5-.8 0-1.2.7-1.3.8-.6 1.4-.3 4 1.3 4.1"
|
|
48
|
-
/>
|
|
49
|
-
<path
|
|
50
|
-
fill="#d1bfa3"
|
|
51
|
-
d="M26.8 34.6c-.4 0-.7-.1-1-.2-.3-.1-.4-.4-.3-.7.1-.3.4-.4.7-.3.5.2 1.5.1 2.2-.4.7-.4 1.1-1 1.2-1.5.1-.4-.1-.9-.4-1.3-.2-.2-.8-.2-1.6-.1-.3 0-.5-.1-.6-.4 0-.3.1-.5.4-.6 1.2-.2 2.1 0 2.6.6.5.7.8 1.4.6 2.1-.1.8-.7 1.6-1.7 2.2-.6.3-1.4.6-2.1.6z"
|
|
52
|
-
/>
|
|
53
|
-
<path
|
|
54
|
-
fill="#593a32"
|
|
55
|
-
d="M27.1 42.1h-.3c-5.3-.2-7.3-4.1-7.4-4.3-.1-.3 0-.6.2-.7.2-.1.6 0 .7.2.1.1 1.9 3.6 6.6 3.8 4.7.2 6.4-3.7 6.4-3.7.1-.3.4-.4.7-.3.3.1.4.4.3.7-.1 0-2.1 4.3-7.2 4.3z"
|
|
56
|
-
/>
|
|
57
|
-
<path
|
|
58
|
-
fill="#f6b873"
|
|
59
|
-
d="M6.6 30.7c.1-.1.1-.2.1-.3v-2c-.1-5.6 1.8-8.1 3.4-10.1 0 0-1 4.3-.3 3.4 3.8-5 21.4-1.6 25-8.1.5 3.6-4.1 4.6-4.1 4.6 3.7.7 6.9-.8 7.7-2.5.3 1.4-.6 2.4-1.9 3.4 4.5-.9 4.6-4 4.6-4 .6 4.1 5.3 2.5 5.3 9.3v6c0 .3.2.6.5.6h.5c.3 0 .5-.3.5-.6V26c.3-15.6-8.5-26-20.6-26C15.9 0 5 10.4 5 24.1v6.3c0 .4.2.6.5.6h.6c.2 0 .3-.1.5-.3"
|
|
60
|
-
/>
|
|
61
|
-
<path
|
|
62
|
-
fill="#f6b873"
|
|
63
|
-
d="M25.9 43.4c-4.4 0-8-1.4-8-3.2s3.6-3.2 8-3.2 8 1.4 8 3.2c0 1.8-3.6 3.2-8 3.2m.8-9.4c-2.9 0-4.7.7-8.8 2.1-12.7 4.6-11.6-14-11.6-14C3.4 46 18.6 52 26.5 52c8.1 0 24.1-8.1 21-30 0 0 .4 17.1-12.9 13.8-3.7-.9-5-1.8-7.9-1.8z"
|
|
64
|
-
/>
|
|
65
|
-
</svg>
|
|
66
|
-
);
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas } from "@storybook/addon-docs";
|
|
2
|
-
import { SpeechBubble, Bubble } from "../../index";
|
|
3
|
-
import { Illustration } from "./illustration";
|
|
4
|
-
|
|
5
|
-
<Meta title="ds-react/speechbubble/intro" />
|
|
6
|
-
|
|
7
|
-
# Hvordan ta i bruk Speechbubble
|
|
8
|
-
|
|
9
|
-
NOTE: Komponenten er i tidlig BETA og ikke testet ordentlig. Derfor kan/vil det komme potensielle
|
|
10
|
-
breaking-changes før v1 er klar. Anbefaler da å ikke override styling som er brukt utenom det som er tilbytt som props.
|
|
11
|
-
|
|
12
|
-
```jsx
|
|
13
|
-
<SpeechBubble illustration="OLA" topText="Ola Normann 01.01.21 14:00">
|
|
14
|
-
<SpeechBubble.Bubble>
|
|
15
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
16
|
-
</SpeechBubble.Bubble>
|
|
17
|
-
<SpeechBubble.Bubble>
|
|
18
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
19
|
-
</SpeechBubble.Bubble>
|
|
20
|
-
<SpeechBubble.Bubble>
|
|
21
|
-
Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
|
|
22
|
-
labore nisi ut.
|
|
23
|
-
</SpeechBubble.Bubble>
|
|
24
|
-
</SpeechBubble>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
<Canvas>
|
|
28
|
-
<SpeechBubble illustration="OLA" topText="Ola Normann 01.01.21 14:00">
|
|
29
|
-
<SpeechBubble.Bubble>
|
|
30
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
31
|
-
</SpeechBubble.Bubble>
|
|
32
|
-
<SpeechBubble.Bubble>
|
|
33
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
34
|
-
</SpeechBubble.Bubble>
|
|
35
|
-
<SpeechBubble.Bubble>
|
|
36
|
-
Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
|
|
37
|
-
labore nisi ut.
|
|
38
|
-
</SpeechBubble.Bubble>
|
|
39
|
-
</SpeechBubble>
|
|
40
|
-
</Canvas>
|
|
41
|
-
|
|
42
|
-
## Posisjonering
|
|
43
|
-
|
|
44
|
-
Speechbubble kan bli posisjonert "left" og "right" med `position`-proppen
|
|
45
|
-
|
|
46
|
-
```jsx
|
|
47
|
-
<SpeechBubble illustration="OLA" position="left">
|
|
48
|
-
<SpeechBubble.Bubble>
|
|
49
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
50
|
-
</SpeechBubble.Bubble>
|
|
51
|
-
</SpeechBubble>
|
|
52
|
-
<SpeechBubble illustration="OLA" position="right">
|
|
53
|
-
<SpeechBubble.Bubble>
|
|
54
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
55
|
-
</SpeechBubble.Bubble>
|
|
56
|
-
</SpeechBubble>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
<Canvas>
|
|
60
|
-
<div>
|
|
61
|
-
<SpeechBubble illustration="OLA" position="left">
|
|
62
|
-
<SpeechBubble.Bubble>
|
|
63
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
64
|
-
</SpeechBubble.Bubble>
|
|
65
|
-
</SpeechBubble>
|
|
66
|
-
<br />
|
|
67
|
-
<SpeechBubble illustration="PER" position="right">
|
|
68
|
-
<SpeechBubble.Bubble>
|
|
69
|
-
Ipsum laborum culpa ea ea commodo eiusmod in aute.
|
|
70
|
-
</SpeechBubble.Bubble>
|
|
71
|
-
</SpeechBubble>
|
|
72
|
-
</div>
|
|
73
|
-
</Canvas>
|
|
74
|
-
|
|
75
|
-
## Endring av farger
|
|
76
|
-
|
|
77
|
-
Man kan endre bakgrunnsfargen selv med `illustrationBgColor` og `backgroundColor` proppene.
|
|
78
|
-
|
|
79
|
-
```jsx
|
|
80
|
-
<SpeechBubble
|
|
81
|
-
illustration="OLA"
|
|
82
|
-
position="left"
|
|
83
|
-
illustrationBgColor="var(--navds-global-color-lightblue-100)"
|
|
84
|
-
backgroundColor="var(--navds-global-color-lightblue-200)"
|
|
85
|
-
>
|
|
86
|
-
<SpeechBubble.Bubble>
|
|
87
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
88
|
-
</SpeechBubble.Bubble>
|
|
89
|
-
</SpeechBubble>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
<Canvas>
|
|
93
|
-
<SpeechBubble
|
|
94
|
-
illustration="OLA"
|
|
95
|
-
position="left"
|
|
96
|
-
illustrationBgColor="var(--navds-global-color-lightblue-100)"
|
|
97
|
-
backgroundColor="var(--navds-global-color-lightblue-200)"
|
|
98
|
-
>
|
|
99
|
-
<SpeechBubble.Bubble>
|
|
100
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
101
|
-
</SpeechBubble.Bubble>
|
|
102
|
-
</SpeechBubble>
|
|
103
|
-
</Canvas>
|
|
104
|
-
|
|
105
|
-
## Illustrasjoner
|
|
106
|
-
|
|
107
|
-
`illustration`-proppen aksepterer `ReactNode`.
|
|
108
|
-
Hvis man bruker en illustrasjon i SVG-fromat vil den fungere likt `nav-frontend-veilederpanel` sin illustrasjon.
|
|
109
|
-
|
|
110
|
-
```jsx
|
|
111
|
-
<SpeechBubble illustration={<Illustration />} position="left">
|
|
112
|
-
<SpeechBubble.Bubble>
|
|
113
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
114
|
-
</SpeechBubble.Bubble>
|
|
115
|
-
</SpeechBubble>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
<Canvas>
|
|
119
|
-
<SpeechBubble illustration={<Illustration />} position="left">
|
|
120
|
-
<SpeechBubble.Bubble>
|
|
121
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
122
|
-
</SpeechBubble.Bubble>
|
|
123
|
-
</SpeechBubble>
|
|
124
|
-
</Canvas>
|
|
125
|
-
|
|
126
|
-
## Styling av topText
|
|
127
|
-
|
|
128
|
-
`topText`-proppen aksepterer `ReactNode` og man kan da selv style den
|
|
129
|
-
|
|
130
|
-
```jsx
|
|
131
|
-
<SpeechBubble
|
|
132
|
-
illustration={<div>OLA</div>}
|
|
133
|
-
topText={
|
|
134
|
-
<div
|
|
135
|
-
style={{
|
|
136
|
-
display: "flex",
|
|
137
|
-
columnGap: "1rem",
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
<span>Ola Normann</span>
|
|
141
|
-
<span className="navds-detail--s">01.01.21 14:00</span>
|
|
142
|
-
</div>
|
|
143
|
-
}
|
|
144
|
-
>
|
|
145
|
-
<SpeechBubble.Bubble>
|
|
146
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
147
|
-
</SpeechBubble.Bubble>
|
|
148
|
-
<SpeechBubble.Bubble>
|
|
149
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
150
|
-
</SpeechBubble.Bubble>
|
|
151
|
-
<SpeechBubble.Bubble>
|
|
152
|
-
Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
|
|
153
|
-
labore nisi ut.
|
|
154
|
-
</SpeechBubble.Bubble>
|
|
155
|
-
</SpeechBubble>
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
<Canvas>
|
|
159
|
-
<SpeechBubble
|
|
160
|
-
illustration={<div>OLA</div>}
|
|
161
|
-
topText={
|
|
162
|
-
<div
|
|
163
|
-
style={{
|
|
164
|
-
display: "flex",
|
|
165
|
-
columnGap: "1rem",
|
|
166
|
-
}}
|
|
167
|
-
>
|
|
168
|
-
<span>Ola Normann</span>
|
|
169
|
-
<span className="navds-detail--s">01.01.21 14:00</span>
|
|
170
|
-
</div>
|
|
171
|
-
}
|
|
172
|
-
>
|
|
173
|
-
<SpeechBubble.Bubble>
|
|
174
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
175
|
-
</SpeechBubble.Bubble>
|
|
176
|
-
<SpeechBubble.Bubble>
|
|
177
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
178
|
-
</SpeechBubble.Bubble>
|
|
179
|
-
<SpeechBubble.Bubble>
|
|
180
|
-
Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
|
|
181
|
-
labore nisi ut.
|
|
182
|
-
</SpeechBubble.Bubble>
|
|
183
|
-
</SpeechBubble>
|
|
184
|
-
</Canvas>
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { SpeechBubble } from "../index";
|
|
3
|
-
import { Meta } from "@storybook/react/types-6-0";
|
|
4
|
-
import { Illustration } from "./illustration";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: "ds-react/speechbubble",
|
|
8
|
-
component: SpeechBubble,
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
export const All = () => {
|
|
12
|
-
return (
|
|
13
|
-
<div style={{ rowGap: "2rem", display: "flex", flexDirection: "column" }}>
|
|
14
|
-
<SpeechBubble
|
|
15
|
-
illustration={<Illustration />}
|
|
16
|
-
topText="Ola Normann 01.01.21 14:00"
|
|
17
|
-
backgroundColor="var(--navds-global-color-lightblue-200)"
|
|
18
|
-
>
|
|
19
|
-
<SpeechBubble.Bubble>
|
|
20
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
21
|
-
</SpeechBubble.Bubble>
|
|
22
|
-
<SpeechBubble.Bubble>
|
|
23
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
24
|
-
</SpeechBubble.Bubble>
|
|
25
|
-
<SpeechBubble.Bubble>
|
|
26
|
-
Adipisicing laborum est eu laborum est sit in commodo enim sint
|
|
27
|
-
laboris labore nisi ut.
|
|
28
|
-
</SpeechBubble.Bubble>
|
|
29
|
-
</SpeechBubble>
|
|
30
|
-
<SpeechBubble
|
|
31
|
-
illustration={<div>KAJ</div>}
|
|
32
|
-
topText={
|
|
33
|
-
<div
|
|
34
|
-
style={{
|
|
35
|
-
columnGap: "1rem",
|
|
36
|
-
display: "flex",
|
|
37
|
-
justifyContent: "flex-end",
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
<span>Ola Normann</span>
|
|
41
|
-
<span className="navds-detail--s">01.01.21 14:00</span>
|
|
42
|
-
</div>
|
|
43
|
-
}
|
|
44
|
-
position="right"
|
|
45
|
-
backgroundColor="var(--navds-global-color-gray-100)"
|
|
46
|
-
>
|
|
47
|
-
<SpeechBubble.Bubble>
|
|
48
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
49
|
-
</SpeechBubble.Bubble>
|
|
50
|
-
<SpeechBubble.Bubble>
|
|
51
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
52
|
-
</SpeechBubble.Bubble>
|
|
53
|
-
<SpeechBubble.Bubble>
|
|
54
|
-
Adipisicing laborum est eu laborum est sit in commodo enim sint
|
|
55
|
-
laboris labore nisi ut.
|
|
56
|
-
</SpeechBubble.Bubble>
|
|
57
|
-
</SpeechBubble>
|
|
58
|
-
<SpeechBubble
|
|
59
|
-
illustration={<div>KAJ</div>}
|
|
60
|
-
topText="Ola Normann 01.01.21 14:00"
|
|
61
|
-
position="left"
|
|
62
|
-
>
|
|
63
|
-
<SpeechBubble.Bubble>
|
|
64
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
65
|
-
</SpeechBubble.Bubble>
|
|
66
|
-
<SpeechBubble.Bubble>
|
|
67
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
68
|
-
</SpeechBubble.Bubble>
|
|
69
|
-
<SpeechBubble.Bubble>
|
|
70
|
-
Adipisicing laborum est eu laborum est sit in commodo enim sint
|
|
71
|
-
laboris labore nisi ut.
|
|
72
|
-
</SpeechBubble.Bubble>
|
|
73
|
-
</SpeechBubble>
|
|
74
|
-
<SpeechBubble
|
|
75
|
-
illustration={<div>KAJ</div>}
|
|
76
|
-
topText="Ola Normann 01.01.21 14:00"
|
|
77
|
-
position="right"
|
|
78
|
-
>
|
|
79
|
-
<SpeechBubble.Bubble>
|
|
80
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
81
|
-
</SpeechBubble.Bubble>
|
|
82
|
-
<SpeechBubble.Bubble>
|
|
83
|
-
Tempor fugiat amet eu sint in in ullamco.
|
|
84
|
-
</SpeechBubble.Bubble>
|
|
85
|
-
</SpeechBubble>
|
|
86
|
-
<SpeechBubble
|
|
87
|
-
illustration={<div>KAJ</div>}
|
|
88
|
-
topText="Ola Normann 01.01.21 14:00"
|
|
89
|
-
position="left"
|
|
90
|
-
>
|
|
91
|
-
<SpeechBubble.Bubble>
|
|
92
|
-
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
93
|
-
</SpeechBubble.Bubble>
|
|
94
|
-
</SpeechBubble>
|
|
95
|
-
<SpeechBubble
|
|
96
|
-
illustration={<div>KAJ</div>}
|
|
97
|
-
topText="Ola Normann 01.01.21 14:00"
|
|
98
|
-
position="right"
|
|
99
|
-
>
|
|
100
|
-
<SpeechBubble.Bubble>Per skriver....</SpeechBubble.Bubble>
|
|
101
|
-
</SpeechBubble>
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useContext } from "react";
|
|
2
|
-
import cl from "classnames";
|
|
3
|
-
import { StepContext } from "./StepIndicator";
|
|
4
|
-
import { BodyShort, Label, OverridableComponent } from "..";
|
|
5
|
-
|
|
6
|
-
export interface StepIndicatorStepProps
|
|
7
|
-
extends React.HTMLAttributes<HTMLButtonElement> {
|
|
8
|
-
/**
|
|
9
|
-
* Text content under indicator
|
|
10
|
-
*/
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Disables interaction with element
|
|
14
|
-
* @note We recommend not using disabled if possible
|
|
15
|
-
*/
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Handled by StepIndicator
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
21
|
-
index?: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface StepIndicatorStepType
|
|
25
|
-
extends OverridableComponent<StepIndicatorStepProps, HTMLButtonElement> {}
|
|
26
|
-
|
|
27
|
-
export const StepIndicatorStepComponent: OverridableComponent<
|
|
28
|
-
StepIndicatorStepProps,
|
|
29
|
-
HTMLButtonElement
|
|
30
|
-
> = forwardRef(
|
|
31
|
-
(
|
|
32
|
-
{ className, children, as: Component = "button", disabled, index, ...rest },
|
|
33
|
-
ref
|
|
34
|
-
) => {
|
|
35
|
-
const context = useContext(StepContext);
|
|
36
|
-
|
|
37
|
-
if (context === null) {
|
|
38
|
-
console.error(
|
|
39
|
-
"<StepIndicator.Step> has to be used within an <StepIndicator>"
|
|
40
|
-
);
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const safeIndex = index ?? 0;
|
|
45
|
-
|
|
46
|
-
const Number = context.activeStep === safeIndex ? Label : BodyShort;
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Component
|
|
50
|
-
{...rest}
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
ref={ref}
|
|
53
|
-
className={cl("navds-step-indicator__step", className, {
|
|
54
|
-
"navds-step-indicator__step--disabled": disabled,
|
|
55
|
-
"navds-step-indicator__step--active":
|
|
56
|
-
context.activeStep === safeIndex,
|
|
57
|
-
"navds-step-indicator__step--finished":
|
|
58
|
-
context.activeStep > safeIndex,
|
|
59
|
-
})}
|
|
60
|
-
onClick={(e) => {
|
|
61
|
-
context.onStepChange(safeIndex);
|
|
62
|
-
rest.onClick && rest.onClick(e);
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
<Number className="navds-step-indicator__step-number">
|
|
66
|
-
{safeIndex + 1}
|
|
67
|
-
</Number>
|
|
68
|
-
<div className={cl("navds-step-indicator__step-label")}>
|
|
69
|
-
{!context.hideLabels && children}
|
|
70
|
-
</div>
|
|
71
|
-
{safeIndex !== 0 && (
|
|
72
|
-
<span aria-hidden className="navds-step-indicator__step-line" />
|
|
73
|
-
)}
|
|
74
|
-
</Component>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const Step = StepIndicatorStepComponent as StepIndicatorStepType;
|
|
80
|
-
|
|
81
|
-
export default Step;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import cl from "classnames";
|
|
2
|
-
import React, {
|
|
3
|
-
createContext,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useCallback,
|
|
6
|
-
useEffect,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from "react";
|
|
10
|
-
import mergeRefs from "react-merge-refs";
|
|
11
|
-
import StepIndicatorStep, {
|
|
12
|
-
StepIndicatorStepProps,
|
|
13
|
-
StepIndicatorStepType,
|
|
14
|
-
} from "./Step";
|
|
15
|
-
|
|
16
|
-
export interface StepIndicatorProps
|
|
17
|
-
extends React.HTMLAttributes<HTMLOListElement> {
|
|
18
|
-
/**
|
|
19
|
-
* <StepIndicator.Step /> elements
|
|
20
|
-
*/
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* Adds classname to wrapper
|
|
24
|
-
*/
|
|
25
|
-
className?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Current active step index
|
|
28
|
-
*/
|
|
29
|
-
activeStep: number;
|
|
30
|
-
/**
|
|
31
|
-
* Callback for clicked step index
|
|
32
|
-
*/
|
|
33
|
-
onStepChange?: (step: number) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Hides labels for each step if true
|
|
36
|
-
* @default false
|
|
37
|
-
*/
|
|
38
|
-
hideLabels?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* enables `hideLabels` internally when steps start to overflow.
|
|
41
|
-
* @note declaring `hideLabels` overwrites this functionality
|
|
42
|
-
*/
|
|
43
|
-
responsive?: boolean;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface StepIndicatorComponent
|
|
47
|
-
extends React.ForwardRefExoticComponent<
|
|
48
|
-
StepIndicatorProps & React.RefAttributes<HTMLOListElement>
|
|
49
|
-
> {
|
|
50
|
-
Step: StepIndicatorStepType;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface StepContextProps {
|
|
54
|
-
activeStep: number;
|
|
55
|
-
onStepChange: (step: number) => void;
|
|
56
|
-
hideLabels: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const StepContext = createContext<StepContextProps | null>(null);
|
|
60
|
-
|
|
61
|
-
export const StepIndicator: StepIndicatorComponent = forwardRef<
|
|
62
|
-
HTMLOListElement,
|
|
63
|
-
StepIndicatorProps
|
|
64
|
-
>(
|
|
65
|
-
(
|
|
66
|
-
{
|
|
67
|
-
children,
|
|
68
|
-
className,
|
|
69
|
-
activeStep,
|
|
70
|
-
hideLabels,
|
|
71
|
-
onStepChange = () => {},
|
|
72
|
-
responsive,
|
|
73
|
-
...rest
|
|
74
|
-
},
|
|
75
|
-
ref
|
|
76
|
-
) => {
|
|
77
|
-
const wrapperRef = useRef<HTMLOListElement | null>(null);
|
|
78
|
-
const mergedRef = mergeRefs([wrapperRef, ref]);
|
|
79
|
-
|
|
80
|
-
const [showLabels, setShowLabels] = useState(true);
|
|
81
|
-
|
|
82
|
-
const removeLabels = hideLabels ?? (!!responsive && !showLabels);
|
|
83
|
-
|
|
84
|
-
const stepsWithIndex = React.Children.map(children, (step, index) => {
|
|
85
|
-
return React.isValidElement<StepIndicatorStepProps>(step) ? (
|
|
86
|
-
<li
|
|
87
|
-
className={cl("navds-step-indicator__step-wrapper", {
|
|
88
|
-
"navds-step-indicator__step-wrapper--hidelabel": removeLabels,
|
|
89
|
-
})}
|
|
90
|
-
key={index}
|
|
91
|
-
aria-current={index === activeStep && "step"}
|
|
92
|
-
>
|
|
93
|
-
{React.cloneElement(step, {
|
|
94
|
-
...step.props,
|
|
95
|
-
index,
|
|
96
|
-
})}
|
|
97
|
-
</li>
|
|
98
|
-
) : (
|
|
99
|
-
step
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const canShowLabels = useCallback(() => {
|
|
104
|
-
const remSize = parseFloat(
|
|
105
|
-
String(getComputedStyle(document.documentElement).fontSize)
|
|
106
|
-
);
|
|
107
|
-
const childrenLength = React.Children.toArray(children).filter((child) =>
|
|
108
|
-
React.isValidElement(child)
|
|
109
|
-
).length;
|
|
110
|
-
|
|
111
|
-
wrapperRef.current &&
|
|
112
|
-
setShowLabels(
|
|
113
|
-
wrapperRef.current?.getBoundingClientRect().width >=
|
|
114
|
-
remSize * 10 * childrenLength
|
|
115
|
-
);
|
|
116
|
-
}, [children]);
|
|
117
|
-
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
window.addEventListener("resize", canShowLabels);
|
|
120
|
-
canShowLabels();
|
|
121
|
-
return () => {
|
|
122
|
-
window.removeEventListener("resize", canShowLabels);
|
|
123
|
-
};
|
|
124
|
-
}, [canShowLabels]);
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<ol
|
|
128
|
-
ref={mergedRef}
|
|
129
|
-
className={cl(`navds-step-indicator`, className)}
|
|
130
|
-
{...rest}
|
|
131
|
-
>
|
|
132
|
-
<StepContext.Provider
|
|
133
|
-
value={{
|
|
134
|
-
activeStep,
|
|
135
|
-
onStepChange,
|
|
136
|
-
hideLabels: removeLabels,
|
|
137
|
-
}}
|
|
138
|
-
>
|
|
139
|
-
{stepsWithIndex}
|
|
140
|
-
</StepContext.Provider>
|
|
141
|
-
</ol>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
) as StepIndicatorComponent;
|
|
145
|
-
|
|
146
|
-
StepIndicator.Step = StepIndicatorStep;
|
|
147
|
-
|
|
148
|
-
export default StepIndicator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as StepIndicator, StepIndicatorProps } from "./StepIndicator";
|