playbook_ui 12.33.1.pre.alpha.PLAY933navkitcollapsible994 → 12.34.0.pre.alpha.play716popoverkitcloseonclickissue998

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_button/_button.scss +32 -0
  3. data/app/pb_kits/playbook/pb_button/_button.tsx +78 -26
  4. data/app/pb_kits/playbook/pb_button/button.html.erb +17 -0
  5. data/app/pb_kits/playbook/pb_button/button.rb +18 -2
  6. data/app/pb_kits/playbook/pb_button/docs/_button_reaction.html.erb +30 -0
  7. data/app/pb_kits/playbook/pb_button/docs/_button_reaction.jsx +47 -0
  8. data/app/pb_kits/playbook/pb_button/docs/_button_reaction.md +3 -0
  9. data/app/pb_kits/playbook/pb_button/docs/example.yml +2 -0
  10. data/app/pb_kits/playbook/pb_button/docs/index.js +2 -1
  11. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +4 -6
  12. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.tsx +11 -19
  13. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +14 -27
  14. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +2 -7
  15. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.rb +7 -2
  16. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_size.md +1 -1
  17. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +1 -3
  18. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +0 -1
  19. data/app/pb_kits/playbook/pb_collapsible/index.js +3 -3
  20. data/app/pb_kits/playbook/pb_collapsible/types.d.ts +1 -0
  21. data/app/pb_kits/playbook/pb_icon/_icon.scss +4 -0
  22. data/app/pb_kits/playbook/pb_icon/_icon.tsx +1 -2
  23. data/app/pb_kits/playbook/pb_icon/icon.html.erb +1 -1
  24. data/app/pb_kits/playbook/pb_nav/_item.tsx +49 -98
  25. data/app/pb_kits/playbook/pb_nav/_nav.scss +0 -1
  26. data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +11 -9
  27. data/app/pb_kits/playbook/pb_nav/docs/example.yml +0 -3
  28. data/app/pb_kits/playbook/pb_nav/docs/index.js +0 -2
  29. data/app/pb_kits/playbook/pb_nav/item.html.erb +12 -34
  30. data/app/pb_kits/playbook/pb_nav/item.rb +0 -5
  31. data/app/pb_kits/playbook/pb_popover/_popover.tsx +14 -6
  32. data/app/pb_kits/playbook/pb_popover/docs/_popover_close.jsx +2 -0
  33. data/app/pb_kits/playbook/pb_popover/index.ts +5 -2
  34. data/dist/playbook-rails.js +7 -7
  35. data/lib/playbook/version.rb +2 -2
  36. metadata +6 -10
  37. data/app/pb_kits/playbook/pb_collapsible/_helper_functions.ts +0 -25
  38. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.html.erb +0 -10
  39. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +0 -19
  40. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.md +0 -2
  41. data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +0 -6
  42. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.html.erb +0 -24
  43. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +0 -83
  44. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom_icons.jsx +0 -86
@@ -95,9 +95,8 @@ const Icon = (props: IconProps) => {
95
95
  )
96
96
 
97
97
  const classesEmoji = classnames(
98
- 'pb_icon_kit',
98
+ 'pb_icon_kit_emoji',
99
99
  globalProps(props),
100
- 'icon_circle_emoji',
101
100
  className
102
101
  )
103
102
 
@@ -1,7 +1,7 @@
1
1
  <% if object.custom_icon %>
2
2
  <%= object.render_svg(object.custom_icon) %>
3
3
  <% elsif object.valid_emoji(object.icon) %>
4
- <span class="pb_icon_kit icon_circle_emoji"><%= object.icon.html_safe %></span>
4
+ <span class="pb_icon_kit_emoji"><%= object.icon.html_safe %></span>
5
5
  <% else %>
6
6
  <%= content_tag(:i, nil,
7
7
  id: object.id,
@@ -6,17 +6,15 @@ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
7
  import Icon from '../pb_icon/_icon'
8
8
  import Image from '../pb_image/_image'
9
- import Collapsible from '../pb_collapsible/_collapsible'
10
9
 
11
10
  type NavItemProps = {
12
11
  active?: boolean,
13
12
  aria?: { [key: string]: string },
14
13
  children?: React.ReactNode[] | React.ReactNode,
15
14
  className?: string,
16
- collapsible?: boolean,
17
15
  data?: object,
18
16
  iconLeft?: string,
19
- iconRight?: string | string[],
17
+ iconRight?: string,
20
18
  id?: string,
21
19
  imageUrl?: string,
22
20
  link?: string,
@@ -31,7 +29,6 @@ const NavItem = (props: NavItemProps) => {
31
29
  aria = {},
32
30
  children,
33
31
  className,
34
- collapsible,
35
32
  data = {},
36
33
  iconLeft,
37
34
  iconRight,
@@ -56,100 +53,54 @@ const NavItem = (props: NavItemProps) => {
56
53
  className={classes}
57
54
  id={id}
58
55
  >
59
- {
60
- collapsible ? (
61
- <Collapsible icon={iconRight ? iconRight : ['plus','minus']} iconSize="xs" padding="none">
62
- <Collapsible.Main>
63
- <Tag
64
- className="pb_nav_list_item_link"
65
- href={link}
66
- onClick={onClick}
67
- target={target}
68
- >
69
- {imageUrl &&
70
- <div
71
- className="pb_nav_list_item_icon_section"
72
- key={imageUrl}
73
- >
74
- <Image
75
- className="pb_nav_img_wrapper"
76
- url={imageUrl}
77
- />
78
- </div>
79
- }
80
-
81
- {iconLeft &&
82
- <div
83
- className="pb_nav_list_item_icon_section"
84
- key={iconLeft}
85
- >
86
- <Icon
87
- className="pb_nav_list_item_icon_left"
88
- fixedWidth
89
- icon={iconLeft}
90
- />
91
- </div>
92
- }
93
- <span className="pb_nav_list_item_text">
94
- {text}
95
- </span>
96
- </Tag>
97
- </Collapsible.Main>
98
- <Collapsible.Content>
99
- {children}
100
- </Collapsible.Content>
101
- </Collapsible>
102
- ) : (
103
- <Tag
104
- className="pb_nav_list_item_link"
105
- href={link}
106
- onClick={onClick}
107
- target={target}
108
- >
109
- {imageUrl &&
110
- <div
111
- className="pb_nav_list_item_icon_section"
112
- key={imageUrl}
113
- >
114
- <Image
115
- className="pb_nav_img_wrapper"
116
- url={imageUrl}
117
- />
118
- </div>
119
- }
120
-
121
- {iconLeft &&
122
- <div
123
- className="pb_nav_list_item_icon_section"
124
- key={iconLeft}
125
- >
126
- <Icon
127
- className="pb_nav_list_item_icon_left"
128
- fixedWidth
129
- icon={iconLeft}
130
- />
131
- </div>
132
- }
133
-
134
- <span className="pb_nav_list_item_text">
135
- {text || children}
136
- </span>
137
-
138
- {iconRight &&
139
- <div
140
- className="pb_nav_list_item_icon_section"
141
- key={iconRight as string}
142
- >
143
- <Icon
144
- className="pb_nav_list_item_icon_right"
145
- fixedWidth
146
- icon={iconRight as string}
147
- />
148
- </div>
149
- }
150
- </Tag>
151
- )
152
- }
56
+ <Tag
57
+ className="pb_nav_list_item_link"
58
+ href={link}
59
+ onClick={onClick}
60
+ target={target}
61
+ >
62
+ {imageUrl &&
63
+ <div
64
+ className="pb_nav_list_item_icon_section"
65
+ key={imageUrl}
66
+ >
67
+ <Image
68
+ className="pb_nav_img_wrapper"
69
+ url={imageUrl}
70
+ />
71
+ </div>
72
+ }
73
+
74
+ {iconLeft &&
75
+ <div
76
+ className="pb_nav_list_item_icon_section"
77
+ key={iconLeft}
78
+ >
79
+ <Icon
80
+ className="pb_nav_list_item_icon_left"
81
+ fixedWidth
82
+ icon={iconLeft}
83
+ />
84
+ </div>
85
+ }
86
+
87
+ <span className="pb_nav_list_item_text">
88
+ {text || children}
89
+ </span>
90
+
91
+ {iconRight &&
92
+ <div
93
+ className="pb_nav_list_item_icon_section"
94
+ key={iconRight}
95
+ >
96
+ <Icon
97
+ className="pb_nav_list_item_icon_right"
98
+ fixedWidth
99
+ icon={iconRight}
100
+ />
101
+ </div>
102
+ }
103
+ </Tag>
153
104
  </li>
154
105
  )
155
106
  }
@@ -4,4 +4,3 @@
4
4
  @import "../tokens/colors";
5
5
  @import "./vertical_nav";
6
6
  @import "./horizontal_nav";
7
- @import "./collapsible_nav";
@@ -29,20 +29,22 @@
29
29
  flex: 1;
30
30
  font-weight: $regular;
31
31
  }
32
+ @media (hover:hover) {
33
+ &:hover {
34
+ background-color: rgba($primary, 0.03);
35
+ [class*=_icon] {
36
+ color: $primary;
37
+ }
38
+ [class*=_text] {
39
+ color: $primary;
40
+ }
41
+ }
42
+ }
32
43
  }
33
44
  &[class*=_active] [class*=_link] {
34
45
  @include pb_title_4;
35
46
  color: $primary;
36
47
  letter-spacing: normal;
37
48
  }
38
- &:hover {
39
- background-color: rgba($primary, 0.03);
40
- [class*=_icon] {
41
- color: $primary;
42
- }
43
- [class*=_text] {
44
- color: $primary;
45
- }
46
- }
47
49
  }
48
50
  }
@@ -7,7 +7,6 @@ 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: Subtle With Collapsible
11
10
  - subtle_no_highlight_nav: Subtle No Highlight
12
11
  - bold_vertical_nav: Bold Variant
13
12
  - horizontal_nav: Horizontal Nav
@@ -25,8 +24,6 @@ examples:
25
24
  - borderless_nav: No Borders
26
25
  - subtle_nav: Subtle Variant
27
26
  - subtle_with_icons_nav: Subtle With Icons
28
- - collapsible_nav: Subtle With Collapsible
29
- - collapsible_nav_custom_icons: Subtle With Collapsible (Custom Toggle Icons)
30
27
  - subtle_no_highlight_nav: Subtle No Highlight
31
28
  - bold_vertical_nav: Bold Variant
32
29
  - horizontal_nav: Horizontal Nav
@@ -13,5 +13,3 @@ export { default as WithImgNav } from './_with_img_nav.jsx'
13
13
  export { default as NewTab } from './_new_tab.jsx'
14
14
  export { default as BoldHorizontalNav } from './_bold_horizontal_nav.jsx'
15
15
  export { default as BoldVerticalNav } from './_bold_vertical_nav.jsx'
16
- export { default as CollapsibleNav } from './_collapsible_nav.jsx'
17
- export { default as CollapsibleNavCustomIcons } from './_collapsible_nav_custom_icons.jsx'
@@ -3,41 +3,19 @@
3
3
  class: object.classname,
4
4
  data: object.data,
5
5
  id: object.id) do %>
6
- <% if object.collapsible %>
7
- <%= pb_rails("collapsible", props: { name: "collapsible-nav-example" }) do %>
8
- <%= pb_rails("collapsible/collapsible_main", props: { name: "default-collapsible-nav", icon: object.collapsible_icons, size: "xs" }) do %>
9
- <%= content_tag(object.tag,
10
- object.link ? object.link_options : object.options) do %>
11
- <% if object.image_url %>
12
- <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper" }) %>
13
- <% end %>
14
- <% if object.icon_left %>
15
- <%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
16
- <% end %>
17
- <span class="pb_nav_list_item_text">
18
- <%= object.text %>
19
- </span>
20
- <% end %>
21
- <% end %>
22
- <%= pb_rails("collapsible/collapsible_content") do %>
23
- <%= content.presence %>
24
- <% end %>
6
+ <%= content_tag(object.tag,
7
+ object.link ? object.link_options : object.options) do %>
8
+ <% if object.image_url %>
9
+ <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper" }) %>
25
10
  <% end %>
26
- <% else %>
27
- <%= content_tag(object.tag,
28
- object.link ? object.link_options : object.options) do %>
29
- <% if object.image_url %>
30
- <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper" }) %>
31
- <% end %>
32
- <% if object.icon_left %>
33
- <%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
34
- <% end %>
35
- <span class="pb_nav_list_item_text">
36
- <%= object.text %><%= content.presence %>
37
- </span>
38
- <% if object.icon_right %>
39
- <%= pb_rails("icon", props: { icon: object.icon_right, classname: "pb_nav_list_item_icon_right", fixed_width: true}) %>
40
- <% end %>
11
+ <% if object.icon_left %>
12
+ <%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
13
+ <% end %>
14
+ <span class="pb_nav_list_item_text">
15
+ <%= object.text %><%= content.presence %>
16
+ </span>
17
+ <% if object.icon_right %>
18
+ <%= pb_rails("icon", props: { icon: object.icon_right, classname: "pb_nav_list_item_icon_right", fixed_width: true}) %>
41
19
  <% end %>
42
20
  <% end %>
43
21
  <% end %>
@@ -4,7 +4,6 @@ module Playbook
4
4
  module PbNav
5
5
  class Item < Playbook::KitBase
6
6
  prop :active, type: Playbook::Props::Boolean, default: false
7
- prop :collapsible, type: Playbook::Props::Boolean, default: false
8
7
  prop :link
9
8
  prop :text
10
9
  prop :icon_left
@@ -34,10 +33,6 @@ module Playbook
34
33
  )
35
34
  end
36
35
 
37
- def collapsible_icons
38
- icon_right.present? ? icon_right : %w[plus minus]
39
- end
40
-
41
36
  private
42
37
 
43
38
  def active_class
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
3
  import {
4
4
  Popper,
@@ -17,6 +17,7 @@ import {
17
17
 
18
18
  import classnames from "classnames";
19
19
  import { globalProps, GlobalProps } from "../utilities/globalProps";
20
+ import _uniqueId from 'lodash/uniqueId';
20
21
 
21
22
  type PbPopoverProps = {
22
23
  aria?: { [key: string]: string };
@@ -72,6 +73,7 @@ const Popover = (props: PbPopoverProps) => {
72
73
  maxWidth,
73
74
  minHeight,
74
75
  minWidth,
76
+ targetId,
75
77
  } = props;
76
78
 
77
79
  const popoverSpacing =
@@ -123,6 +125,7 @@ const Popover = (props: PbPopoverProps) => {
123
125
  popoverSpacing,
124
126
  overflowHandling
125
127
  )}
128
+ id={targetId}
126
129
  style={widthHeightStyles()}
127
130
  >
128
131
  {children}
@@ -136,6 +139,7 @@ const Popover = (props: PbPopoverProps) => {
136
139
  };
137
140
 
138
141
  const PbReactPopover = (props: PbPopoverProps) => {
142
+ const [targetId] = useState(_uniqueId('id-'))
139
143
  const {
140
144
  className,
141
145
  children,
@@ -163,25 +167,27 @@ const PbReactPopover = (props: PbPopoverProps) => {
163
167
  "click",
164
168
  ({ target }) => {
165
169
  const targetIsPopover =
166
- (target as HTMLElement).closest("[class^=pb_popover_tooltip]") !==
170
+ (target as HTMLElement).closest("#" + targetId) !==
167
171
  null;
168
172
  const targetIsReference =
169
- (target as HTMLElement).closest(".pb_popover_reference_wrapper") !==
173
+ (target as HTMLElement).closest("#reference-" + targetId) !==
170
174
  null;
171
175
 
172
176
  switch (closeOnClick) {
173
177
  case "outside":
174
- if (!targetIsPopover || targetIsReference) {
178
+ if (!targetIsPopover && !targetIsReference) {
175
179
  shouldClosePopover(true);
176
180
  }
177
181
  break;
178
182
  case "inside":
179
- if (targetIsPopover || targetIsReference) {
183
+ if (targetIsPopover) {
180
184
  shouldClosePopover(true);
181
185
  }
182
186
  break;
183
187
  case "any":
184
- shouldClosePopover(true);
188
+ if (targetIsPopover || !targetIsPopover && !targetIsReference) {
189
+ shouldClosePopover(true);
190
+ }
185
191
  break;
186
192
  }
187
193
  },
@@ -200,6 +206,7 @@ const PbReactPopover = (props: PbPopoverProps) => {
200
206
  offset={offset}
201
207
  placement={placement}
202
208
  referenceElement={referenceElement}
209
+ targetId={targetId}
203
210
  zIndex={zIndex}
204
211
  {...props}
205
212
  >
@@ -214,6 +221,7 @@ const PbReactPopover = (props: PbPopoverProps) => {
214
221
  <PopperReference>
215
222
  {({ ref }) => (
216
223
  <span
224
+ id={"reference-" + targetId}
217
225
  className="pb_popover_reference_wrapper"
218
226
  ref={ref}>
219
227
  <reference.type {...reference.props} />
@@ -24,6 +24,7 @@ const PopoverClose = (props) => {
24
24
 
25
25
  const handleOutsideTogglePopover = () => {
26
26
  setOutsideShowPopover(!showOutsidePopover)
27
+ setAnyShowPopover(false)
27
28
  }
28
29
 
29
30
  const handleAnyShouldClosePopover = (shouldClosePopover) => {
@@ -32,6 +33,7 @@ const PopoverClose = (props) => {
32
33
 
33
34
  const handleAnyTogglePopover = () => {
34
35
  setAnyShowPopover(!showAnyPopover)
36
+ setOutsideShowPopover(false)
35
37
  }
36
38
 
37
39
  const insidePopoverTrigger = (
@@ -49,13 +49,16 @@ export default class PbPopover extends PbEnhancedElement {
49
49
  checkCloseTooltip() {
50
50
  document.querySelector('body').addEventListener('click', ({ target } ) => {
51
51
  const isTooltipElement = (target as HTMLElement).closest(`#${this.tooltipId}`) !== null
52
+ const isTriggerElement = (target as HTMLElement).closest(`#${this.triggerElementId}`) !== null
52
53
 
53
54
  switch (this.closeOnClick) {
54
55
  case 'any':
55
- this.hideTooltip()
56
+ if (isTooltipElement || !isTooltipElement && !isTriggerElement) {
57
+ this.hideTooltip()
58
+ }
56
59
  break
57
60
  case 'outside':
58
- if (!isTooltipElement) {
61
+ if (!isTooltipElement && !isTriggerElement) {
59
62
  this.hideTooltip()
60
63
  }
61
64
  break