File tree Expand file tree Collapse file tree 5 files changed +92
-7
lines changed Expand file tree Collapse file tree 5 files changed +92
-7
lines changed Original file line number Diff line number Diff line change
1
+ import { Button , Centering , Dropdown } from '@solved-ac/ui-react'
2
+ import { Meta , StoryFn } from '@storybook/react'
3
+ import React from 'react'
4
+
5
+ import TooltipStories from './Tooltip.stories'
6
+
7
+ export default {
8
+ title : 'Components/Dropdown' ,
9
+ component : Dropdown ,
10
+ argTypes : {
11
+ ...TooltipStories . argTypes ,
12
+ interactive : {
13
+ ...( TooltipStories . argTypes ?. interactive || { } ) ,
14
+ defaultValue : true ,
15
+ } ,
16
+ activateOnHover : {
17
+ ...( TooltipStories . argTypes ?. activateOnHover || { } ) ,
18
+ defaultValue : false ,
19
+ } ,
20
+ activateOnClick : {
21
+ ...( TooltipStories . argTypes ?. activateOnClick || { } ) ,
22
+ defaultValue : true ,
23
+ } ,
24
+ noThemeChange : {
25
+ ...( TooltipStories . argTypes ?. noThemeChange || { } ) ,
26
+ defaultValue : true ,
27
+ } ,
28
+ } ,
29
+ } as Meta < typeof Dropdown >
30
+
31
+ const Template : StoryFn < typeof Dropdown > = ( args ) => (
32
+ < Centering
33
+ style = { {
34
+ height : 200 ,
35
+ } }
36
+ >
37
+ < Dropdown { ...args } />
38
+ </ Centering >
39
+ )
40
+
41
+ export const Default = Template . bind ( { } )
42
+ Default . args = {
43
+ children : < Button > Click me!</ Button > ,
44
+ title : 'Dropdown' ,
45
+ }
Original file line number Diff line number Diff line change @@ -11,11 +11,6 @@ export default {
11
11
description : 'The title to display' ,
12
12
defaultValue : 'Tooltip' ,
13
13
} ,
14
- noDefaultStyles : {
15
- control : 'boolean' ,
16
- description : 'Whether to use the default styles' ,
17
- defaultValue : false ,
18
- } ,
19
14
arrow : {
20
15
control : 'boolean' ,
21
16
description : 'Whether to show the arrow' ,
@@ -62,6 +57,18 @@ export default {
62
57
'Whether to activate the tooltip on mouse click - repeated clicks will toggle the tooltip' ,
63
58
defaultValue : false ,
64
59
} ,
60
+ noDefaultStyles : {
61
+ control : 'boolean' ,
62
+ description :
63
+ 'Whether to use the default styles - this will also disable the theme change.' ,
64
+ defaultValue : false ,
65
+ } ,
66
+ noThemeChange : {
67
+ control : 'boolean' ,
68
+ description :
69
+ 'Whether to prevent the theme from changing - Tooltip is set to use the dark theme by default. This will prevent that.' ,
70
+ defaultValue : false ,
71
+ } ,
65
72
} ,
66
73
} as Meta < typeof Tooltip >
67
74
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { Tooltip , TooltipProps } from './Tooltip'
3
+
4
+ export type DropdownProps = TooltipProps
5
+
6
+ export const Dropdown : React . FC < TooltipProps > = ( props ) => {
7
+ const {
8
+ interactive = true ,
9
+ activateOnHover = false ,
10
+ activateOnClick = true ,
11
+ noThemeChange = true ,
12
+ ...rest
13
+ } = props
14
+
15
+ return (
16
+ < Tooltip
17
+ interactive = { interactive }
18
+ activateOnHover = { activateOnHover }
19
+ activateOnClick = { activateOnClick }
20
+ noThemeChange = { noThemeChange }
21
+ { ...rest }
22
+ />
23
+ )
24
+ }
Original file line number Diff line number Diff line change 9
9
safePolygon ,
10
10
shift ,
11
11
useClick ,
12
+ useDismiss ,
12
13
useFloating ,
13
14
useHover ,
14
15
useInteractions ,
@@ -71,6 +72,7 @@ export type TooltipProps = {
71
72
interactive ?: boolean
72
73
activateOnHover ?: boolean
73
74
activateOnClick ?: boolean
75
+ noThemeChange ?: boolean
74
76
} & (
75
77
| {
76
78
noDefaultStyles : false
@@ -128,6 +130,7 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
128
130
interactive = false ,
129
131
activateOnHover = true ,
130
132
activateOnClick = false ,
133
+ noThemeChange = false ,
131
134
...cardProps
132
135
} = props
133
136
const [ isOpen , setIsOpen ] = useState ( false )
@@ -172,9 +175,14 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
172
175
useClick ( context , {
173
176
enabled : activateOnClick ,
174
177
} ) ,
178
+ useDismiss ( context , {
179
+ enabled : activateOnClick && ! keepOpen ,
180
+ } ) ,
175
181
] )
176
182
177
183
const RenderComponent = noBackground ? motion . div : TooltipContainer
184
+ const ThemeProviderComponent =
185
+ noThemeChange || noBackground ? React . Fragment : ThemeProvider
178
186
179
187
const arrowPosition =
180
188
renderSide [ placement . split ( '-' ) [ 0 ] as keyof typeof renderSide ]
@@ -185,7 +193,7 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
185
193
{ children }
186
194
</ TooltipWrapper >
187
195
< FloatingPortal >
188
- < ThemeProvider theme = { theme || solvedThemes . dark } >
196
+ < ThemeProviderComponent theme = { theme || solvedThemes . dark } >
189
197
< AnimatePresence >
190
198
{ renderTooltip && (
191
199
< React . Fragment >
@@ -216,7 +224,7 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
216
224
</ React . Fragment >
217
225
) }
218
226
</ AnimatePresence >
219
- </ ThemeProvider >
227
+ </ ThemeProviderComponent >
220
228
</ FloatingPortal >
221
229
</ React . Fragment >
222
230
)
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export * from './Chip'
10
10
export * from './Collapse'
11
11
export * from './Container'
12
12
export * from './Divider'
13
+ export * from './Dropdown'
13
14
export * from './EmptyStatePlaceholder'
14
15
export * from './Footer'
15
16
export * from './NavBar'
You can’t perform that action at this time.
0 commit comments