playbook_ui 13.27.0.pre.alpha.PBNTR294paginationstylingfix2899 → 13.27.0.pre.alpha.PLAY888Cardkithighlightoverflowtooltiperror2930

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -5
  3. data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +1 -5
  4. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +1 -5
  5. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +1 -5
  6. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +1 -6
  7. data/app/pb_kits/playbook/pb_badge/badge.html.erb +1 -6
  8. data/app/pb_kits/playbook/pb_button/_button_mixins.scss +1 -0
  9. data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +1 -6
  10. data/app/pb_kits/playbook/pb_card/_card.scss +1 -1
  11. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -6
  12. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +21 -10
  13. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleIcon.tsx +92 -0
  14. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +3 -75
  15. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +1 -6
  16. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +1 -6
  17. data/app/pb_kits/playbook/pb_collapsible/collapsible_icon.html.erb +15 -0
  18. data/app/pb_kits/playbook/pb_collapsible/collapsible_icon.rb +37 -0
  19. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -6
  20. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main.jsx +72 -0
  21. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main.md +3 -0
  22. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main_rails.html.erb +19 -0
  23. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main_rails.md +3 -0
  24. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main_with_icon.jsx +73 -0
  25. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main_with_icon.md +3 -0
  26. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main_with_icon_rails.html.erb +20 -0
  27. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_custom_main_with_icon_rails.md +3 -0
  28. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +7 -0
  29. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +3 -1
  30. data/app/pb_kits/playbook/pb_collapsible/index.js +16 -6
  31. data/app/pb_kits/playbook/pb_contact/contact.html.erb +1 -6
  32. data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -6
  33. data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +1 -6
  34. data/app/pb_kits/playbook/pb_date/date.html.erb +1 -6
  35. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +1 -5
  36. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_default_swift.md +61 -0
  37. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_props_swift.md +11 -0
  38. data/app/pb_kits/playbook/pb_date_range_inline/docs/example.yml +4 -1
  39. data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +1 -5
  40. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +1 -5
  41. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_bold_swift.md +32 -0
  42. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_default_swift.md +17 -0
  43. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_not_current_year_swift.md +19 -0
  44. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_props_swift.md +10 -0
  45. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_reversed_swift.md +17 -0
  46. data/app/pb_kits/playbook/pb_date_stacked/docs/example.yml +7 -0
  47. data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +1 -6
  48. data/app/pb_kits/playbook/pb_date_time/docs/_date_time_alignment_swift.md +39 -0
  49. data/app/pb_kits/playbook/pb_date_time/docs/_date_time_default_swift.md +39 -0
  50. data/app/pb_kits/playbook/pb_date_time/docs/_date_time_props_swift.md +15 -0
  51. data/app/pb_kits/playbook/pb_date_time/docs/_date_time_size_swift.md +78 -0
  52. data/app/pb_kits/playbook/pb_date_time/docs/example.yml +6 -0
  53. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +1 -6
  54. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +1 -5
  55. data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_default_swift.md +20 -0
  56. data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_props_swift.md +6 -0
  57. data/app/pb_kits/playbook/pb_date_year_stacked/docs/example.yml +4 -0
  58. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +4 -0
  59. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +1 -4
  60. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +1 -1
  61. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.md +5 -6
  62. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure_rails.md +6 -0
  63. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +6 -3
  64. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +3 -3
  65. data/app/pb_kits/playbook/pb_dropdown/docs/{_dropdown_with_custom_display.html.erb → _dropdown_with_custom_display_rails.html.erb} +11 -6
  66. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.md +5 -0
  67. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +5 -2
  68. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.md +1 -1
  69. data/app/pb_kits/playbook/pb_dropdown/docs/{_dropdown_with_custom_options.html.erb → _dropdown_with_custom_options_rails.html.erb} +13 -8
  70. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options_rails.md +1 -0
  71. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.md +1 -1
  72. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +5 -2
  73. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.md +1 -1
  74. data/app/pb_kits/playbook/pb_dropdown/docs/{_dropdown_with_custom_trigger.html.erb → _dropdown_with_custom_trigger_rails.html.erb} +13 -8
  75. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger_rails.md +1 -0
  76. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.md +1 -1
  77. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +6 -6
  78. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +1 -1
  79. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +2 -8
  80. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.rb +2 -6
  81. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +2 -12
  82. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_children_swift.md +23 -0
  83. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_close_swift.md +7 -0
  84. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_default_swift.md +9 -0
  85. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_dismiss_with_timer_swift.md +22 -0
  86. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line_swift.md +9 -0
  87. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions_swift.md +62 -0
  88. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_props_swift.md +8 -0
  89. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +9 -0
  90. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +1 -6
  91. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -1
  92. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
  93. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +1 -6
  94. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -6
  95. data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +1 -6
  96. data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +1 -6
  97. data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +1 -6
  98. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +1 -5
  99. data/app/pb_kits/playbook/pb_message/message_mention.html.erb +6 -6
  100. data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +1 -6
  101. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +1 -6
  102. data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +1 -6
  103. data/app/pb_kits/playbook/pb_person/person.html.erb +1 -6
  104. data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +1 -6
  105. data/app/pb_kits/playbook/pb_pill/pill.html.erb +1 -6
  106. data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +1 -6
  107. data/app/pb_kits/playbook/pb_select/_select.scss +8 -0
  108. data/app/pb_kits/playbook/pb_source/source.html.erb +1 -5
  109. data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +1 -5
  110. data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +1 -5
  111. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +19 -0
  112. data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +1 -5
  113. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +1 -5
  114. data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -5
  115. data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +1 -5
  116. data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +1 -6
  117. data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +1 -6
  118. data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +1 -5
  119. data/app/pb_kits/playbook/pb_tooltip/index.js +1 -0
  120. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +1 -6
  121. data/dist/menu.yml +2 -2
  122. data/dist/playbook-rails.js +5 -5
  123. data/lib/playbook/forms/builder/phone_number_field.rb +12 -0
  124. data/lib/playbook/forms/builder.rb +1 -0
  125. data/lib/playbook/kit_base.rb +1 -1
  126. data/lib/playbook/version.rb +1 -1
  127. metadata +42 -6
  128. /data/app/pb_kits/playbook/pb_dropdown/docs/{_dropdown_subcomponent_structure.html.erb → _dropdown_subcomponent_structure_rails.html.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df317431562db34f02e8780e9f2bdfda5acbf9fbb0f0bf9df3c9c3eb1893b0c0
4
- data.tar.gz: 6d4a66b89f01aec006c4f383088d5b471e6c5e094107682a6defea39068c0e29
3
+ metadata.gz: 84d66eed5b978ecd745e826ec17f388a4dbe57dfa989b153aca53faf75cded75
4
+ data.tar.gz: 5b9618559b5d5a6dd1ddae3523df8e9f8e690af6ac0e0cd711ccc6bb41756601
5
5
  SHA512:
6
- metadata.gz: adbdaaaa51705b69b8ce4e8ffd889dea79228e771ae456556de4c040b24c8e6eb0b79d33745153c338b0c06e66c5456c76b7af3b13d80d6acee740a7f4631b3c
7
- data.tar.gz: 3682695def6dff69286da1a81b2b90f884f0482c6470aa315dcaaee929c03eedefea816608a9b21313ba5dfc6079cf55ef4adb1d02795c03e8a490584f9e0a22
6
+ metadata.gz: 605001caf6eb9108ec8456543bebb0123a7897a3a9c60a708db790712ddcbdd2ad064ae8520c80fd4eb545b61cbb11e53f06e338ddff87a85f766cb9db69c290
7
+ data.tar.gz: ac4df765d7761099f29b4e7c57d538473f52e6b0b0727e8e5783abcbfeee2cbf4e28a8c1bca55ac5f8ef98ad29550308ff339ab3f39b47713e1bee52b2721d95
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id) do %>
1
+ <%= pb_content_tag do %>
6
2
  <%= pb_rails("table", props: { size: "sm", tag:"div", data_table: true, number_spacing:"tabular", responsive:"none" }) do %>
7
3
  <% if content.present? %>
8
4
  <% content.presence %>
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id) do %>
1
+ <%= pb_content_tag do %>
6
2
  <% object.table_data.each do |row| %>
7
3
  <%= render_row_and_children(row, object.column_definitions) %>
8
4
  <% end %>
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id) do %>
1
+ <%= pb_content_tag do %>
6
2
  <%= pb_rails("table/table_row", props: {tag:"div"}) do %>
7
3
  <% object.column_definitions.each_with_index do |item, index| %>
8
4
  <%= pb_rails("table/table_header", props: { tag:"div", id:item[:accessor], classname:object.th_classname}) do %>
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id) do %>
1
+ <%= pb_content_tag do %>
6
2
  <% object.column_definitions.each_with_index do |column, index| %>
7
3
  <%= pb_rails("table/table_cell", props: { tag:"div", classname:object.td_classname}) do %>
8
4
  <%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end" }) do %>
@@ -1,9 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- id: object.id,
4
- data: object.data,
5
- class: object.classname,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
  <% if object.tooltip_text.present? %>
8
3
  <%= pb_rails("tooltip", props: {
9
4
  trigger_element_id: object.tooltip_id,
@@ -1,8 +1,3 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- id: object.id,
4
- data: object.data,
5
- class: object.classname,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
  <span><%= object.text %></span>
8
3
  <% end %>
@@ -28,6 +28,7 @@ $pb_button_border_width: 0px;
28
28
  font-size: $font_small;
29
29
  font-weight: $bold;
30
30
  text-align: center;
31
+ text-decoration: none;
31
32
  vertical-align: middle;
32
33
  text-transform: none;
33
34
  border-width: $pb_button_border_width;
@@ -1,8 +1,3 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
  <%= content.presence || object.text %>
8
3
  <% end %>
@@ -81,4 +81,4 @@
81
81
  }
82
82
  }
83
83
  }
84
- }
84
+ }
@@ -1,9 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- id: object.id,
4
- data: object.data,
5
- class: object.classname,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
  <%= pb_rails("button", props: {type: object.type, link: object.link, new_window:object.new_window, variant: object.variant, disabled: object.disabled, dark: object.dark}) do %>
8
3
  <%= pb_rails("icon", props: {icon: object.icon, fixed_width: true, dark: object.dark}) %>
9
4
  <% end %>
@@ -9,6 +9,7 @@ import CollapsibleContent from './child_kits/CollapsibleContent'
9
9
  import CollapsibleMain from './child_kits/CollapsibleMain'
10
10
  import CollapsibleContext from './context'
11
11
  import { IconSizes } from "../pb_icon/_icon"
12
+ import CollapsibleIcon from './child_kits/CollapsibleIcon'
12
13
 
13
14
 
14
15
  type CollapsibleProps = {
@@ -52,12 +53,15 @@ const Collapsible = ({
52
53
  if (CollapsibleParent.length !== 2) {
53
54
  throw new Error('Collapsible requires <CollapsibleMain> and <CollapsibleContent> to function properly.')
54
55
  }
56
+ const FirstChild = CollapsibleParent[0]
57
+ const SecondChild = CollapsibleParent[1]
55
58
 
56
- const Main = CollapsibleParent[0]
57
- const Content = CollapsibleParent[1]
59
+ const Main = FirstChild.type === CollapsibleMain ? FirstChild : null
60
+ const Content = SecondChild.type === CollapsibleContent ? SecondChild : null
58
61
 
59
- const { children: mainChildren, ...mainProps } = Main.props
60
- const { children: contentChildren, ...contentProps } = Content.props
62
+
63
+ const { children: mainChildren = null, ...mainProps } = Main ? Main.props : {}
64
+ const { children: contentChildren = null, ...contentProps } = Content ? Content.props : {}
61
65
  const ariaProps = buildAriaProps(aria)
62
66
  const dataProps = buildDataProps(data)
63
67
  const htmlProps = buildHtmlProps(htmlOptions)
@@ -75,13 +79,19 @@ const Collapsible = ({
75
79
  className={classes}
76
80
  id={id}
77
81
  >
78
- <CollapsibleMain {...mainProps}>
79
- {mainChildren}
80
- </CollapsibleMain>
82
+ {Main ? (
83
+ <CollapsibleMain {...mainProps}>
84
+ {mainChildren}
85
+ </CollapsibleMain>
86
+ ) : (
87
+ FirstChild
88
+ )}
81
89
 
82
- <CollapsibleContent {...contentProps}>
83
- {contentChildren}
84
- </CollapsibleContent>
90
+ {Content && (
91
+ <CollapsibleContent {...contentProps}>
92
+ {contentChildren}
93
+ </CollapsibleContent>
94
+ )}
85
95
  </div>
86
96
  </CollapsibleContext.Provider>
87
97
  )
@@ -89,5 +99,6 @@ const Collapsible = ({
89
99
 
90
100
  Collapsible.Main = CollapsibleMain
91
101
  Collapsible.Content = CollapsibleContent
102
+ Collapsible.Icon = CollapsibleIcon
92
103
 
93
104
  export default Collapsible
@@ -0,0 +1,92 @@
1
+ import React from "react";
2
+ import Icon, { IconSizes } from "../../pb_icon/_icon";
3
+
4
+ type IconColors =
5
+ | "default"
6
+ | "light"
7
+ | "lighter"
8
+ | "link"
9
+ | "error"
10
+ | "success";
11
+
12
+ type IconProps = {
13
+ collapsed: boolean | (() => void);
14
+ icon?: string[] | string;
15
+ iconColor?: IconColors;
16
+ iconSize?: IconSizes;
17
+ onIconClick?: () => void;
18
+ };
19
+
20
+ type colorMap = {
21
+ default: string;
22
+ light: string;
23
+ lighter: string;
24
+ link: string;
25
+ error: string;
26
+ success: string;
27
+ };
28
+
29
+ const colorMap = {
30
+ default: "#242B42",
31
+ light: "#687887",
32
+ lighter: "#C1CDD6",
33
+ link: "#0056CF",
34
+ error: "#FF2229",
35
+ success: "#00CA74",
36
+ };
37
+
38
+ const CollapsibleIcon = ({
39
+ collapsed,
40
+ icon,
41
+ iconSize,
42
+ iconColor,
43
+ onIconClick,
44
+ }: IconProps) => {
45
+ const color = colorMap[iconColor];
46
+
47
+ const showIcon = (icon: string | string[]) => {
48
+ if (typeof icon === "string") {
49
+ return [icon, icon];
50
+ }
51
+ return icon;
52
+ };
53
+
54
+ const handleIconClick = (e: React.MouseEvent<HTMLElement>) => {
55
+ if (onIconClick) {
56
+ e.stopPropagation();
57
+ onIconClick();
58
+ }
59
+ };
60
+
61
+ return (
62
+ <>
63
+ {collapsed ? (
64
+ <div
65
+ className="icon_wrapper"
66
+ key={icon ? showIcon(icon)[0] : "chevron-down"}
67
+ onClick={(e) => handleIconClick(e)}
68
+ style={{ verticalAlign: "middle", color: color }}
69
+ >
70
+ <Icon
71
+ icon={icon ? showIcon(icon)[0] : "chevron-down"}
72
+ size={iconSize}
73
+ />
74
+ </div>
75
+ ) : (
76
+ <div
77
+ className="icon_wrapper"
78
+ key={icon ? showIcon(icon)[1] : "chevron-up"}
79
+ onClick={(e) => handleIconClick(e)}
80
+ style={{ verticalAlign: "middle", color: color }}
81
+ >
82
+ <Icon
83
+ icon={icon ? showIcon(icon)[1] : "chevron-up"}
84
+ size={iconSize}
85
+ />
86
+ </div>
87
+ )}
88
+ </>
89
+ );
90
+ };
91
+
92
+ export default CollapsibleIcon;
@@ -7,27 +7,9 @@ import { globalProps } from '../../utilities/globalProps'
7
7
 
8
8
  import Flex from '../../pb_flex/_flex'
9
9
  import FlexItem from '../../pb_flex/_flex_item'
10
- import Icon, { IconSizes } from "../../pb_icon/_icon"
10
+ import { IconSizes } from "../../pb_icon/_icon"
11
11
  import CollapsibleContext from '../context'
12
-
13
-
14
- type colorMap = {
15
- default: string,
16
- light: string,
17
- lighter: string,
18
- link: string,
19
- error: string,
20
- success: string
21
- }
22
-
23
- const colorMap = {
24
- default: "#242B42",
25
- light: "#687887",
26
- lighter: "#C1CDD6",
27
- link: "#0056CF",
28
- error: "#FF2229",
29
- success: "#00CA74",
30
- }
12
+ import CollapsibleIcon from './CollapsibleIcon'
31
13
 
32
14
  type CollapsibleMainProps = {
33
15
  children: React.ReactNode[] | React.ReactNode,
@@ -38,60 +20,6 @@ type CollapsibleMainProps = {
38
20
  }
39
21
  type IconColors = "default" | "light" | "lighter" | "link" | "error" | "success"
40
22
 
41
- type IconProps = {
42
- collapsed: boolean | (()=> void)
43
- icon?: string[] | string
44
- iconColor?: IconColors
45
- iconSize?: IconSizes
46
- onIconClick?: ()=> void
47
- }
48
-
49
- const ToggleIcon = ({ collapsed, icon, iconSize, iconColor, onIconClick }: IconProps) => {
50
- const color = colorMap[iconColor]
51
-
52
- const showIcon = (icon: string |string[]) => {
53
- if (typeof icon === "string") {
54
- return [icon, icon]
55
- }
56
- return icon
57
- }
58
-
59
- const handleIconClick = (e: React.MouseEvent<HTMLElement>) => {
60
- if (onIconClick) {
61
- e.stopPropagation();
62
- onIconClick()
63
- }
64
- }
65
-
66
- return (
67
- <>
68
- {collapsed ? (
69
- <div
70
- className="icon_wrapper"
71
- key={icon ? showIcon(icon)[0] : "chevron-down"}
72
- onClick={(e)=> handleIconClick(e)}
73
- style={{ verticalAlign: "middle", color: color }}
74
- >
75
- <Icon icon={icon ? showIcon(icon)[0] : "chevron-down"}
76
- size={iconSize}
77
- />
78
- </div>
79
- ) : (
80
- <div
81
- className="icon_wrapper"
82
- key={icon ? showIcon(icon)[1] : "chevron-up"}
83
- onClick={(e)=> handleIconClick(e)}
84
- style={{ verticalAlign: "middle", color: color }}
85
- >
86
- <Icon icon={icon ? showIcon(icon)[1] : "chevron-up"}
87
- size={iconSize}
88
- />
89
- </div>
90
- )}
91
- </>
92
- );
93
- }
94
-
95
23
  const CollapsibleMain = ({
96
24
  children,
97
25
  className,
@@ -120,7 +48,7 @@ const CollapsibleMain = ({
120
48
  >
121
49
  <FlexItem>{children}</FlexItem>
122
50
  <FlexItem>
123
- <ToggleIcon
51
+ <CollapsibleIcon
124
52
  collapsed={collapsed as () => void}
125
53
  icon={icon as string[] | string}
126
54
  iconColor={iconColor as IconColors}
@@ -1,8 +1,3 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
  <%= content.presence %>
8
3
  <% end %>
@@ -1,8 +1,3 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- aria: object.aria,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
  <%= content.presence %>
8
3
  <% end %>
@@ -0,0 +1,15 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ aria: object.aria,
6
+ style: "color: #{object.icon_color};",
7
+ **combined_html_options) do %>
8
+ <% if object.icon.present? %>
9
+ <%= pb_rails("icon", props: { icon: object.show_icon(object.icon)[0], id:"collapsible_open_icon", size: object.size }) %>
10
+ <%= pb_rails("icon", props: { icon: object.show_icon(object.icon)[1], id:"collapsible_close_icon", size: object.size }) %>
11
+ <% else %>
12
+ <%= pb_rails("icon", props: { icon: "chevron-down", id:"collapsible_open_icon", size: object.size }) %>
13
+ <%= pb_rails("icon", props: { icon: "chevron-up", id:"collapsible_close_icon", size: object.size }) %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbCollapsible
5
+ class CollapsibleIcon < Playbook::KitBase
6
+ prop :collapsed, type: Playbook::Props::Boolean,
7
+ default: true
8
+ prop :color, type: Playbook::Props::Enum,
9
+ values: %w[default light lighter link success error],
10
+ default: "default"
11
+ prop :icon
12
+ prop :size, type: Playbook::Props::Enum,
13
+ values: ["lg", "xs", "sm", "1x", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "9x", "10x", nil],
14
+ default: nil
15
+
16
+ def classname
17
+ generate_classname("pb_collapsible_icon_kit", separator: " ")
18
+ end
19
+
20
+ def show_icon(icon)
21
+ case icon
22
+ when ::String
23
+ [icon, icon]
24
+ when ::Array
25
+ icon
26
+ end
27
+ end
28
+
29
+ def icon_color
30
+ return "" if color.nil?
31
+
32
+ color_object = { light: "#687887", lighter: "#C1CDD6", link: "#0056CF", success: "#00CA74", error: "#FF2229", default: "#242B42" }
33
+ color_object[color.to_sym]
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,9 +1,4 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- aria: object.aria,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
 
8
3
  <%= pb_rails("flex", props: {vertical: "center", spacing: "between", cursor: "pointer"}) do %>
9
4
  <%= pb_rails("flex/flex_item") do %>
@@ -0,0 +1,72 @@
1
+ import React from 'react'
2
+ import { Collapsible, useCollapsible, Background, Flex, Title, List, ListItem } from '../..'
3
+
4
+ const CollapsibleCustomMain = () => {
5
+ const [isCollapsed, setIsCollapsed] = useCollapsible(true)
6
+
7
+ return (
8
+ <>
9
+ <Collapsible
10
+ collapsed={isCollapsed}
11
+ >
12
+ <Background
13
+ backgroundColor="white"
14
+ cursor="pointer"
15
+ htmlOptions={{onClick:() => setIsCollapsed(!isCollapsed)}}
16
+ position="sticky"
17
+ top="0"
18
+ >
19
+ <Flex
20
+ align="center"
21
+ gap="sm"
22
+ justify="between"
23
+ >
24
+ <Title
25
+ size={4}
26
+ text="Custom Main Section"
27
+ />
28
+ </Flex>
29
+ </Background>
30
+ <Collapsible.Content padding="none">
31
+ <div>
32
+ <List>
33
+ <ListItem
34
+ align="stretch"
35
+ flexDirection="column"
36
+ >
37
+ Checklist item
38
+ </ListItem>
39
+ <ListItem
40
+ align="stretch"
41
+ flexDirection="column"
42
+ >
43
+ Checklist item
44
+ </ListItem>
45
+ <ListItem
46
+ align="stretch"
47
+ flexDirection="column"
48
+ >
49
+ Checklist item
50
+ </ListItem>
51
+ <ListItem
52
+ align="stretch"
53
+ flexDirection="column"
54
+ >
55
+ Checklist item
56
+ </ListItem>
57
+ <ListItem
58
+ align="stretch"
59
+ flexDirection="column"
60
+ >
61
+ Checklist item
62
+ </ListItem>
63
+ </List>
64
+ </div>
65
+ </Collapsible.Content>
66
+ </Collapsible>
67
+
68
+ </>
69
+ )
70
+ }
71
+
72
+ export default CollapsibleCustomMain
@@ -0,0 +1,3 @@
1
+ Optionally replace your `Collapsible.Main` with any component to customize your Main section's contents and/or style. This gives you full control over that subcomponent. For example, here we are using global props to make that custom Main 'sticky' on scroll.
2
+
3
+ __NOTE__: Custom main sections requires the `useCollapsible` hook to ensure the collapsible's toggle action works correctly.
@@ -0,0 +1,19 @@
1
+ <%= pb_rails("collapsible", props: { name: "default-example" }) do %>
2
+ <%= pb_rails("background", props: { background_color: "white", position: "sticky", top: "0", cursor:"pointer", data: {"collapsible-main": "true"} }) do %>
3
+ <%= pb_rails("flex", props: {align:"center", gap:"sm", justify:"between"}) do %>
4
+ <%= pb_rails("title", props: { text: "Custom Main Section", tag: "h4", size: 4 }) %>
5
+ <% end %>
6
+ <% end %>
7
+ <%= pb_rails("flex", props: { align: "center", justify: "between" }) do %>
8
+ <% end %>
9
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "none" }) do %>
10
+ <%= pb_rails("list", props: {ordered: false, dark: false, borderless: false}) do %>
11
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
12
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
13
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
14
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
15
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
16
+ <% end %>
17
+ <% end %>
18
+ <% end %>
19
+
@@ -0,0 +1,3 @@
1
+ Optionally replace your `collapsible/collapsible_main` with any component to customize your Main section's contents and/or style. This gives you full control over that subcomponent. For example, here we are using global props to make that custom Main 'sticky' on scroll.
2
+
3
+ __NOTE__: Custom main sections require `data: {"collapsible-main": "true"}` to ensure the collapsible's toggle action works correctly.
@@ -0,0 +1,73 @@
1
+ import React from 'react'
2
+ import { Collapsible, useCollapsible, Background, Flex, Title, List, ListItem } from '../..'
3
+
4
+ const CollapsibleCustomMainWithIcon = () => {
5
+ const [isCollapsed, setIsCollapsed] = useCollapsible(true)
6
+
7
+ return (
8
+ <>
9
+ <Collapsible
10
+ collapsed={isCollapsed}
11
+ >
12
+ <Background
13
+ backgroundColor="white"
14
+ cursor="pointer"
15
+ htmlOptions={{onClick:() => setIsCollapsed(!isCollapsed)}}
16
+ position="sticky"
17
+ top="0"
18
+ >
19
+ <Flex
20
+ align="center"
21
+ gap="sm"
22
+ justify="between"
23
+ >
24
+ <Title
25
+ size={4}
26
+ text="Custom Main Section"
27
+ />
28
+ <Collapsible.Icon collapsed={isCollapsed}/>
29
+ </Flex>
30
+ </Background>
31
+ <Collapsible.Content padding="none">
32
+ <div>
33
+ <List>
34
+ <ListItem
35
+ align="stretch"
36
+ flexDirection="column"
37
+ >
38
+ Checklist item
39
+ </ListItem>
40
+ <ListItem
41
+ align="stretch"
42
+ flexDirection="column"
43
+ >
44
+ Checklist item
45
+ </ListItem>
46
+ <ListItem
47
+ align="stretch"
48
+ flexDirection="column"
49
+ >
50
+ Checklist item
51
+ </ListItem>
52
+ <ListItem
53
+ align="stretch"
54
+ flexDirection="column"
55
+ >
56
+ Checklist item
57
+ </ListItem>
58
+ <ListItem
59
+ align="stretch"
60
+ flexDirection="column"
61
+ >
62
+ Checklist item
63
+ </ListItem>
64
+ </List>
65
+ </div>
66
+ </Collapsible.Content>
67
+ </Collapsible>
68
+
69
+ </>
70
+ )
71
+ }
72
+
73
+ export default CollapsibleCustomMainWithIcon
@@ -0,0 +1,3 @@
1
+ When using a custom Main Section, you can also use the optional `Collapsible.Icon`.
2
+
3
+ __NOTE__: The optional icon subcomponent must receive the `collapsed` state of the collapsible in order to toggle correctly. It also accepts all icon-related props (`icon`, `size`, and `color`) for further customization. If none of these are specified, the default icon will be rendered.
@@ -0,0 +1,20 @@
1
+ <%= pb_rails("collapsible", props: { name: "default-example" }) do %>
2
+ <%= pb_rails("background", props: { background_color: "white", position: "sticky", top: "0", cursor:"pointer", data: {"collapsible-main": "true"} }) do %>
3
+ <%= pb_rails("flex", props: {align:"center", gap:"sm", justify:"between"}) do %>
4
+ <%= pb_rails("title", props: { text: "Custom Main Section", tag: "h4", size: 4 }) %>
5
+ <%= pb_rails("collapsible/collapsible_icon") %>
6
+ <% end %>
7
+ <% end %>
8
+ <%= pb_rails("flex", props: { align: "center", justify: "between" }) do %>
9
+ <% end %>
10
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "none" }) do %>
11
+ <%= pb_rails("list", props: {ordered: false, dark: false, borderless: false}) do %>
12
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
13
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
14
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
15
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
16
+ <%= pb_rails("list/item") do %> Checklist Item <% end %>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
20
+
@@ -0,0 +1,3 @@
1
+ When using a custom Main Section, you can also use the optional `collapsible/collapsible_icon` subcomponent.
2
+
3
+ __NOTE__: The optional icon subcomponent accepts all icon-related props (`icon`, `size`, and `color`) for further customization. If none of these are specified, the default icon will be rendered.