@dxos/react-ui 0.8.4-main.1da679c → 0.8.4-main.21d9917
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/dist/lib/browser/chunk-CEKVHJ27.mjs +774 -0
- package/dist/lib/browser/chunk-CEKVHJ27.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3068 -61
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +65 -49
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-2NHEX4AD.mjs +776 -0
- package/dist/lib/node-esm/chunk-2NHEX4AD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3068 -61
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +65 -49
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +0 -6
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +0 -6
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts +0 -6
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Buttons → Button}/Button.d.ts +2 -2
- package/dist/types/src/components/Button/Button.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/Button.stories.d.ts +1 -7
- package/dist/types/src/components/Button/Button.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/IconButton.d.ts +2 -2
- package/dist/types/src/components/Button/IconButton.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/IconButton.stories.d.ts +0 -6
- package/dist/types/src/components/Button/IconButton.stories.d.ts.map +1 -0
- package/dist/types/src/components/Button/Toggle.d.ts.map +1 -0
- package/dist/types/src/components/Button/Toggle.stories.d.ts +16 -0
- package/dist/types/src/components/Button/Toggle.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/ToggleGroup.d.ts +6 -10
- package/dist/types/src/components/Button/ToggleGroup.d.ts.map +1 -0
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts +27 -0
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts.map +1 -0
- package/dist/types/src/components/Button/index.d.ts.map +1 -0
- package/dist/types/src/components/Clipboard/CopyButton.d.ts +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.d.ts.map +1 -0
- package/dist/types/src/components/{Dialogs → Dialog}/AlertDialog.stories.d.ts +0 -6
- package/dist/types/src/components/Dialog/AlertDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts +40 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/types/src/components/{Dialogs → Dialog}/Dialog.stories.d.ts +7 -6
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/index.d.ts.map +1 -0
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts +2 -2
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.stories.d.ts +17 -0
- package/dist/types/src/components/Icon/Icon.stories.d.ts.map +1 -0
- package/dist/types/src/components/Input/Input.d.ts +5 -4
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +1 -7
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Link/Link.stories.d.ts +0 -6
- package/dist/types/src/components/Link/Link.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Lists → List}/List.d.ts +1 -1
- package/dist/types/src/components/List/List.d.ts.map +1 -0
- package/dist/types/src/components/{Lists → List}/List.stories.d.ts +0 -6
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -0
- package/dist/types/src/components/List/ListDropIndicator.d.ts.map +1 -0
- package/dist/types/src/components/List/Tree.d.ts.map +1 -0
- package/dist/types/src/components/{Lists → List}/Tree.stories.d.ts +0 -6
- package/dist/types/src/components/List/Tree.stories.d.ts.map +1 -0
- package/dist/types/src/components/List/TreeDropIndicator.d.ts.map +1 -0
- package/dist/types/src/components/{Lists → List}/Treegrid.d.ts.map +1 -1
- package/dist/types/src/components/List/Treegrid.stories.d.ts.map +1 -0
- package/dist/types/src/components/List/index.d.ts.map +1 -0
- package/dist/types/src/components/Main/Main.d.ts +9 -18
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +1 -2
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Menus → Menu}/ContextMenu.d.ts +6 -6
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/ContextMenu.stories.d.ts +0 -6
- package/dist/types/src/components/Menu/ContextMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/DropdownMenu.d.ts +4 -5
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/DropdownMenu.stories.d.ts +0 -6
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/Menu/index.d.ts.map +1 -0
- package/dist/types/src/components/Message/Message.d.ts +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +1 -2
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +2 -2
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +0 -6
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +9 -7
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +2 -4
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +39 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +19 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScrollContainer/index.d.ts +2 -0
- package/dist/types/src/components/ScrollContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/Select/Select.d.ts +10 -10
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +0 -6
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Separator/Separator.d.ts +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts +0 -6
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.stories.d.ts +8 -8
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +1 -2
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -8
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts +2 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +4 -4
- package/dist/types/src/components/Toast/Toast.stories.d.ts +0 -6
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +17 -17
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +0 -6
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +1 -3
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +0 -6
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeArea.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisualViewport.d.ts +2 -2
- package/dist/types/src/hooks/useVisualViewport.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +0 -6
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts +1 -2
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts +0 -6
- package/dist/types/src/playground/Typography.stories.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/index.d.ts +2 -1
- package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayout.d.ts +15 -0
- package/dist/types/src/testing/decorators/withLayout.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts +12 -0
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withTheme.d.ts +3 -0
- package/dist/types/src/testing/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/usePx.d.ts +8 -0
- package/dist/types/src/util/usePx.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -27
- package/src/components/Avatars/Avatar.stories.tsx +2 -4
- package/src/components/Avatars/Avatar.tsx +1 -1
- package/src/components/Avatars/AvatarGroup.stories.tsx +0 -3
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -4
- package/src/components/{Buttons → Button}/Button.stories.tsx +3 -5
- package/src/components/{Buttons → Button}/Button.tsx +1 -1
- package/src/components/{Buttons → Button}/IconButton.stories.tsx +0 -3
- package/src/components/{Buttons → Button}/IconButton.tsx +19 -13
- package/src/components/{Buttons → Button}/Toggle.stories.tsx +5 -7
- package/src/components/{Buttons → Button}/ToggleGroup.stories.tsx +0 -3
- package/src/components/Clipboard/CopyButton.tsx +4 -4
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/{Dialogs → Dialog}/AlertDialog.stories.tsx +1 -4
- package/src/components/Dialog/Dialog.stories.tsx +97 -0
- package/src/components/{Dialogs → Dialog}/Dialog.tsx +140 -40
- package/src/components/ElevationProvider/ElevationProvider.tsx +1 -1
- package/src/components/Icon/Icon.stories.tsx +113 -0
- package/src/components/Icon/Icon.tsx +2 -2
- package/src/components/Input/Input.stories.tsx +2 -5
- package/src/components/Input/Input.tsx +16 -7
- package/src/components/Link/Link.stories.tsx +0 -3
- package/src/components/{Lists → List}/List.stories.tsx +18 -18
- package/src/components/{Lists → List}/List.tsx +1 -1
- package/src/components/{Lists → List}/ListDropIndicator.tsx +1 -1
- package/src/components/{Lists → List}/Tree.stories.tsx +0 -3
- package/src/components/{Lists → List}/Treegrid.tsx +57 -16
- package/src/components/Main/Main.stories.tsx +4 -4
- package/src/components/Main/Main.tsx +28 -19
- package/src/components/{Menus → Menu}/ContextMenu.stories.tsx +0 -3
- package/src/components/{Menus → Menu}/DropdownMenu.stories.tsx +1 -4
- package/src/components/{Menus → Menu}/DropdownMenu.tsx +81 -60
- package/src/components/Message/Message.stories.tsx +1 -3
- package/src/components/Message/Message.tsx +30 -5
- package/src/components/Popover/Popover.stories.tsx +1 -4
- package/src/components/Popover/Popover.tsx +57 -38
- package/src/components/ScrollArea/ScrollArea.stories.tsx +54 -7
- package/src/components/ScrollArea/ScrollArea.tsx +50 -4
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +70 -0
- package/src/components/ScrollContainer/ScrollContainer.tsx +233 -0
- package/src/components/ScrollContainer/index.ts +5 -0
- package/src/components/Select/Select.stories.tsx +3 -5
- package/src/components/Select/Select.tsx +4 -4
- package/src/components/Status/Status.stories.tsx +0 -3
- package/src/components/Tag/Tag.stories.tsx +10 -9
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +1 -3
- package/src/components/ThemeProvider/TranslationsProvider.tsx +1 -16
- package/src/components/ThemeProvider/index.ts +3 -3
- package/src/components/Toast/Toast.stories.tsx +1 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -7
- package/src/components/Toolbar/Toolbar.tsx +34 -8
- package/src/components/Tooltip/Tooltip.stories.tsx +1 -4
- package/src/components/Tooltip/Tooltip.tsx +24 -21
- package/src/components/index.ts +5 -4
- package/src/hooks/useDensityContext.ts +1 -1
- package/src/hooks/useElevationContext.ts +1 -1
- package/src/hooks/useSafeArea.ts +3 -2
- package/src/hooks/useVisualViewport.ts +4 -4
- package/src/index.ts +1 -1
- package/src/playground/Controls.stories.tsx +3 -5
- package/src/playground/Custom.stories.tsx +9 -20
- package/src/playground/Typography.stories.tsx +0 -3
- package/src/testing/decorators/index.ts +2 -1
- package/src/testing/decorators/withLayout.tsx +63 -0
- package/src/testing/decorators/{withSurfaceVariantsLayout.tsx → withLayoutVariants.tsx} +5 -5
- package/src/testing/decorators/withTheme.tsx +32 -0
- package/src/util/index.ts +3 -1
- package/src/util/usePx.ts +61 -0
- package/dist/lib/browser/chunk-Y4PW3CX2.mjs +0 -4402
- package/dist/lib/browser/chunk-Y4PW3CX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L6LIOSFT.mjs +0 -4404
- package/dist/lib/node-esm/chunk-L6LIOSFT.mjs.map +0 -7
- package/dist/types/src/components/Buttons/Button.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/IconButton.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/Toggle.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts +0 -19
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/ToggleGroup.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +0 -37
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/index.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/AlertDialog.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/Dialog.d.ts +0 -31
- package/dist/types/src/components/Dialogs/Dialog.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/index.d.ts.map +0 -1
- package/dist/types/src/components/Lists/List.d.ts.map +0 -1
- package/dist/types/src/components/Lists/List.stories.d.ts.map +0 -1
- package/dist/types/src/components/Lists/ListDropIndicator.d.ts.map +0 -1
- package/dist/types/src/components/Lists/Tree.d.ts.map +0 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +0 -1
- package/dist/types/src/components/Lists/TreeDropIndicator.d.ts.map +0 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +0 -1
- package/dist/types/src/components/Lists/index.d.ts.map +0 -1
- package/dist/types/src/components/Menus/ContextMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/Menus/index.d.ts.map +0 -1
- package/dist/types/src/testing/decorators/withSurfaceVariantsLayout.d.ts +0 -12
- package/dist/types/src/testing/decorators/withSurfaceVariantsLayout.d.ts.map +0 -1
- package/dist/types/src/util/ThemedClassName.d.ts +0 -5
- package/dist/types/src/util/ThemedClassName.d.ts.map +0 -1
- package/src/components/Dialogs/Dialog.stories.tsx +0 -65
- package/src/testing/decorators/withTheme.ts +0 -25
- package/src/util/ThemedClassName.ts +0 -7
- /package/dist/types/src/components/{Buttons → Button}/Toggle.d.ts +0 -0
- /package/dist/types/src/components/{Buttons → Button}/index.d.ts +0 -0
- /package/dist/types/src/components/{Dialogs → Dialog}/AlertDialog.d.ts +0 -0
- /package/dist/types/src/components/{Dialogs → Dialog}/index.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/ListDropIndicator.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/Tree.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/TreeDropIndicator.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/Treegrid.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/Treegrid.stories.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/index.d.ts +0 -0
- /package/dist/types/src/components/{Menus → Menu}/index.d.ts +0 -0
- /package/src/components/{Buttons → Button}/Toggle.tsx +0 -0
- /package/src/components/{Buttons → Button}/ToggleGroup.tsx +0 -0
- /package/src/components/{Buttons → Button}/index.ts +0 -0
- /package/src/components/{Dialogs → Dialog}/AlertDialog.tsx +0 -0
- /package/src/components/{Dialogs → Dialog}/index.ts +0 -0
- /package/src/components/{Lists → List}/Tree.tsx +0 -0
- /package/src/components/{Lists → List}/TreeDropIndicator.tsx +0 -0
- /package/src/components/{Lists → List}/Treegrid.stories.tsx +0 -0
- /package/src/components/{Lists → List}/index.ts +0 -0
- /package/src/components/{Menus → Menu}/ContextMenu.tsx +0 -0
- /package/src/components/{Menus → Menu}/index.ts +0 -0
|
@@ -25,6 +25,7 @@ import React, {
|
|
|
25
25
|
type FC,
|
|
26
26
|
type MutableRefObject,
|
|
27
27
|
type ReactNode,
|
|
28
|
+
type RefObject,
|
|
28
29
|
type SyntheticEvent,
|
|
29
30
|
forwardRef,
|
|
30
31
|
useCallback,
|
|
@@ -40,9 +41,9 @@ type TooltipScopedProps<P = {}> = P & { __scopeTooltip?: Scope };
|
|
|
40
41
|
const [createTooltipContext, createTooltipScope] = createContextScope('Tooltip', [createPopperScope]);
|
|
41
42
|
const usePopperScope = createPopperScope();
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
//
|
|
45
|
+
// Tooltip
|
|
46
|
+
//
|
|
46
47
|
|
|
47
48
|
const DEFAULT_DELAY_DURATION = 700;
|
|
48
49
|
const TOOLTIP_OPEN = 'tooltip.open';
|
|
@@ -218,7 +219,7 @@ const TooltipProvider: FC<TooltipProviderProps> = (props: TooltipScopedProps<Too
|
|
|
218
219
|
{content}
|
|
219
220
|
<TooltipArrow className={tx('tooltip.arrow', 'tooltip__arrow')} />
|
|
220
221
|
</TooltipContent>
|
|
221
|
-
<TooltipVirtualTrigger virtualRef={triggerRef} />
|
|
222
|
+
<TooltipVirtualTrigger virtualRef={triggerRef as RefObject<HTMLButtonElement>} />
|
|
222
223
|
{children}
|
|
223
224
|
</TooltipContextProvider>
|
|
224
225
|
</PopperPrimitive.Root>
|
|
@@ -227,9 +228,9 @@ const TooltipProvider: FC<TooltipProviderProps> = (props: TooltipScopedProps<Too
|
|
|
227
228
|
|
|
228
229
|
TooltipProvider.displayName = TOOLTIP_NAME;
|
|
229
230
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
//
|
|
232
|
+
// TooltipVirtualTrigger
|
|
233
|
+
//
|
|
233
234
|
|
|
234
235
|
const TooltipVirtualTrigger = ({
|
|
235
236
|
virtualRef,
|
|
@@ -239,9 +240,9 @@ const TooltipVirtualTrigger = ({
|
|
|
239
240
|
return <PopperPrimitive.Anchor asChild {...popperScope} virtualRef={virtualRef} />;
|
|
240
241
|
};
|
|
241
242
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
//
|
|
244
|
+
// TooltipTrigger
|
|
245
|
+
//
|
|
245
246
|
|
|
246
247
|
const TRIGGER_NAME = 'TooltipTrigger';
|
|
247
248
|
|
|
@@ -321,9 +322,9 @@ const TooltipTrigger = forwardRef<TooltipTriggerElement, TooltipTriggerProps>(
|
|
|
321
322
|
|
|
322
323
|
TooltipTrigger.displayName = TRIGGER_NAME;
|
|
323
324
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
//
|
|
326
|
+
// TooltipPortal
|
|
327
|
+
//
|
|
327
328
|
|
|
328
329
|
const PORTAL_NAME = 'TooltipPortal';
|
|
329
330
|
|
|
@@ -362,9 +363,9 @@ const TooltipPortal: FC<TooltipPortalProps> = (props: TooltipScopedProps<Tooltip
|
|
|
362
363
|
|
|
363
364
|
TooltipPortal.displayName = PORTAL_NAME;
|
|
364
365
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
//
|
|
367
|
+
// TooltipContent
|
|
368
|
+
//
|
|
368
369
|
|
|
369
370
|
const CONTENT_NAME = 'TooltipContent';
|
|
370
371
|
|
|
@@ -573,9 +574,9 @@ const TooltipContentImpl = forwardRef<TooltipContentImplElement, TooltipContentI
|
|
|
573
574
|
|
|
574
575
|
TooltipContent.displayName = CONTENT_NAME;
|
|
575
576
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
577
|
+
//
|
|
578
|
+
// TooltipArrow
|
|
579
|
+
//
|
|
579
580
|
|
|
580
581
|
const ARROW_NAME = 'TooltipArrow';
|
|
581
582
|
|
|
@@ -598,8 +599,6 @@ const TooltipArrow = forwardRef<TooltipArrowElement, TooltipArrowProps>(
|
|
|
598
599
|
|
|
599
600
|
TooltipArrow.displayName = ARROW_NAME;
|
|
600
601
|
|
|
601
|
-
/* ----------------------------------------------------------------------------------------------- */
|
|
602
|
-
|
|
603
602
|
type TooltipSide = NonNullable<TooltipContentProps['side']>;
|
|
604
603
|
|
|
605
604
|
const getExitSideFromRect = (point: Point, rect: DOMRect): TooltipSide => {
|
|
@@ -754,6 +753,10 @@ const getHullPresorted = <P extends Point>(points: Readonly<Array<P>>): Array<P>
|
|
|
754
753
|
}
|
|
755
754
|
};
|
|
756
755
|
|
|
756
|
+
//
|
|
757
|
+
// Tooltip
|
|
758
|
+
//
|
|
759
|
+
|
|
757
760
|
export const Tooltip = {
|
|
758
761
|
Provider: TooltipProvider,
|
|
759
762
|
Trigger: TooltipTrigger,
|
package/src/components/index.ts
CHANGED
|
@@ -5,19 +5,20 @@
|
|
|
5
5
|
export * from './AnchoredOverflow';
|
|
6
6
|
export * from './Avatars';
|
|
7
7
|
export * from './Breadcrumb';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './Button';
|
|
9
9
|
export * from './Clipboard';
|
|
10
|
-
export * from './
|
|
10
|
+
export * from './Dialog';
|
|
11
11
|
export * from './Icon';
|
|
12
12
|
export * from './Input';
|
|
13
13
|
export * from './Link';
|
|
14
|
-
export * from './
|
|
14
|
+
export * from './List';
|
|
15
15
|
export * from './Main';
|
|
16
|
-
export * from './
|
|
16
|
+
export * from './Menu';
|
|
17
17
|
export * from './Message';
|
|
18
18
|
export * from './Popover';
|
|
19
19
|
export * from './Status';
|
|
20
20
|
export * from './ScrollArea';
|
|
21
|
+
export * from './ScrollContainer';
|
|
21
22
|
export * from './Select';
|
|
22
23
|
export * from './Separator';
|
|
23
24
|
export * from './Tag';
|
package/src/hooks/useSafeArea.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useCallback, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useViewportResize } from '@dxos/react-hooks';
|
|
8
8
|
|
|
9
9
|
export type SafeAreaPadding = Record<'top' | 'right' | 'bottom' | 'left', number>;
|
|
10
10
|
|
|
@@ -20,6 +20,7 @@ export const useSafeArea = (): SafeAreaPadding => {
|
|
|
20
20
|
left: parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--safe-area-left')),
|
|
21
21
|
});
|
|
22
22
|
}, []);
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
useViewportResize(handleResize);
|
|
24
25
|
return padding;
|
|
25
26
|
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useCallback,
|
|
5
|
+
import { useCallback, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useViewportResize } from '@dxos/react-hooks';
|
|
8
8
|
|
|
9
|
-
export const useVisualViewport = (deps?: Parameters<typeof
|
|
9
|
+
export const useVisualViewport = (deps?: Parameters<typeof useViewportResize>[1]) => {
|
|
10
10
|
const [width, setWidth] = useState<number | null>(null);
|
|
11
11
|
const [height, setHeight] = useState<number | null>(null);
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ export const useVisualViewport = (deps?: Parameters<typeof useEffect>[1]) => {
|
|
|
17
17
|
}
|
|
18
18
|
}, []);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
useViewportResize(handleResize, deps);
|
|
21
21
|
|
|
22
22
|
return { width, height };
|
|
23
23
|
};
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { type Resource, type TFunction } from 'i18next';
|
|
|
6
6
|
export { Trans } from 'react-i18next';
|
|
7
7
|
|
|
8
8
|
export * from '@dxos/react-hooks';
|
|
9
|
-
export * from '@dxos/
|
|
9
|
+
export * from '@dxos/ui-types';
|
|
10
10
|
|
|
11
11
|
export * from './components';
|
|
12
12
|
export * from './hooks';
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Icon, Input, Select, Toggle, Toolbar } from '../components';
|
|
11
|
-
import {
|
|
9
|
+
import { withTheme } from '../testing';
|
|
10
|
+
import { withLayoutVariants } from '../testing';
|
|
12
11
|
|
|
13
12
|
const DefaultStory = () => {
|
|
14
13
|
const [checked, setChecked] = useState<boolean>(false);
|
|
@@ -85,8 +84,7 @@ const DefaultStory = () => {
|
|
|
85
84
|
const meta = {
|
|
86
85
|
title: 'ui/react-ui-core/Playground/Controls',
|
|
87
86
|
render: DefaultStory,
|
|
88
|
-
decorators: [
|
|
89
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
87
|
+
decorators: [withTheme, withLayoutVariants()],
|
|
90
88
|
} satisfies Meta<typeof Icon>;
|
|
91
89
|
|
|
92
90
|
export default meta;
|
|
@@ -2,23 +2,12 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
8
|
import { Button, type ButtonProps, IconButton, Tooltip } from '../components';
|
|
11
9
|
import { withTheme } from '../testing';
|
|
12
10
|
|
|
13
|
-
// TODO(burdon): Change density to 3 or 4 sizes: (large, medium, small; or 22, 28, 32, 40)
|
|
14
|
-
// TODO(burdon): IconButton should be square if no text.
|
|
15
|
-
// TODO(burdon): IconButton icon should be auto-sized based on density.
|
|
16
|
-
|
|
17
|
-
// TODO(burdon): Remove custom padding from all Buttons.
|
|
18
|
-
|
|
19
|
-
// TODO(burdon): Forms w/ labels.
|
|
20
|
-
// TODO(burdon): Card preview with sections.
|
|
21
|
-
|
|
22
11
|
const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
23
12
|
return (
|
|
24
13
|
<Tooltip.Provider>
|
|
@@ -41,7 +30,7 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
41
30
|
iconOnly
|
|
42
31
|
size={7}
|
|
43
32
|
density='coarse'
|
|
44
|
-
classNames='
|
|
33
|
+
classNames='pli-1.5'
|
|
45
34
|
/>
|
|
46
35
|
</div>
|
|
47
36
|
</div>
|
|
@@ -54,7 +43,7 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
54
43
|
</Button>
|
|
55
44
|
</div>
|
|
56
45
|
<div className='flex justify-center'>
|
|
57
|
-
<IconButton {...args} label='Test' icon='ph--atom--regular'
|
|
46
|
+
<IconButton {...args} label='Test' icon='ph--atom--regular' density='fine' classNames='pli-2' />
|
|
58
47
|
</div>
|
|
59
48
|
<div className='flex justify-center'>
|
|
60
49
|
<IconButton
|
|
@@ -62,9 +51,8 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
62
51
|
label='Test'
|
|
63
52
|
icon='ph--atom--regular'
|
|
64
53
|
iconOnly
|
|
65
|
-
size={5}
|
|
66
54
|
density='fine'
|
|
67
|
-
classNames='
|
|
55
|
+
classNames='plb-1 pli-1.5'
|
|
68
56
|
/>
|
|
69
57
|
</div>
|
|
70
58
|
</div>
|
|
@@ -72,7 +60,7 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
72
60
|
{/* Small */}
|
|
73
61
|
<div className='grid grid-cols-3 gap-4'>
|
|
74
62
|
<div className='flex justify-center'>
|
|
75
|
-
<Button {...args} density='fine' classNames={'!h-[24px] !text-[14px] p-0
|
|
63
|
+
<Button {...args} density='fine' classNames={'!h-[24px] !text-[14px] p-0 pli-1.5 min-bs-0'}>
|
|
76
64
|
{children}
|
|
77
65
|
</Button>
|
|
78
66
|
</div>
|
|
@@ -101,18 +89,17 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
101
89
|
|
|
102
90
|
{/* TODO(burdon): Full variant with max width. */}
|
|
103
91
|
<div className='flex justify-center'>
|
|
104
|
-
<Button classNames='
|
|
92
|
+
<Button classNames='is-full max-is-[15rem] rounded' variant='default'>
|
|
105
93
|
Test
|
|
106
94
|
</Button>
|
|
107
95
|
</div>
|
|
108
96
|
<div className='flex justify-center'>
|
|
109
97
|
{/* TODO(burdon): Option to have button on RHS. Default size for icon should be 5 for this (medium) density. */}
|
|
110
98
|
<IconButton
|
|
111
|
-
classNames='
|
|
99
|
+
classNames='is-full max-is-[15rem] rounded'
|
|
112
100
|
variant='primary'
|
|
113
101
|
icon='ph--arrows-clockwise--regular'
|
|
114
102
|
label='Test'
|
|
115
|
-
size={5}
|
|
116
103
|
/>
|
|
117
104
|
</div>
|
|
118
105
|
</div>
|
|
@@ -125,7 +112,9 @@ const meta = {
|
|
|
125
112
|
component: Button,
|
|
126
113
|
render: DefaultStory,
|
|
127
114
|
decorators: [withTheme],
|
|
128
|
-
parameters: {
|
|
115
|
+
parameters: {
|
|
116
|
+
layout: 'centered',
|
|
117
|
+
},
|
|
129
118
|
} satisfies Meta<typeof Button>;
|
|
130
119
|
|
|
131
120
|
export default meta;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
@@ -48,7 +46,6 @@ const meta = {
|
|
|
48
46
|
title: 'ui/react-ui-core/Playground/Typography',
|
|
49
47
|
render: DefaultStory,
|
|
50
48
|
decorators: [withTheme],
|
|
51
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
52
49
|
} satisfies Meta<typeof DefaultStory>;
|
|
53
50
|
|
|
54
51
|
export default meta;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Decorator } from '@storybook/react';
|
|
6
|
+
import React, { type FC, type PropsWithChildren, memo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type ClassNameValue, type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
+
import { mx } from '@dxos/ui-theme';
|
|
10
|
+
|
|
11
|
+
export type ContainerProps = ThemedClassName<PropsWithChildren>;
|
|
12
|
+
|
|
13
|
+
export type ContainerType = 'fullscreen' | 'column';
|
|
14
|
+
|
|
15
|
+
export type WithLayoutProps =
|
|
16
|
+
| FC<ContainerProps>
|
|
17
|
+
| {
|
|
18
|
+
classNames?: ClassNameValue;
|
|
19
|
+
layout?: ContainerType;
|
|
20
|
+
scroll?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Adds layout container.
|
|
25
|
+
*/
|
|
26
|
+
export const withLayout =
|
|
27
|
+
(props: WithLayoutProps = {}): Decorator =>
|
|
28
|
+
(Story) => {
|
|
29
|
+
// Prevent re-rendering of the story.
|
|
30
|
+
const MemoizedStory = memo(Story);
|
|
31
|
+
if (typeof props === 'function') {
|
|
32
|
+
const Container = props;
|
|
33
|
+
return (
|
|
34
|
+
<Container>
|
|
35
|
+
<MemoizedStory />
|
|
36
|
+
</Container>
|
|
37
|
+
);
|
|
38
|
+
} else {
|
|
39
|
+
const { layout = 'fullscreen', classNames, scroll } = props;
|
|
40
|
+
const Container = layouts[layout] ?? layouts.fullscreen;
|
|
41
|
+
return (
|
|
42
|
+
<Container classNames={mx(classNames, scroll ? 'overflow-y-auto' : 'overflow-hidden')}>
|
|
43
|
+
<MemoizedStory />
|
|
44
|
+
</Container>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const layouts: Record<ContainerType, FC<ContainerProps>> = {
|
|
50
|
+
fullscreen: ({ children, classNames }: ContainerProps) => (
|
|
51
|
+
<div role='none' className={mx('fixed inset-0 flex overflow-hidden bg-deckSurface', classNames)}>
|
|
52
|
+
{children}
|
|
53
|
+
</div>
|
|
54
|
+
),
|
|
55
|
+
|
|
56
|
+
column: ({ children, classNames }: ContainerProps) => (
|
|
57
|
+
<div role='none' className='fixed inset-0 flex justify-center overflow-hidden bg-deckSurface'>
|
|
58
|
+
<div role='none' className={mx('flex flex-col is-[40rem] bg-baseSurface', classNames)}>
|
|
59
|
+
{children}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
),
|
|
63
|
+
};
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { type Decorator } from '@storybook/react';
|
|
6
6
|
import React, { type ComponentType, type PropsWithChildren } from 'react';
|
|
7
7
|
|
|
8
|
-
import { mx, surfaceShadow } from '@dxos/
|
|
9
|
-
import { type Density, type Elevation } from '@dxos/
|
|
8
|
+
import { mx, surfaceShadow } from '@dxos/ui-theme';
|
|
9
|
+
import { type Density, type Elevation } from '@dxos/ui-types';
|
|
10
10
|
|
|
11
11
|
type Config = {
|
|
12
12
|
elevations?: { elevation: Elevation; surface?: string }[];
|
|
@@ -14,7 +14,7 @@ type Config = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const Container = ({ children, elevation, surface }: PropsWithChildren<{ elevation: Elevation; surface?: string }>) => (
|
|
17
|
-
<div className={mx('rounded-md border border-separator
|
|
17
|
+
<div className={mx('rounded-md border border-separator', surface, surfaceShadow({ elevation }))}>{children}</div>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const Panel = ({
|
|
@@ -23,7 +23,7 @@ const Panel = ({
|
|
|
23
23
|
densities,
|
|
24
24
|
className,
|
|
25
25
|
}: { Story: ComponentType } & Config & { className?: string }) => (
|
|
26
|
-
<div className={mx('flex flex-col
|
|
26
|
+
<div className={mx('flex flex-col bs-full p-4 gap-4', className)}>
|
|
27
27
|
{elevations?.map(({ elevation, surface }) =>
|
|
28
28
|
densities?.map((density) => (
|
|
29
29
|
<Container key={`${elevation}--${density}`} surface={surface} elevation={elevation}>
|
|
@@ -34,7 +34,7 @@ const Panel = ({
|
|
|
34
34
|
</div>
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
export const
|
|
37
|
+
export const withLayoutVariants = ({
|
|
38
38
|
elevations = [
|
|
39
39
|
{ elevation: 'base', surface: 'bg-baseSurface' },
|
|
40
40
|
{ elevation: 'positioned', surface: 'bg-cardSurface' },
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Decorator } from '@storybook/react';
|
|
6
|
+
import React, { memo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { defaultTx } from '@dxos/ui-theme';
|
|
9
|
+
import { type ThemeMode } from '@dxos/ui-types';
|
|
10
|
+
|
|
11
|
+
import { ThemeProvider, Tooltip } from '../../components';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Adds theme decorator (add to preview.ts)
|
|
15
|
+
*/
|
|
16
|
+
export const withTheme: Decorator = (Story, context) => {
|
|
17
|
+
const {
|
|
18
|
+
globals: { theme },
|
|
19
|
+
parameters: { translations },
|
|
20
|
+
} = context;
|
|
21
|
+
|
|
22
|
+
// Prevent re-rendering of the story.
|
|
23
|
+
const MemoizedStory = memo(Story);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ThemeProvider tx={defaultTx} themeMode={theme as ThemeMode} resourceExtensions={translations} noCache>
|
|
27
|
+
<Tooltip.Provider>
|
|
28
|
+
<MemoizedStory />
|
|
29
|
+
</Tooltip.Provider>
|
|
30
|
+
</ThemeProvider>
|
|
31
|
+
);
|
|
32
|
+
};
|
package/src/util/index.ts
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
const getDocumentElementFontSize = () => parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* React hook that converts rem values to pixels and updates when the root font size changes.
|
|
11
|
+
*
|
|
12
|
+
* @param rem The rem value to convert to pixels
|
|
13
|
+
* @returns The current pixel value equivalent of the rem input
|
|
14
|
+
*/
|
|
15
|
+
export const usePx = (rem: number): number => {
|
|
16
|
+
const [fontSize, setFontSize] = useState(() => {
|
|
17
|
+
if (typeof document !== 'undefined') {
|
|
18
|
+
return getDocumentElementFontSize();
|
|
19
|
+
}
|
|
20
|
+
return 16; // Default fallback for SSR
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const updateFontSize = useCallback(() => {
|
|
24
|
+
setFontSize(getDocumentElementFontSize());
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (typeof document === 'undefined') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Create a ResizeObserver to watch for font size changes on the document element
|
|
33
|
+
const resizeObserver = new ResizeObserver(updateFontSize);
|
|
34
|
+
resizeObserver.observe(document.documentElement);
|
|
35
|
+
|
|
36
|
+
// Also listen for viewport changes that might affect font size
|
|
37
|
+
const mediaQueryList = window.matchMedia('all');
|
|
38
|
+
const handleMediaChange = () => {
|
|
39
|
+
updateFontSize();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
if (mediaQueryList.addEventListener) {
|
|
43
|
+
mediaQueryList.addEventListener('change', handleMediaChange);
|
|
44
|
+
} else {
|
|
45
|
+
// Fallback for older browsers
|
|
46
|
+
mediaQueryList.addListener(handleMediaChange);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return () => {
|
|
50
|
+
resizeObserver.disconnect();
|
|
51
|
+
if (mediaQueryList.removeEventListener) {
|
|
52
|
+
mediaQueryList.removeEventListener('change', handleMediaChange);
|
|
53
|
+
} else {
|
|
54
|
+
// Fallback for older browsers
|
|
55
|
+
mediaQueryList.removeListener(handleMediaChange);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
|
|
60
|
+
return useMemo(() => rem * fontSize, [fontSize]);
|
|
61
|
+
};
|