playbook_ui 14.3.2 → 14.4.0.pre.alpha.PLAY1546highchartsbump3831

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +2 -6
  3. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.ts +2 -7
  4. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +2 -3
  5. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +245 -23
  6. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +1 -1
  7. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.html.erb +117 -0
  8. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.jsx +227 -0
  9. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.md +1 -0
  10. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
  11. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
  12. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -1
  13. data/app/pb_kits/playbook/pb_icon/icon.rb +1 -1
  14. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +5 -1
  15. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.html.erb +72 -0
  16. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.jsx +91 -0
  17. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color_rails.md +1 -0
  18. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color_react.md +1 -0
  19. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -0
  20. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
  21. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +4 -0
  22. data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.scss +97 -21
  23. data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.test.js +166 -0
  24. data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.tsx +45 -6
  25. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_bubble.html.erb +73 -0
  26. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_bubble.jsx +86 -0
  27. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/example.yml +2 -0
  28. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/index.js +1 -0
  29. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +6 -2
  30. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.rb +21 -1
  31. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.html.erb +48 -0
  32. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.md +1 -0
  33. data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -0
  34. data/app/pb_kits/playbook/pb_radio/index.js +17 -0
  35. data/app/pb_kits/playbook/pb_radio/radio.html.erb +35 -13
  36. data/app/pb_kits/playbook/pb_radio/radio.rb +3 -1
  37. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +16 -0
  38. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +4 -0
  39. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +26 -18
  40. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color.html.erb +31 -0
  41. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color.jsx +26 -0
  42. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color_rails.md +1 -0
  43. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color_react.md +1 -0
  44. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  45. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  46. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
  47. data/app/pb_kits/playbook/tokens/_colors.scss +2 -0
  48. data/dist/chunks/_typeahead-D7A7UtDj.js +22 -0
  49. data/dist/chunks/_weekday_stacked-cRBjVQjA.js +45 -0
  50. data/dist/chunks/lib-D2U4I1U6.js +16 -0
  51. data/dist/chunks/{pb_form_validation-u2wnZ3oe.js → pb_form_validation-zV9OpdSt.js} +1 -1
  52. data/dist/chunks/vendor.js +1 -1
  53. data/dist/playbook-doc.js +1 -1
  54. data/dist/playbook-rails-react-bindings.js +1 -1
  55. data/dist/playbook-rails.js +1 -1
  56. data/dist/playbook.css +1 -1
  57. data/lib/playbook/version.rb +2 -2
  58. metadata +25 -9
  59. data/dist/chunks/_typeahead-DbAz2Okr.js +0 -22
  60. data/dist/chunks/_weekday_stacked-CZ5S17_d.js +0 -45
  61. data/dist/chunks/lib-D9uVVKnh.js +0 -16
@@ -58,4 +58,170 @@ test('should pass aria prop', () => {
58
58
  render(<MultipleUsersStackedDefault />)
59
59
  const kit = screen.getByTestId(testId)
60
60
  expect(kit).toHaveAttribute('aria-label', testId)
61
+ })
62
+
63
+ const MultipleUsersStackedSingleBubble = () => {
64
+ return (
65
+ <MultipleUsersStacked
66
+ aria={{ label: testId }}
67
+ className={className}
68
+ data={{ testid: testId }}
69
+ users={[
70
+ {
71
+ name: "user1",
72
+ imageUrl: "imageUser1",
73
+ imageAlt: "nameUser1",
74
+ }
75
+ ]}
76
+ variant="bubble"
77
+ />
78
+ )
79
+ }
80
+
81
+ test('should have a single bubble', () => {
82
+ render(<MultipleUsersStackedSingleBubble />)
83
+ const kit = screen.getByTestId(testId)
84
+ expect(kit).toHaveClass("pb_multiple_users_stacked_kit_single_bubble")
85
+
86
+ const firstItem = kit.querySelector('.first_item');
87
+ expect(firstItem).toBeInTheDocument();
88
+ })
89
+
90
+ const MultipleUsersStackedDoubleBubble = () => {
91
+ return (
92
+ <MultipleUsersStacked
93
+ aria={{ label: testId }}
94
+ className={className}
95
+ data={{ testid: testId }}
96
+ users={[
97
+ {
98
+ name: "user1",
99
+ imageUrl: "imageUser1",
100
+ imageAlt: "nameUser1",
101
+ },
102
+ {
103
+ name: "user2",
104
+ imageUrl: "imageUser2",
105
+ imageAlt: "nameUser2",
106
+ },
107
+ ]}
108
+ variant="bubble"
109
+ />
110
+ )
111
+ }
112
+
113
+ test('should have a double bubble', () => {
114
+ render(<MultipleUsersStackedDoubleBubble />)
115
+ const kit = screen.getByTestId(testId)
116
+ expect(kit).toHaveClass("pb_multiple_users_stacked_kit_bubble")
117
+
118
+ const firstItem = kit.querySelector('.first_item');
119
+ expect(firstItem).toBeInTheDocument();
120
+
121
+ const secondItem = kit.querySelector('.second_item');
122
+ expect(secondItem).toBeInTheDocument();
123
+ })
124
+
125
+ const MultipleUsersStackedTripleBubble = () => {
126
+ return (
127
+ <MultipleUsersStacked
128
+ aria={{ label: testId }}
129
+ className={className}
130
+ data={{ testid: testId }}
131
+ users={[
132
+ {
133
+ name: "user1",
134
+ imageUrl: "imageUser1",
135
+ imageAlt: "nameUser1",
136
+ },
137
+ {
138
+ name: "user2",
139
+ imageUrl: "imageUser2",
140
+ imageAlt: "nameUser2",
141
+ },
142
+ {
143
+ name: "user3",
144
+ imageUrl: "imageUser3",
145
+ imageAlt: "nameUser3",
146
+ },
147
+ ]}
148
+ variant="bubble"
149
+ />
150
+ )
151
+ }
152
+
153
+ test('should have a triple bubble', () => {
154
+ render(<MultipleUsersStackedTripleBubble />)
155
+ const kit = screen.getByTestId(testId)
156
+ expect(kit).toHaveClass("pb_multiple_users_stacked_kit_bubble")
157
+
158
+ const firstItem = kit.querySelector('.first_item');
159
+ expect(firstItem).toBeInTheDocument();
160
+ expect(firstItem).toHaveClass("triple_bubble")
161
+
162
+ const secondItem = kit.querySelector('.second_item');
163
+ expect(secondItem).toBeInTheDocument();
164
+ expect(secondItem).toHaveClass("triple_bubble")
165
+
166
+ const thirdItem = kit.querySelector('.third_item');
167
+ expect(thirdItem).toBeInTheDocument();
168
+ })
169
+
170
+ const MultipleUsersStackedQuadrupleBubble = () => {
171
+ return (
172
+ <MultipleUsersStacked
173
+ aria={{ label: testId }}
174
+ className={className}
175
+ data={{ testid: testId }}
176
+ users={[
177
+ {
178
+ name: "user1",
179
+ imageUrl: "imageUser1",
180
+ imageAlt: "nameUser1",
181
+ },
182
+ {
183
+ name: "user2",
184
+ imageUrl: "imageUser2",
185
+ imageAlt: "nameUser2",
186
+ },
187
+ {
188
+ name: "user3",
189
+ imageUrl: "imageUser3",
190
+ imageAlt: "nameUser3",
191
+ },
192
+ {
193
+ name: "user4",
194
+ imageUrl: "imageUser4",
195
+ imageAlt: "nameUser4",
196
+ },
197
+ {
198
+ name: "user5",
199
+ imageUrl: "imageUser5",
200
+ imageAlt: "nameUser5",
201
+ },
202
+ ]}
203
+ variant="bubble"
204
+ />
205
+ )
206
+ }
207
+
208
+ test('should have a quadruple bubble', () => {
209
+ render(<MultipleUsersStackedQuadrupleBubble />)
210
+ const kit = screen.getByTestId(testId)
211
+ expect(kit).toHaveClass("pb_multiple_users_stacked_kit_bubble")
212
+
213
+ const firstItem = kit.querySelector('.first_item');
214
+ expect(firstItem).toBeInTheDocument();
215
+ expect(firstItem).toHaveClass("quadruple_bubble")
216
+
217
+ const secondItem = kit.querySelector('.second_item');
218
+ expect(secondItem).toBeInTheDocument();
219
+ expect(secondItem).toHaveClass("quadruple_bubble")
220
+
221
+ const thirdItem = kit.querySelector('.third_item');
222
+ expect(thirdItem).toBeInTheDocument();
223
+ expect(thirdItem).toHaveClass("quadruple_bubble")
224
+
225
+ const fourthItem = kit.querySelector('.fourth_item');
226
+ expect(fourthItem).toBeInTheDocument();
61
227
  })
@@ -15,6 +15,7 @@ type MultipleUsersStackedProps = {
15
15
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
16
16
  id?: string,
17
17
  users: Array<{ [key: string]: string }>,
18
+ variant: "default" | "bubble",
18
19
  }
19
20
 
20
21
  const MultipleUsersStacked = (props: MultipleUsersStackedProps) => {
@@ -26,10 +27,14 @@ const MultipleUsersStacked = (props: MultipleUsersStackedProps) => {
26
27
  htmlOptions = {},
27
28
  id,
28
29
  users,
30
+ variant = "default",
29
31
  } = props
30
32
 
31
33
  const moreThanTwo = users.length > 2
32
34
  const onlyOne = users.length == 1
35
+ const isBubble = variant === "bubble"
36
+ const tripleBubble = isBubble && users.length === 3
37
+ const quadrupleBubble = isBubble && users.length > 3
33
38
  const displayCount = () => {
34
39
  return moreThanTwo ? 1 : users.length
35
40
  }
@@ -38,29 +43,61 @@ const MultipleUsersStacked = (props: MultipleUsersStackedProps) => {
38
43
  const htmlProps = buildHtmlProps(htmlOptions)
39
44
  const classes = classnames(buildCss(
40
45
  'pb_multiple_users_stacked_kit',
41
- { single: onlyOne }), globalProps(props), className)
46
+ { single: onlyOne, bubble: isBubble }), globalProps(props), className)
42
47
 
43
48
  const firstUser = () => {
44
49
  return users.slice(0, 1).map((userObject, index) => {
45
50
  return (
46
51
  <Avatar
47
52
  {...userObject}
48
- className="pb_multiple_users_stacked_item"
53
+ className={`pb_multiple_users_stacked_item first_item${tripleBubble ? " triple_bubble" : ""}${quadrupleBubble ? " quadruple_bubble" : ""}`}
49
54
  dark={dark}
50
55
  key={index}
51
- size="xs"
56
+ size={isBubble ? "sm" : "xs"}
52
57
  />
53
58
  )
54
59
  })
55
60
  }
56
61
 
57
62
  const secondUser = () => {
58
- if (moreThanTwo === false) {
63
+ if (!moreThanTwo || (isBubble && users.length > 1)) {
59
64
  return users.slice(1, 2).map((userObject, index) => {
60
65
  return (
61
66
  <Avatar
62
67
  {...userObject}
63
- className="pb_multiple_users_stacked_item second_item"
68
+ className={`pb_multiple_users_stacked_item second_item${tripleBubble ? " triple_bubble" : ""}${quadrupleBubble ? " quadruple_bubble" : ""}`}
69
+ dark={dark}
70
+ key={index}
71
+ size="xs"
72
+ />
73
+ )
74
+ })
75
+ }
76
+ }
77
+
78
+ const thirdUser = () => {
79
+ if (isBubble && users.length > 2) {
80
+ return users.slice(2, 3).map((userObject, index) => {
81
+ return (
82
+ <Avatar
83
+ {...userObject}
84
+ className={`pb_multiple_users_stacked_item third_item${quadrupleBubble ? " quadruple_bubble" : ""}`}
85
+ dark={dark}
86
+ key={index}
87
+ size="xs"
88
+ />
89
+ )
90
+ })
91
+ }
92
+ }
93
+
94
+ const fourthUser = () => {
95
+ if (isBubble && users.length > 3) {
96
+ return users.slice(3, 4).map((userObject, index) => {
97
+ return (
98
+ <Avatar
99
+ {...userObject}
100
+ className="pb_multiple_users_stacked_item fourth_item"
64
101
  dark={dark}
65
102
  key={index}
66
103
  size="xs"
@@ -71,7 +108,7 @@ const MultipleUsersStacked = (props: MultipleUsersStackedProps) => {
71
108
  }
72
109
 
73
110
  const plusUsers = () => {
74
- if (moreThanTwo === true) {
111
+ if (moreThanTwo && !isBubble) {
75
112
  return (
76
113
  <Badge
77
114
  className="pb_multiple_users_stacked_item second_item"
@@ -94,6 +131,8 @@ const MultipleUsersStacked = (props: MultipleUsersStackedProps) => {
94
131
  >
95
132
  {firstUser()}
96
133
  {secondUser()}
134
+ {thirdUser()}
135
+ {fourthUser()}
97
136
  {plusUsers()}
98
137
  </div>
99
138
  )
@@ -0,0 +1,73 @@
1
+ <%= pb_rails("multiple_users_stacked", props: {
2
+ variant: "bubble",
3
+ users: [
4
+ {
5
+ name: "Patrick Welch",
6
+ image_url: "https://randomuser.me/api/portraits/men/9.jpg",
7
+ }
8
+ ]
9
+ }) %>
10
+
11
+ <br/><br/>
12
+
13
+ <%= pb_rails("multiple_users_stacked", props: {
14
+ variant: "bubble",
15
+ users: [
16
+ {
17
+ name: "Patrick Welch",
18
+ image_url: "https://randomuser.me/api/portraits/men/9.jpg",
19
+ },
20
+ {
21
+ name: "Lucille Sanchez",
22
+ image_url: "https://randomuser.me/api/portraits/women/6.jpg",
23
+ }
24
+ ]
25
+ }) %>
26
+
27
+ <br/><br/>
28
+
29
+ <%= pb_rails("multiple_users_stacked", props: {
30
+ variant: "bubble",
31
+ users: [
32
+ {
33
+ name: "Patrick Welch",
34
+ image_url: "https://randomuser.me/api/portraits/men/9.jpg",
35
+ },
36
+ {
37
+ name: "Lucille Sanchez",
38
+ image_url: "https://randomuser.me/api/portraits/women/6.jpg",
39
+ },
40
+ {
41
+ name: "Beverly Reyes",
42
+ image_url: "https://randomuser.me/api/portraits/women/74.jpg",
43
+ },
44
+ ]
45
+ }) %>
46
+
47
+ <br/><br/>
48
+
49
+ <%= pb_rails("multiple_users_stacked", props: {
50
+ variant: "bubble",
51
+ users: [
52
+ {
53
+ name: "Patrick Welch",
54
+ image_url: "https://randomuser.me/api/portraits/men/9.jpg",
55
+ },
56
+ {
57
+ name: "Lucille Sanchez",
58
+ image_url: "https://randomuser.me/api/portraits/women/6.jpg",
59
+ },
60
+ {
61
+ name: "Beverly Reyes",
62
+ image_url: "https://randomuser.me/api/portraits/women/74.jpg",
63
+ },
64
+ {
65
+ name: "Keith Craig",
66
+ image_url: "https://randomuser.me/api/portraits/men/40.jpg",
67
+ },
68
+ {
69
+ name: "Alicia Cooper",
70
+ image_url: "https://randomuser.me/api/portraits/women/46.jpg",
71
+ }
72
+ ]
73
+ }) %>
@@ -0,0 +1,86 @@
1
+ import React from 'react'
2
+
3
+ import MultipleUsersStacked from '../_multiple_users_stacked'
4
+
5
+ const MultipleUsersStackedBubble = (props) => {
6
+ return (
7
+ <div>
8
+ <MultipleUsersStacked
9
+ users={[
10
+ {
11
+ name: 'Patrick Welch',
12
+ imageUrl: 'https://randomuser.me/api/portraits/men/9.jpg',
13
+ },
14
+ ]}
15
+ variant="bubble"
16
+ {...props}
17
+ />
18
+ <br />
19
+ <br />
20
+ <MultipleUsersStacked
21
+ users={[
22
+ {
23
+ name: 'Patrick Welch',
24
+ imageUrl: 'https://randomuser.me/api/portraits/men/9.jpg',
25
+ },
26
+ {
27
+ name: 'Lucille Sanchez',
28
+ imageUrl: 'https://randomuser.me/api/portraits/women/6.jpg',
29
+ },
30
+ ]}
31
+ variant="bubble"
32
+ {...props}
33
+ />
34
+ <br />
35
+ <br />
36
+ <MultipleUsersStacked
37
+ users={[
38
+ {
39
+ name: 'Patrick Welch',
40
+ imageUrl: 'https://randomuser.me/api/portraits/men/9.jpg',
41
+ },
42
+ {
43
+ name: 'Lucille Sanchez',
44
+ imageUrl: 'https://randomuser.me/api/portraits/women/6.jpg',
45
+ },
46
+ {
47
+ name: 'Beverly Reyes',
48
+ imageUrl: 'https://randomuser.me/api/portraits/women/74.jpg',
49
+ },
50
+ ]}
51
+ variant="bubble"
52
+ {...props}
53
+ />
54
+ <br />
55
+ <br />
56
+ <MultipleUsersStacked
57
+ users={[
58
+ {
59
+ name: 'Patrick Welch',
60
+ imageUrl: 'https://randomuser.me/api/portraits/men/9.jpg',
61
+ },
62
+ {
63
+ name: 'Lucille Sanchez',
64
+ imageUrl: 'https://randomuser.me/api/portraits/women/6.jpg',
65
+ },
66
+ {
67
+ name: 'Beverly Reyes',
68
+ imageUrl: 'https://randomuser.me/api/portraits/women/74.jpg',
69
+ },
70
+ {
71
+ name: 'Keith Craig',
72
+ imageUrl: 'https://randomuser.me/api/portraits/men/40.jpg',
73
+ },
74
+ {
75
+ name: 'Alicia Cooper',
76
+ imageUrl: 'https://randomuser.me/api/portraits/women/46.jpg',
77
+ },
78
+ ]}
79
+ variant="bubble"
80
+ {...props}
81
+ />
82
+ </div>
83
+ )
84
+ }
85
+
86
+ export default MultipleUsersStackedBubble
@@ -2,10 +2,12 @@ examples:
2
2
 
3
3
  rails:
4
4
  - multiple_users_stacked_default: Default
5
+ - multiple_users_stacked_bubble: Bubble
5
6
 
6
7
 
7
8
  react:
8
9
  - multiple_users_stacked_default: Default
10
+ - multiple_users_stacked_bubble: Bubble
9
11
 
10
12
  swift:
11
13
  - multiple_users_stacked_default_swift: Default
@@ -1 +1,2 @@
1
1
  export { default as MultipleUsersStackedDefault } from './_multiple_users_stacked_default.jsx'
2
+ export { default as MultipleUsersStackedBubble } from './_multiple_users_stacked_bubble.jsx'
@@ -1,14 +1,18 @@
1
1
  <%= pb_content_tag do %>
2
- <%= pb_rails("avatar", props: object.users[0].merge({size: "xs", classname: "pb_multiple_users_stacked_item", dark: object.dark}) ) %>
2
+ <%= pb_rails("avatar", props: object.users[0].merge({size: object.bubble ? "sm" : "xs", classname: "pb_multiple_users_stacked_item first_item#{object.triple_bubble ? " triple_bubble" : ""}#{object.quadruple_bubble ? " quadruple_bubble" : ""}", dark: object.dark}) ) %>
3
3
 
4
4
  <% unless object.only_one %>
5
- <% if object.more_than_two %>
5
+ <% if object.more_than_two && !object.bubble %>
6
6
  <%= pb_rails("badge", props: {
7
7
  dark: object.dark,
8
8
  text: "+#{object.users.count - object.display_count}",
9
9
  variant: "primary",
10
10
  rounded: true,
11
11
  classname: "pb_multiple_users_stacked_item second_item" }) %>
12
+ <% elsif object.bubble %>
13
+ <% object.users.slice(1,3).each_with_index do |item, idx| %>
14
+ <%= pb_rails("avatar", props: item.merge({size: "xs", classname: "pb_multiple_users_stacked_item #{idx == 0 ? "second_item#{object.triple_bubble ? " triple_bubble" : ""}#{object.quadruple_bubble ? " quadruple_bubble" : ""}" : idx == 1 ? "third_item#{object.quadruple_bubble ? " quadruple_bubble" : ""}" : "fourth_item"}", dark: object.dark}) ) %>
15
+ <% end %>
12
16
  <% else %>
13
17
  <%= pb_rails("avatar", props: object.users[1].merge({size: "xs", classname: "pb_multiple_users_stacked_item second_item", dark: object.dark}) ) %>
14
18
  <% end %>
@@ -5,6 +5,10 @@ module Playbook
5
5
  class MultipleUsersStacked < Playbook::KitBase
6
6
  prop :users, type: Playbook::Props::HashArray, required: true
7
7
 
8
+ prop :variant, type: Playbook::Props::Enum,
9
+ values: %w[default bubble],
10
+ default: "default"
11
+
8
12
  def more_than_two
9
13
  users.count > 2
10
14
  end
@@ -17,8 +21,20 @@ module Playbook
17
21
  more_than_two ? 1 : users.count
18
22
  end
19
23
 
24
+ def bubble
25
+ variant == "bubble"
26
+ end
27
+
28
+ def triple_bubble
29
+ bubble && users.count === 3
30
+ end
31
+
32
+ def quadruple_bubble
33
+ bubble && users.count > 3
34
+ end
35
+
20
36
  def classname
21
- generate_classname("pb_multiple_users_stacked_kit", single_class)
37
+ generate_classname("pb_multiple_users_stacked_kit", single_class, bubble_class)
22
38
  end
23
39
 
24
40
  private
@@ -26,6 +42,10 @@ module Playbook
26
42
  def single_class
27
43
  only_one ? "single" : nil
28
44
  end
45
+
46
+ def bubble_class
47
+ bubble ? "bubble" : nil
48
+ end
29
49
  end
30
50
  end
31
51
  end
@@ -0,0 +1,48 @@
1
+ <%
2
+ options = [
3
+ { label: "Orange", value: "Orange" },
4
+ { label: "Red", value: "Red" },
5
+ { label: "Green", value: "Green" },
6
+ { label: "Blue", value: "Blue" },
7
+ ]
8
+ %>
9
+
10
+ <%= pb_rails("radio", props: {
11
+ custom_children: true,
12
+ label: "Select",
13
+ name: "Group1",
14
+ value: "Select",
15
+ }) do %>
16
+ <%= pb_rails("select", props: {
17
+ min_width: "xs",
18
+ options: options,
19
+ }) %>
20
+ <% end %>
21
+
22
+ <%= pb_rails("radio", props: {
23
+ custom_children: true,
24
+ label: "Typeahead",
25
+ name: "Group1",
26
+ value: "Typeahead",
27
+ }) do %>
28
+ <%= pb_rails("typeahead", props: {
29
+ id: "typeahead-radio",
30
+ is_multi: false,
31
+ min_width: "xs",
32
+ options: options,
33
+ placeholder: "Select...",
34
+ })
35
+ %>
36
+ <% end %>
37
+
38
+ <%= pb_rails("radio", props: {
39
+ custom_children: true,
40
+ label: "Typography",
41
+ name: "Group1",
42
+ value: "Typography",
43
+ }) do %>
44
+ <%= pb_rails("title", props: {
45
+ text: "Custom Typography",
46
+ })
47
+ %>
48
+ <% end %>
@@ -0,0 +1 @@
1
+ Use the `custom_children` prop to enable the use of kits instead of text labels.
@@ -7,6 +7,7 @@ examples:
7
7
  - radio_options: With Options
8
8
  - radio_alignment: Alignment
9
9
  - radio_disabled: Disabled
10
+ - radio_custom_children: Custom Children
10
11
 
11
12
  react:
12
13
  - radio_default: Default
@@ -0,0 +1,17 @@
1
+ import PbEnhancedElement from "../pb_enhanced_element"
2
+
3
+ const RADIO_SELECTOR = "[data-pb-radio-children]"
4
+ const RADIO_WRAPPER_SELECTOR = "[data-pb-radio-children-wrapper]"
5
+
6
+ export default class PbRadio extends PbEnhancedElement {
7
+ static get selector() {
8
+ return RADIO_SELECTOR
9
+ }
10
+
11
+ connect() {
12
+ const radioWrapperElement = this.element.parentElement.querySelector(RADIO_WRAPPER_SELECTOR)
13
+ radioWrapperElement.addEventListener("click", () => {
14
+ this.element.querySelector("input[type='radio']").click()
15
+ })
16
+ }
17
+ }
@@ -1,18 +1,40 @@
1
- <%= content_tag(:label,
1
+ <% if object.custom_children %>
2
+ <%= pb_rails("flex", props: {
2
3
  aria: object.aria,
3
- checked: object.checked,
4
+ align: "center",
4
5
  class: object.classname,
6
+ cursor: "pointer",
5
7
  data: object.data,
6
- id: object.id,
7
- value: object.value,
8
- **combined_html_options) do %>
9
-
10
- <% if content.present? %>
11
- <%= content %>
12
- <% else %>
13
- <%= radio_button_tag object.name, object.value, object.selected, object.input_options %>
8
+ **combined_html_options
9
+ }) do %>
10
+ <%= content_tag(:label,
11
+ 'data-pb-radio-children': 'true',
12
+ checked: object.checked,
13
+ class: object.classname,
14
+ id: object.id,
15
+ value: object.value) do %>
16
+ <%= input %>
17
+ <span class="pb_radio_button"></span>
14
18
  <% end %>
19
+ <div data-pb-radio-children-wrapper="true"> <%= content %> </div>
20
+ <% end %>
21
+ <% else %>
22
+ <%= content_tag(:label,
23
+ aria: object.aria,
24
+ checked: object.checked,
25
+ class: object.classname,
26
+ data: object.data,
27
+ id: object.id,
28
+ value: object.value,
29
+ **combined_html_options) do %>
30
+
31
+ <% if content.present? %>
32
+ <%= content %>
33
+ <% else %>
34
+ <%= radio_button_tag object.name, object.value, object.selected, object.input_options %>
35
+ <% end %>
15
36
 
16
- <span class="pb_radio_button"></span>
17
- <%= pb_rails("body", props: { status: object.body_status, text: object.text, dark: object.dark }) %>
18
- <% end %>
37
+ <span class="pb_radio_button"></span>
38
+ <%= pb_rails("body", props: { status: object.body_status, text: object.text, dark: object.dark }) %>
39
+ <% end %>
40
+ <% end %>
@@ -20,6 +20,8 @@ module Playbook
20
20
  default: "Radio Text"
21
21
  prop :value, type: Playbook::Props::String,
22
22
  default: "radio_text"
23
+ prop :custom_children, type: Playbook::Props::Boolean,
24
+ default: false
23
25
 
24
26
  def classname
25
27
  generate_classname("pb_radio_kit") + error_class + alignment_class
@@ -34,7 +36,7 @@ module Playbook
34
36
  end
35
37
 
36
38
  def input
37
- radio_button_tag(name, value, checked, input_options.merge(disabled: disabled))
39
+ radio_button_tag(name, value, checked, input_options.merge(disabled: disabled || input_options[:disabled]))
38
40
  end
39
41
 
40
42
  private