playbook_ui 8.2.0.pre.alpha2 → 8.2.1.pre.alpha2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -18
  3. data/app/pb_kits/playbook/_playbook.scss +1 -0
  4. data/app/pb_kits/playbook/data/menu.yml +2 -1
  5. data/app/pb_kits/playbook/index.js +1 -0
  6. data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +14 -2
  7. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -1
  8. data/app/pb_kits/playbook/pb_avatar/avatar.rb +5 -2
  9. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +5 -2
  10. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.html.erb +5 -0
  11. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.jsx +5 -0
  12. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_status.html.erb +4 -0
  13. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_status.jsx +4 -0
  14. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx +6 -0
  15. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +2 -1
  16. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb +2 -0
  17. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.html.erb +4 -0
  18. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.jsx +4 -0
  19. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.html.erb +2 -0
  20. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.jsx +2 -0
  21. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_on_click.jsx +2 -0
  22. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_onclick.html.erb +2 -0
  23. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb +8 -0
  24. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.jsx +8 -0
  25. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_tooltip.html.erb +2 -0
  26. data/app/pb_kits/playbook/pb_avatar_action_button/pb_avatar_action_button.test.js +31 -0
  27. data/app/pb_kits/playbook/pb_badge/_badge.jsx +26 -1
  28. data/app/pb_kits/playbook/pb_caption/_caption.jsx +3 -2
  29. data/app/pb_kits/playbook/pb_caption/caption.rb +1 -1
  30. data/app/pb_kits/playbook/pb_card/_card.jsx +18 -3
  31. data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
  32. data/app/pb_kits/playbook/pb_card/card.rb +3 -0
  33. data/app/pb_kits/playbook/pb_card/docs/_card_tag.html.erb +25 -0
  34. data/app/pb_kits/playbook/pb_card/docs/_card_tag.jsx +59 -0
  35. data/app/pb_kits/playbook/pb_card/docs/example.yml +2 -0
  36. data/app/pb_kits/playbook/pb_card/docs/index.js +1 -0
  37. data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +31 -9
  38. data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +28 -19
  39. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +11 -3
  40. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +6 -1
  41. data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +94 -0
  42. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_custom.jsx +0 -1
  43. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +7 -0
  44. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.jsx +16 -0
  45. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -0
  46. data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
  47. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +6 -1
  48. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +3 -0
  49. data/app/pb_kits/playbook/pb_dialog/_close_icon.jsx +23 -0
  50. data/app/pb_kits/playbook/pb_dialog/_dialog.html.erb +10 -0
  51. data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +142 -0
  52. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +133 -0
  53. data/app/pb_kits/playbook/pb_dialog/_dialog_context.jsx +3 -0
  54. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.jsx +21 -0
  55. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.jsx +36 -0
  56. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx +68 -0
  57. data/app/pb_kits/playbook/pb_dialog/dialog.rb +47 -0
  58. data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +23 -0
  59. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +31 -0
  60. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.jsx +53 -0
  61. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +2 -0
  62. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +27 -0
  63. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.jsx +27 -0
  64. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.md +2 -0
  65. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_separators.jsx +119 -0
  66. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_separators.md +2 -0
  67. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.jsx +28 -0
  68. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.md +2 -0
  69. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.jsx +93 -0
  70. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +10 -0
  71. data/app/pb_kits/playbook/pb_dialog/docs/index.js +6 -0
  72. data/app/pb_kits/playbook/pb_flex/_flex.jsx +6 -3
  73. data/app/pb_kits/playbook/pb_form/form_builder.rb +4 -2
  74. data/app/pb_kits/playbook/pb_form/form_builder/action_area.rb +14 -7
  75. data/app/pb_kits/playbook/pb_form/simple_form.html.erb +2 -4
  76. data/app/pb_kits/playbook/pb_form/simple_form.rb +4 -0
  77. data/app/pb_kits/playbook/pb_online_status/_online_status.jsx +2 -0
  78. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +1 -1
  79. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +4 -3
  80. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +3 -0
  81. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +3 -0
  82. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +9 -1
  83. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +9 -0
  84. data/app/pb_kits/playbook/pb_typeahead/components/Input.jsx +43 -0
  85. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx +21 -11
  86. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.jsx +1 -0
  87. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.jsx +8 -3
  88. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +4 -4
  89. data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +1 -1
  90. data/app/pb_kits/playbook/react_rails_kits.js +4 -0
  91. data/lib/playbook/version.rb +2 -1
  92. metadata +55 -27
  93. data/app/pb_kits/playbook/pb_form/form_builder/action_area.html.erb +0 -3
@@ -0,0 +1,133 @@
1
+ @import "../tokens/positioning";
2
+ @import "../tokens/colors";
3
+ @import "../pb_card/card_mixin";
4
+ @import "../tokens/shadows";
5
+ @import "../tokens/border_radius";
6
+ @import "../tokens/spacing";
7
+ @import "../tokens/animation-curves";
8
+
9
+
10
+
11
+ // Dialog Animations
12
+
13
+ @keyframes modalFadeIn {
14
+ from {
15
+ transform: translate3d(0, -100%, 0);
16
+ opacity: 0;
17
+ }
18
+ to {
19
+ transform: translate3d(0, 0, 0);
20
+ opacity: 1;
21
+ }
22
+ }
23
+
24
+ @keyframes modalFadeOut {
25
+ from {
26
+ transform: translate3d(0, 0, 0);
27
+ opacity: 1;
28
+ }
29
+ to {
30
+ transform: translate3d(0, -50%, 0);
31
+ opacity: 0;
32
+ }
33
+ }
34
+
35
+ @keyframes overlayFade {
36
+ from {
37
+ opacity: 0;
38
+ transform: translateY(0);
39
+ }
40
+ to {
41
+ opacity: 1;
42
+ transform: translateY(0);
43
+ }
44
+ }
45
+
46
+ @keyframes overlayFadeOut {
47
+ from {
48
+ opacity: 1;
49
+ }
50
+ to {
51
+ opacity: 0;
52
+ }
53
+ }
54
+
55
+ // Dialog Styles
56
+
57
+ .pb_dialog {
58
+
59
+ // Local Variables
60
+ $gutter: $space_lg;
61
+ $small: 300px;
62
+ $medium: 500px;
63
+ $large: 800px;
64
+ $animation-duration: 0.2s;
65
+ $z-index: 100;
66
+ $opacity_visible: 1;
67
+ $opacity_hidden: 0;
68
+
69
+ @include pb_card;
70
+ box-shadow: $shadow_deepest;
71
+ border: 0;
72
+ max-height: calc(100vh - #{$gutter * 2});
73
+ max-width: calc(100vw - #{$gutter * 2});
74
+ overflow: scroll;
75
+ animation-name: modalFadeIn;
76
+ animation-duration: $animation-duration;
77
+ outline: none;
78
+ animation-timing-function: $easeInOutQuint;
79
+
80
+ &[class*="_sm"] {
81
+ width: $small;
82
+ }
83
+
84
+ &[class*="_md"] {
85
+ width: $medium;
86
+ }
87
+
88
+ &[class*="_lg"] {
89
+ width: $large;
90
+ }
91
+
92
+ &_body_open {
93
+ overflow: hidden;
94
+ }
95
+
96
+ &_after_open {
97
+ opacity: $opacity_visible;
98
+ }
99
+
100
+ &_before_close {
101
+ animation-name: modalFadeOut;
102
+ animation-duration: $animation-duration;
103
+ opacity: $opacity_hidden;
104
+ }
105
+
106
+ &_close_icon {
107
+ cursor: pointer;
108
+ }
109
+
110
+ &_overlay {
111
+ position: fixed;
112
+ top: 0;
113
+ left: 0;
114
+ right: 0;
115
+ bottom: 0;
116
+ display: flex;
117
+ align-items: center;
118
+ justify-content: center;
119
+ background-color: rgba($bg_dark, $opacity_4);
120
+ z-index: $z-index;
121
+ animation-name: overlayFade;
122
+ animation-duration: $animation-duration;
123
+
124
+ &_after_open {
125
+ opacity: $opacity_visible;
126
+ }
127
+ &_before_close {
128
+ animation-name: overlayFadeOut;
129
+ animation-duration: $animation-duration;
130
+ opacity: $opacity_hidden;
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,3 @@
1
+ import React from 'react'
2
+
3
+ export const DialogContext = React.createContext()
@@ -0,0 +1,21 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import classnames from 'classnames'
5
+ import { buildCss } from '../../utilities/props'
6
+ import { globalProps } from '../../utilities/globalProps.js'
7
+
8
+ // Body component
9
+ const DialogBody = (props: DialogBodyProps) => {
10
+ const { children, padding = 'sm', className } = props
11
+ const bodyCSS = buildCss('dialog_body')
12
+ const bodySpacing = globalProps(props, { padding })
13
+
14
+ return (
15
+ <div className={classnames(bodyCSS, bodySpacing, className)}>
16
+ {children}
17
+ </div>
18
+ )
19
+ }
20
+
21
+ export default DialogBody
@@ -0,0 +1,36 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import classnames from 'classnames'
5
+ import { buildCss } from '../../utilities/props'
6
+ import { globalProps } from '../../utilities/globalProps.js'
7
+ import { Flex, SectionSeparator } from '../../'
8
+
9
+ // Footer component
10
+ const DialogFooter = (props: DialogFooterProps) => {
11
+ const {
12
+ children,
13
+ padding = 'sm',
14
+ className,
15
+ spacing = 'between',
16
+ separator = false,
17
+ } = props
18
+ const footerCSS = buildCss('dialog_footer')
19
+ const footerSpacing = globalProps(props, { padding })
20
+
21
+ return (
22
+ <>
23
+ <If condition={separator}>
24
+ <SectionSeparator />
25
+ </If>
26
+ <Flex
27
+ className={classnames(footerCSS, footerSpacing, className)}
28
+ spacing={spacing}
29
+ >
30
+ {children}
31
+ </Flex>
32
+ </>
33
+ )
34
+ }
35
+
36
+ export default DialogFooter
@@ -0,0 +1,68 @@
1
+ /* @flow */
2
+
3
+ import React, { useContext } from 'react'
4
+ import classnames from 'classnames'
5
+ import { buildAriaProps, buildCss, buildDataProps } from '../../utilities/props'
6
+ import { globalProps } from '../../utilities/globalProps.js'
7
+ import { Flex, SectionSeparator } from '../../'
8
+ import { CloseIcon } from '../_close_icon'
9
+ import { DialogContext } from '../_dialog_context'
10
+
11
+ type DialogHeaderProps = {
12
+ aria?: object,
13
+ children: array<React.ReactNode> | React.ReactNode | string,
14
+ className?: string,
15
+ closeable: boolean,
16
+ data?: object,
17
+ id?: string,
18
+ padding?: string,
19
+ separator: boolean,
20
+ spacing?: string,
21
+ text?: string,
22
+ title?: string,
23
+ }
24
+
25
+ const DialogHeader = (props: DialogHeaderProps) => {
26
+ const {
27
+ aria = {},
28
+ children,
29
+ className,
30
+ data = {},
31
+ padding = 'sm',
32
+ spacing = 'between',
33
+ closeable = true,
34
+ separator = true,
35
+ } = props
36
+
37
+ const ariaProps = buildAriaProps(aria)
38
+ const dataProps = buildDataProps(data)
39
+ const api = useContext(DialogContext)
40
+ const headerCSS = buildCss('dialog_header')
41
+ const headerSpacing = globalProps(props, { padding })
42
+
43
+ /* eslint-disable react/jsx-handler-names */
44
+
45
+ return (
46
+ <>
47
+ <Flex
48
+ {...ariaProps}
49
+ {...dataProps}
50
+ className={classnames(headerCSS, headerSpacing, className)}
51
+ spacing={spacing}
52
+ >
53
+ {children}
54
+ <If condition={closeable}>
55
+ <CloseIcon
56
+ className="close-icon"
57
+ onClose={api.onClose}
58
+ />
59
+ </If>
60
+ </Flex>
61
+ <If condition={separator}>
62
+ <SectionSeparator />
63
+ </If>
64
+ </>
65
+ )
66
+ }
67
+
68
+ export default DialogHeader
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbDialog
5
+ class Dialog
6
+ include Playbook::Props
7
+
8
+ partial "pb_dialog/dialog"
9
+
10
+ prop :ref
11
+ prop :cancel_button
12
+ prop :closeable, type: Playbook::Props::Boolean, default: true
13
+ prop :confirm_button
14
+ prop :oncancel
15
+ prop :onchange
16
+ prop :onclose
17
+ prop :onconfirm
18
+ prop :opened, type: Playbook::Props::Boolean, default: false
19
+ prop :size, type: Playbook::Props::Enum,
20
+ values: %w[sm md lg content],
21
+ default: "md"
22
+ prop :text
23
+ prop :title
24
+ prop :trigger
25
+
26
+ def dialog_options
27
+ {
28
+ id: id,
29
+ ref: ref,
30
+ trigger: trigger,
31
+ className: classname,
32
+ cancelButton: cancel_button,
33
+ closeable: closeable,
34
+ confirmButton: confirm_button,
35
+ onCancel: oncancel,
36
+ onChange: onchange,
37
+ onClose: onclose,
38
+ onConfirm: onconfirm,
39
+ opened: opened,
40
+ size: size,
41
+ text: text,
42
+ title: title,
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,23 @@
1
+ import React from 'react'
2
+ import { render, screen } from '../utilities/test-utils'
3
+ import { Dialog } from '../'
4
+
5
+ /* eslint-disable jsx-control-statements/jsx-jcs-no-undef */
6
+
7
+ /* See these resources for more testing info:
8
+ - https://github.com/testing-library/jest-dom#usage for useage and examples
9
+ - https://jestjs.io/docs/en/using-matchers
10
+ */
11
+
12
+ test('generated scaffold test - update me', () => {
13
+ const testId = 'test1'
14
+
15
+ render(
16
+ <Dialog
17
+ data={{ testid: testId }}
18
+ />
19
+ )
20
+
21
+ const kit = screen.getByTestId(testId)
22
+ expect(kit).toBeInTheDocument()
23
+ })
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbDialog
5
+ class DialogHeader
6
+ include Playbook::Props
7
+
8
+ partial "pb_dialog/child_kits/dialog_header"
9
+
10
+ prop :closeable, type: Playbook::Props::Boolean, default: true
11
+ prop :padding
12
+ prop :separator, type: Playbook::Props::Boolean, default: true
13
+ prop :spacing
14
+ prop :text
15
+ prop :title
16
+
17
+ def dialog_header_options
18
+ {
19
+ id: id,
20
+ closeable: closeable,
21
+ padding: padding,
22
+ separator: separator,
23
+ spacing: spacing,
24
+ text: text,
25
+ title: title,
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,53 @@
1
+ import React, { useState } from 'react'
2
+ import {
3
+ Body,
4
+ Button,
5
+ Caption,
6
+ Dialog,
7
+ RichTextEditor,
8
+ Typeahead,
9
+ } from '../../'
10
+
11
+ const DialogCompound = () => {
12
+ const [isOpen, setIsOpen] = useState(false)
13
+ const close = () => setIsOpen(false)
14
+ const open = () => setIsOpen(true)
15
+
16
+ return (
17
+ <>
18
+ <Button onClick={open}>{'Open a Complex Dialog'}</Button>
19
+ <Dialog
20
+ onClose={close}
21
+ opened={isOpen}
22
+ size="lg"
23
+ >
24
+ <Dialog.Header>
25
+ <Body>{'What do you need us to take care of?'}</Body>
26
+ </Dialog.Header>
27
+ <Dialog.Body>
28
+ <Caption marginBottom="xs">{'Description'}</Caption>
29
+ <RichTextEditor />
30
+ <br />
31
+ <Caption>
32
+ {
33
+ 'Type in a word or term too help find tickets later. ex. training,'
34
+ }
35
+ {'phone setup, hr'}
36
+ </Caption>
37
+ <Typeahead placeholder="Tags.." />
38
+ </Dialog.Body>
39
+ <Dialog.Footer>
40
+ <Button onClick={close}>{'Send My Issue'}</Button>
41
+ <Button
42
+ onClick={close}
43
+ variant="link"
44
+ >
45
+ {'Back'}
46
+ </Button>
47
+ </Dialog.Footer>
48
+ </Dialog>
49
+ </>
50
+ )
51
+ }
52
+
53
+ export default DialogCompound
@@ -0,0 +1,2 @@
1
+ The dialog kit also supports customizing your dialog with a [compound component](https://kentcdodds.com/blog/compound-components-with-react-hooks) structure.
2
+ This allows for greater flexibility and more complex dialogs.
@@ -0,0 +1,27 @@
1
+ import React, { useState } from 'react'
2
+ import { Button, Dialog } from '../../'
3
+
4
+ const DialogDefault = () => {
5
+ const [isOpen, setIsOpen] = useState(false)
6
+ const close = () => setIsOpen(false)
7
+ const open = () => setIsOpen(true)
8
+
9
+ return (
10
+ <>
11
+ <Button onClick={open}>{'Open Dialog'}</Button>
12
+ <Dialog
13
+ cancelButton="Cancel"
14
+ confirmButton="Okay"
15
+ onCancel={close}
16
+ onClose={close}
17
+ onConfirm={close}
18
+ opened={isOpen}
19
+ size="sm"
20
+ text="Hello Body Text, Nice to meet ya."
21
+ title="Header Title is the Title Prop"
22
+ />
23
+ </>
24
+ )
25
+ }
26
+
27
+ export default DialogDefault