@dxos/react-ui 0.7.5-labs.e27f9b9 → 0.7.5-main.2567c87
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/index.mjs +70 -69
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +70 -70
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +70 -69
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Avatars/Avatar.d.ts +9 -5
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +2 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.d.ts +0 -2
- package/dist/types/src/components/Buttons/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +22 -35
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts +6 -2
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.stories.d.ts +5 -12
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +1 -13
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/util/ThemedClassName.d.ts +1 -1
- package/dist/types/src/util/ThemedClassName.d.ts.map +1 -1
- package/package.json +42 -42
- package/src/components/Avatars/Avatar.tsx +6 -3
- package/src/components/Buttons/IconButton.tsx +3 -4
- package/src/components/Input/Input.tsx +1 -1
- package/src/components/Main/Main.stories.tsx +1 -1
- package/src/components/Main/Main.tsx +72 -78
- package/src/components/Tag/Tag.stories.tsx +31 -20
- package/src/components/Tag/Tag.tsx +6 -15
- package/src/components/Tooltip/Tooltip.stories.tsx +2 -13
- package/src/util/ThemedClassName.ts +1 -1
|
@@ -35,14 +35,12 @@ const COMPLEMENTARY_SIDEBAR_NAME = 'ComplementarySidebar';
|
|
|
35
35
|
const MAIN_NAME = 'Main';
|
|
36
36
|
const GENERIC_CONSUMER_NAME = 'GenericConsumer';
|
|
37
37
|
|
|
38
|
-
type SidebarState = 'expanded' | 'collapsed' | 'closed';
|
|
39
|
-
|
|
40
38
|
type MainContextValue = {
|
|
41
39
|
resizing: boolean;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
navigationSidebarOpen: boolean;
|
|
41
|
+
setNavigationSidebarOpen: Dispatch<SetStateAction<boolean | undefined>>;
|
|
42
|
+
complementarySidebarOpen: boolean;
|
|
43
|
+
setComplementarySidebarOpen: Dispatch<SetStateAction<boolean | undefined>>;
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
const landmarkAttr = 'data-main-landmark';
|
|
@@ -75,77 +73,73 @@ const useLandmarkMover = (propsOnKeyDown: ComponentPropsWithoutRef<'div'>['onKey
|
|
|
75
73
|
|
|
76
74
|
const [MainProvider, useMainContext] = createContext<MainContextValue>(MAIN_NAME, {
|
|
77
75
|
resizing: false,
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
navigationSidebarOpen: false,
|
|
77
|
+
setNavigationSidebarOpen: (nextOpen) => {
|
|
80
78
|
// TODO(burdon): Standardize with other context missing errors using raise.
|
|
81
79
|
log.warn('Attempt to set sidebar state without initializing `MainRoot`');
|
|
82
80
|
},
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
complementarySidebarOpen: false,
|
|
82
|
+
setComplementarySidebarOpen: (nextOpen) => {
|
|
85
83
|
// TODO(burdon): Standardize with other context missing errors using raise.
|
|
86
84
|
log.warn('Attempt to set sidebar state without initializing `MainRoot`');
|
|
87
85
|
},
|
|
88
86
|
});
|
|
89
87
|
|
|
90
88
|
const useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
|
|
91
|
-
const {
|
|
89
|
+
const { setNavigationSidebarOpen, navigationSidebarOpen, setComplementarySidebarOpen, complementarySidebarOpen } =
|
|
92
90
|
useMainContext(consumerName);
|
|
93
91
|
return {
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
navigationSidebarOpen,
|
|
93
|
+
setNavigationSidebarOpen,
|
|
96
94
|
toggleNavigationSidebar: useCallback(
|
|
97
|
-
() =>
|
|
98
|
-
[
|
|
95
|
+
() => setNavigationSidebarOpen(!navigationSidebarOpen),
|
|
96
|
+
[navigationSidebarOpen, setNavigationSidebarOpen],
|
|
99
97
|
),
|
|
100
|
-
openNavigationSidebar: useCallback(() =>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
setComplementarySidebarState,
|
|
98
|
+
openNavigationSidebar: useCallback(() => setNavigationSidebarOpen(true), [setNavigationSidebarOpen]),
|
|
99
|
+
closeNavigationSidebar: useCallback(() => setNavigationSidebarOpen(false), [setNavigationSidebarOpen]),
|
|
100
|
+
complementarySidebarOpen,
|
|
101
|
+
setComplementarySidebarOpen,
|
|
105
102
|
toggleComplementarySidebar: useCallback(
|
|
106
|
-
() =>
|
|
107
|
-
[
|
|
103
|
+
() => setComplementarySidebarOpen(!complementarySidebarOpen),
|
|
104
|
+
[complementarySidebarOpen, setComplementarySidebarOpen],
|
|
108
105
|
),
|
|
109
|
-
openComplementarySidebar: useCallback(() =>
|
|
110
|
-
|
|
111
|
-
closeComplementarySidebar: useCallback(() => setComplementarySidebarState('closed'), []),
|
|
106
|
+
openComplementarySidebar: useCallback(() => setComplementarySidebarOpen(true), [setComplementarySidebarOpen]),
|
|
107
|
+
closeComplementarySidebar: useCallback(() => setComplementarySidebarOpen(false), [setComplementarySidebarOpen]),
|
|
112
108
|
};
|
|
113
109
|
};
|
|
114
110
|
|
|
115
111
|
type MainRootProps = PropsWithChildren<{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
navigationSidebarOpen?: boolean;
|
|
113
|
+
defaultNavigationSidebarOpen?: boolean;
|
|
114
|
+
onNavigationSidebarOpenChange?: (nextOpen: boolean) => void;
|
|
115
|
+
complementarySidebarOpen?: boolean;
|
|
116
|
+
defaultComplementarySidebarOpen?: boolean;
|
|
117
|
+
onComplementarySidebarOpenChange?: (nextOpen: boolean) => void;
|
|
122
118
|
}>;
|
|
123
119
|
|
|
124
120
|
const resizeDebounce = 3000;
|
|
125
121
|
|
|
126
122
|
const MainRoot = ({
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
navigationSidebarOpen: propsNavigationSidebarOpen,
|
|
124
|
+
defaultNavigationSidebarOpen,
|
|
125
|
+
onNavigationSidebarOpenChange,
|
|
126
|
+
complementarySidebarOpen: propsComplementarySidebarOpen,
|
|
127
|
+
defaultComplementarySidebarOpen,
|
|
128
|
+
onComplementarySidebarOpenChange,
|
|
133
129
|
children,
|
|
134
130
|
...props
|
|
135
131
|
}: MainRootProps) => {
|
|
136
132
|
const [isLg] = useMediaQuery('lg', { ssr: false });
|
|
137
|
-
const [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
onChange: onComplementarySidebarStateChange,
|
|
148
|
-
});
|
|
133
|
+
const [navigationSidebarOpen = isLg, setNavigationSidebarOpen] = useControllableState<boolean>({
|
|
134
|
+
prop: propsNavigationSidebarOpen,
|
|
135
|
+
defaultProp: defaultNavigationSidebarOpen,
|
|
136
|
+
onChange: onNavigationSidebarOpenChange,
|
|
137
|
+
});
|
|
138
|
+
const [complementarySidebarOpen = false, setComplementarySidebarOpen] = useControllableState<boolean>({
|
|
139
|
+
prop: propsComplementarySidebarOpen,
|
|
140
|
+
defaultProp: defaultComplementarySidebarOpen,
|
|
141
|
+
onChange: onComplementarySidebarOpenChange,
|
|
142
|
+
});
|
|
149
143
|
|
|
150
144
|
const [resizing, setResizing] = useState(false);
|
|
151
145
|
const resizeInterval = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
@@ -170,10 +164,10 @@ const MainRoot = ({
|
|
|
170
164
|
<MainProvider
|
|
171
165
|
{...props}
|
|
172
166
|
{...{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
167
|
+
navigationSidebarOpen,
|
|
168
|
+
setNavigationSidebarOpen,
|
|
169
|
+
complementarySidebarOpen,
|
|
170
|
+
setComplementarySidebarOpen,
|
|
177
171
|
}}
|
|
178
172
|
resizing={resizing}
|
|
179
173
|
>
|
|
@@ -190,15 +184,15 @@ const handleOpenAutoFocus = (event: Event) => {
|
|
|
190
184
|
|
|
191
185
|
type MainSidebarProps = ThemedClassName<ComponentPropsWithRef<typeof DialogContent>> & {
|
|
192
186
|
swipeToDismiss?: boolean;
|
|
193
|
-
|
|
187
|
+
open: boolean;
|
|
194
188
|
resizing?: boolean;
|
|
195
|
-
|
|
189
|
+
setOpen: Dispatch<SetStateAction<boolean | undefined>>;
|
|
196
190
|
side: 'inline-start' | 'inline-end';
|
|
197
191
|
};
|
|
198
192
|
|
|
199
193
|
const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
200
194
|
(
|
|
201
|
-
{ classNames, children, swipeToDismiss, onOpenAutoFocus,
|
|
195
|
+
{ classNames, children, swipeToDismiss, onOpenAutoFocus, open, resizing, setOpen, side, ...props },
|
|
202
196
|
forwardedRef,
|
|
203
197
|
) => {
|
|
204
198
|
const [isLg] = useMediaQuery('lg', { ssr: false });
|
|
@@ -206,7 +200,7 @@ const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
|
206
200
|
const ref = useForwardedRef(forwardedRef);
|
|
207
201
|
const noopRef = useRef(null);
|
|
208
202
|
useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
|
|
209
|
-
onDismiss: () =>
|
|
203
|
+
onDismiss: () => setOpen(false),
|
|
210
204
|
});
|
|
211
205
|
const handleKeyDown = useCallback(
|
|
212
206
|
(event: KeyboardEvent<HTMLDivElement>) => {
|
|
@@ -219,16 +213,16 @@ const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
|
219
213
|
);
|
|
220
214
|
const Root = isLg ? Primitive.div : DialogContent;
|
|
221
215
|
return (
|
|
222
|
-
<DialogRoot open={
|
|
216
|
+
<DialogRoot open={open} modal={false}>
|
|
223
217
|
<Root
|
|
224
218
|
{...(!isLg && { forceMount: true, tabIndex: -1, onOpenAutoFocus: onOpenAutoFocus ?? handleOpenAutoFocus })}
|
|
225
219
|
{...props}
|
|
226
220
|
data-side={side === 'inline-end' ? 'ie' : 'is'}
|
|
227
|
-
data-state={
|
|
221
|
+
data-state={open ? 'open' : 'closed'}
|
|
228
222
|
data-resizing={resizing ? 'true' : 'false'}
|
|
229
223
|
className={tx('main.sidebar', 'main__sidebar', {}, classNames)}
|
|
230
224
|
onKeyDown={handleKeyDown}
|
|
231
|
-
{...(
|
|
225
|
+
{...(!open && { inert: 'true' })}
|
|
232
226
|
ref={ref}
|
|
233
227
|
>
|
|
234
228
|
{children}
|
|
@@ -238,17 +232,17 @@ const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
|
238
232
|
},
|
|
239
233
|
);
|
|
240
234
|
|
|
241
|
-
type MainNavigationSidebarProps = Omit<MainSidebarProps, '
|
|
235
|
+
type MainNavigationSidebarProps = Omit<MainSidebarProps, 'open' | 'setOpen' | 'side'>;
|
|
242
236
|
|
|
243
237
|
const MainNavigationSidebar = forwardRef<HTMLDivElement, MainNavigationSidebarProps>((props, forwardedRef) => {
|
|
244
|
-
const {
|
|
238
|
+
const { navigationSidebarOpen, setNavigationSidebarOpen, resizing } = useMainContext(NAVIGATION_SIDEBAR_NAME);
|
|
245
239
|
const mover = useLandmarkMover(props.onKeyDown, '0');
|
|
246
240
|
return (
|
|
247
241
|
<MainSidebar
|
|
248
242
|
{...mover}
|
|
249
243
|
{...props}
|
|
250
|
-
|
|
251
|
-
|
|
244
|
+
open={navigationSidebarOpen}
|
|
245
|
+
setOpen={setNavigationSidebarOpen}
|
|
252
246
|
resizing={resizing}
|
|
253
247
|
side='inline-start'
|
|
254
248
|
ref={forwardedRef}
|
|
@@ -258,18 +252,18 @@ const MainNavigationSidebar = forwardRef<HTMLDivElement, MainNavigationSidebarPr
|
|
|
258
252
|
|
|
259
253
|
MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
|
|
260
254
|
|
|
261
|
-
type MainComplementarySidebarProps = Omit<MainSidebarProps, '
|
|
255
|
+
type MainComplementarySidebarProps = Omit<MainSidebarProps, 'open' | 'setOpen' | 'side'>;
|
|
262
256
|
|
|
263
257
|
const MainComplementarySidebar = forwardRef<HTMLDivElement, MainComplementarySidebarProps>((props, forwardedRef) => {
|
|
264
|
-
const {
|
|
258
|
+
const { complementarySidebarOpen, setComplementarySidebarOpen, resizing } =
|
|
265
259
|
useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
|
|
266
260
|
const mover = useLandmarkMover(props.onKeyDown, '2');
|
|
267
261
|
return (
|
|
268
262
|
<MainSidebar
|
|
269
263
|
{...mover}
|
|
270
264
|
{...props}
|
|
271
|
-
|
|
272
|
-
|
|
265
|
+
open={complementarySidebarOpen}
|
|
266
|
+
setOpen={setComplementarySidebarOpen}
|
|
273
267
|
resizing={resizing}
|
|
274
268
|
side='inline-end'
|
|
275
269
|
ref={forwardedRef}
|
|
@@ -287,7 +281,7 @@ type MainProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> &
|
|
|
287
281
|
|
|
288
282
|
const MainContent = forwardRef<HTMLDivElement, MainProps>(
|
|
289
283
|
({ asChild, classNames, bounce, handlesFocus, children, role, ...props }: MainProps, forwardedRef) => {
|
|
290
|
-
const {
|
|
284
|
+
const { navigationSidebarOpen, complementarySidebarOpen } = useMainContext(MAIN_NAME);
|
|
291
285
|
const { tx } = useThemeContext();
|
|
292
286
|
const Root = asChild ? Slot : role ? 'div' : 'main';
|
|
293
287
|
|
|
@@ -298,8 +292,8 @@ const MainContent = forwardRef<HTMLDivElement, MainProps>(
|
|
|
298
292
|
role={role}
|
|
299
293
|
{...(handlesFocus && { ...mover })}
|
|
300
294
|
{...props}
|
|
301
|
-
data-sidebar-inline-start-state={
|
|
302
|
-
data-sidebar-inline-end-state={
|
|
295
|
+
data-sidebar-inline-start-state={navigationSidebarOpen ? 'open' : 'closed'}
|
|
296
|
+
data-sidebar-inline-end-state={complementarySidebarOpen ? 'open' : 'closed'}
|
|
303
297
|
className={tx('main.content', 'main', { bounce, handlesFocus }, classNames)}
|
|
304
298
|
ref={forwardedRef}
|
|
305
299
|
>
|
|
@@ -315,23 +309,23 @@ type MainOverlayProps = ThemedClassName<Omit<ComponentPropsWithRef<typeof Primit
|
|
|
315
309
|
|
|
316
310
|
const MainOverlay = forwardRef<HTMLDivElement, MainOverlayProps>(({ classNames, ...props }, forwardedRef) => {
|
|
317
311
|
const [isLg] = useMediaQuery('lg', { ssr: false });
|
|
318
|
-
const {
|
|
312
|
+
const { navigationSidebarOpen, setNavigationSidebarOpen, complementarySidebarOpen, setComplementarySidebarOpen } =
|
|
319
313
|
useMainContext(MAIN_NAME);
|
|
320
314
|
const { tx } = useThemeContext();
|
|
321
315
|
return (
|
|
322
316
|
<div
|
|
323
317
|
onClick={() => {
|
|
324
|
-
|
|
325
|
-
|
|
318
|
+
setNavigationSidebarOpen(false);
|
|
319
|
+
setComplementarySidebarOpen(false);
|
|
326
320
|
}}
|
|
327
321
|
{...props}
|
|
328
322
|
className={tx(
|
|
329
323
|
'main.overlay',
|
|
330
324
|
'main__overlay',
|
|
331
|
-
{ isLg, inlineStartSidebarOpen:
|
|
325
|
+
{ isLg, inlineStartSidebarOpen: navigationSidebarOpen, inlineEndSidebarOpen: complementarySidebarOpen },
|
|
332
326
|
classNames,
|
|
333
327
|
)}
|
|
334
|
-
data-state={
|
|
328
|
+
data-state={navigationSidebarOpen || complementarySidebarOpen ? 'open' : 'closed'}
|
|
335
329
|
aria-hidden='true'
|
|
336
330
|
ref={forwardedRef}
|
|
337
331
|
/>
|
|
@@ -346,6 +340,6 @@ export const Main = {
|
|
|
346
340
|
ComplementarySidebar: MainComplementarySidebar,
|
|
347
341
|
};
|
|
348
342
|
|
|
349
|
-
export { useMainContext, useSidebars
|
|
343
|
+
export { useMainContext, useSidebars };
|
|
350
344
|
|
|
351
|
-
export type { MainRootProps, MainProps, MainOverlayProps, MainNavigationSidebarProps
|
|
345
|
+
export type { MainRootProps, MainProps, MainOverlayProps, MainNavigationSidebarProps };
|
|
@@ -1,35 +1,46 @@
|
|
|
1
1
|
//
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
|
-
import React from 'react';
|
|
5
4
|
|
|
6
|
-
import { hueTokenThemes } from '@dxos/react-ui-theme';
|
|
7
5
|
import '@dxos-theme';
|
|
8
|
-
import { type ChromaticPalette, type MessageValence } from '@dxos/react-ui-types';
|
|
9
6
|
|
|
10
7
|
import { Tag } from './Tag';
|
|
11
8
|
import { withTheme } from '../../testing';
|
|
12
9
|
|
|
13
|
-
const palettes = ['neutral', 'success', 'info', 'warning', 'error', ...Object.keys(hueTokenThemes)] as (
|
|
14
|
-
| ChromaticPalette
|
|
15
|
-
| MessageValence
|
|
16
|
-
)[];
|
|
17
|
-
|
|
18
10
|
export default {
|
|
19
11
|
title: 'ui/react-ui-core/Tag',
|
|
20
12
|
component: Tag,
|
|
21
13
|
decorators: [withTheme],
|
|
22
14
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
23
|
-
|
|
15
|
+
argTypes: {
|
|
16
|
+
palette: {
|
|
17
|
+
control: 'select',
|
|
18
|
+
options: [
|
|
19
|
+
'neutral',
|
|
20
|
+
'success',
|
|
21
|
+
'info',
|
|
22
|
+
'warning',
|
|
23
|
+
'error',
|
|
24
|
+
'red',
|
|
25
|
+
'orange',
|
|
26
|
+
'amber',
|
|
27
|
+
'yellow',
|
|
28
|
+
'lime',
|
|
29
|
+
'green',
|
|
30
|
+
'emerald',
|
|
31
|
+
'teal',
|
|
32
|
+
'cyan',
|
|
33
|
+
'sky',
|
|
34
|
+
'blue',
|
|
35
|
+
'indigo',
|
|
36
|
+
'violet',
|
|
37
|
+
'purple',
|
|
38
|
+
'fuchsia',
|
|
39
|
+
'pink',
|
|
40
|
+
'rose',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
} as any;
|
|
24
45
|
|
|
25
|
-
export const Default = {
|
|
26
|
-
render: () => (
|
|
27
|
-
<div role='grid' className='grid grid-cols-5 gap-2 max-is-screen-md'>
|
|
28
|
-
{palettes.map((palette) => (
|
|
29
|
-
<Tag key={palette} palette={palette}>
|
|
30
|
-
{palette}
|
|
31
|
-
</Tag>
|
|
32
|
-
))}
|
|
33
|
-
</div>
|
|
34
|
-
),
|
|
35
|
-
};
|
|
46
|
+
export const Default = { args: { children: 'Hello', palette: 'success' } };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
@@ -16,17 +16,8 @@ export type TagProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.sp
|
|
|
16
16
|
asChild?: boolean;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const Tag = forwardRef<HTMLSpanElement, TagProps>(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<Root
|
|
25
|
-
{...props}
|
|
26
|
-
className={tx('tag.root', 'dx-tag', { palette }, classNames)}
|
|
27
|
-
data-hue={palette}
|
|
28
|
-
ref={forwardedRef}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
);
|
|
19
|
+
export const Tag = forwardRef<HTMLSpanElement, TagProps>(({ asChild, palette, classNames, ...props }, forwardedRef) => {
|
|
20
|
+
const { tx } = useThemeContext();
|
|
21
|
+
const Root = asChild ? Slot : Primitive.span;
|
|
22
|
+
return <Root {...props} className={tx('tag.root', 'tag', { palette }, classNames)} ref={forwardedRef} />;
|
|
23
|
+
});
|
|
@@ -12,12 +12,11 @@ import { Button } from '../Buttons';
|
|
|
12
12
|
|
|
13
13
|
type StoryTooltipProps = {
|
|
14
14
|
content: string;
|
|
15
|
-
defaultOpen?: boolean;
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
const StoryTooltip = ({ content
|
|
17
|
+
const StoryTooltip = ({ content }: StoryTooltipProps) => (
|
|
19
18
|
<Tooltip.Provider>
|
|
20
|
-
<Tooltip.Root defaultOpen
|
|
19
|
+
<Tooltip.Root defaultOpen>
|
|
21
20
|
<Tooltip.Trigger asChild>
|
|
22
21
|
<Button>Trigger tooltip</Button>
|
|
23
22
|
</Tooltip.Trigger>
|
|
@@ -45,13 +44,3 @@ export const Default = {
|
|
|
45
44
|
chromatic: { delay: 500 },
|
|
46
45
|
},
|
|
47
46
|
};
|
|
48
|
-
|
|
49
|
-
export const Testing = {
|
|
50
|
-
args: {
|
|
51
|
-
defaultOption: true,
|
|
52
|
-
content: 'This is the tooltip content',
|
|
53
|
-
},
|
|
54
|
-
parameters: {
|
|
55
|
-
chromatic: { delay: 500 },
|
|
56
|
-
},
|
|
57
|
-
};
|