playbook_ui 14.11.0 → 14.11.1.pre.alpha.PBNTR440enableglobalpropspbformwith5624
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +18 -2
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +27 -5
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +17 -2
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +23 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +29 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +61 -4
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_no_subrows.jsx +50 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.jsx +60 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx +78 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.jsx +53 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.jsx +52 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_no_subrows.json +42 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_with_id.json +299 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +6 -1
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +9 -11
- data/app/pb_kits/playbook/pb_badge/_badge.scss +2 -4
- data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.scss +1 -3
- data/app/pb_kits/playbook/pb_button/_button.scss +1 -3
- data/app/pb_kits/playbook/pb_button/button.html.erb +2 -3
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +1 -6
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +2 -4
- data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +3 -1
- data/app/pb_kits/playbook/pb_collapsible/collapsible.rb +3 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +24 -16
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_turbo_frames.html.erb +13 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_turbo_frames_rails.md +3 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +1 -3
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_overrides.scss +3 -5
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.scss +4 -6
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.scss +2 -4
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.html.erb +3 -9
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.html.erb +38 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.md +3 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +145 -183
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +158 -268
- data/app/pb_kits/playbook/pb_drawer/context.ts +11 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.jsx +38 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -45
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +0 -1
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.jsx +9 -16
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +44 -19
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.md +21 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +16 -21
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.jsx +2 -19
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_drawer/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_drawer/drawer.test.jsx +5 -5
- data/app/pb_kits/playbook/pb_drawer/hooks/useBreakpoint.tsx +60 -0
- data/app/pb_kits/playbook/pb_drawer/hooks/useDrawerAnimation.tsx +21 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +8 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subtle_variant.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +7 -12
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +9 -14
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +6 -11
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +8 -14
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +4 -6
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.scss +78 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.html.erb +3 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +7 -0
- data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +16 -0
- data/app/pb_kits/playbook/pb_icon_button/icon_button.rb +22 -0
- data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +1 -3
- data/app/pb_kits/playbook/pb_label_value/_label_value.scss +2 -4
- data/app/pb_kits/playbook/pb_list/item.html.erb +30 -8
- data/app/pb_kits/playbook/pb_list/item.rb +7 -0
- data/app/pb_kits/playbook/pb_list/list.html.erb +31 -11
- data/app/pb_kits/playbook/pb_list/list.rb +4 -0
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +6 -1
- data/app/pb_kits/playbook/pb_message/_message_mixins.scss +1 -3
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.scss +5 -3
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.tsx +1 -0
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +1 -1
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.scss +3 -5
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +8 -10
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +30 -12
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.html.erb +15 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.jsx +24 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.md +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.test.js +20 -1
- data/app/pb_kits/playbook/pb_pill/_pill.scss +2 -4
- data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +2 -4
- data/app/pb_kits/playbook/pb_radio/_radio.scss +12 -8
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +8 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +2 -4
- data/app/pb_kits/playbook/pb_select/_select.scss +6 -10
- data/app/pb_kits/playbook/pb_select/_select.tsx +5 -1
- data/app/pb_kits/playbook/pb_select/select.html.erb +2 -2
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +3 -5
- data/app/pb_kits/playbook/pb_selectable_icon/_selectable_icon.tsx +9 -1
- data/app/pb_kits/playbook/pb_selectable_icon/docs/_selectable_icon_default.jsx +4 -1
- data/app/pb_kits/playbook/pb_selectable_icon/docs/_selectable_icon_single_select.jsx +4 -1
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +17 -3
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.rb +3 -0
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +11 -4
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.rb +3 -0
- data/app/pb_kits/playbook/pb_table/_table.tsx +2 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +74 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +2 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +74 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.html.erb +47 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_rails.md +2 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_table/index.ts +187 -88
- data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +12 -0
- data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +6 -5
- data/app/pb_kits/playbook/pb_table/table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/table.rb +17 -2
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +20 -1
- data/app/pb_kits/playbook/pb_table/table_row.rb +5 -0
- data/app/pb_kits/playbook/pb_table/utilities/addDataTitle.ts +22 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -3
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +46 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask_rails.md +3 -0
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_text_input/index.js +103 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +4 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +33 -3
- data/app/pb_kits/playbook/pb_textarea/_textarea.scss +1 -3
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.scss +4 -5
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +32 -34
- data/app/pb_kits/playbook/pb_toggle/_toggle.scss +3 -5
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -2
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +12 -4
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +5 -1
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +8 -3
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +6 -1
- data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +21 -6
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +13 -6
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +7 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.html.erb +19 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.jsx +27 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.md +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +4 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +5 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/dist/chunks/_typeahead-BWwaAo_0.js +36 -0
- data/dist/chunks/_weekday_stacked-zyBCd1s8.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/{lib-B7sgJtGS.js → lib-kMuhBuU7.js} +2 -2
- data/dist/chunks/{pb_form_validation-C5Cc0-1v.js → pb_form_validation-DBJ0wZuS.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +6 -0
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/pb_forms_global_props_helper.rb +136 -0
- data/lib/playbook/pb_forms_helper.rb +13 -4
- data/lib/playbook/version.rb +2 -2
- metadata +67 -9
- data/dist/chunks/_typeahead-C2iCBqxQ.js +0 -36
- data/dist/chunks/_weekday_stacked-E-5KcEkc.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_table_props.md → _advanced_table_table_props_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_table/docs/{_table_with_collapsible.md → _table_with_collapsible_react.md} +0 -0
@@ -9,8 +9,8 @@ const useDrawer = (visible = false) => {
|
|
9
9
|
};
|
10
10
|
|
11
11
|
const DrawerDefault = () => {
|
12
|
-
const [
|
13
|
-
const [
|
12
|
+
const [drawerLeftOpen, toggleDrawerLeftOpen] = useDrawer();
|
13
|
+
const [drawerRightOpen, toggleDrawerRightOpen ] = useDrawer();
|
14
14
|
|
15
15
|
return (
|
16
16
|
<>
|
@@ -18,13 +18,13 @@ const DrawerDefault = () => {
|
|
18
18
|
<Button
|
19
19
|
id="sm"
|
20
20
|
marginRight="md"
|
21
|
-
onClick={
|
21
|
+
onClick={toggleDrawerLeftOpen}
|
22
22
|
>
|
23
23
|
{"Left Drawer"}
|
24
24
|
</Button>
|
25
25
|
<Button
|
26
26
|
marginRight="xl"
|
27
|
-
onClick={
|
27
|
+
onClick={toggleDrawerRightOpen}
|
28
28
|
>
|
29
29
|
{"Right Drawer"}
|
30
30
|
</Button>
|
@@ -32,12 +32,8 @@ const DrawerDefault = () => {
|
|
32
32
|
<Flex>
|
33
33
|
{/* Left Drawer */}
|
34
34
|
<Drawer
|
35
|
-
|
36
|
-
|
37
|
-
onClose={toggleHeaderSeparatorDrawer}
|
38
|
-
opened={headerSeparatorDrawerOpened}
|
39
|
-
overlay
|
40
|
-
placement={"left"}
|
35
|
+
onClose={toggleDrawerLeftOpen}
|
36
|
+
opened={drawerLeftOpen}
|
41
37
|
size={"lg"}
|
42
38
|
>
|
43
39
|
Test me (Left Drawer)
|
@@ -45,11 +41,8 @@ const DrawerDefault = () => {
|
|
45
41
|
|
46
42
|
{/* Right Drawer */}
|
47
43
|
<Drawer
|
48
|
-
|
49
|
-
|
50
|
-
onClose={toggleBothSeparatorsDrawer}
|
51
|
-
opened={bothSeparatorsDrawerOpened}
|
52
|
-
overlay
|
44
|
+
onClose={toggleDrawerRightOpen}
|
45
|
+
opened={drawerRightOpen}
|
53
46
|
placement={"right"}
|
54
47
|
size={"lg"}
|
55
48
|
>
|
@@ -60,4 +53,4 @@ const DrawerDefault = () => {
|
|
60
53
|
);
|
61
54
|
};
|
62
55
|
|
63
|
-
export default DrawerDefault;
|
56
|
+
export default DrawerDefault;
|
@@ -1,31 +1,56 @@
|
|
1
|
-
import React from "react"
|
2
|
-
import { Button, Drawer, Icon,
|
1
|
+
import React, { useState, useEffect } from "react"
|
2
|
+
import { Button, Drawer, Icon, Nav, NavItem } from "playbook-ui"
|
3
3
|
|
4
4
|
const DrawerMenu = () => {
|
5
|
+
const [isSmallScreen, setIsSmallScreen] = useState(false)
|
6
|
+
|
7
|
+
useEffect(() => {
|
8
|
+
const mediaQuery = window.matchMedia("(max-width: 600px)")
|
9
|
+
setIsSmallScreen(mediaQuery.matches)
|
10
|
+
const handler = (e) => setIsSmallScreen(e.matches)
|
11
|
+
mediaQuery.addEventListener('change', handler)
|
12
|
+
return () => mediaQuery.removeEventListener('change', handler)
|
13
|
+
}, [])
|
5
14
|
|
6
15
|
return (
|
7
|
-
|
8
|
-
<Button id=
|
9
|
-
padding=
|
16
|
+
<div>
|
17
|
+
<Button id='menuButton'
|
18
|
+
padding='xs'
|
10
19
|
>
|
11
|
-
<Icon icon=
|
12
|
-
size=
|
20
|
+
<Icon icon='bars'
|
21
|
+
size='2x'
|
13
22
|
/>
|
14
23
|
</Button>
|
15
24
|
<Drawer
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
placement="left"
|
21
|
-
size="lg"
|
25
|
+
breakpoint="md"
|
26
|
+
placement='bottom'
|
27
|
+
size='full'
|
28
|
+
triggerId='menuButton'
|
22
29
|
withinElement
|
23
30
|
>
|
24
|
-
<
|
25
|
-
|
31
|
+
<Nav
|
32
|
+
highlight={false}
|
33
|
+
link='#'
|
34
|
+
orientation={isSmallScreen ? 'vertical' : 'horizontal'}
|
35
|
+
padding={isSmallScreen ? 'none' : 'sm'}
|
36
|
+
>
|
37
|
+
<NavItem link='#'
|
38
|
+
text='About'
|
39
|
+
/>
|
40
|
+
<NavItem active
|
41
|
+
link='#'
|
42
|
+
text='Case Studies'
|
43
|
+
/>
|
44
|
+
<NavItem link='#'
|
45
|
+
text='Service'
|
46
|
+
/>
|
47
|
+
<NavItem link='#'
|
48
|
+
text='Contacts'
|
49
|
+
/>
|
50
|
+
</Nav>
|
26
51
|
</Drawer>
|
27
|
-
|
28
|
-
)
|
29
|
-
}
|
52
|
+
</div>
|
53
|
+
)
|
54
|
+
}
|
30
55
|
|
31
|
-
export default DrawerMenu
|
56
|
+
export default DrawerMenu
|
@@ -1,6 +1,24 @@
|
|
1
|
-
|
1
|
+
The Drawer component can be used to create responsive navigation menus and sidebars. It provides flexible options for controlling when and how the drawer appears based on screen size.
|
2
|
+
|
3
|
+
### Within Element
|
4
|
+
The `withinElement` prop allows you to render the drawer within its parent container:
|
5
|
+
- The drawer will be positioned relative to its parent element
|
6
|
+
- Useful for creating nested navigation structures
|
7
|
+
- This must be used in conjunction with the `triggerId` prop
|
8
|
+
|
9
|
+
This provides a clean way to create responsive navigation patterns that adapt to different screen sizes while maintaining a consistent user experience.
|
10
|
+
|
11
|
+
### Trigger Id
|
12
|
+
The `triggerId` prop allows you to connect an element to control the drawer:
|
13
|
+
- The specified element will toggle the drawer open/closed
|
14
|
+
- The element is automatically hidden when the drawer is opened via breakpoint
|
15
|
+
- The element reappears when the drawer is closed via breakpoint
|
16
|
+
|
17
|
+
### Breakpoint
|
18
|
+
Use the `breakpoint` prop to control when the drawer automatically opens or closes based on screen size. For example, setting `breakpoint="md"` will:
|
19
|
+
- Close the drawer on screens smaller than the medium breakpoint (992px)
|
20
|
+
- Automatically open the drawer on screens larger than or equal to the medium breakpoint
|
21
|
+
|
2
22
|
|
3
|
-
Set a menu button with the `menuButtonID` props. When the Drawer is open, the menu button will be hidden. But when your Brakpoint closes the drawer, you can toggle the Drawer open/close with your menu butotn.
|
4
23
|
|
5
|
-
Also use the `withinElement` props to have the Drawer open within a specific element, instead of the default behavior of it taking up the entire screen size.
|
6
24
|
|
@@ -1,24 +1,25 @@
|
|
1
|
-
import React, { useState } from "react"
|
2
|
-
import { Button, Drawer, Flex } from "playbook-ui"
|
1
|
+
import React, { useState } from "react"
|
2
|
+
import { Button, Drawer, Flex } from "playbook-ui"
|
3
3
|
|
4
4
|
const DrawerSizes = () => {
|
5
5
|
// Individual state variables for each drawer size
|
6
|
-
const [openedNoOverlayDrawer, setOpenedNoOverlayDrawer] = useState(false)
|
7
|
-
const [openedOverlayDrawer, setOpenedOverlayDrawer] = useState(false)
|
6
|
+
const [openedNoOverlayDrawer, setOpenedNoOverlayDrawer] = useState(false)
|
7
|
+
const [openedOverlayDrawer, setOpenedOverlayDrawer] = useState(false)
|
8
8
|
|
9
9
|
// Toggle functions for each drawer
|
10
|
-
const toggleNoOverlayDrawer = () =>
|
11
|
-
|
10
|
+
const toggleNoOverlayDrawer = () =>
|
11
|
+
setOpenedNoOverlayDrawer(!openedNoOverlayDrawer)
|
12
|
+
const toggleOverlayDrawer = () => setOpenedOverlayDrawer(!openedOverlayDrawer)
|
12
13
|
|
13
14
|
return (
|
14
15
|
<>
|
15
16
|
<Flex wrap>
|
16
|
-
<Button marginRight=
|
17
|
+
<Button marginRight='md'
|
17
18
|
onClick={toggleNoOverlayDrawer}
|
18
19
|
>
|
19
20
|
No Overlay Drawer
|
20
21
|
</Button>
|
21
|
-
<Button marginRight=
|
22
|
+
<Button marginRight='md'
|
22
23
|
onClick={toggleOverlayDrawer}
|
23
24
|
>
|
24
25
|
Overlay Drawer
|
@@ -27,29 +28,23 @@ const DrawerSizes = () => {
|
|
27
28
|
|
28
29
|
{/* Drawers for each size */}
|
29
30
|
<Drawer
|
30
|
-
behavior="push"
|
31
|
-
fullHeight
|
32
31
|
onClose={toggleNoOverlayDrawer}
|
33
32
|
opened={openedNoOverlayDrawer}
|
34
33
|
overlay={false}
|
35
|
-
|
36
|
-
size="lg"
|
34
|
+
size='lg'
|
37
35
|
>
|
38
36
|
This is a Drawer with no overlay
|
39
37
|
</Drawer>
|
40
38
|
<Drawer
|
41
|
-
behavior="push"
|
42
|
-
fullHeight
|
43
39
|
onClose={toggleOverlayDrawer}
|
44
40
|
opened={openedOverlayDrawer}
|
45
|
-
|
46
|
-
|
47
|
-
size="lg"
|
41
|
+
placement='right'
|
42
|
+
size='lg'
|
48
43
|
>
|
49
|
-
This is a Drawer with an overlay
|
44
|
+
This is a Drawer with an overlay
|
50
45
|
</Drawer>
|
51
46
|
</>
|
52
|
-
)
|
53
|
-
}
|
47
|
+
)
|
48
|
+
}
|
54
49
|
|
55
|
-
export default DrawerSizes
|
50
|
+
export default DrawerSizes
|
@@ -19,7 +19,8 @@ const DrawerSizes = () => {
|
|
19
19
|
return (
|
20
20
|
<>
|
21
21
|
<Flex wrap>
|
22
|
-
<Button
|
22
|
+
<Button
|
23
|
+
marginRight="md"
|
23
24
|
onClick={toggleXsDrawer}
|
24
25
|
>
|
25
26
|
XS Drawer
|
@@ -48,11 +49,8 @@ const DrawerSizes = () => {
|
|
48
49
|
|
49
50
|
{/* Drawers for each size */}
|
50
51
|
<Drawer
|
51
|
-
behavior="push"
|
52
|
-
fullHeight
|
53
52
|
onClose={toggleXsDrawer}
|
54
53
|
opened={openedXsDrawer}
|
55
|
-
overlay
|
56
54
|
placement="right"
|
57
55
|
size="xs"
|
58
56
|
>
|
@@ -60,47 +58,32 @@ const DrawerSizes = () => {
|
|
60
58
|
</Drawer>
|
61
59
|
|
62
60
|
<Drawer
|
63
|
-
behavior="push"
|
64
|
-
fullHeight
|
65
61
|
onClose={toggleSmDrawer}
|
66
62
|
opened={openedSmDrawer}
|
67
|
-
overlay
|
68
|
-
placement="right"
|
69
63
|
size="sm"
|
70
64
|
>
|
71
65
|
This is an SM Drawer
|
72
66
|
</Drawer>
|
73
67
|
|
74
68
|
<Drawer
|
75
|
-
behavior="push"
|
76
|
-
fullHeight
|
77
69
|
onClose={toggleMdDrawer}
|
78
70
|
opened={openedMdDrawer}
|
79
|
-
overlay
|
80
71
|
placement="right"
|
81
|
-
size="md"
|
82
72
|
>
|
83
73
|
This is an MD Drawer
|
84
74
|
</Drawer>
|
85
75
|
|
86
76
|
<Drawer
|
87
|
-
behavior="push"
|
88
|
-
fullHeight
|
89
77
|
onClose={toggleLgDrawer}
|
90
78
|
opened={openedLgDrawer}
|
91
|
-
overlay
|
92
|
-
placement="right"
|
93
79
|
size="lg"
|
94
80
|
>
|
95
81
|
This is an LG Drawer
|
96
82
|
</Drawer>
|
97
83
|
|
98
84
|
<Drawer
|
99
|
-
behavior="push"
|
100
|
-
fullHeight
|
101
85
|
onClose={toggleXlDrawer}
|
102
86
|
opened={openedXlDrawer}
|
103
|
-
overlay
|
104
87
|
placement="right"
|
105
88
|
size="xl"
|
106
89
|
>
|
@@ -4,3 +4,4 @@ export { default as DrawerOverlay } from './_drawer_overlay.jsx'
|
|
4
4
|
export { default as DrawerBorders } from './_drawer_borders.jsx'
|
5
5
|
export { default as DrawerBreakpoints } from './_drawer_breakpoints.jsx'
|
6
6
|
export { default as DrawerMenu } from './_drawer_menu.jsx'
|
7
|
+
export { default as DrawerBehavior } from './_drawer_behavior.jsx'
|
@@ -39,7 +39,7 @@ test('renders with the right border class when border prop is right', async () =
|
|
39
39
|
const container = document.getElementById('drawer-id');
|
40
40
|
const drawer = container.querySelector('#drawer-id .pb_drawer');
|
41
41
|
|
42
|
-
expect(drawer).toHaveClass('
|
42
|
+
expect(drawer).toHaveClass('drawer_border-right');
|
43
43
|
});
|
44
44
|
|
45
45
|
test('renders with the full border class when border prop is full', async () => {
|
@@ -51,7 +51,7 @@ test('renders with the full border class when border prop is full', async () =>
|
|
51
51
|
|
52
52
|
const container = document.getElementById('drawer-id');
|
53
53
|
const drawer = container.querySelector('#drawer-id .pb_drawer');
|
54
|
-
expect(drawer).toHaveClass('
|
54
|
+
expect(drawer).toHaveClass('drawer_border-full');
|
55
55
|
});
|
56
56
|
|
57
57
|
test('does not have a border class when border prop is none', async () => {
|
@@ -63,9 +63,9 @@ test('does not have a border class when border prop is none', async () => {
|
|
63
63
|
|
64
64
|
const container = document.getElementById('drawer-id');
|
65
65
|
const drawer = container.querySelector('#drawer-id .pb_drawer');
|
66
|
-
expect(drawer).not.toHaveClass('
|
67
|
-
expect(drawer).not.toHaveClass('
|
68
|
-
expect(drawer).not.toHaveClass('
|
66
|
+
expect(drawer).not.toHaveClass('drawer_border-right');
|
67
|
+
expect(drawer).not.toHaveClass('drawer_border-left');
|
68
|
+
expect(drawer).not.toHaveClass('drawer_border-full');
|
69
69
|
});
|
70
70
|
|
71
71
|
test('renders the correct size class for a large drawer', async () => {
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { useState, useEffect } from 'react'
|
2
|
+
|
3
|
+
export const breakpointValues = {
|
4
|
+
none: 0,
|
5
|
+
xs: 575,
|
6
|
+
sm: 768,
|
7
|
+
md: 992,
|
8
|
+
lg: 1200,
|
9
|
+
xl: 1400,
|
10
|
+
} as const
|
11
|
+
|
12
|
+
type BreakpointSize = keyof typeof breakpointValues
|
13
|
+
|
14
|
+
interface UseBreakpointProps {
|
15
|
+
breakpoint?: BreakpointSize
|
16
|
+
triggerId?: string
|
17
|
+
}
|
18
|
+
|
19
|
+
export const useBreakpoint = ({
|
20
|
+
breakpoint = 'none',
|
21
|
+
triggerId
|
22
|
+
}: UseBreakpointProps) => {
|
23
|
+
const [isOpenBreakpointOpen, setIsOpenBreakpointOpen] = useState(false)
|
24
|
+
const [isUserClosed, setIsUserClosed] = useState(false)
|
25
|
+
|
26
|
+
useEffect(() => {
|
27
|
+
if (breakpoint === 'none') return
|
28
|
+
|
29
|
+
const handleResize = () => {
|
30
|
+
const width = window.innerWidth
|
31
|
+
|
32
|
+
const openBreakpointWidth = breakpointValues[breakpoint]
|
33
|
+
if (width >= openBreakpointWidth) {
|
34
|
+
setIsOpenBreakpointOpen(true)
|
35
|
+
} else {
|
36
|
+
setIsOpenBreakpointOpen(false)
|
37
|
+
setIsUserClosed(false)
|
38
|
+
}
|
39
|
+
|
40
|
+
// Handle menu button visibility
|
41
|
+
if (triggerId) {
|
42
|
+
const menuButton = document.getElementById(triggerId)
|
43
|
+
if (menuButton) {
|
44
|
+
menuButton.style.display = isOpenBreakpointOpen ? 'none' : ''
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
window.addEventListener('resize', handleResize)
|
50
|
+
handleResize()
|
51
|
+
|
52
|
+
return () => window.removeEventListener('resize', handleResize)
|
53
|
+
}, [breakpoint, triggerId, isOpenBreakpointOpen])
|
54
|
+
|
55
|
+
return {
|
56
|
+
isOpenBreakpointOpen,
|
57
|
+
isUserClosed,
|
58
|
+
setIsUserClosed
|
59
|
+
}
|
60
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { useState, useEffect } from 'react'
|
2
|
+
|
3
|
+
export const useDrawerAnimation = (isOpen: boolean) => {
|
4
|
+
const [animationState, setAnimationState] = useState('')
|
5
|
+
|
6
|
+
useEffect(() => {
|
7
|
+
if (isOpen) {
|
8
|
+
setAnimationState('afterOpen')
|
9
|
+
} else if (!isOpen && animationState === 'afterOpen') {
|
10
|
+
setAnimationState('beforeClose')
|
11
|
+
setTimeout(() => {
|
12
|
+
setAnimationState('')
|
13
|
+
}, 200)
|
14
|
+
}
|
15
|
+
}, [isOpen])
|
16
|
+
|
17
|
+
return {
|
18
|
+
animationState,
|
19
|
+
isVisible: isOpen || animationState === 'beforeClose'
|
20
|
+
}
|
21
|
+
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
@use "sass:math";
|
2
|
-
|
3
1
|
@import "../tokens/colors";
|
4
2
|
@import "../tokens/spacing";
|
5
3
|
@import "../tokens/typography";
|
@@ -124,7 +122,7 @@
|
|
124
122
|
|
125
123
|
&.error {
|
126
124
|
[class*=pb_body_kit] {
|
127
|
-
margin-top:
|
125
|
+
margin-top: $space_xs / 2;
|
128
126
|
}
|
129
127
|
|
130
128
|
[class*="dropdown_trigger_wrapper"] {
|
@@ -148,7 +146,7 @@
|
|
148
146
|
&[class*="subtle"] {
|
149
147
|
.dropdown_wrapper {
|
150
148
|
.pb_dropdown_container {
|
151
|
-
|
149
|
+
|
152
150
|
[class*="pb_dropdown_option"]:first-child {
|
153
151
|
margin-top: $space_xs;
|
154
152
|
}
|
@@ -163,7 +161,7 @@
|
|
163
161
|
border-radius: $border_radius_md;
|
164
162
|
border-bottom: none;
|
165
163
|
position: relative;
|
166
|
-
|
164
|
+
|
167
165
|
&::after {
|
168
166
|
content: "";
|
169
167
|
position: absolute;
|
@@ -174,20 +172,20 @@
|
|
174
172
|
background: $border_light;
|
175
173
|
}
|
176
174
|
}
|
177
|
-
|
175
|
+
|
178
176
|
[class*="pb_dropdown_option"]:last-child::after {
|
179
|
-
display: none;
|
177
|
+
display: none;
|
180
178
|
}
|
181
179
|
}
|
182
180
|
}
|
183
|
-
|
181
|
+
|
184
182
|
&[class*="separators_hidden"] {
|
185
183
|
.dropdown_wrapper {
|
186
184
|
.pb_dropdown_container {
|
187
185
|
[class*="pb_dropdown_option"]:first-child {
|
188
186
|
margin-top: $space_xs;
|
189
187
|
}
|
190
|
-
|
188
|
+
|
191
189
|
[class*="pb_dropdown_option"]:last-child {
|
192
190
|
margin-bottom: $space_xs;
|
193
191
|
}
|
@@ -195,7 +193,7 @@
|
|
195
193
|
[class*="pb_dropdown_option"] {
|
196
194
|
padding: $space_xxs $space_xs;
|
197
195
|
margin: $space_xxs $space_xs;
|
198
|
-
|
196
|
+
|
199
197
|
&::after {
|
200
198
|
height: 0px;
|
201
199
|
}
|
@@ -1 +1 @@
|
|
1
|
-
For the `subtle` variant, it is recommended that you set the `Separators` prop to `false` to remove the separator lines between the options for a
|
1
|
+
For the `subtle` variant, it is recommended that you set the `Separators` prop to `false` to remove the separator lines between the options for a cleaner look.
|
@@ -1,19 +1,14 @@
|
|
1
|
-
<%=
|
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
|
<% if object.label.present? %>
|
8
3
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
9
4
|
<% end %>
|
10
5
|
<div class="dropdown_wrapper<%= error_class %>" style="position: relative">
|
11
|
-
<input
|
12
|
-
data-default-value="<%= input_default_value %>"
|
13
|
-
id="dropdown-selected-option"
|
14
|
-
name="<%= object.name %>"
|
15
|
-
style="display: none"
|
16
|
-
<%= object.required ? "required" : ""%>
|
6
|
+
<input
|
7
|
+
data-default-value="<%= input_default_value %>"
|
8
|
+
id="dropdown-selected-option"
|
9
|
+
name="<%= object.name %>"
|
10
|
+
style="display: none"
|
11
|
+
<%= object.required ? "required" : ""%>
|
17
12
|
/>
|
18
13
|
<% if content.present? %>
|
19
14
|
<%= content.presence %>
|
@@ -1,20 +1,15 @@
|
|
1
|
-
<%=
|
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
|
<%= pb_rails("list", props: {ordered: false, borderless: false}) do %>
|
8
|
-
<% if content.present? %>
|
3
|
+
<% if content.present? %>
|
9
4
|
<%= content.presence %>
|
10
|
-
<% else %>
|
5
|
+
<% else %>
|
11
6
|
<%= pb_rails("list/item", props: {
|
12
|
-
display: "flex",
|
13
|
-
justify_content: "center",
|
14
|
-
padding:"xs",
|
15
|
-
}) do %>
|
7
|
+
display: "flex",
|
8
|
+
justify_content: "center",
|
9
|
+
padding:"xs",
|
10
|
+
}) do %>
|
16
11
|
<%= pb_rails("body", props: {text: "No option"}) %>
|
17
12
|
<% end %>
|
18
13
|
<% end %>
|
19
|
-
<% end %>
|
20
|
-
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
@@ -1,15 +1,10 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
class: object.classname,
|
4
|
-
data: object.data,
|
5
|
-
id: object.option[:id],
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag(:div, id: object.option[:id]) do %>
|
7
2
|
<%= pb_rails("list/item", props: {
|
8
|
-
display: "flex",
|
9
|
-
justify_content: "center",
|
10
|
-
padding:"none",
|
3
|
+
display: "flex",
|
4
|
+
justify_content: "center",
|
5
|
+
padding:"none",
|
11
6
|
cursor: "pointer"
|
12
|
-
}) do %>
|
7
|
+
}) do %>
|
13
8
|
<div class="dropdown_option_wrapper">
|
14
9
|
<% if content.present? %>
|
15
10
|
<%= content.presence %>
|
@@ -18,4 +13,4 @@
|
|
18
13
|
<% end %>
|
19
14
|
</div>
|
20
15
|
<% end %>
|
21
|
-
<% end %>
|
16
|
+
<% end %>
|
@@ -1,21 +1,16 @@
|
|
1
|
-
<%=
|
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
|
<% if content.present? %>
|
8
3
|
<div style="display: inline-block" tabindex="0" data-dropdown-custom-trigger>
|
9
4
|
<%= content.presence %>
|
10
5
|
</div>
|
11
6
|
<% else %>
|
12
7
|
<%= pb_rails("flex", props: {
|
13
|
-
align: "center",
|
14
|
-
border_radius:"lg",
|
15
|
-
classname: object.trigger_wrapper_classes,
|
16
|
-
cursor: "pointer",
|
17
|
-
justify: "between",
|
18
|
-
padding_x:"sm",
|
8
|
+
align: "center",
|
9
|
+
border_radius:"lg",
|
10
|
+
classname: object.trigger_wrapper_classes,
|
11
|
+
cursor: "pointer",
|
12
|
+
justify: "between",
|
13
|
+
padding_x:"sm",
|
19
14
|
padding_y:"xs",
|
20
15
|
html_options: {tabindex:"0"}
|
21
16
|
}) do %>
|
@@ -23,7 +18,7 @@
|
|
23
18
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
24
19
|
<% if object.custom_display.present? %>
|
25
20
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
26
|
-
<div id="dropdown_trigger_custom_display" style="display: none;">
|
21
|
+
<div id="dropdown_trigger_custom_display" style="display: none;">
|
27
22
|
<%= object.custom_display %>
|
28
23
|
</div>
|
29
24
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
@@ -40,4 +35,3 @@
|
|
40
35
|
<% end %>
|
41
36
|
<% end %>
|
42
37
|
<% end %>
|
43
|
-
|
@@ -1,5 +1,3 @@
|
|
1
|
-
@use "sass:math";
|
2
|
-
|
3
1
|
@import "../tokens/spacing";
|
4
2
|
@import "../tokens/colors";
|
5
3
|
@import "../tokens/opacity";
|
@@ -16,9 +14,9 @@ $form_pill_colors: map-merge($status_color_text, map-merge($data_colors, $produc
|
|
16
14
|
display: inline-flex;
|
17
15
|
justify-content: center;
|
18
16
|
align-items: center;
|
19
|
-
padding: 0
|
17
|
+
padding: 0 $space-md/2;
|
20
18
|
height: $pb_form_pill_height;
|
21
|
-
border-radius:
|
19
|
+
border-radius: $pb_form_pill_height/2;
|
22
20
|
margin-bottom: 2px;
|
23
21
|
margin-top: 2px;
|
24
22
|
cursor: pointer;
|
@@ -144,7 +142,7 @@ $form_pill_colors: map-merge($status_color_text, map-merge($data_colors, $produc
|
|
144
142
|
height: 12px !important;
|
145
143
|
width: 12px !important;
|
146
144
|
padding-right: $space_xs;
|
147
|
-
+ .pb_form_pill_text, + .pb_form_pill_tag,
|
145
|
+
+ .pb_form_pill_text, + .pb_form_pill_tag,
|
148
146
|
+ .pb_tooltip_kit .pb_form_pill_text, + .pb_tooltip_kit .pb_form_pill_tag,
|
149
147
|
+ div .pb_form_pill_text, + div .pb_form_pill_tag {
|
150
148
|
padding-left: 0;
|
@@ -173,7 +171,7 @@ $form_pill_colors: map-merge($status_color_text, map-merge($data_colors, $produc
|
|
173
171
|
}
|
174
172
|
.pb_form_pill_icon {
|
175
173
|
padding-right: $space_xxs;
|
176
|
-
+ .pb_form_pill_text, + .pb_form_pill_tag,
|
174
|
+
+ .pb_form_pill_text, + .pb_form_pill_tag,
|
177
175
|
+ .pb_tooltip_kit .pb_form_pill_text, + .pb_tooltip_kit .pb_form_pill_tag,
|
178
176
|
+ div .pb_form_pill_text, + div .pb_form_pill_tag {
|
179
177
|
padding-left: 0;
|