File tree 3 files changed +38
-20
lines changed
3 files changed +38
-20
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @ultraviolet/ui " : minor
3
+ ---
4
+
5
+ Add prop ` emptyState ` on ` <MenuV2.Group /> ` that can be usefull when searching
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export const Searchable: StoryFn<typeof MenuV2> = () => (
18
18
/>
19
19
}
20
20
>
21
- < MenuV2 . Group label = "Projects" >
21
+ < MenuV2 . Group label = "Projects" emptyState = "No project" >
22
22
< MenuV2 . Item sentiment = "primary" active >
23
23
< Stack direction = "row" gap = { 1 } alignItems = "center" >
24
24
< AvatarV2
Original file line number Diff line number Diff line change 1
1
import styled from '@emotion/styled'
2
- import type { ReactNode } from 'react'
2
+ import { Children , type ReactNode } from 'react'
3
3
import { Stack } from '../../Stack'
4
4
import { Text } from '../../Text'
5
5
@@ -12,23 +12,36 @@ type GroupProps = {
12
12
label : string
13
13
children : ReactNode
14
14
labelDescription ?: ReactNode
15
+ /**
16
+ * Empty state will be shown when there are no children
17
+ */
18
+ emptyState ?: ReactNode
15
19
}
16
20
17
- export const Group = ( { label, children, labelDescription } : GroupProps ) => (
18
- < >
19
- < Container >
20
- < Stack gap = { 1 } alignItems = "center" direction = "row" >
21
- < Text
22
- variant = "captionStrong"
23
- as = "span"
24
- prominence = "weak"
25
- sentiment = "neutral"
26
- >
27
- { label }
28
- </ Text >
29
- { labelDescription || null }
30
- </ Stack >
31
- </ Container >
32
- { children }
33
- </ >
34
- )
21
+ export const Group = ( {
22
+ label,
23
+ children,
24
+ labelDescription,
25
+ emptyState,
26
+ } : GroupProps ) => {
27
+ const isChildrenEmpty = Children . count ( children ) === 0
28
+
29
+ return (
30
+ < >
31
+ < Container >
32
+ < Stack gap = { 1 } alignItems = "center" direction = "row" >
33
+ < Text
34
+ variant = "captionStrong"
35
+ as = "span"
36
+ prominence = "weak"
37
+ sentiment = "neutral"
38
+ >
39
+ { label }
40
+ </ Text >
41
+ { labelDescription || null }
42
+ </ Stack >
43
+ </ Container >
44
+ { isChildrenEmpty && emptyState ? emptyState : children }
45
+ </ >
46
+ )
47
+ }
You can’t perform that action at this time.
0 commit comments