playbook_ui 12.38.0.pre.alpha.PLAY966collapsiblenav41082 → 12.38.0.pre.alpha.PLAY966collapsiblenav41086
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_nav/_item.tsx +36 -11
- data/app/pb_kits/playbook/pb_nav/_nav.tsx +7 -3
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eae0f530402898fcbefd959203904bbf32732eb48281f3c02be9b0ee45bc29c
|
4
|
+
data.tar.gz: fafdafb80adce91cc980b713d8e4be65ca9660b3c4e8634b3f77db98407a02a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c73ddd4680ede853733bf7efecebe98c3300e0033cde494c29c052ac06f0bae5e8c829a7872bd6f7ce60c6016117a7eea8d6cff895985ef7790da0679a5bb4d
|
7
|
+
data.tar.gz: fd9ad011a7d1ba1cf90c716a2aaaf3d317bb8de166947908a9c1b5c0281afcb142b5cdb2c62b3ad768496d975e1b59b8bfbb8ba00043d66e9e210a0026d788ac
|
@@ -7,6 +7,7 @@ import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
7
7
|
import Icon from '../pb_icon/_icon'
|
8
8
|
import Image from '../pb_image/_image'
|
9
9
|
import Collapsible from '../pb_collapsible/_collapsible'
|
10
|
+
import { NavChildProps } from './_nav'
|
10
11
|
|
11
12
|
type NavItemProps = {
|
12
13
|
active?: boolean,
|
@@ -66,6 +67,7 @@ const NavItem = (props: NavItemProps) => {
|
|
66
67
|
collapsed,
|
67
68
|
// orientation,
|
68
69
|
// variant,
|
70
|
+
itemPadding,
|
69
71
|
padding,
|
70
72
|
paddingX,
|
71
73
|
paddingY,
|
@@ -98,17 +100,28 @@ const NavItem = (props: NavItemProps) => {
|
|
98
100
|
globalProps(filteredProps),
|
99
101
|
className)
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
103
|
+
const paddingProps = {
|
104
|
+
padding,
|
105
|
+
paddingBottom,
|
106
|
+
paddingTop,
|
107
|
+
paddingRight,
|
108
|
+
paddingLeft,
|
109
|
+
paddingX,
|
110
|
+
paddingY,
|
111
|
+
};
|
112
|
+
|
113
|
+
const finalItemPadding = {
|
114
|
+
...(itemPadding || {}),
|
115
|
+
...Object.entries(paddingProps).reduce((acc:any, [prop, value]) => {
|
116
|
+
if (value) {
|
117
|
+
acc[prop] = value;
|
118
|
+
}
|
119
|
+
return acc;
|
120
|
+
}, {}),
|
121
|
+
};
|
111
122
|
|
123
|
+
const tagClasses = classnames(collapsible ? 'pb_nav_list_item_link_collapsible' : "pb_nav_list_item_link",
|
124
|
+
globalProps({...finalItemPadding}))
|
112
125
|
|
113
126
|
const handleIconClick = (e:any) => {
|
114
127
|
if (onIconLeftClick) {
|
@@ -117,6 +130,18 @@ const NavItem = (props: NavItemProps) => {
|
|
117
130
|
}
|
118
131
|
}
|
119
132
|
|
133
|
+
// Map over the children and clone them with itemPadding prop so nested navItems all get itemPadding
|
134
|
+
const childrenWithProps = React.Children.map(children, (child) => {
|
135
|
+
if (React.isValidElement(child)) {
|
136
|
+
const childProps: NavChildProps = {
|
137
|
+
itemPadding: itemPadding
|
138
|
+
};
|
139
|
+
return React.cloneElement(child, childProps);
|
140
|
+
}
|
141
|
+
return child;
|
142
|
+
});
|
143
|
+
|
144
|
+
|
120
145
|
return (
|
121
146
|
<li
|
122
147
|
{...ariaProps}
|
@@ -171,7 +196,7 @@ const NavItem = (props: NavItemProps) => {
|
|
171
196
|
</Tag>
|
172
197
|
</Collapsible.Main>
|
173
198
|
<Collapsible.Content>
|
174
|
-
{
|
199
|
+
{childrenWithProps}
|
175
200
|
</Collapsible.Content>
|
176
201
|
</Collapsible>
|
177
202
|
) : (
|
@@ -20,11 +20,13 @@ type NavProps = {
|
|
20
20
|
link?: string,
|
21
21
|
title?: string,
|
22
22
|
variant?: "normal" | "subtle",
|
23
|
+
itemPadding?: {padding?: string, paddingBottom?: string, paddingTop?: string, paddingRight?: string, paddingLeft?: string, paddingX?: string, paddingY?: string}
|
23
24
|
} & GlobalProps
|
24
25
|
|
25
|
-
type NavChildProps = {
|
26
|
-
orientation
|
27
|
-
variant
|
26
|
+
export type NavChildProps = {
|
27
|
+
orientation?: "vertical" | "horizontal";
|
28
|
+
variant?: "normal" | "subtle";
|
29
|
+
itemPadding?: {padding?: string, paddingBottom?: string, paddingTop?: string, paddingRight?: string, paddingLeft?: string, paddingX?: string, paddingY?: string}
|
28
30
|
};
|
29
31
|
|
30
32
|
const Nav = (props: NavProps) => {
|
@@ -42,6 +44,7 @@ const Nav = (props: NavProps) => {
|
|
42
44
|
orientation = 'vertical',
|
43
45
|
title = '',
|
44
46
|
variant = 'normal',
|
47
|
+
itemPadding,
|
45
48
|
} = props
|
46
49
|
|
47
50
|
const ariaProps = buildAriaProps(aria)
|
@@ -61,6 +64,7 @@ const childrenWithProps = React.Children.map(children, (child) => {
|
|
61
64
|
const childProps: NavChildProps = {
|
62
65
|
orientation: orientation,
|
63
66
|
variant: variant,
|
67
|
+
itemPadding: itemPadding
|
64
68
|
};
|
65
69
|
return React.cloneElement(child, childProps);
|
66
70
|
}
|