playbook_ui 12.39.0.pre.alpha.PLAY966collapsiblenav41115 → 12.39.0.pre.alpha.salesbookmismatchingdate1117

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,71 +1,42 @@
1
- import React from "react";
2
- import classnames from "classnames";
1
+ import React from 'react'
2
+ import classnames from 'classnames'
3
3
 
4
- import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
5
- import { globalProps, GlobalProps } from "../utilities/globalProps";
4
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
- import Icon from "../pb_icon/_icon";
8
- import Image from "../pb_image/_image";
9
- import Collapsible from "../pb_collapsible/_collapsible";
10
- import { NavChildProps } from "./navTypes";
11
- import { Spacing } from "../types";
7
+ import Icon from '../pb_icon/_icon'
8
+ import Image from '../pb_image/_image'
9
+ import Collapsible from '../pb_collapsible/_collapsible'
12
10
 
13
11
  type NavItemProps = {
14
- active?: boolean;
15
- aria?: { [key: string]: string };
16
- fontWeight?: "regular" | "bold" | "bolder";
17
- children?: React.ReactNode[] | React.ReactNode;
18
- className?: string;
19
- collapsible?: boolean;
20
- data?: object;
21
- dark?: boolean;
22
- fontSize?: "normal" | "small";
23
- iconLeft?: string;
24
- iconRight?: string | string[];
25
- onIconRightClick?: () => void;
26
- onIconLeftClick?: () => void;
27
- id?: string;
28
- imageUrl?: string;
29
- link?: string;
30
- onClick?: () => void;
31
- target?: "_blank" | "_self" | "_parent" | "_top";
32
- text: string;
33
- collapsibleTrail?: boolean;
34
- collapsed?: boolean;
35
- paddingBottom?: Spacing;
36
- paddingTop?: Spacing;
37
- paddingLeft?: Spacing;
38
- paddingRight?: Spacing;
39
- paddingX?: Spacing;
40
- paddingY?: Spacing;
41
- padding?: Spacing;
42
- margin?: Spacing,
43
- marginBottom?: Spacing,
44
- marginTop?: Spacing,
45
- marginRight?: Spacing,
46
- marginLeft?: Spacing,
47
- marginX?: Spacing,
48
- marginY?: Spacing,
49
- orientation?: "vertical" | "horizontal";
50
- variant?: "normal" | "subtle";
51
- } & GlobalProps;
12
+ active?: boolean,
13
+ aria?: { [key: string]: string },
14
+ fontWeight?: "regular" | "bold" | "bolder",
15
+ children?: React.ReactNode[] | React.ReactNode,
16
+ className?: string,
17
+ collapsible?: boolean,
18
+ data?: object,
19
+ dark?: boolean,
20
+ fontSize?: "normal" | "small",
21
+ iconLeft?: string,
22
+ iconRight?: string | string[],
23
+ onIconRightClick?: () => void,
24
+ onIconLeftClick?: () => void,
25
+ id?: string,
26
+ imageUrl?: string,
27
+ link?: string,
28
+ onClick?: () => void,
29
+ target?: '_blank' | '_self' | '_parent' | '_top',
30
+ text: string,
31
+ collapsibleTrail?: boolean,
32
+ collapsed?: boolean
33
+ } & GlobalProps
52
34
 
53
35
  const NavItem = (props: NavItemProps) => {
54
-
55
- const fontWeightDefault = (orientation: string, variant: string) => {
56
- return orientation === "horizontal" && variant === "subtle"
57
- ? "regular "
58
- : orientation === "horizontal" && variant === "normal"
59
- ? "bold"
60
- : "regular";
61
- };
62
-
63
36
  const {
64
37
  active = false,
65
38
  aria = {},
66
- orientation,
67
- variant,
68
- fontWeight = fontWeightDefault(orientation, variant),
39
+ fontWeight = "regular",
69
40
  children,
70
41
  className,
71
42
  collapsible,
@@ -79,188 +50,129 @@ const NavItem = (props: NavItemProps) => {
79
50
  id,
80
51
  imageUrl,
81
52
  link,
82
- onClick = () => {},
83
- target = "_self",
84
- text = "",
53
+ onClick = () => { },
54
+ target = '_self',
55
+ text = '',
85
56
  collapsibleTrail,
86
- collapsed,
87
- itemSpacing,
88
- padding,
89
- paddingX,
90
- paddingY,
91
- paddingBottom,
92
- paddingTop,
93
- paddingLeft,
94
- paddingRight,
95
- margin,
96
- marginBottom,
97
- marginTop,
98
- marginRight,
99
- marginLeft,
100
- marginX,
101
- marginY
102
- } = props;
103
-
104
- const filteredProps = { ...props };
105
- [
106
- "padding",
107
- "paddingX",
108
- "paddingY",
109
- "paddingBottom",
110
- "paddingTop",
111
- "paddingRight",
112
- "paddingLeft",
113
- "margin",
114
- "marginX",
115
- "marginY",
116
- "marginBottom",
117
- "marginTop",
118
- "marginRight",
119
- "marginLeft",
120
- ].forEach((prop) => delete filteredProps[prop]);
121
-
122
- const Tag = link ? "a" : "div";
123
- const activeClass = active === true ? "active" : "";
124
- const collapsibleTrailClass =
125
- collapsible && collapsibleTrail ? "collapsible_trail" : "";
126
- const fontSizeClass =
127
- fontSize === "small" ? "font_size_small" : "font_size_normal";
128
- const fontWeightClass =
129
- fontWeight === "bold"
130
- ? "font_bold"
131
- : fontWeight === "bolder"
132
- ? "font_bolder"
133
- : "font_regular";
134
- const ariaProps = buildAriaProps(aria);
135
- const dataProps = buildDataProps(data);
136
- const classes = classnames(
137
- buildCss("pb_nav_list_kit_item", activeClass),
138
- collapsible
139
- ? buildCss("pb_collapsible_nav_item", activeClass, collapsibleTrailClass)
140
- : "",
141
- fontSizeClass,
142
- fontWeightClass,
143
- globalProps(filteredProps),
144
- className
145
- );
146
-
147
- const spacingProps = {
148
- padding,
149
- paddingBottom,
150
- paddingTop,
151
- paddingRight,
152
- paddingLeft,
153
- paddingX,
154
- paddingY,
155
- margin,
156
- marginBottom,
157
- marginTop,
158
- marginRight,
159
- marginLeft,
160
- marginX,
161
- marginY,
162
- };
163
-
164
- const finalItemSpacing = {
165
- ...(itemSpacing || {}),
166
- ...Object.entries(spacingProps).reduce((acc: any, [prop, value]) => {
167
- if (value) {
168
- acc[prop] = value;
169
- }
170
- return acc;
171
- }, {}),
172
- };
173
-
174
- const tagClasses = classnames(
175
- collapsible ? "pb_nav_list_item_link_collapsible" : "pb_nav_list_item_link",
176
- globalProps({ ...finalItemSpacing })
177
- );
178
-
179
- const handleIconClick = (e: any) => {
57
+ collapsed
58
+ } = props
59
+
60
+ const Tag = link ? 'a' : 'div'
61
+ const activeClass = active === true ? 'active' : ''
62
+ const collapsibleTrailClass = collapsible && collapsibleTrail ? 'collapsible_trail' : ''
63
+ const fontSizeClass = fontSize === 'small' ? "font_size_small" : "font_size_normal"
64
+ const fontWeightClass = fontWeight === 'bold' ? "font_bold" : fontWeight === 'bolder' ? "font_bolder" : "font_regular"
65
+ const ariaProps = buildAriaProps(aria)
66
+ const dataProps = buildDataProps(data)
67
+ const classes = classnames(buildCss('pb_nav_list_kit_item', activeClass),
68
+ collapsible ? buildCss('pb_collapsible_nav_item', activeClass, collapsibleTrailClass) : '',
69
+ fontSizeClass,
70
+ fontWeightClass,
71
+ globalProps(props),
72
+ className)
73
+
74
+
75
+ const handleIconClick = (e:any) => {
180
76
  if (onIconLeftClick) {
181
- e.stopPropagation();
182
- onIconLeftClick();
183
- }
184
- };
185
-
186
- // Map over the children and clone them with itemSpacing prop so nested navItems all get itemSpacing
187
- const childrenWithProps = React.Children.map(children, (child) => {
188
- if (React.isValidElement(child)) {
189
- const childProps: NavChildProps = {
190
- itemSpacing: itemSpacing,
191
- };
192
- return React.cloneElement(child, childProps);
77
+ e.stopPropagation();
78
+ onIconLeftClick()
193
79
  }
194
- return child;
195
- });
80
+ }
196
81
 
197
82
  return (
198
- <li {...ariaProps} {...dataProps} className={classes} id={id}>
199
- {collapsible ? (
200
- <Collapsible
201
- icon={iconRight ? iconRight : ["plus", "minus"]}
202
- iconSize="xs"
203
- id={id}
204
- collapsed={collapsed}
205
- onIconClick={onIconRightClick}
206
- onClick={onClick}
207
- >
83
+ <li
84
+ {...ariaProps}
85
+ {...dataProps}
86
+ className={classes}
87
+ id={id}
88
+ >
89
+ {
90
+ collapsible ? (
91
+ <Collapsible icon={iconRight ? iconRight : ['plus','minus']}
92
+ iconSize="xs"
93
+ id={id}
94
+ collapsed={collapsed}
95
+ onIconClick={onIconRightClick}
96
+ onClick={onClick}
97
+ >
208
98
  <Collapsible.Main dark={dark}>
209
- <Tag className={tagClasses} href={link} target={target}>
210
- {imageUrl && (
211
- <div
212
- className="pb_nav_list_item_icon_section_collapsible"
213
- key={imageUrl}
214
- onClick={(e) => handleIconClick(e)}
215
- >
216
- <Image className="pb_nav_img_wrapper" url={imageUrl} />
217
- </div>
218
- )}
219
-
220
- {iconLeft && (
221
- <div
222
- className="pb_nav_list_item_icon_section_collapsible"
223
- key={iconLeft}
224
- onClick={(e) => handleIconClick(e)}
225
- >
226
- <Icon
227
- className="pb_nav_list_item_icon_left_collapsible"
228
- fixedWidth
229
- icon={iconLeft}
230
- />
231
- </div>
232
- )}
233
- <span className="pb_nav_list_item_text_collapsible">{text}</span>
234
- </Tag>
235
- </Collapsible.Main>
236
- <Collapsible.Content>{childrenWithProps}</Collapsible.Content>
99
+ <Tag
100
+ className="pb_nav_list_item_link_collapsible"
101
+ href={link}
102
+ target={target}
103
+ >
104
+ {imageUrl &&
105
+ <div
106
+ className="pb_nav_list_item_icon_section_collapsible"
107
+ key={imageUrl}
108
+ onClick={(e)=>handleIconClick(e)}
109
+ >
110
+ <Image
111
+ className="pb_nav_img_wrapper"
112
+ url={imageUrl}
113
+ />
114
+ </div>
115
+ }
116
+
117
+ {iconLeft &&
118
+ <div
119
+ className="pb_nav_list_item_icon_section_collapsible"
120
+ key={iconLeft}
121
+ onClick={(e)=>handleIconClick(e)}
122
+ >
123
+ <Icon
124
+ className="pb_nav_list_item_icon_left_collapsible"
125
+ fixedWidth
126
+ icon={iconLeft}
127
+ />
128
+ </div>
129
+ }
130
+ <span className="pb_nav_list_item_text_collapsible">
131
+ {text}
132
+ </span>
133
+ </Tag>
134
+ </Collapsible.Main>
135
+ <Collapsible.Content>
136
+ {children}
137
+ </Collapsible.Content>
237
138
  </Collapsible>
238
- ) : (
139
+ ) : (
239
140
  <Tag
240
- className={tagClasses}
141
+ className="pb_nav_list_item_link"
241
142
  href={link}
242
143
  onClick={onClick}
243
144
  target={target}
244
145
  >
245
- {imageUrl && (
246
- <div className="pb_nav_list_item_icon_section" key={imageUrl}>
247
- <Image className="pb_nav_img_wrapper" url={imageUrl} />
146
+ {imageUrl &&
147
+ <div
148
+ className="pb_nav_list_item_icon_section"
149
+ key={imageUrl}
150
+ >
151
+ <Image
152
+ className="pb_nav_img_wrapper"
153
+ url={imageUrl}
154
+ />
248
155
  </div>
249
- )}
250
-
251
- {iconLeft && (
252
- <div className="pb_nav_list_item_icon_section" key={iconLeft}>
156
+ }
157
+
158
+ {iconLeft &&
159
+ <div
160
+ className="pb_nav_list_item_icon_section"
161
+ key={iconLeft}
162
+ >
253
163
  <Icon
254
164
  className="pb_nav_list_item_icon_left"
255
165
  fixedWidth
256
166
  icon={iconLeft}
257
167
  />
258
168
  </div>
259
- )}
260
-
261
- <span className="pb_nav_list_item_text">{text || children}</span>
262
-
263
- {iconRight && (
169
+ }
170
+
171
+ <span className="pb_nav_list_item_text">
172
+ {text || children}
173
+ </span>
174
+
175
+ {iconRight &&
264
176
  <div
265
177
  className="pb_nav_list_item_icon_section"
266
178
  key={iconRight as string}
@@ -271,11 +183,12 @@ const NavItem = (props: NavItemProps) => {
271
183
  icon={iconRight as string}
272
184
  />
273
185
  </div>
274
- )}
186
+ }
275
187
  </Tag>
276
- )}
188
+ )
189
+ }
277
190
  </li>
278
- );
279
- };
191
+ )
192
+ }
280
193
 
281
- export default NavItem;
194
+ export default NavItem
@@ -1,14 +1,5 @@
1
1
  @mixin collapsible_trail_class {
2
2
  .pb_collapsible_content_kit {
3
- position: relative;
4
- &::after {
5
- content: "";
6
- position: absolute;
7
- top: 4px;
8
- bottom: 4px;
9
- left: 5px;
10
- width: 1px;
11
- background-color: $border_light;
12
- }
3
+ border-color: $border_light;
13
4
  }
14
5
  }
@@ -5,7 +5,6 @@ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
5
  import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
7
  import Caption from '../pb_caption/_caption'
8
- import { SpacingObject, NavChildProps } from './navTypes'
9
8
 
10
9
  type NavProps = {
11
10
  aria?: { [key: string]: string },
@@ -21,7 +20,6 @@ type NavProps = {
21
20
  link?: string,
22
21
  title?: string,
23
22
  variant?: "normal" | "subtle",
24
- itemSpacing?: SpacingObject
25
23
  } & GlobalProps
26
24
 
27
25
  const Nav = (props: NavProps) => {
@@ -39,7 +37,6 @@ const Nav = (props: NavProps) => {
39
37
  orientation = 'vertical',
40
38
  title = '',
41
39
  variant = 'normal',
42
- itemSpacing,
43
40
  } = props
44
41
 
45
42
  const ariaProps = buildAriaProps(aria)
@@ -53,19 +50,6 @@ const Nav = (props: NavProps) => {
53
50
  className
54
51
  )
55
52
 
56
- // Map over the children and clone them with orientation, variant and itemSpacing props to gain access to them in navItem
57
- const childrenWithProps = React.Children.map(children, (child) => {
58
- if (React.isValidElement(child)) {
59
- const childProps: NavChildProps = {
60
- orientation: orientation,
61
- variant: variant,
62
- itemSpacing: itemSpacing
63
- };
64
- return React.cloneElement(child, childProps);
65
- }
66
- return child;
67
- });
68
-
69
53
  return (
70
54
  <nav
71
55
  {...ariaProps}
@@ -88,7 +72,7 @@ const childrenWithProps = React.Children.map(children, (child) => {
88
72
  </a>
89
73
  </div>
90
74
  }
91
- <ul>{childrenWithProps}</ul>
75
+ <ul>{children}</ul>
92
76
  </nav>
93
77
  )
94
78
  }
@@ -3,7 +3,7 @@ import { Nav, NavItem } from '../..'
3
3
 
4
4
  const CollapsibleNav = (props) => {
5
5
  return (
6
- <Nav variant="bold">
6
+ <Nav>
7
7
  <NavItem
8
8
  active
9
9
  collapsible
@@ -18,7 +18,7 @@ const CollapsibleNavCustom = (props) => {
18
18
 
19
19
  return (
20
20
  <>
21
- <Nav variant='subtle'>
21
+ <Nav variant='bold'>
22
22
  {navItems.map((text, index) => {
23
23
  const [collapsed] = collapsibles[index]
24
24
  return (
@@ -7,8 +7,8 @@ examples:
7
7
  - borderless_nav: No Borders
8
8
  - subtle_nav: Subtle Variant
9
9
  - subtle_with_icons_nav: Subtle With Icons
10
- - collapsible_nav: Collapsible Nav
11
- - collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
10
+ # - collapsible_nav: Collapsible Nav
11
+ # - collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
12
12
  - subtle_no_highlight_nav: Subtle No Highlight
13
13
  - bold_vertical_nav: Bold Variant
14
14
  - horizontal_nav: Horizontal Nav
@@ -26,9 +26,9 @@ examples:
26
26
  - borderless_nav: No Borders
27
27
  - subtle_nav: Subtle Variant
28
28
  - subtle_with_icons_nav: Subtle With Icons
29
- - collapsible_nav: Collapsible Nav
30
- - collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
31
- - collapsible_nav_custom: Collapsible Nav With Custom Toggling
29
+ # - collapsible_nav: Collapsible Nav
30
+ # - collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
31
+ # - collapsible_nav_custom: Collapsible Nav With Custom Toggling
32
32
  - subtle_no_highlight_nav: Subtle No Highlight
33
33
  - bold_vertical_nav: Bold Variant
34
34
  - horizontal_nav: Horizontal Nav
@@ -42,18 +42,3 @@
42
42
  <% end %>
43
43
  <% end %>
44
44
  <% end %>
45
-
46
- <script>
47
- document.addEventListener("DOMContentLoaded", function() {
48
- var liElements = document.querySelectorAll('li');
49
-
50
- liElements.forEach(function(liElement) {
51
- var orientation = liElement.getAttribute('data-orientation');
52
- var variant = liElement.getAttribute('data-variant');
53
- if (orientation === "horizontal" && variant === "normal") {
54
- liElement.classList.remove('font_regular')
55
- liElement.classList.add('font_bold')
56
- }
57
- })
58
- })
59
- </script>
@@ -28,45 +28,13 @@ module Playbook
28
28
  end
29
29
  end
30
30
 
31
- def spacing_props
32
- if object.padding || object.padding_x || object.padding_y || object.padding_bottom || object.padding_top || object.padding_right || object.padding_left || object.margin || object.margin_x || object.margin_y || object.margin_bottom || object.margin_top || object.margin_right || object.margin_left
33
- # Call the original method
34
- original_result = super
35
-
36
- # Remove p_value, px_value, py_value, etc. based on the object's properties
37
- padding_classes_to_remove = []
38
- padding_classes_to_remove << "p_#{object.padding}" if object.padding
39
- padding_classes_to_remove << "px_#{object.padding_x}" if object.padding_x
40
- padding_classes_to_remove << "py_#{object.padding_y}" if object.padding_y
41
- padding_classes_to_remove << "pb_#{object.padding_bottom}" if object.padding_bottom
42
- padding_classes_to_remove << "pt_#{object.padding_top}" if object.padding_top
43
- padding_classes_to_remove << "pr_#{object.padding_right}" if object.padding_right
44
- padding_classes_to_remove << "pl_#{object.padding_left}" if object.padding_left
45
- padding_classes_to_remove << "m_#{object.margin}" if object.margin
46
- padding_classes_to_remove << "mx_#{object.margin_x}" if object.margin_x
47
- padding_classes_to_remove << "my_#{object.margin_y}" if object.margin_y
48
- padding_classes_to_remove << "mb_#{object.margin_bottom}" if object.margin_bottom
49
- padding_classes_to_remove << "mt_#{object.margin_top}" if object.margin_top
50
- padding_classes_to_remove << "mr_#{object.margin_right}" if object.margin_right
51
- padding_classes_to_remove << "ml_#{object.margin_left}" if object.margin_left
52
-
53
- padding_classes_to_remove.each do |class_to_remove|
54
- original_result.gsub!(class_to_remove, "")
55
- end
56
-
57
- original_result.strip
58
- else
59
- super
60
- end
61
- end
62
-
63
31
  def tag
64
32
  link ? "a" : "div"
65
33
  end
66
34
 
67
35
  def options
68
36
  {
69
- class: collapsible ? "pb_nav_list_item_link_collapsible #{padding_classes}" : "pb_nav_list_item_link #{padding_classes}",
37
+ class: collapsible ? "pb_nav_list_item_link_collapsible" : "pb_nav_list_item_link",
70
38
  }.compact
71
39
  end
72
40
 
@@ -105,34 +73,6 @@ module Playbook
105
73
  def font_size_class
106
74
  font_size === "small" ? "font_size_small" : "font_size_normal"
107
75
  end
108
-
109
- def padding_classes
110
- spacing_attributes = {
111
- padding: "p",
112
- padding_x: "px",
113
- padding_y: "py",
114
- padding_bottom: "pb",
115
- padding_top: "pt",
116
- padding_right: "pr",
117
- padding_left: "pl",
118
- margin: "m",
119
- margin_x: "mx",
120
- margin_y: "my",
121
- margin_bottom: "mb",
122
- margin_top: "mt",
123
- margin_right: "mr",
124
- margin_left: "ml",
125
- }
126
-
127
- # rubocop:disable Style/RedundantAssignment
128
- padding_classes = spacing_attributes.map do |attr, class_prefix|
129
- # rubocop:enable Style/RedundantAssignment
130
- value = object.public_send(attr)
131
- " #{class_prefix}_#{value}" if value
132
- end.compact.join
133
-
134
- padding_classes
135
- end
136
76
  end
137
77
  end
138
78
  end
@@ -10,7 +10,5 @@
10
10
  <% end %>
11
11
  <% end %>
12
12
  <% end %>
13
- <ul>
14
- <%= raw object.modified_content %>
15
- </ul>
13
+ <ul><%= content.presence %></ul>
16
14
  <% end %>
@@ -13,7 +13,6 @@ module Playbook
13
13
  default: "normal"
14
14
  prop :highlight, type: Playbook::Props::Boolean, default: true
15
15
  prop :borderless, type: Playbook::Props::Boolean, default: false
16
- prop :item_padding, type: Playbook::Props::Hash, default: {}
17
16
 
18
17
  def classname
19
18
  generate_classname("pb_nav_list", variant, orientation, highlight_class, borderless_class)
@@ -26,18 +25,6 @@ module Playbook
26
25
  def borderless_class
27
26
  borderless ? "borderless" : nil
28
27
  end
29
-
30
- def modified_content
31
- parsed_content = Nokogiri::HTML.fragment(content.presence)
32
-
33
- parsed_content.css("li").each do |element|
34
- element["data-orientation"] = orientation
35
- element["data-variant"] = variant
36
- element["data-spacing"] = item_padding
37
- end
38
-
39
- parsed_content.to_html
40
- end
41
28
  end
42
29
  end
43
30
  end
@@ -68,7 +68,7 @@ const Time = (props: TimeProps) => {
68
68
  )
69
69
  )}
70
70
 
71
- <time dateTime={date.toString()}>
71
+ <time dateTime={date.toLocaleString()}>
72
72
  <span>
73
73
  {unstyled
74
74
  ? (