playbook_ui 12.25.0.pre.alpha.play822bolddefaultfortitle3764 → 12.25.0.pre.alpha.railsmultilevelimprovements776

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_swift.md +82 -1
  3. data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +14 -13
  4. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +3 -2
  5. data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +212 -0
  6. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +58 -98
  7. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +354 -86
  8. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.md +1 -1
  9. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb +1 -0
  10. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_form.html.erb +72 -0
  11. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -0
  12. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +3 -0
  13. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +1 -1
  14. data/app/pb_kits/playbook/pb_title/_title.scss +1 -1
  15. data/app/pb_kits/playbook/pb_title/_title.tsx +3 -2
  16. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +0 -1
  17. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +0 -6
  18. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +2 -1
  19. data/app/pb_kits/playbook/pb_title/title.rb +10 -3
  20. data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
  21. data/dist/playbook-rails.js +7 -7
  22. data/lib/playbook/forms/builder/multi_level_select_field.rb +12 -0
  23. data/lib/playbook/forms/builder.rb +1 -0
  24. data/lib/playbook/version.rb +1 -1
  25. metadata +5 -4
  26. data/app/pb_kits/playbook/pb_multi_level_select/_multi_select_helper.tsx +0 -31
  27. data/app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts +0 -87
@@ -1,19 +1,35 @@
1
- import React, { useState, useEffect, useMemo } from "react";
1
+ import React, { useState, useEffect, useRef } from "react";
2
2
  import classnames from "classnames";
3
3
  import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
4
- import { globalProps } from "../utilities/globalProps";
5
- import { findItemById, checkIt, unCheckIt, getParentAndAncestorsIds } from "./helper_functions";
6
- import MultiSelectHelper from "./_multi_select_helper";
4
+ import { globalProps, GlobalProps } from "../utilities/globalProps";
5
+ import Icon from "../pb_icon/_icon";
6
+ import Checkbox from "../pb_checkbox/_checkbox";
7
+ import FormPill from "../pb_form_pill/_form_pill";
8
+ import CircleIconButton from "../pb_circle_icon_button/_circle_icon_button";
9
+ import {
10
+ unCheckIt,
11
+ getAncestorsOfUnchecked,
12
+ unCheckedRecursive,
13
+ checkedRecursive,
14
+ filterFormattedDataById,
15
+ findByFilter,
16
+ getCheckedItems,
17
+ updateReturnItems,
18
+ recursiveReturnOnlyParent,
19
+ removeChildrenIfParentChecked,
20
+ getChildIds,
21
+ } from "./_helper_functions";
7
22
 
8
23
  type MultiLevelSelectProps = {
9
24
  aria?: { [key: string]: string };
10
25
  className?: string;
11
26
  data?: { [key: string]: string };
12
27
  id?: string;
28
+ name?: string;
13
29
  returnAllSelected?: boolean;
14
30
  treeData?: { [key: string]: string }[];
15
31
  onSelect?: (prop: { [key: string]: any }) => void;
16
- };
32
+ } & GlobalProps;
17
33
 
18
34
  const MultiLevelSelect = (props: MultiLevelSelectProps) => {
19
35
  const {
@@ -21,6 +37,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
21
37
  className,
22
38
  data = {},
23
39
  id,
40
+ name,
24
41
  returnAllSelected = false,
25
42
  treeData,
26
43
  onSelect = () => {},
@@ -34,104 +51,355 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
34
51
  className
35
52
  );
36
53
 
54
+ const dropdownRef = useRef(null);
55
+
56
+ //state for whether dropdown is open or closed
57
+ const [isClosed, setIsClosed] = useState(true);
58
+ //state from onchange for textinput, to use for filtering to create typeahead
59
+ const [filterItem, setFilterItem] = useState("");
60
+ //this is essentially the return that the user will get when they use the kit
61
+ const [returnedArray, setReturnedArray] = useState([]);
62
+ //formattedData with checked and parent_id added
37
63
  const [formattedData, setFormattedData] = useState(treeData);
38
- const [selectedItems, setSelectedItems] = useState([]);
39
- const [checkedData, setCheckedData] = useState([]);
40
-
41
- const onChange = (currentNode: { [key: string]: any }) => {
42
- const updatedData = formattedData.map((item: any) => {
43
- if (item.id === currentNode._id) {
44
- if (currentNode.checked) {
45
- checkIt(item, selectedItems, setSelectedItems, false);
46
- } else {
47
- unCheckIt(item, selectedItems, setSelectedItems, false);
48
- }
49
- } else if (item.children) {
50
- const foundItem = findItemById(item.children, currentNode._id);
51
- if (foundItem) {
52
- if (currentNode.checked) {
53
- checkIt(foundItem, selectedItems, setSelectedItems, false);
54
- if (currentNode._parent) {
55
- const parents = getParentAndAncestorsIds(currentNode._parent, formattedData)
56
- parents.forEach((item:string) => {
57
- const ancestor = findItemById(formattedData,item)
58
- ancestor.expanded = true
59
- });
60
- }
61
- } else {
62
- unCheckIt(foundItem, selectedItems, setSelectedItems, false);
63
- if (currentNode._parent) {
64
- const parents = getParentAndAncestorsIds(currentNode._parent, formattedData)
65
- parents.forEach((item:string) => {
66
- const ancestor = findItemById(formattedData,item)
67
- ancestor.expanded = true
68
- });
69
- }
70
- }
71
- }
72
- }
64
+ //toggle chevron in dropdown
65
+ //@ts-ignore
66
+ const [isToggled, setIsToggled] = useState<{ [id: number]: boolean }>({});
67
+ //state for return for default
68
+ const [defaultReturn, setDefaultReturn] = useState([]);
73
69
 
74
- return item;
75
- });
70
+ useEffect(() => {
71
+ let el = document.getElementById(`pb_data_wrapper_${id}`);
72
+ if (el) {
73
+ el.setAttribute(
74
+ "data-tree",
75
+ JSON.stringify(returnAllSelected ? returnedArray : defaultReturn)
76
+ );
77
+ }
78
+ updateHiddenInputValue(returnAllSelected ? returnedArray : defaultReturn);
79
+ returnAllSelected
80
+ ? onSelect(returnedArray)
81
+ : onSelect(
82
+ defaultReturn.filter(
83
+ (item, index, self) =>
84
+ index === self.findIndex((obj) => obj.id === item.id)
85
+ )
86
+ );
87
+ }, [returnedArray, defaultReturn]);
76
88
 
77
- setFormattedData(updatedData);
89
+
90
+
91
+ const updateHiddenInputValue = (value: any) => {
92
+ const hiddenInput = document.querySelector('input#'+id) as HTMLInputElement;
93
+ if (hiddenInput) {
94
+ hiddenInput.value = JSON.stringify(value);
95
+ }
78
96
  };
79
97
 
80
98
  useEffect(() => {
99
+ //Create new formattedData array for use
100
+ setFormattedData(addCheckedAndParentProperty(treeData));
101
+ // Function to handle clicks outside the dropdown
102
+ const handleClickOutside = (event: any) => {
103
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
104
+ setIsClosed(true);
105
+ }
106
+ };
107
+ //if any items already checked in first render, set return accordingly
108
+ const initialChecked = getCheckedItems(treeData)
109
+ initialChecked && returnAllSelected && setReturnedArray(initialChecked)
110
+ initialChecked && !returnAllSelected && setDefaultReturn(initialChecked)
111
+
112
+ // Attach the event listener
113
+ window.addEventListener("click", handleClickOutside);
114
+ // Clean up the event listener on unmount
115
+ return () => {
116
+ window.removeEventListener("click", handleClickOutside);
117
+ };
118
+ }, []);
119
+
120
+
121
+ //function to map over data and add parent_id + depth property to each item
122
+ const addCheckedAndParentProperty = (
123
+ treeData: { [key: string]: any }[],
124
+ parent_id: string = null,
125
+ depth: number = 0,
126
+ ) => {
127
+ if (!Array.isArray(treeData)) {
128
+ return;
129
+ }
130
+ return treeData.map((item: { [key: string]: any } | any) => {
131
+ const newItem = {
132
+ ...item,
133
+ parent_id,
134
+ depth,
135
+ };
136
+ if (newItem.children && newItem.children.length > 0) {
137
+ newItem.children = addCheckedAndParentProperty(
138
+ newItem.children,
139
+ newItem.id,
140
+ depth + 1,
141
+ );
142
+ }
143
+ return newItem;
144
+ });
145
+ };
146
+
147
+ //click event for x on form pill
148
+ const handlePillClose = (event: any, clickedItem: { [key: string]: any }) => {
149
+ // prevents the dropdown from closing when clicking on the pill
150
+ event.stopPropagation();
151
+ //logic for removing items from returnArray or defaultReturn when pills clicked
81
152
  if (returnAllSelected) {
82
- const selected = selectedItems.filter(
83
- (item: { [key: string]: any }) => item.checked
84
- );
85
- //filter to remove duplicate items
86
- const uniqueSelected = selected.filter(
87
- (obj, index, self) => index === self.findIndex((t) => t.id === obj.id)
88
- );
89
- setCheckedData(uniqueSelected);
153
+ if (returnedArray.includes(clickedItem)) {
154
+ if (clickedItem.children && clickedItem.children.length > 0) {
155
+ const childrenOfChecked = getChildIds(clickedItem, returnedArray);
156
+ const updatedFiltered = returnedArray
157
+ .filter((item) => item !== clickedItem)
158
+ .filter((item) => !childrenOfChecked.includes(item.id));
159
+ setReturnedArray(updatedFiltered);
160
+ } else {
161
+ const updatedFiltered = returnedArray.filter(
162
+ (item) => item !== clickedItem
163
+ );
164
+ setReturnedArray(updatedFiltered);
165
+ }
166
+ }
167
+ } else {
168
+ if (defaultReturn.includes(clickedItem)) {
169
+ getAncestorsOfUnchecked(formattedData, clickedItem);
170
+ const newChecked = getCheckedItems(formattedData);
171
+ const filteredReturn = updateReturnItems(newChecked).filter(
172
+ (item) => item.id !== clickedItem.id
173
+ );
174
+ setDefaultReturn(filteredReturn);
175
+ }
176
+ }
177
+ if (clickedItem.children && clickedItem.children.length > 0) {
178
+ unCheckedRecursive(clickedItem);
90
179
  }
91
- }, [selectedItems]);
180
+ //logic to uncheck clickedItem in formattedData
181
+ unCheckIt(formattedData, clickedItem.id);
182
+ };
92
183
 
93
- useEffect(() => {
94
- let el = document.getElementById(`pb_data_wrapper_${id}`);
95
- if (el) {
96
- el.setAttribute("data-tree", JSON.stringify(checkedData));
184
+ //handle click on input wrapper(entire div with pills, typeahead, etc) so it doesn't close when input or form pill is clicked
185
+ const handleInputWrapperClick = (e: any) => {
186
+ e.stopPropagation();
187
+ if (
188
+ e.target.id === "multiselect_input" ||
189
+ e.target.classList.contains("pb_form_pill_tag")
190
+ ) {
191
+ return;
97
192
  }
98
- if (returnAllSelected) {
99
- onSelect(checkedData);
193
+ setIsClosed(!isClosed);
194
+ };
195
+
196
+ //Main function to handle any click inside dropdown
197
+ const handledropdownItemClick = (e: any) => {
198
+ const clickedItem = e.target.parentNode.id;
199
+ //setting filterItem to "" will clear textinput and clear typeahead
200
+ setFilterItem("");
201
+
202
+ const filtered = filterFormattedDataById(formattedData, clickedItem);
203
+ //check and uncheck all children of checked/unchecked parent item
204
+ if (filtered[0].children && filtered[0].children.length > 0) {
205
+ if (filtered[0].checked) {
206
+ filtered[0].children.forEach((item: { [key: string]: any }) => {
207
+ checkedRecursive(item);
208
+ });
209
+ } else if (!filtered[0].checked) {
210
+ filtered[0].children.forEach((item: { [key: string]: any }) => {
211
+ unCheckedRecursive(item);
212
+ });
213
+ }
214
+ }
215
+
216
+ const checkedItems = getCheckedItems(formattedData);
217
+
218
+ //checking and unchecking items for returnAllSelected variant
219
+ if (returnedArray.includes(filtered[0])) {
220
+ if (!filtered[0].checked) {
221
+ if (filtered[0].children && filtered[0].children.length > 0) {
222
+ const childrenOfChecked = getChildIds(filtered[0], returnedArray);
223
+ const updatedFiltered = returnedArray
224
+ .filter((item) => item !== filtered[0])
225
+ .filter((item) => !childrenOfChecked.includes(item.id));
226
+
227
+ setReturnedArray(updatedFiltered);
228
+ } else {
229
+ const updatedFiltered = returnedArray.filter(
230
+ (item) => item !== filtered[0]
231
+ );
232
+ setReturnedArray(updatedFiltered);
233
+ }
234
+ }
235
+ } else {
236
+ setReturnedArray(checkedItems);
237
+ }
238
+
239
+ //when item is unchecked for default variant
240
+ if (!filtered[0].checked && !returnAllSelected) {
241
+ //uncheck parent and grandparent if any child unchecked
242
+ getAncestorsOfUnchecked(formattedData, filtered[0]);
243
+
244
+ const newChecked = getCheckedItems(formattedData);
245
+ //get all checked items, and filter to check if all children checked, if yes return only parent
246
+ const filteredReturn = updateReturnItems(newChecked);
247
+ setDefaultReturn(filteredReturn);
100
248
  }
101
- }, [checkedData]);
102
249
 
103
- const DropDownSelectComponent = useMemo(() => {
250
+ //when item is checked for default variant
251
+ if (!returnAllSelected && filtered[0].checked) {
252
+ //if checked item has children
253
+ if (filtered[0].children && filtered[0].children.length > 0) {
254
+ removeChildrenIfParentChecked(
255
+ filtered[0],
256
+ defaultReturn,
257
+ setDefaultReturn
258
+ );
259
+ }
260
+
261
+ //if clicked item has parent_id, find parent and check if all children checked or not
262
+ if (filtered[0].parent_id !== null) {
263
+ recursiveReturnOnlyParent(
264
+ filtered[0],
265
+ formattedData,
266
+ defaultReturn,
267
+ setDefaultReturn
268
+ );
269
+ } else {
270
+ setDefaultReturn([filtered[0]]);
271
+ }
272
+ }
273
+ };
274
+
275
+ //handle click on chevron toggles in dropdown
276
+ const handleToggleClick = (id: string, event: React.MouseEvent) => {
277
+ event.stopPropagation();
278
+ setIsToggled((prevState: { [id: string]: boolean }) => ({
279
+ ...prevState,
280
+ [id]: !prevState[id],
281
+ }));
282
+ const clickedItem = filterFormattedDataById(formattedData, id);
283
+
284
+ if (clickedItem) {
285
+ clickedItem[0].expanded = !clickedItem[0].expanded;
286
+ }
287
+ };
288
+
289
+ //rendering formattedData to UI based on typeahead
290
+ const renderNestedOptions = (items: { [key: string]: any }[]) => {
104
291
  return (
105
- <MultiSelectHelper
106
- treeData={formattedData}
107
- onChange={(
108
- // @ts-ignore
109
- selectedNodes: { [key: string]: any }[],
110
- currentNode: { [key: string]: any }[]
111
- ) => {
112
- setCheckedData(currentNode);
113
- onSelect(currentNode);
114
-
115
- }}
116
- id={id}
117
- {...props}
118
- />
292
+ <ul>
293
+ {Array.isArray(items) &&
294
+ items.map((item: { [key: string]: any }) => {
295
+ return (
296
+ <>
297
+ <li
298
+ key={item.id}
299
+ className="dropdown_item"
300
+ data-name={item.id}
301
+ >
302
+ <div className="dropdown_item_checkbox_row">
303
+ <div
304
+ key={
305
+ item.expanded ? "chevron-down" : "chevron-right"
306
+ }
307
+ >
308
+ <CircleIconButton
309
+ icon={
310
+ item.expanded ? "chevron-down" : "chevron-right"
311
+ }
312
+ className={item.children && item.children.length > 0 ? "" : "toggle_icon"}
313
+ onClick={(event) => handleToggleClick(item.id, event)}
314
+ variant="link"
315
+ />
316
+ </div>
317
+ <Checkbox text={item.label} id={item.id}>
318
+ <input
319
+ checked={item.checked}
320
+ type="checkbox"
321
+ name={item.label}
322
+ value={item.label}
323
+ onChange={(e) => {
324
+ item.checked = !item.checked;
325
+ handledropdownItemClick(e);
326
+ }}
327
+ />
328
+ </Checkbox>
329
+ </div>
330
+ {item.expanded &&
331
+ item.children &&
332
+ item.children.length > 0 &&
333
+ !filterItem && ( // Show children if expanded is true
334
+ <div>{renderNestedOptions(item.children)}</div>
335
+ )}
336
+ </li>
337
+ </>
338
+ );
339
+ })}
340
+ </ul>
119
341
  );
120
- }, [formattedData])
342
+ };
121
343
 
122
344
  return (
123
345
  <div {...ariaProps} {...dataProps} className={classes} id={id}>
124
- {returnAllSelected ? (
125
- <MultiSelectHelper
126
- treeData={formattedData}
127
- treeMode={returnAllSelected}
128
- id={id}
129
- onChange={onChange}
130
- {...props}
131
- />
132
- ) : (
133
- <>{DropDownSelectComponent}</>
134
- )}
346
+ <div ref={dropdownRef} className="wrapper">
347
+ <div className="input_wrapper" onClick={handleInputWrapperClick}>
348
+ <div className="input_inner_container">
349
+ <input type="hidden" id={id} name={name} value="" />
350
+ {returnedArray.length !== 0 && returnAllSelected
351
+ ? returnedArray.map((item, index) => (
352
+ <FormPill
353
+ key={index}
354
+ text={item.label}
355
+ size="small"
356
+ onClick={(event) => handlePillClose(event, item)}
357
+ />
358
+ ))
359
+ : null}
360
+ {!returnAllSelected &&
361
+ defaultReturn.length !== 0 &&
362
+ defaultReturn
363
+ .filter(
364
+ (item, index, self) =>
365
+ index === self.findIndex((obj) => obj.id === item.id)
366
+ )
367
+ .map((item, index) => (
368
+ <FormPill
369
+ key={index}
370
+ text={item.label}
371
+ size="small"
372
+ onClick={(event) => handlePillClose(event, item)}
373
+ />
374
+ ))}
375
+ {returnedArray.length !== 0 && returnAllSelected && <br />}
376
+ {defaultReturn.length !== 0 && !returnAllSelected && <br />}
377
+ <input
378
+ id="multiselect_input"
379
+ onChange={(e) => {
380
+ setFilterItem(e.target.value);
381
+ }}
382
+ placeholder="Start typing..."
383
+ value={filterItem}
384
+ onClick={() => setIsClosed(false)}
385
+ />
386
+ </div>
387
+ {isClosed ? (
388
+ <div key="chevron-down">
389
+ <Icon icon="chevron-down" />
390
+ </div>
391
+ ) : (
392
+ <div key="chevron-up">
393
+ <Icon icon="chevron-up" />
394
+ </div>
395
+ )}
396
+ </div>
397
+ <div className={`dropdown_menu ${isClosed ? "close" : "open"}`}>
398
+ {renderNestedOptions(
399
+ filterItem ? findByFilter(formattedData, filterItem) : formattedData
400
+ )}
401
+ </div>
402
+ </div>
135
403
  </div>
136
404
  );
137
405
  };
@@ -2,4 +2,4 @@ The MultiLevelSelect kit renders a multi leveled select dropdown based on data f
2
2
 
3
3
  For the React version of the kit, the `onSelect` prop returns an array of all checked items, irrespective of whether it is a parent, child or grandchild. Open the console on this example and check and uncheck checkboxes to see this is action!
4
4
 
5
- For the Rails version, the array of checked items is attached to the DOM in a data attribute titled `data-tree` on the wrapping div around the MultiLevelSelect.
5
+ For the Rails version, the array of checked items is attached to the DOM in a data attribute titled `data-tree` on the wrapping div around the MultiLevelSelect.
@@ -3,6 +3,7 @@
3
3
  value: "Power Home Remodeling",
4
4
  id: "powerhome1",
5
5
  expanded: true,
6
+
6
7
  children: [
7
8
  {
8
9
  label: "People",
@@ -0,0 +1,72 @@
1
+ <%= pb_form_with(scope: :example, url: "", method: :get) do |form| %>
2
+
3
+ <% treeData = [{
4
+ label: "Power Home Remodeling",
5
+ value: "Power Home Remodeling",
6
+ id: "powerhome1",
7
+ expanded: true,
8
+ children: [
9
+ {
10
+ label: "People",
11
+ value: "People",
12
+ id: "people1",
13
+ children: [
14
+ {
15
+ label: "Talent Acquisition",
16
+ value: "Talent Acquisition",
17
+ id: "talent1",
18
+ },
19
+ {
20
+ label: "Business Affairs",
21
+ value: "Business Affairs",
22
+ id: "business1",
23
+ children: [
24
+ {
25
+ label: "Initiatives",
26
+ value: "Initiatives",
27
+ id: "initiative1",
28
+ },
29
+ {
30
+ label: "Learning & Development",
31
+ value: "Learning & Development",
32
+ id: "development1",
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ label: "People Experience",
38
+ value: "People Experience",
39
+ id: "experience1",
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ label: "Contact Center",
45
+ value: "Contact Center",
46
+ id: "contact1",
47
+ children: [
48
+ {
49
+ label: "Appointment Management",
50
+ value: "Appointment Management",
51
+ id: "appointment1",
52
+ },
53
+ {
54
+ label: "Customer Service",
55
+ value: "Customer Service",
56
+ id: "customer1",
57
+ },
58
+ {
59
+ label: "Energy",
60
+ value: "Energy",
61
+ id: "energy1",
62
+ },
63
+ ],
64
+ },
65
+ ],
66
+ }] %>
67
+
68
+ <%= form.multi_level_select :example, props: {id: "with-form-multi-level-select", tree_data: treeData, return_all_selected: true } %>
69
+ <%= form.actions do |action| %>
70
+ <%= action.button props: { type: "submit", text: "Submit", variant: "primary", margin_top: "lg" } %>
71
+ <% end %>
72
+ <% end %>
@@ -2,6 +2,7 @@ examples:
2
2
  rails:
3
3
  - multi_level_select_default: Default
4
4
  - multi_level_select_return_all_selected: Return All Selected
5
+ - multi_level_select_with_form: With Form
5
6
 
6
7
  react:
7
8
  - multi_level_select_default: Default
@@ -3,6 +3,8 @@
3
3
  module Playbook
4
4
  module PbMultiLevelSelect
5
5
  class MultiLevelSelect < Playbook::KitBase
6
+ prop :id
7
+ prop :name
6
8
  prop :tree_data, type: Playbook::Props::Array,
7
9
  default: []
8
10
  prop :return_all_selected, type: Playbook::Props::Boolean,
@@ -15,6 +17,7 @@ module Playbook
15
17
  def multi_level_select_options
16
18
  {
17
19
  id: id,
20
+ name: name,
18
21
  treeData: tree_data,
19
22
  returnAllSelected: return_all_selected,
20
23
  }
@@ -16,7 +16,7 @@ const treeData = {
16
16
  {
17
17
  label: 'No one can get me',
18
18
  value: 'anonymous',
19
- id:'default2',
19
+ id:'default3',
20
20
  },
21
21
  ],
22
22
  },
@@ -30,7 +30,7 @@
30
30
  @include pb_title_dark;
31
31
  }
32
32
 
33
- &[class*=_thin] {
33
+ &[class*=thin] {
34
34
  @include pb_title_thin;
35
35
  }
36
36
  }
@@ -27,7 +27,7 @@ const Title = (props: TitleProps): React.ReactElement => {
27
27
  data = {},
28
28
  id,
29
29
  size = 3,
30
- bold = true,
30
+ bold = size === 3 ? false : true,
31
31
  tag = 'h3',
32
32
  text,
33
33
  variant = null,
@@ -35,9 +35,10 @@ const Title = (props: TitleProps): React.ReactElement => {
35
35
 
36
36
  const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
37
37
  const dataProps: {[key: string]: string | number} = buildDataProps(data)
38
+
38
39
  const getBold = bold ? '' : 'thin'
39
40
  const classes = classnames(
40
- buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
41
+ buildCss("pb_title_kit", `size_${size}`, variant, color) + ` ${getBold}`,
41
42
  globalProps(props),
42
43
  className
43
44
  )
@@ -1,3 +1,2 @@
1
1
  <%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1, bold: false }) %>
2
2
  <%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2, bold: false }) %>
3
- <%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3, bold: false }) %>
@@ -17,12 +17,6 @@ const TitleLightWeight = (props) => {
17
17
  text='Title 2'
18
18
  {...props}
19
19
  />
20
- <Title bold={false}
21
- size={3}
22
- tag='h2'
23
- text='Title 3'
24
- {...props}
25
- />
26
20
  </div>
27
21
  )
28
22
  }
@@ -1,3 +1,4 @@
1
1
  ##### Prop
2
- Title `size 1`, `size 2`, & `size 3` will use `font-weight: 700` by default, if you want a lighter font weight, use the `bold` prop set to `false`.
2
+ Title `size 1` & `size 2` will use `font-weight: 700` by default, if you want a lighter font weight, use the `bold` prop set to `false`.
3
+ Title `size 3` uses a light font weight by default and will not accept a bold font weight.
3
4
  Title `size 4` uses a heavy font weight by default and will not accept a lighter font weight.