playbook_ui_docs 14.11.1.pre.alpha.responsivetablerails5364 → 14.12.0.pre.alpha.PBNTR456fixedconftoastrailsautoclose5673

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_no_subrows.jsx +50 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +1 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +1 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.html.erb +38 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.jsx +60 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.md +5 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx +78 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.md +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.jsx +53 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.md +1 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.jsx +52 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.md +1 -0
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +2 -2
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_no_subrows.json +42 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_with_id.json +299 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +6 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +6 -1
  19. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md +1 -1
  20. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_turbo_frames.html.erb +13 -0
  21. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_turbo_frames_rails.md +3 -0
  22. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +1 -0
  23. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.html.erb +1 -3
  24. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.md +7 -0
  25. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.html.erb +3 -9
  26. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.md +5 -0
  27. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.html.erb +38 -0
  28. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.md +3 -0
  29. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +1 -0
  30. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.jsx +38 -0
  31. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -45
  32. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +0 -1
  33. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.jsx +9 -16
  34. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +44 -19
  35. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.md +21 -3
  36. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +16 -21
  37. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.jsx +2 -19
  38. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +2 -1
  39. data/app/pb_kits/playbook/pb_drawer/docs/index.js +1 -0
  40. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subtle_variant.md +1 -1
  41. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +74 -0
  42. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close_rails.md +3 -0
  43. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +1 -0
  44. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.html.erb +3 -0
  45. data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +7 -0
  46. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.html.erb +15 -0
  47. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.jsx +24 -0
  48. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.md +1 -0
  49. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
  50. data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
  51. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +8 -3
  52. data/app/pb_kits/playbook/pb_selectable_icon/docs/_selectable_icon_default.jsx +4 -1
  53. data/app/pb_kits/playbook/pb_selectable_icon/docs/_selectable_icon_single_select.jsx +4 -1
  54. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +74 -0
  55. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_rails.md +3 -0
  56. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +2 -2
  57. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +74 -0
  58. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_rails.md +3 -0
  59. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.html.erb +47 -0
  60. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_rails.md +2 -0
  61. data/app/pb_kits/playbook/pb_table/docs/example.yml +3 -0
  62. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +46 -0
  63. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask_rails.md +3 -0
  64. data/app/pb_kits/playbook/pb_text_input/docs/example.yml +2 -1
  65. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.html.erb +19 -0
  66. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.jsx +27 -0
  67. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.md +1 -0
  68. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  69. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  70. data/dist/playbook-doc.js +1 -1
  71. metadata +40 -4
  72. /data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/{_fixed_confirmation_toast_auto_close.md → _fixed_confirmation_toast_auto_close_react.md} +0 -0
  73. /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 [headerSeparatorDrawerOpened, toggleHeaderSeparatorDrawer] = useDrawer();
13
- const [bothSeparatorsDrawerOpened, toggleBothSeparatorsDrawer] = useDrawer();
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={toggleHeaderSeparatorDrawer}
21
+ onClick={toggleDrawerLeftOpen}
22
22
  >
23
23
  {"Left Drawer"}
24
24
  </Button>
25
25
  <Button
26
26
  marginRight="xl"
27
- onClick={toggleBothSeparatorsDrawer}
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
- behavior={"push"}
36
- fullHeight
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
- behavior={"push"}
49
- fullHeight
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, Title } from "playbook-ui";
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="menuButton"
9
- padding="sm"
16
+ <div>
17
+ <Button id='menuButton'
18
+ padding='xs'
10
19
  >
11
- <Icon icon="bars"
12
- size="3x"
20
+ <Icon icon='bars'
21
+ size='2x'
13
22
  />
14
23
  </Button>
15
24
  <Drawer
16
- behavior="push"
17
- closeBreakpoint="md"
18
- menuButtonID="menuButton"
19
- overlay={false}
20
- placement="left"
21
- size="lg"
25
+ breakpoint="md"
26
+ placement='bottom'
27
+ size='full'
28
+ triggerId='menuButton'
22
29
  withinElement
23
30
  >
24
- <Title paddingBottom="md">A really neat menu</Title>
25
- <Button text="This Button does nothing" />
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
- Our drawer kit can fulfill your responsive menu needs! Using the `closeBreakpoint` prop you can have the menu close on smaller screens like phones/tablets.
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 = () => setOpenedNoOverlayDrawer(!openedNoOverlayDrawer);
11
- const toggleOverlayDrawer = () => setOpenedOverlayDrawer(!openedOverlayDrawer);
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="md"
17
+ <Button marginRight='md'
17
18
  onClick={toggleNoOverlayDrawer}
18
19
  >
19
20
  No Overlay Drawer
20
21
  </Button>
21
- <Button marginRight="md"
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
- placement="right"
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
- overlay
46
- placement="right"
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 marginRight="md"
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
  >
@@ -6,7 +6,8 @@ examples:
6
6
 
7
7
  react:
8
8
  - drawer_default: Default
9
- - drawer_menu: Menu Behavior
9
+ - drawer_behavior: Push Behavior
10
+ - drawer_menu: Within Element
10
11
  - drawer_sizes: Sizes
11
12
  - drawer_overlay: Overlay
12
13
  - drawer_borders: Borders
@@ -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'
@@ -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 more cleaner look.
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.
@@ -0,0 +1,74 @@
1
+ <%= pb_rails("button", props: { text: "Show Auto Close Toast", variant: "secondary", data: { toast: "#toast-auto-close" } }) %>
2
+ <%= pb_rails("button", props: { text: "Show Closeable Auto Close Toast", variant: "secondary", data: { toast: "#toast-auto-close-closeable" } }) %>
3
+
4
+ <%= pb_rails("fixed_confirmation_toast", props: {
5
+ auto_close: 3000,
6
+ id: "toast-auto-close",
7
+ text: "I will disappear in 3 seconds.",
8
+ status: "tip",
9
+ vertical: "top",
10
+ horizontal: "center"
11
+ }) %>
12
+
13
+ <%= pb_rails("fixed_confirmation_toast", props: {
14
+ auto_close: 10000,
15
+ closeable: true,
16
+ id: "toast-auto-close-closeable",
17
+ text: "I will disappear in 10 seconds.",
18
+ status: "tip",
19
+ vertical: "top",
20
+ horizontal: "center"
21
+ }) %>
22
+
23
+ <script>
24
+ document.addEventListener('DOMContentLoaded', () => {
25
+ const toasts = {
26
+ '#toast-auto-close': document.querySelector("#toast-auto-close"),
27
+ '#toast-auto-close-closeable': document.querySelector("#toast-auto-close-closeable")
28
+ }
29
+
30
+ const buttons = {
31
+ '#toast-auto-close': document.querySelector("button[data-toast='#toast-auto-close']"),
32
+ '#toast-auto-close-closeable': document.querySelector("button[data-toast='#toast-auto-close-closeable']")
33
+ }
34
+
35
+ const hideAllToastsUponPageLoad = () => {
36
+ Object.values(toasts).forEach(toast => {
37
+ if (toast) toast.style.display = "none"
38
+ })
39
+ }
40
+
41
+ const showAndAutoCloseToast = (toastId) => {
42
+ hideAllToastsUponPageLoad()
43
+ const toast = toasts[toastId]
44
+
45
+ if (toast) {
46
+ toast.style.display = "flex" // Show the selected toast
47
+
48
+ const autoCloseClass = Array.from(toast.classList).find(cls => cls.startsWith('auto_close_'))
49
+ if (autoCloseClass) {
50
+ const duration = parseInt(autoCloseClass.split('_')[2]) || 0; // Use 0 as fallback if parsing fails
51
+
52
+ if (toast.autoCloseTimeout) {
53
+ clearTimeout(toast.autoCloseTimeout)
54
+ }
55
+
56
+ toast.autoCloseTimeout = setTimeout(() => {
57
+ toast.style.display = "none"
58
+ }, duration)
59
+ }
60
+ }
61
+ }
62
+
63
+ Object.keys(buttons).forEach((key) => {
64
+ const button = buttons[key]
65
+ if (button) {
66
+ button.onclick = () => {
67
+ showAndAutoCloseToast(key)
68
+ }
69
+ }
70
+ })
71
+
72
+ hideAllToastsUponPageLoad()
73
+ })
74
+ </script>
@@ -0,0 +1,3 @@
1
+ Auto close is used when you want the confirmation toast to close automatically after a certain time. `auto_close` property will be a delay number in ms.
2
+
3
+ Script tag in code snippet is for demonstration purposes only. It provides the functionality needed to show and hide the toaster in response to user interaction, and hides them from appearing upon initial page load. In a typical production environment this functionality would be handled by a controller or a separate javascript file.
@@ -5,6 +5,7 @@ examples:
5
5
  - fixed_confirmation_toast_multi_line: Multi Line
6
6
  - fixed_confirmation_toast_close: Click to Close
7
7
  - fixed_confirmation_toast_positions: Click to Show Positions
8
+ - fixed_confirmation_toast_auto_close: Click to Show Auto Close
8
9
  - fixed_confirmation_toast_children: Children
9
10
  - fixed_confirmation_toast_custom_icon: Custom Icon
10
11
 
@@ -0,0 +1,3 @@
1
+ <%= pb_rails("icon_button") %>
2
+ </br>
3
+ <%= pb_rails("icon_button", props: {variant: "link"}) %>
@@ -0,0 +1,7 @@
1
+ examples:
2
+
3
+ rails:
4
+ - icon_button_default: Default
5
+
6
+
7
+
@@ -0,0 +1,15 @@
1
+ <%= pb_rails("phone_number_input", props: {
2
+ id: "phone_number_input",
3
+ format_as_you_type: true
4
+ }) %>
5
+
6
+ <%= pb_rails("button", props: {id: "clickable", text: "Save Phone Number"}) %>
7
+
8
+ <%= javascript_tag do %>
9
+ document.querySelector('#clickable').addEventListener('click', () => {
10
+ const formattedPhoneNumber = document.querySelector('#phone_number_input').value
11
+ const unformattedPhoneNumber = formattedPhoneNumber.replace(/\D/g, "")
12
+
13
+ alert(`Formatted: ${formattedPhoneNumber}. Unformatted: ${unformattedPhoneNumber}`)
14
+ })
15
+ <% end %>
@@ -0,0 +1,24 @@
1
+ import React, { useState } from "react";
2
+ import { PhoneNumberInput, Body } from "playbook-ui";
3
+
4
+ const PhoneNumberInputFormat = (props) => {
5
+ const [phoneNumber, setPhoneNumber] = useState("");
6
+
7
+ const handleOnChange = ({ number }) => {
8
+ setPhoneNumber(number);
9
+ };
10
+
11
+ return (
12
+ <>
13
+ <PhoneNumberInput
14
+ formatAsYouType
15
+ id="format"
16
+ onChange={handleOnChange}
17
+ {...props}
18
+ />
19
+ {phoneNumber && <Body>Unformatted number: {phoneNumber}</Body>}
20
+ </>
21
+ );
22
+ };
23
+
24
+ export default PhoneNumberInputFormat;
@@ -0,0 +1 @@
1
+ NOTE: the `number` in the React `onChange` event will not include formatting (no spaces, dashes, and parentheses). For Rails, the `value` will include formatting and its value must be sanitized manually.
@@ -8,10 +8,12 @@ examples:
8
8
  - phone_number_input_validation: Form Validation
9
9
  - phone_number_input_clear_field: Clearing the Input Field
10
10
  - phone_number_input_access_input_element: Accessing the Input Element
11
+ - phone_number_input_format: Format as You Type
11
12
 
12
13
  rails:
13
14
  - phone_number_input_default: Default
14
15
  - phone_number_input_preferred_countries: Preferred Countries
15
16
  - phone_number_input_initial_country: Initial Country
16
17
  - phone_number_input_only_countries: Limited Countries
17
- - phone_number_input_validation: Form Validation
18
+ - phone_number_input_validation: Form Validation
19
+ - phone_number_input_format: Format as You Type
@@ -5,3 +5,4 @@ export { default as PhoneNumberInputOnlyCountries } from './_phone_number_input_
5
5
  export { default as PhoneNumberInputValidation } from './_phone_number_input_validation'
6
6
  export { default as PhoneNumberInputClearField } from './_phone_number_input_clear_field'
7
7
  export { default as PhoneNumberInputAccessInputElement } from './_phone_number_input_access_input_element'
8
+ export { default as PhoneNumberInputFormat } from './_phone_number_input_format'
@@ -29,6 +29,7 @@ const RadioChildren = (props) => {
29
29
  marginBottom="none"
30
30
  minWidth="xs"
31
31
  options={options}
32
+ {...props}
32
33
  />
33
34
  </Radio>
34
35
  <Radio
@@ -40,10 +41,11 @@ const RadioChildren = (props) => {
40
41
  value="Typeahead"
41
42
  {...props}
42
43
  >
43
- <Typeahead
44
+ <Typeahead
44
45
  marginBottom="none"
45
46
  minWidth="xs"
46
47
  options={options}
48
+ {...props}
47
49
  />
48
50
  </Radio>
49
51
  <Radio
@@ -54,9 +56,12 @@ const RadioChildren = (props) => {
54
56
  value="Typography"
55
57
  {...props}
56
58
  >
57
- <Title text="Custom Typography" />
59
+ <Title
60
+ text="Custom Typography"
61
+ {...props}
62
+ />
58
63
  </Radio>
59
64
  </div>
60
65
  )
61
66
  }
62
- export default RadioChildren
67
+ export default RadioChildren
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react'
2
2
  import SelectableIcon from '../_selectable_icon'
3
3
 
4
- const SelectableIconDefault = () => {
4
+ const SelectableIconDefault = (props) => {
5
5
  const [ checkSelected, toggleSelected ] = useState(true)
6
6
  const [ checkUnselected, toggleUnselected ] = useState(false)
7
7
  const [ checkDisabled, toggleDisabled ] = useState(false)
@@ -15,6 +15,7 @@ const SelectableIconDefault = () => {
15
15
  inputId={10}
16
16
  onChange={() => toggleSelected(!checkSelected)}
17
17
  text="US Dollar"
18
+ {...props}
18
19
  />
19
20
 
20
21
  <SelectableIcon
@@ -23,6 +24,7 @@ const SelectableIconDefault = () => {
23
24
  inputId={11}
24
25
  onChange={() => toggleUnselected(!checkUnselected)}
25
26
  text="Euro"
27
+ {...props}
26
28
  />
27
29
 
28
30
  <SelectableIcon
@@ -32,6 +34,7 @@ const SelectableIconDefault = () => {
32
34
  inputId={12}
33
35
  onChange={() => toggleDisabled(!checkDisabled)}
34
36
  text="Yen"
37
+ {...props}
35
38
  />
36
39
  </div>
37
40
  )
@@ -2,7 +2,7 @@ import React, { useState } from 'react'
2
2
 
3
3
  import SelectableIcon from '../_selectable_icon'
4
4
 
5
- const SelectableIconSingleSelect = () => {
5
+ const SelectableIconSingleSelect = (props) => {
6
6
  const [ selectedFormat, toggleFormat ] = useState(null)
7
7
 
8
8
  return (
@@ -17,6 +17,7 @@ const SelectableIconSingleSelect = () => {
17
17
  onChange={() => toggleFormat('Cassette')}
18
18
  text="Cassette"
19
19
  value="Cassette"
20
+ {...props}
20
21
  />
21
22
 
22
23
  <SelectableIcon
@@ -28,6 +29,7 @@ const SelectableIconSingleSelect = () => {
28
29
  onChange={() => toggleFormat('CD')}
29
30
  text="CD"
30
31
  value="CD"
32
+ {...props}
31
33
  />
32
34
 
33
35
  <SelectableIcon
@@ -39,6 +41,7 @@ const SelectableIconSingleSelect = () => {
39
41
  onChange={() => toggleFormat('Vinyl')}
40
42
  text="Vinyl"
41
43
  value="Vinyl"
44
+ {...props}
42
45
  />
43
46
  </div>
44
47
  )