@dxos/react-ui 0.1.0
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/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/src/components/Alert/Alert.d.ts +10 -0
- package/dist/src/components/Alert/Alert.d.ts.map +1 -0
- package/dist/src/components/Alert/Alert.js +21 -0
- package/dist/src/components/Alert/Alert.js.map +1 -0
- package/dist/src/components/Alert/Alert.stories.d.ts +9 -0
- package/dist/src/components/Alert/Alert.stories.d.ts.map +1 -0
- package/dist/src/components/Alert/Alert.stories.js +30 -0
- package/dist/src/components/Alert/Alert.stories.js.map +1 -0
- package/dist/src/components/Alert/index.d.ts +2 -0
- package/dist/src/components/Alert/index.d.ts.map +1 -0
- package/dist/src/components/Alert/index.js +21 -0
- package/dist/src/components/Alert/index.js.map +1 -0
- package/dist/src/components/AlertDialog/AlertDialog.d.ts +17 -0
- package/dist/src/components/AlertDialog/AlertDialog.d.ts.map +1 -0
- package/dist/src/components/AlertDialog/AlertDialog.js +65 -0
- package/dist/src/components/AlertDialog/AlertDialog.js.map +1 -0
- package/dist/src/components/AlertDialog/AlertDialog.stories.d.ts +9 -0
- package/dist/src/components/AlertDialog/AlertDialog.stories.d.ts.map +1 -0
- package/dist/src/components/AlertDialog/AlertDialog.stories.js +37 -0
- package/dist/src/components/AlertDialog/AlertDialog.stories.js.map +1 -0
- package/dist/src/components/AlertDialog/index.d.ts +2 -0
- package/dist/src/components/AlertDialog/index.d.ts.map +1 -0
- package/dist/src/components/AlertDialog/index.js +21 -0
- package/dist/src/components/AlertDialog/index.js.map +1 -0
- package/dist/src/components/Avatar/Avatar.d.ts +13 -0
- package/dist/src/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/src/components/Avatar/Avatar.js +53 -0
- package/dist/src/components/Avatar/Avatar.js.map +1 -0
- package/dist/src/components/Avatar/Avatar.stories.d.ts +10 -0
- package/dist/src/components/Avatar/Avatar.stories.d.ts.map +1 -0
- package/dist/src/components/Avatar/Avatar.stories.js +30 -0
- package/dist/src/components/Avatar/Avatar.stories.js.map +1 -0
- package/dist/src/components/Avatar/index.d.ts +2 -0
- package/dist/src/components/Avatar/index.d.ts.map +1 -0
- package/dist/src/components/Avatar/index.js +21 -0
- package/dist/src/components/Avatar/index.js.map +1 -0
- package/dist/src/components/Button/Button.d.ts +4 -0
- package/dist/src/components/Button/Button.d.ts.map +1 -0
- package/dist/src/components/Button/Button.js +37 -0
- package/dist/src/components/Button/Button.js.map +1 -0
- package/dist/src/components/Button/Button.stories.d.ts +12 -0
- package/dist/src/components/Button/Button.stories.d.ts.map +1 -0
- package/dist/src/components/Button/Button.stories.js +31 -0
- package/dist/src/components/Button/Button.stories.js.map +1 -0
- package/dist/src/components/Button/ButtonProps.d.ts +8 -0
- package/dist/src/components/Button/ButtonProps.d.ts.map +1 -0
- package/dist/src/components/Button/ButtonProps.js +6 -0
- package/dist/src/components/Button/ButtonProps.js.map +1 -0
- package/dist/src/components/Button/buttonStyles.d.ts +5 -0
- package/dist/src/components/Button/buttonStyles.d.ts.map +1 -0
- package/dist/src/components/Button/buttonStyles.js +24 -0
- package/dist/src/components/Button/buttonStyles.js.map +1 -0
- package/dist/src/components/Button/index.d.ts +4 -0
- package/dist/src/components/Button/index.d.ts.map +1 -0
- package/dist/src/components/Button/index.js +23 -0
- package/dist/src/components/Button/index.js.map +1 -0
- package/dist/src/components/CompoundButton/CompoundButton.d.ts +10 -0
- package/dist/src/components/CompoundButton/CompoundButton.d.ts.map +1 -0
- package/dist/src/components/CompoundButton/CompoundButton.js +27 -0
- package/dist/src/components/CompoundButton/CompoundButton.js.map +1 -0
- package/dist/src/components/CompoundButton/CompoundButton.stories.d.ts +10 -0
- package/dist/src/components/CompoundButton/CompoundButton.stories.d.ts.map +1 -0
- package/dist/src/components/CompoundButton/CompoundButton.stories.js +40 -0
- package/dist/src/components/CompoundButton/CompoundButton.stories.js.map +1 -0
- package/dist/src/components/CompoundButton/index.d.ts +2 -0
- package/dist/src/components/CompoundButton/index.d.ts.map +1 -0
- package/dist/src/components/CompoundButton/index.js +21 -0
- package/dist/src/components/CompoundButton/index.js.map +1 -0
- package/dist/src/components/Dialog/Dialog.d.ts +14 -0
- package/dist/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/src/components/Dialog/Dialog.js +59 -0
- package/dist/src/components/Dialog/Dialog.js.map +1 -0
- package/dist/src/components/Dialog/Dialog.stories.d.ts +9 -0
- package/dist/src/components/Dialog/Dialog.stories.d.ts.map +1 -0
- package/dist/src/components/Dialog/Dialog.stories.js +37 -0
- package/dist/src/components/Dialog/Dialog.stories.js.map +1 -0
- package/dist/src/components/Dialog/index.d.ts +2 -0
- package/dist/src/components/Dialog/index.d.ts.map +1 -0
- package/dist/src/components/Dialog/index.js +21 -0
- package/dist/src/components/Dialog/index.js.map +1 -0
- package/dist/src/components/Group/Group.d.ts +10 -0
- package/dist/src/components/Group/Group.d.ts.map +1 -0
- package/dist/src/components/Group/Group.js +22 -0
- package/dist/src/components/Group/Group.js.map +1 -0
- package/dist/src/components/Group/Group.stories.d.ts +9 -0
- package/dist/src/components/Group/Group.stories.d.ts.map +1 -0
- package/dist/src/components/Group/Group.stories.js +27 -0
- package/dist/src/components/Group/Group.stories.js.map +1 -0
- package/dist/src/components/Group/index.d.ts +2 -0
- package/dist/src/components/Group/index.d.ts.map +1 -0
- package/dist/src/components/Group/index.js +21 -0
- package/dist/src/components/Group/index.js.map +1 -0
- package/dist/src/components/Heading/Heading.d.ts +266 -0
- package/dist/src/components/Heading/Heading.d.ts.map +1 -0
- package/dist/src/components/Heading/Heading.js +28 -0
- package/dist/src/components/Heading/Heading.js.map +1 -0
- package/dist/src/components/Heading/Heading.stories.d.ts +274 -0
- package/dist/src/components/Heading/Heading.stories.d.ts.map +1 -0
- package/dist/src/components/Heading/Heading.stories.js +34 -0
- package/dist/src/components/Heading/Heading.stories.js.map +1 -0
- package/dist/src/components/Heading/index.d.ts +2 -0
- package/dist/src/components/Heading/index.d.ts.map +1 -0
- package/dist/src/components/Heading/index.js +21 -0
- package/dist/src/components/Heading/index.js.map +1 -0
- package/dist/src/components/Input/Input.d.ts +17 -0
- package/dist/src/components/Input/Input.d.ts.map +1 -0
- package/dist/src/components/Input/Input.js +70 -0
- package/dist/src/components/Input/Input.js.map +1 -0
- package/dist/src/components/Input/Input.stories.d.ts +23 -0
- package/dist/src/components/Input/Input.stories.d.ts.map +1 -0
- package/dist/src/components/Input/Input.stories.js +73 -0
- package/dist/src/components/Input/Input.stories.js.map +1 -0
- package/dist/src/components/Input/index.d.ts +2 -0
- package/dist/src/components/Input/index.d.ts.map +1 -0
- package/dist/src/components/Input/index.js +21 -0
- package/dist/src/components/Input/index.js.map +1 -0
- package/dist/src/components/Loading/Loading.d.ts +12 -0
- package/dist/src/components/Loading/Loading.d.ts.map +1 -0
- package/dist/src/components/Loading/Loading.js +29 -0
- package/dist/src/components/Loading/Loading.js.map +1 -0
- package/dist/src/components/Loading/Loading.stories.d.ts +25 -0
- package/dist/src/components/Loading/Loading.stories.d.ts.map +1 -0
- package/dist/src/components/Loading/Loading.stories.js +39 -0
- package/dist/src/components/Loading/Loading.stories.js.map +1 -0
- package/dist/src/components/Loading/index.d.ts +2 -0
- package/dist/src/components/Loading/index.d.ts.map +1 -0
- package/dist/src/components/Loading/index.js +21 -0
- package/dist/src/components/Loading/index.js.map +1 -0
- package/dist/src/components/NavMenu/NavMenu.d.ts +31 -0
- package/dist/src/components/NavMenu/NavMenu.d.ts.map +1 -0
- package/dist/src/components/NavMenu/NavMenu.js +71 -0
- package/dist/src/components/NavMenu/NavMenu.js.map +1 -0
- package/dist/src/components/NavMenu/NavMenu.stories.d.ts +9 -0
- package/dist/src/components/NavMenu/NavMenu.stories.d.ts.map +1 -0
- package/dist/src/components/NavMenu/NavMenu.stories.js +50 -0
- package/dist/src/components/NavMenu/NavMenu.stories.js.map +1 -0
- package/dist/src/components/NavMenu/index.d.ts +2 -0
- package/dist/src/components/NavMenu/index.d.ts.map +1 -0
- package/dist/src/components/NavMenu/index.js +21 -0
- package/dist/src/components/NavMenu/index.js.map +1 -0
- package/dist/src/components/Popover/Popover.d.ts +11 -0
- package/dist/src/components/Popover/Popover.d.ts.map +1 -0
- package/dist/src/components/Popover/Popover.js +56 -0
- package/dist/src/components/Popover/Popover.js.map +1 -0
- package/dist/src/components/Popover/Popover.stories.d.ts +10 -0
- package/dist/src/components/Popover/Popover.stories.d.ts.map +1 -0
- package/dist/src/components/Popover/Popover.stories.js +39 -0
- package/dist/src/components/Popover/Popover.stories.js.map +1 -0
- package/dist/src/components/Popover/index.d.ts +2 -0
- package/dist/src/components/Popover/index.d.ts.map +1 -0
- package/dist/src/components/Popover/index.js +21 -0
- package/dist/src/components/Popover/index.js.map +1 -0
- package/dist/src/components/QrCode/QrCode.d.ts +11 -0
- package/dist/src/components/QrCode/QrCode.d.ts.map +1 -0
- package/dist/src/components/QrCode/QrCode.js +51 -0
- package/dist/src/components/QrCode/QrCode.js.map +1 -0
- package/dist/src/components/QrCode/QrCode.stories.d.ts +9 -0
- package/dist/src/components/QrCode/QrCode.stories.d.ts.map +1 -0
- package/dist/src/components/QrCode/QrCode.stories.js +29 -0
- package/dist/src/components/QrCode/QrCode.stories.js.map +1 -0
- package/dist/src/components/QrCode/index.d.ts +2 -0
- package/dist/src/components/QrCode/index.d.ts.map +1 -0
- package/dist/src/components/QrCode/index.js +21 -0
- package/dist/src/components/QrCode/index.js.map +1 -0
- package/dist/src/components/Tag/Tag.d.ts +8 -0
- package/dist/src/components/Tag/Tag.d.ts.map +1 -0
- package/dist/src/components/Tag/Tag.js +23 -0
- package/dist/src/components/Tag/Tag.js.map +1 -0
- package/dist/src/components/Tag/Tag.stories.d.ts +10 -0
- package/dist/src/components/Tag/Tag.stories.d.ts.map +1 -0
- package/dist/src/components/Tag/Tag.stories.js +24 -0
- package/dist/src/components/Tag/Tag.stories.js.map +1 -0
- package/dist/src/components/Tag/index.d.ts +2 -0
- package/dist/src/components/Tag/index.d.ts.map +1 -0
- package/dist/src/components/Tag/index.js +21 -0
- package/dist/src/components/Tag/index.js.map +1 -0
- package/dist/src/components/Toast/Toast.d.ts +16 -0
- package/dist/src/components/Toast/Toast.d.ts.map +1 -0
- package/dist/src/components/Toast/Toast.js +54 -0
- package/dist/src/components/Toast/Toast.js.map +1 -0
- package/dist/src/components/Toast/Toast.stories.d.ts +9 -0
- package/dist/src/components/Toast/Toast.stories.d.ts.map +1 -0
- package/dist/src/components/Toast/Toast.stories.js +32 -0
- package/dist/src/components/Toast/Toast.stories.js.map +1 -0
- package/dist/src/components/Toast/index.d.ts +2 -0
- package/dist/src/components/Toast/index.d.ts.map +1 -0
- package/dist/src/components/Toast/index.js +21 -0
- package/dist/src/components/Toast/index.js.map +1 -0
- package/dist/src/components/Tooltip/Tooltip.d.ts +10 -0
- package/dist/src/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/src/components/Tooltip/Tooltip.js +50 -0
- package/dist/src/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/src/components/Tooltip/Tooltip.stories.d.ts +9 -0
- package/dist/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -0
- package/dist/src/components/Tooltip/Tooltip.stories.js +30 -0
- package/dist/src/components/Tooltip/Tooltip.stories.js.map +1 -0
- package/dist/src/components/Tooltip/index.d.ts +2 -0
- package/dist/src/components/Tooltip/index.d.ts.map +1 -0
- package/dist/src/components/Tooltip/index.js +21 -0
- package/dist/src/components/Tooltip/index.js.map +1 -0
- package/dist/src/components/UiProvider/UiProvider.d.ts +10 -0
- package/dist/src/components/UiProvider/UiProvider.d.ts.map +1 -0
- package/dist/src/components/UiProvider/UiProvider.js +21 -0
- package/dist/src/components/UiProvider/UiProvider.js.map +1 -0
- package/dist/src/components/UiProvider/index.d.ts +2 -0
- package/dist/src/components/UiProvider/index.d.ts.map +1 -0
- package/dist/src/components/UiProvider/index.js +21 -0
- package/dist/src/components/UiProvider/index.js.map +1 -0
- package/dist/src/components/index.d.ts +18 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +37 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/index.d.ts.map +1 -0
- package/dist/src/hooks/index.js +21 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/useId.d.ts +2 -0
- package/dist/src/hooks/useId.d.ts.map +1 -0
- package/dist/src/hooks/useId.js +19 -0
- package/dist/src/hooks/useId.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/plugin.d.ts +9 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +268 -0
- package/dist/src/plugin.js.map +1 -0
- package/dist/src/props/Elevation.d.ts +2 -0
- package/dist/src/props/Elevation.d.ts.map +1 -0
- package/dist/src/props/Elevation.js +6 -0
- package/dist/src/props/Elevation.js.map +1 -0
- package/dist/src/props/MessageValence.d.ts +2 -0
- package/dist/src/props/MessageValence.d.ts.map +1 -0
- package/dist/src/props/MessageValence.js +6 -0
- package/dist/src/props/MessageValence.js.map +1 -0
- package/dist/src/props/Size.d.ts +2 -0
- package/dist/src/props/Size.d.ts.map +1 -0
- package/dist/src/props/Size.js +6 -0
- package/dist/src/props/Size.js.map +1 -0
- package/dist/src/props/index.d.ts +4 -0
- package/dist/src/props/index.d.ts.map +1 -0
- package/dist/src/props/index.js +23 -0
- package/dist/src/props/index.js.map +1 -0
- package/dist/src/styles/active.d.ts +2 -0
- package/dist/src/styles/active.d.ts.map +1 -0
- package/dist/src/styles/active.js +12 -0
- package/dist/src/styles/active.js.map +1 -0
- package/dist/src/styles/disabled.d.ts +2 -0
- package/dist/src/styles/disabled.d.ts.map +1 -0
- package/dist/src/styles/disabled.js +8 -0
- package/dist/src/styles/disabled.js.map +1 -0
- package/dist/src/styles/focus.d.ts +2 -0
- package/dist/src/styles/focus.d.ts.map +1 -0
- package/dist/src/styles/focus.js +8 -0
- package/dist/src/styles/focus.js.map +1 -0
- package/dist/src/styles/group.d.ts +5 -0
- package/dist/src/styles/group.d.ts.map +1 -0
- package/dist/src/styles/group.js +26 -0
- package/dist/src/styles/group.js.map +1 -0
- package/dist/src/styles/hover.d.ts +4 -0
- package/dist/src/styles/hover.d.ts.map +1 -0
- package/dist/src/styles/hover.js +12 -0
- package/dist/src/styles/hover.js.map +1 -0
- package/dist/src/styles/index.d.ts +10 -0
- package/dist/src/styles/index.d.ts.map +1 -0
- package/dist/src/styles/index.js +29 -0
- package/dist/src/styles/index.js.map +1 -0
- package/dist/src/styles/ornament.d.ts +3 -0
- package/dist/src/styles/ornament.d.ts.map +1 -0
- package/dist/src/styles/ornament.js +9 -0
- package/dist/src/styles/ornament.js.map +1 -0
- package/dist/src/styles/size.d.ts +7 -0
- package/dist/src/styles/size.d.ts.map +1 -0
- package/dist/src/styles/size.js +89 -0
- package/dist/src/styles/size.js.map +1 -0
- package/dist/src/styles/text.d.ts +5 -0
- package/dist/src/styles/text.d.ts.map +1 -0
- package/dist/src/styles/text.js +11 -0
- package/dist/src/styles/text.js.map +1 -0
- package/dist/src/styles/valence.d.ts +19 -0
- package/dist/src/styles/valence.d.ts.map +1 -0
- package/dist/src/styles/valence.js +66 -0
- package/dist/src/styles/valence.js.map +1 -0
- package/dist/src/testing/index.d.ts +2 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +21 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/templateForComponent.d.ts +4 -0
- package/dist/src/testing/templateForComponent.d.ts.map +1 -0
- package/dist/src/testing/templateForComponent.js +18 -0
- package/dist/src/testing/templateForComponent.js.map +1 -0
- package/dist/src/theme.css +62 -0
- package/package.json +55 -0
- package/src/components/Alert/Alert.stories.tsx +31 -0
- package/src/components/Alert/Alert.tsx +34 -0
- package/src/components/Alert/index.ts +5 -0
- package/src/components/Avatar/Avatar.stories.tsx +29 -0
- package/src/components/Avatar/Avatar.tsx +82 -0
- package/src/components/Avatar/index.ts +5 -0
- package/src/components/Button/Button.stories.tsx +43 -0
- package/src/components/Button/Button.tsx +20 -0
- package/src/components/Button/ButtonProps.ts +10 -0
- package/src/components/Button/buttonStyles.ts +32 -0
- package/src/components/Button/index.ts +7 -0
- package/src/components/CompoundButton/CompoundButton.stories.tsx +46 -0
- package/src/components/CompoundButton/CompoundButton.tsx +53 -0
- package/src/components/CompoundButton/index.ts +5 -0
- package/src/components/Dialog/Dialog.stories.tsx +37 -0
- package/src/components/Dialog/Dialog.tsx +124 -0
- package/src/components/Dialog/index.ts +5 -0
- package/src/components/Group/Group.stories.tsx +25 -0
- package/src/components/Group/Group.tsx +48 -0
- package/src/components/Group/index.ts +5 -0
- package/src/components/Heading/Heading.stories.tsx +29 -0
- package/src/components/Heading/Heading.tsx +28 -0
- package/src/components/Heading/index.ts +5 -0
- package/src/components/Input/Input.stories.tsx +91 -0
- package/src/components/Input/Input.tsx +132 -0
- package/src/components/Input/index.ts +5 -0
- package/src/components/Loading/Loading.stories.tsx +34 -0
- package/src/components/Loading/Loading.tsx +59 -0
- package/src/components/Loading/index.ts +5 -0
- package/src/components/Main/Main.tsx +14 -0
- package/src/components/Main/index.ts +5 -0
- package/src/components/NavMenu/NavMenu.stories.tsx +54 -0
- package/src/components/NavMenu/NavMenu.tsx +180 -0
- package/src/components/NavMenu/index.ts +5 -0
- package/src/components/Popover/Popover.stories.tsx +45 -0
- package/src/components/Popover/Popover.tsx +76 -0
- package/src/components/Popover/index.ts +5 -0
- package/src/components/QrCode/QrCode.stories.tsx +27 -0
- package/src/components/QrCode/QrCode.tsx +42 -0
- package/src/components/QrCode/index.ts +5 -0
- package/src/components/Toast/Toast.stories.tsx +31 -0
- package/src/components/Toast/Toast.tsx +84 -0
- package/src/components/Toast/index.ts +5 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +28 -0
- package/src/components/Tooltip/Tooltip.tsx +57 -0
- package/src/components/Tooltip/index.ts +5 -0
- package/src/components/UiProvider/UiProvider.tsx +44 -0
- package/src/components/UiProvider/index.ts +5 -0
- package/src/components/index.ts +20 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useId.ts +21 -0
- package/src/index.ts +8 -0
- package/src/plugin.ts +270 -0
- package/src/props/MessageValence.ts +5 -0
- package/src/props/Size.ts +40 -0
- package/src/props/index.ts +6 -0
- package/src/styles/active.ts +11 -0
- package/src/styles/disabled.ts +5 -0
- package/src/styles/focus.ts +6 -0
- package/src/styles/hover.ts +10 -0
- package/src/styles/index.ts +11 -0
- package/src/styles/size.ts +87 -0
- package/src/styles/text.ts +10 -0
- package/src/styles/valence.ts +71 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/templateForComponent.tsx +16 -0
- package/src/theme.css +62 -0
- package/src/typings.d.ts +7 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import React, { ComponentProps, ReactNode } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useId } from '../../hooks';
|
|
9
|
+
import { MessageValence } from '../../props';
|
|
10
|
+
import { valenceAlertColors } from '../../styles';
|
|
11
|
+
|
|
12
|
+
export interface AlertProps extends Omit<ComponentProps<'div'>, 'title'> {
|
|
13
|
+
title: ReactNode;
|
|
14
|
+
assertive?: boolean;
|
|
15
|
+
valence?: MessageValence;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Alert = ({ title, children, assertive, valence, ...divProps }: AlertProps) => {
|
|
20
|
+
const labelId = useId('alertLabel');
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
role={assertive ? 'alert' : 'group'}
|
|
24
|
+
{...divProps}
|
|
25
|
+
className={cx('p-3 border rounded-md', valenceAlertColors(valence), divProps.className)}
|
|
26
|
+
aria-labelledby={labelId}
|
|
27
|
+
>
|
|
28
|
+
<p id={labelId} className='font-medium mb-2'>
|
|
29
|
+
{title}
|
|
30
|
+
</p>
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { templateForComponent } from '../../testing';
|
|
9
|
+
import { Avatar, AvatarProps } from './Avatar';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'react-ui/Avatar',
|
|
13
|
+
component: Avatar
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Template = ({ children, ...props }: AvatarProps) => {
|
|
17
|
+
return <Avatar {...props} />;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const defaultProps = {
|
|
21
|
+
fallbackValue: '',
|
|
22
|
+
label: <span />
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Default = templateForComponent(Template)(defaultProps);
|
|
26
|
+
Default.args = {
|
|
27
|
+
fallbackValue: '20970b563fc49b5bb194a6ffdff376031a3a11f9481360c071c3fed87874106b',
|
|
28
|
+
label: <span className='sr-only'>Hello</span>
|
|
29
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import { toSvg } from 'jdenticon';
|
|
8
|
+
import React, {
|
|
9
|
+
cloneElement,
|
|
10
|
+
ComponentProps,
|
|
11
|
+
ForwardedRef,
|
|
12
|
+
forwardRef,
|
|
13
|
+
PropsWithChildren,
|
|
14
|
+
ReactHTMLElement,
|
|
15
|
+
ReactNode,
|
|
16
|
+
useMemo
|
|
17
|
+
} from 'react';
|
|
18
|
+
|
|
19
|
+
import { useId } from '../../hooks';
|
|
20
|
+
import { Size } from '../../props';
|
|
21
|
+
import { getSize } from '../../styles';
|
|
22
|
+
|
|
23
|
+
export interface AvatarProps extends ComponentProps<typeof AvatarPrimitive.Root> {
|
|
24
|
+
fallbackValue: string;
|
|
25
|
+
label: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;
|
|
26
|
+
size?: Size;
|
|
27
|
+
variant?: 'square' | 'circle';
|
|
28
|
+
mediaSrc?: string;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const shapeStyles = {
|
|
33
|
+
circle: 'rounded-full',
|
|
34
|
+
square: 'rounded'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Avatar = forwardRef(
|
|
38
|
+
(
|
|
39
|
+
{ mediaSrc, fallbackValue, label, variant = 'square', size = 10, ...rootProps }: PropsWithChildren<AvatarProps>,
|
|
40
|
+
ref: ForwardedRef<HTMLSpanElement>
|
|
41
|
+
) => {
|
|
42
|
+
const labelId = useId('avatarLabel');
|
|
43
|
+
const imgSrc = useMemo(
|
|
44
|
+
() => `data:image/svg+xml;utf8,${encodeURIComponent(toSvg(fallbackValue, size === 'px' ? 1 : size * 4))}`,
|
|
45
|
+
[fallbackValue]
|
|
46
|
+
);
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<AvatarPrimitive.Root
|
|
50
|
+
{...rootProps}
|
|
51
|
+
className={cx('relative inline-flex', getSize(size), rootProps.className)}
|
|
52
|
+
aria-labelledby={labelId}
|
|
53
|
+
ref={ref}
|
|
54
|
+
>
|
|
55
|
+
{mediaSrc && (
|
|
56
|
+
<AvatarPrimitive.Image
|
|
57
|
+
src={mediaSrc}
|
|
58
|
+
alt='Avatar'
|
|
59
|
+
className={cx('h-full w-full object-cover overflow-hidden', shapeStyles[variant])}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
<AvatarPrimitive.Fallback
|
|
63
|
+
className={cx(
|
|
64
|
+
'flex h-full w-full items-center justify-center bg-white dark:bg-neutral-800 overflow-hidden',
|
|
65
|
+
shapeStyles[variant]
|
|
66
|
+
)}
|
|
67
|
+
delayMs={0}
|
|
68
|
+
>
|
|
69
|
+
<img role='none' alt={fallbackValue} src={imgSrc} className='h-full w-full' />
|
|
70
|
+
</AvatarPrimitive.Fallback>
|
|
71
|
+
</AvatarPrimitive.Root>
|
|
72
|
+
{typeof label === 'string' ? (
|
|
73
|
+
<span id={labelId} className='sr-only'>
|
|
74
|
+
{label}
|
|
75
|
+
</span>
|
|
76
|
+
) : (
|
|
77
|
+
cloneElement(label, { id: labelId })
|
|
78
|
+
)}
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
import React, { PropsWithChildren } from 'react';
|
|
7
|
+
|
|
8
|
+
import { templateForComponent } from '../../testing';
|
|
9
|
+
import { Group } from '../Group';
|
|
10
|
+
import { Button } from './Button';
|
|
11
|
+
import { ButtonProps } from './ButtonProps';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: 'react-ui/Button',
|
|
15
|
+
component: Button
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Container = ({ children }: PropsWithChildren<{}>) => (
|
|
19
|
+
<>
|
|
20
|
+
<Group label={{ children: null }} elevation={0} className='flex gap-4 px-1 mb-4'>
|
|
21
|
+
{children}
|
|
22
|
+
</Group>
|
|
23
|
+
<Group label={{ children: null }} elevation={5} className='flex gap-4 px-1'>
|
|
24
|
+
{children}
|
|
25
|
+
</Group>
|
|
26
|
+
</>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const Template = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => (
|
|
30
|
+
<Container>
|
|
31
|
+
<Button {...args}>{children}</Button>
|
|
32
|
+
<Button {...args} disabled>
|
|
33
|
+
Disabled
|
|
34
|
+
</Button>
|
|
35
|
+
</Container>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export const Default = templateForComponent(Template)({});
|
|
39
|
+
Default.args = { children: 'Hello', disabled: false, variant: 'default' };
|
|
40
|
+
|
|
41
|
+
export const Primary = () => <Template {...{ variant: 'primary', children: 'Hello' }} />;
|
|
42
|
+
|
|
43
|
+
export const Outline = () => <Template {...{ variant: 'outline', children: 'Hello' }} />;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import React, { forwardRef } from 'react';
|
|
7
|
+
|
|
8
|
+
import { ButtonProps } from './ButtonProps';
|
|
9
|
+
import { buttonStyles } from './buttonStyles';
|
|
10
|
+
|
|
11
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(({ children, ...props }, ref) => (
|
|
12
|
+
<button
|
|
13
|
+
ref={ref}
|
|
14
|
+
{...props}
|
|
15
|
+
className={cx(buttonStyles(props), props.className)}
|
|
16
|
+
{...(props.disabled && { disabled: true })}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</button>
|
|
20
|
+
));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
|
|
7
|
+
import { defaultDisabled, defaultFocus, defaultHover, defaultActive } from '../../styles';
|
|
8
|
+
import { ButtonProps } from './ButtonProps';
|
|
9
|
+
|
|
10
|
+
export const primaryButtonColors = 'bg-primary-600 text-white hover:bg-primary-650';
|
|
11
|
+
export const defaultButtonColors = 'bg-white text-neutral-900 dark:bg-neutral-750 dark:text-neutral-50';
|
|
12
|
+
|
|
13
|
+
export const buttonStyles = (props: ButtonProps) => {
|
|
14
|
+
const resolvedVariant = props.variant || 'default';
|
|
15
|
+
return cx(
|
|
16
|
+
'inline-flex select-none items-center justify-center rounded-md px-4 py-2 text-sm font-medium',
|
|
17
|
+
'transition-color duration-100',
|
|
18
|
+
defaultHover(props),
|
|
19
|
+
resolvedVariant === 'default' &&
|
|
20
|
+
'border border-neutral-100 dark:border-neutral-650 hover:focus:border-neutral-100 hover:border-transparent',
|
|
21
|
+
resolvedVariant === 'default' && defaultButtonColors,
|
|
22
|
+
resolvedVariant === 'primary' && 'border border-primary-550 hover:border-transparent',
|
|
23
|
+
resolvedVariant === 'primary' && primaryButtonColors,
|
|
24
|
+
resolvedVariant === 'outline' &&
|
|
25
|
+
'text-neutral-700 border border-neutral-600 font-medium rounded-lg text-sm text-center dark:border-neutral-300 dark:text-neutral-150',
|
|
26
|
+
defaultFocus,
|
|
27
|
+
props.disabled ? defaultDisabled : resolvedVariant !== 'outline' && 'button-elevation',
|
|
28
|
+
// Register all radix states
|
|
29
|
+
'group',
|
|
30
|
+
defaultActive
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
import { ArrowRight, ClockCounterClockwise } from 'phosphor-react';
|
|
7
|
+
import React, { PropsWithChildren } from 'react';
|
|
8
|
+
|
|
9
|
+
import { templateForComponent } from '../../testing';
|
|
10
|
+
import { CompoundButton, CompoundButtonProps } from './CompoundButton';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'react-ui/CompoundButton',
|
|
14
|
+
component: CompoundButton
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const Container = ({ children }: PropsWithChildren<{}>) => <div className='flex gap-4'>{children}</div>;
|
|
18
|
+
|
|
19
|
+
const Template = ({ ...args }: Omit<CompoundButtonProps, 'ref'>) => (
|
|
20
|
+
<Container>
|
|
21
|
+
<CompoundButton {...args} />
|
|
22
|
+
<CompoundButton {...args} disabled />
|
|
23
|
+
</Container>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const Default = templateForComponent(Template)({});
|
|
27
|
+
Default.args = {
|
|
28
|
+
children: 'Hello',
|
|
29
|
+
description: 'This is a compound button',
|
|
30
|
+
before: <ClockCounterClockwise className='w-5 h-5' />,
|
|
31
|
+
after: <ArrowRight className='w-5 h-5' />,
|
|
32
|
+
disabled: false
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Primary = () => (
|
|
36
|
+
<Template
|
|
37
|
+
{...{
|
|
38
|
+
children: 'Hello',
|
|
39
|
+
description: 'This is a compound button',
|
|
40
|
+
before: <ClockCounterClockwise className='w-5 h-5' />,
|
|
41
|
+
after: <ArrowRight className='w-5 h-5' />,
|
|
42
|
+
disabled: false,
|
|
43
|
+
variant: 'primary'
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import React, { ReactNode } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useId } from '../../hooks';
|
|
9
|
+
import { defaultDescription, primaryDescription } from '../../styles';
|
|
10
|
+
import { ButtonProps, buttonStyles } from '../Button';
|
|
11
|
+
|
|
12
|
+
export interface CompoundButtonProps extends ButtonProps {
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
description?: ReactNode;
|
|
15
|
+
before?: ReactNode;
|
|
16
|
+
after?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const CompoundButton = ({ children, description, before, after, ...buttonProps }: CompoundButtonProps) => {
|
|
20
|
+
const variant = buttonProps.variant || 'default';
|
|
21
|
+
const labelId = useId('compoundButton-label');
|
|
22
|
+
const descriptionId = useId('compoundButton-description');
|
|
23
|
+
return (
|
|
24
|
+
<button
|
|
25
|
+
{...buttonProps}
|
|
26
|
+
className={cx(buttonStyles(buttonProps), 'flex items-center gap-4 py-2.5', buttonProps.className)}
|
|
27
|
+
aria-labelledby={labelId}
|
|
28
|
+
{...(description && { 'aria-describedby': descriptionId })}
|
|
29
|
+
>
|
|
30
|
+
{before && (
|
|
31
|
+
<div role='none' className='grow-0'>
|
|
32
|
+
{before}
|
|
33
|
+
</div>
|
|
34
|
+
)}
|
|
35
|
+
<div role='none' className='grow flex flex-col gap-1 text-left'>
|
|
36
|
+
<p id={labelId}>{children}</p>
|
|
37
|
+
{description && (
|
|
38
|
+
<p
|
|
39
|
+
id={descriptionId}
|
|
40
|
+
className={cx('text-xs font-normal mb-1', variant === 'primary' ? primaryDescription : defaultDescription)}
|
|
41
|
+
>
|
|
42
|
+
{description}
|
|
43
|
+
</p>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
{after && (
|
|
47
|
+
<div role='none' className='grow-0'>
|
|
48
|
+
{after}
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
51
|
+
</button>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { templateForComponent } from '../../testing';
|
|
9
|
+
import { Button } from '../Button';
|
|
10
|
+
import { Dialog, DialogProps } from './Dialog';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'react-ui/Dialog',
|
|
14
|
+
component: Dialog
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const Template = ({ children, ...props }: DialogProps) => {
|
|
18
|
+
return <Dialog {...props}>{children}</Dialog>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const Default = templateForComponent(Template)({
|
|
22
|
+
openTrigger: '',
|
|
23
|
+
title: '',
|
|
24
|
+
closeTriggers: ['']
|
|
25
|
+
});
|
|
26
|
+
Default.args = {
|
|
27
|
+
openTrigger: <Button>Open dialog</Button>,
|
|
28
|
+
closeTriggers: [
|
|
29
|
+
<Button key='cancel'>Close trigger 1</Button>,
|
|
30
|
+
<Button key='save' variant='primary'>
|
|
31
|
+
Close trigger 2
|
|
32
|
+
</Button>
|
|
33
|
+
],
|
|
34
|
+
title: 'Dialog title',
|
|
35
|
+
children: 'Dialog content',
|
|
36
|
+
closeLabel: 'Close'
|
|
37
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Transition } from '@headlessui/react';
|
|
6
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
7
|
+
import cx from 'classnames';
|
|
8
|
+
import { X } from 'phosphor-react';
|
|
9
|
+
import React, { Fragment, ReactNode, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
import { defaultDescription, defaultFocus, defaultHover } from '../../styles';
|
|
12
|
+
import { Tooltip } from '../Tooltip';
|
|
13
|
+
|
|
14
|
+
export interface DialogProps {
|
|
15
|
+
title: ReactNode;
|
|
16
|
+
openTrigger?: ReactNode;
|
|
17
|
+
closeTriggers?: [ReactNode, ...ReactNode[]];
|
|
18
|
+
titleVisuallyHidden?: boolean;
|
|
19
|
+
description?: ReactNode;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
closeLabel?: string;
|
|
22
|
+
initiallyOpen?: boolean;
|
|
23
|
+
mountAsSibling?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const Dialog = ({
|
|
27
|
+
title,
|
|
28
|
+
titleVisuallyHidden,
|
|
29
|
+
description,
|
|
30
|
+
openTrigger,
|
|
31
|
+
children,
|
|
32
|
+
closeTriggers,
|
|
33
|
+
closeLabel,
|
|
34
|
+
initiallyOpen,
|
|
35
|
+
mountAsSibling
|
|
36
|
+
}: DialogProps) => {
|
|
37
|
+
const [isOpen, setIsOpen] = useState(!!initiallyOpen);
|
|
38
|
+
|
|
39
|
+
const dialogOverlayAndContent = (
|
|
40
|
+
<Transition.Root show={isOpen}>
|
|
41
|
+
<Transition.Child
|
|
42
|
+
as={Fragment}
|
|
43
|
+
enter='ease-out duration-300'
|
|
44
|
+
enterFrom='opacity-0'
|
|
45
|
+
enterTo='opacity-100'
|
|
46
|
+
leave='ease-in duration-200'
|
|
47
|
+
leaveFrom='opacity-100'
|
|
48
|
+
leaveTo='opacity-0'
|
|
49
|
+
>
|
|
50
|
+
<DialogPrimitive.Overlay forceMount className='fixed inset-0 z-20 bg-black/50' />
|
|
51
|
+
</Transition.Child>
|
|
52
|
+
<Transition.Child
|
|
53
|
+
as={Fragment}
|
|
54
|
+
enter='ease-out duration-300'
|
|
55
|
+
enterFrom='opacity-0 scale-95'
|
|
56
|
+
enterTo='opacity-100 scale-100'
|
|
57
|
+
leave='ease-in duration-200'
|
|
58
|
+
leaveFrom='opacity-100 scale-100'
|
|
59
|
+
leaveTo='opacity-0 scale-95'
|
|
60
|
+
>
|
|
61
|
+
<DialogPrimitive.Content
|
|
62
|
+
forceMount
|
|
63
|
+
className={cx(
|
|
64
|
+
'fixed z-50',
|
|
65
|
+
'w-[95vw] max-w-md rounded-xl p-4 md:w-full',
|
|
66
|
+
'top-[50%] left-[50%] -translate-x-[50%] -translate-y-[50%]',
|
|
67
|
+
'shadow-2xl bg-white dark:bg-neutral-800 elevated-buttons',
|
|
68
|
+
defaultFocus
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
<DialogPrimitive.Title
|
|
72
|
+
className={cx(
|
|
73
|
+
'text-2xl font-display font-medium text-neutral-900 dark:text-neutral-100 rounded-md',
|
|
74
|
+
titleVisuallyHidden && 'sr-only',
|
|
75
|
+
defaultFocus
|
|
76
|
+
)}
|
|
77
|
+
tabIndex={0}
|
|
78
|
+
>
|
|
79
|
+
{title}
|
|
80
|
+
</DialogPrimitive.Title>
|
|
81
|
+
{description && (
|
|
82
|
+
<DialogPrimitive.Description className={cx('mt-2', defaultDescription)}>
|
|
83
|
+
{description}
|
|
84
|
+
</DialogPrimitive.Description>
|
|
85
|
+
)}
|
|
86
|
+
|
|
87
|
+
{children}
|
|
88
|
+
|
|
89
|
+
{closeLabel && (
|
|
90
|
+
<Tooltip content={closeLabel}>
|
|
91
|
+
<DialogPrimitive.Close
|
|
92
|
+
className={cx(
|
|
93
|
+
'absolute top-3.5 right-3.5 inline-flex items-center justify-center rounded-sm p-1',
|
|
94
|
+
defaultFocus,
|
|
95
|
+
defaultHover({})
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
<X className='h-4 w-4 text-neutral-500 hover:text-neutral-700 dark:text-neutral-500 dark:hover:text-neutral-400' />
|
|
99
|
+
</DialogPrimitive.Close>
|
|
100
|
+
</Tooltip>
|
|
101
|
+
)}
|
|
102
|
+
{closeTriggers && (
|
|
103
|
+
<div className='flex flex-wrap justify-end gap-4'>
|
|
104
|
+
{closeTriggers.map((closeTrigger, key) => (
|
|
105
|
+
<DialogPrimitive.Close key={key}>{closeTrigger}</DialogPrimitive.Close>
|
|
106
|
+
))}
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
</DialogPrimitive.Content>
|
|
110
|
+
</Transition.Child>
|
|
111
|
+
</Transition.Root>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<DialogPrimitive.Root open={isOpen} onOpenChange={setIsOpen}>
|
|
116
|
+
{openTrigger && <DialogPrimitive.Trigger asChild>{openTrigger}</DialogPrimitive.Trigger>}
|
|
117
|
+
{mountAsSibling ? (
|
|
118
|
+
dialogOverlayAndContent
|
|
119
|
+
) : (
|
|
120
|
+
<DialogPrimitive.Portal>{dialogOverlayAndContent}</DialogPrimitive.Portal>
|
|
121
|
+
)}
|
|
122
|
+
</DialogPrimitive.Root>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { templateForComponent } from '../../testing';
|
|
9
|
+
import { Group, GroupProps } from './Group';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'react-ui/Group',
|
|
13
|
+
component: Group
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Template = ({ children, ...props }: GroupProps) => {
|
|
17
|
+
return <Group {...props}>{children}</Group>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Default = templateForComponent(Template)({ label: {} });
|
|
21
|
+
Default.args = {
|
|
22
|
+
label: { level: 3, children: 'Hello' },
|
|
23
|
+
children: 'This is a group.',
|
|
24
|
+
elevation: 3
|
|
25
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import React, { ReactNode } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useId } from '../../hooks';
|
|
9
|
+
import { Heading, HeadingProps } from '../Heading';
|
|
10
|
+
|
|
11
|
+
export interface GroupProps extends React.ComponentProps<'div'> {
|
|
12
|
+
label: HeadingProps;
|
|
13
|
+
labelVisuallyHidden?: boolean;
|
|
14
|
+
elevation?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const elevationClassNameMap = new Map<number, string>([
|
|
19
|
+
[0, 'shadow-none'],
|
|
20
|
+
[1, 'shadow-sm'],
|
|
21
|
+
[2, 'shadow'],
|
|
22
|
+
[3, 'shadow-md'],
|
|
23
|
+
[4, 'shadow-lg'],
|
|
24
|
+
[5, 'shadow-xl'],
|
|
25
|
+
[6, 'shadow-2xl']
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
export const Group = ({ elevation, children, label, labelVisuallyHidden, className, ...props }: GroupProps) => {
|
|
29
|
+
const labelId = useId('groupLabel');
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
role='group'
|
|
33
|
+
aria-labelledby={labelId}
|
|
34
|
+
className={cx(
|
|
35
|
+
'rounded-lg p-4',
|
|
36
|
+
elevation === 0
|
|
37
|
+
? 'bg-transparent border border-neutral-200 dark:border-neutral-700'
|
|
38
|
+
: 'bg-white dark:bg-neutral-800 elevated-buttons',
|
|
39
|
+
elevationClassNameMap.get(typeof elevation === 'undefined' ? 3 : elevation),
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
<Heading {...label} id={labelId} className={cx(labelVisuallyHidden && 'sr-only', 'mb-2', label?.className)} />
|
|
45
|
+
{children}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { templateForComponent } from '../../testing';
|
|
9
|
+
import { Heading, HeadingProps } from './Heading';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'react-ui/Heading',
|
|
13
|
+
component: Heading
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Template = ({ children, ...props }: HeadingProps) => {
|
|
17
|
+
return <Heading {...props}>{children}</Heading>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const defaultProps = { level: 1 as const };
|
|
21
|
+
|
|
22
|
+
export const Default = templateForComponent(Template)(defaultProps);
|
|
23
|
+
Default.args = { level: 1, children: 'Hello' };
|
|
24
|
+
|
|
25
|
+
export const Level2 = () => <Template level={2}>Hello</Template>;
|
|
26
|
+
export const Level3 = () => <Template level={3}>Hello</Template>;
|
|
27
|
+
export const Level4 = () => <Template level={4}>Hello</Template>;
|
|
28
|
+
export const Level5 = () => <Template level={5}>Hello</Template>;
|
|
29
|
+
export const Level6 = () => <Template level={6}>Hello</Template>;
|