playbook_ui 7.13.0 → 7.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/playbook/application_helper.rb +4 -0
  3. data/app/pb_kits/playbook/_playbook.scss +1 -0
  4. data/app/pb_kits/playbook/pb_card/_card.jsx +3 -1
  5. data/app/pb_kits/playbook/pb_card/_card.scss +3 -2
  6. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +6 -0
  7. data/app/pb_kits/playbook/pb_card/card.rb +9 -1
  8. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.html.erb +53 -0
  9. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.jsx +71 -0
  10. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.md +1 -0
  11. data/app/pb_kits/playbook/pb_card/docs/_card_light.md +1 -0
  12. data/app/pb_kits/playbook/pb_card/docs/example.yml +2 -0
  13. data/app/pb_kits/playbook/pb_card/docs/index.js +1 -0
  14. data/app/pb_kits/playbook/pb_filter/Filter/FiltersPopover.jsx +5 -1
  15. data/app/pb_kits/playbook/pb_filter/docs/_filter_close_popover.jsx +61 -0
  16. data/app/pb_kits/playbook/pb_filter/docs/_filter_default.md +1 -0
  17. data/app/pb_kits/playbook/pb_filter/docs/example.yml +1 -0
  18. data/app/pb_kits/playbook/pb_filter/docs/index.js +1 -0
  19. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +2 -0
  20. data/app/pb_kits/playbook/pb_image/_image.scss +1 -0
  21. data/app/pb_kits/playbook/pb_layout/docs/_layout_collection.html.erb +4 -4
  22. data/app/pb_kits/playbook/pb_layout/docs/_layout_collection.md +1 -0
  23. data/app/pb_kits/playbook/pb_radio/_radio.scss +1 -0
  24. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.html.erb +54 -11
  25. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.jsx +53 -6
  26. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +48 -9
  27. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_block.jsx +41 -44
  28. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_default.html.erb +2 -2
  29. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_default.jsx +53 -62
  30. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_image.jsx +43 -53
  31. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_input.html.erb +105 -0
  32. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_input.jsx +158 -0
  33. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_input.md +1 -0
  34. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_single_select.html.erb +2 -2
  35. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_single_select.jsx +46 -53
  36. data/app/pb_kits/playbook/pb_selectable_card/docs/example.yml +2 -0
  37. data/app/pb_kits/playbook/pb_selectable_card/docs/index.js +1 -0
  38. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb +27 -2
  39. data/app/pb_kits/playbook/pb_selectable_card_icon/_selectable_card_icon.scss +8 -8
  40. data/app/pb_kits/playbook/pb_table/docs/_table_sm.md +2 -0
  41. data/app/pb_kits/playbook/pb_typeahead/_typeahead.html.erb +1 -1
  42. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +6 -1
  43. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +38 -2
  44. data/app/pb_kits/playbook/pb_typeahead/components/Control.jsx +1 -0
  45. data/app/pb_kits/playbook/pb_typeahead/components/Option.jsx +8 -3
  46. data/app/pb_kits/playbook/pb_typeahead/docs/{_typeahead_with_context_dark.html.erb → _typeahead_with_context.html.erb} +10 -2
  47. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.html.erb +1 -1
  48. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +13 -1
  49. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +111 -0
  50. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.md +1 -0
  51. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.html.erb +1 -1
  52. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -0
  53. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +3 -2
  54. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  55. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -1
  56. data/app/pb_kits/playbook/tokens/_border_radius.scss +21 -7
  57. data/app/pb_kits/playbook/utilities/_max_width.scss +15 -0
  58. data/app/pb_kits/playbook/utilities/_spacing.scss +20 -20
  59. data/app/pb_kits/playbook/utilities/globalProps.js +7 -1
  60. data/lib/playbook.rb +11 -0
  61. data/lib/playbook/engine.rb +15 -0
  62. data/lib/playbook/props.rb +23 -1
  63. data/lib/playbook/version.rb +1 -1
  64. metadata +22 -10
@@ -5,18 +5,18 @@
5
5
 
6
6
  input[type="checkbox"],
7
7
  input[type="radio"] {
8
-
8
+
9
9
  transition-duration: $transition_short;
10
-
10
+
11
11
  &:checked ~ label {
12
12
  transition-timing-function: $easeIn;
13
13
  color: $primary;
14
-
14
+
15
15
  h4 {
16
16
  color: $primary;
17
17
  }
18
18
  }
19
-
19
+
20
20
  &:not(:checked) ~ label {
21
21
  transition-timing-function: $easeOut;
22
22
  color: $slate;
@@ -26,7 +26,7 @@
26
26
  &[class*=_disabled] {
27
27
  opacity: $opacity_6;
28
28
  cursor: not-allowed;
29
-
29
+
30
30
  * {
31
31
  cursor: not-allowed;
32
32
  }
@@ -35,10 +35,10 @@
35
35
  &.dark {
36
36
 
37
37
  input[type="checkbox"],
38
- input[type="radio"] {
39
-
38
+ input[type="radio"] {
39
+
40
40
  transition-duration: $transition_short;
41
-
41
+
42
42
  &:checked ~ label {
43
43
  transition-timing-function: $easeIn;
44
44
  color: $active_dark;
@@ -1 +1,3 @@
1
1
  Use table size `"sm"` when data density is a priority. Smaller row height enables the user to view more data without the need for scrolling.
2
+
3
+ Table can leverage the max-width property. Learn more in our <a href="https://playbook.powerapp.cloud/visual_guidelines" target="_blank">visual guidelines.</a>
@@ -26,4 +26,4 @@
26
26
  <% end %>
27
27
  </template>
28
28
  <% end %>
29
- <% end %>
29
+ <% end %>
@@ -4,6 +4,7 @@ import React from 'react'
4
4
  import Select from 'react-select'
5
5
  import AsyncSelect from 'react-select/async'
6
6
  import { get } from 'lodash'
7
+ import { globalProps } from '../utilities/globalProps.js'
7
8
 
8
9
  import Control from './components/Control'
9
10
  import ClearIndicator from './components/ClearIndicator'
@@ -25,6 +26,7 @@ import { noop } from '../utilities/props'
25
26
 
26
27
  type Props = {
27
28
  async?: boolean,
29
+ dark?: boolean,
28
30
  label?: string,
29
31
  loadOptions?: noop | string,
30
32
  getOptionLabel?: () => any,
@@ -81,9 +83,12 @@ const Typeahead = (props: Props) => {
81
83
  }
82
84
  }
83
85
 
86
+ const classes = `pb_typeahead_kit react-select ${globalProps(props)}`
87
+
84
88
  return (
85
- <div className="pb_typeahead_kit react-select">
89
+ <div className={classes}>
86
90
  <Tag
91
+ classNamePrefix="typeahead-kit-select"
87
92
  onChange={handleOnChange}
88
93
  {...selectProps}
89
94
  />
@@ -85,13 +85,49 @@
85
85
  }
86
86
  }
87
87
 
88
- .dark {
88
+ &[class*=dark] {
89
89
  .pb_typeahead_wrapper .pb_typeahead_loading_indicator {
90
90
  color: $text_dk_light;
91
91
  }
92
+ [class^=pb_text_input_kit].dark .text_input_wrapper .text_input {
93
+ display: inherit !important;
94
+ }
95
+ .typeahead-kit-select__menu {
96
+ background-color: $bg_dark;
97
+ color: $white;
98
+ }
99
+ .typeahead-kit-select__option:hover {
100
+ background-color: tint($focus_input_dark, 5%);
101
+ }
102
+ .typeahead-kit-select__input {
103
+ color: white;
104
+ input:focus {
105
+ box-shadow: none;
106
+ }
107
+ }
108
+ .typeahead-kit-select__single-value{
109
+ color: white;
110
+ }
111
+ .typeahead-kit-select__option--is-focused {
112
+ background-color: tint($focus_input_dark, 5%);
113
+ }
114
+
115
+ [class^=pb_list_kit] {
116
+ background-color: $bg_dark;
117
+ }
118
+ .pb_item_kit {
119
+ button {
120
+ color: white !important;
121
+ }
122
+ @media (hover:hover) {
123
+ &:hover {
124
+ background-color: tint($focus_input_dark, 5%);
125
+ }
126
+ }
127
+ }
92
128
  }
93
129
 
94
- &.react-select {
130
+ &.react-select, &.react-select .dark {
95
131
  .text_input {
96
132
  display: inherit;
97
133
  padding: 3px 4px;
@@ -15,6 +15,7 @@ type Props = {
15
15
  const TypeaheadControl = (props: Props) => (
16
16
  <div className="pb_typeahead_wrapper">
17
17
  <TextInput
18
+ dark={props.selectProps.dark}
18
19
  label={props.selectProps.label}
19
20
  >
20
21
  <Flex>
@@ -11,22 +11,27 @@ const Option = (props: any) => {
11
11
  const {
12
12
  imageUrl,
13
13
  } = props.data
14
+ const { valueComponent } = props.selectProps
14
15
 
15
16
  return (
16
17
  <components.Option {...props}>
17
18
  <div>
18
19
  <Choose>
19
- <When condition={imageUrl}>
20
+ <When condition={!valueComponent && imageUrl}>
20
21
  <User
21
22
  align="left"
22
23
  avatarUrl={imageUrl}
24
+ dark={props.selectProps.dark}
23
25
  name={props.label}
24
26
  orientation="horizontal"
25
27
  />
26
28
  </When>
27
- <When condition={!imageUrl}>
28
- {props.label}
29
+ <When condition={valueComponent}>
30
+ { valueComponent(props.data) }
29
31
  </When>
32
+ <Otherwise>
33
+ {props.label}
34
+ </Otherwise>
30
35
  </Choose>
31
36
  </div>
32
37
  </components.Option>
@@ -1,7 +1,6 @@
1
1
  <%= pb_rails("select", props: {
2
2
  label: "Colors",
3
3
  name: "foo",
4
- dark: true,
5
4
  data: { context_select: true },
6
5
  options: [
7
6
  { value: "red", value_text: "Red" },
@@ -12,11 +11,20 @@
12
11
  { value: "purple", value_text: "Purple" },
13
12
  ]
14
13
  }) %>
15
- <%= pb_rails("typeahead", props: { label: "Crayola Crayons", dark: true, name: :foo, data: { typeahead_example2: true, search_context_value_selector: "[data-context-select] select" } }) %>
14
+
15
+ <%= pb_rails("typeahead", props: {
16
+ label: "Crayola Crayons",
17
+ name: :foo,
18
+ data: {
19
+ typeahead_example2: true,
20
+ search_context_value_selector: "[data-context-select] select"
21
+ }
22
+ }) %>
16
23
 
17
24
  <br><br><br>
18
25
 
19
26
  <%= javascript_tag defer: "defer" do %>
27
+
20
28
  document.addEventListener("pb-typeahead-kit-search", function(event) {
21
29
  if (!event.target.dataset || !event.target.dataset.typeaheadExample2) return;
22
30
 
@@ -28,4 +28,4 @@
28
28
  document.querySelector('#clear-pills').addEventListener('click', function() {
29
29
  document.dispatchEvent(new CustomEvent('pb-typeahead-kit-typeahead-pills-example1:clear'))
30
30
  })
31
- <% end %>
31
+ <% end %>
@@ -47,7 +47,18 @@ const promiseOptions = (inputValue) =>
47
47
 
48
48
  const TypeaheadWithPillsAsync = (props) => {
49
49
  const [users, setUsers] = useState([])
50
- const handleOnChange = (value) => setUsers(value)
50
+ const handleOnChange = (value) => setUsers(formatUsers(value))
51
+ const formatValue = (users) => formatUsers(users)
52
+ const formatUsers = (users) => {
53
+ const results = () => (users.map((user) => {
54
+ if (Object.keys(user)[0] === 'name' || Object.keys(user)[1] === 'id'){
55
+ return ({ label: user.name, value: user.id })
56
+ } else {
57
+ return user
58
+ }
59
+ }))
60
+ return results()
61
+ }
51
62
 
52
63
  return (
53
64
  <>
@@ -80,6 +91,7 @@ const TypeaheadWithPillsAsync = (props) => {
80
91
  loadOptions={promiseOptions}
81
92
  onChange={handleOnChange}
82
93
  placeholder="type the name of a Github user"
94
+ value={formatValue(users)}
83
95
  {...props}
84
96
  />
85
97
  </>
@@ -0,0 +1,111 @@
1
+ /* @flow */
2
+
3
+ import React, { useState } from 'react'
4
+
5
+ import {
6
+ Caption,
7
+ Typeahead,
8
+ User,
9
+ } from '../..'
10
+
11
+ /**
12
+ *
13
+ * @const filterResults
14
+ * @ignore
15
+ * @returns {[Object]} - a custom mapping of objects, minimally containing
16
+ * `value` and `label` among other possible fields
17
+ * @summary - for doc example purposes only
18
+ */
19
+
20
+ type UserProps = {
21
+ imageUrl?: String,
22
+ label?: String,
23
+ territory?: String,
24
+ type?: String,
25
+ }
26
+
27
+ const filterResults = (results) =>
28
+ results.items.map((result) => {
29
+ return {
30
+ imageUrl: result.avatar_url, //add the custom field
31
+ label: result.login,
32
+ value: result.id,
33
+ territory: 'PHL',
34
+ type: result.type,
35
+ }
36
+ })
37
+
38
+ const promiseOptions = (inputValue) =>
39
+ new Promise((resolve) => {
40
+ if (inputValue) {
41
+ fetch(`https://api.github.com/search/users?q=${inputValue}`)
42
+ .then((response) => response.json())
43
+ .then((results) => resolve(filterResults(results)))
44
+ } else {
45
+ resolve([])
46
+ }
47
+ })
48
+
49
+ const TypeaheadWithPillsAsyncCustomOptions = (props) => {
50
+ const [users, setUsers] = useState([])
51
+ const handleOnChange = (value) => setUsers(value)
52
+
53
+ /**
54
+ *
55
+ * @const handleOnMultiValueClick {function} - a custom callback for the MultiValue click
56
+ * @ignore
57
+ * @returns {null}
58
+ * @summary - for doc example purposes only
59
+ */
60
+ const handleOnMultiValueClick = (value) => {
61
+ alert(`You removed the user: "${value.label}"`)
62
+ }
63
+
64
+ return (
65
+ <>
66
+ <If condition={users && users.length > 0}>
67
+ <Caption
68
+ marginBottom="xs"
69
+ text="State (Users)"
70
+ {...props}
71
+ />
72
+ <For
73
+ each="user"
74
+ of={users}
75
+ >
76
+ <User
77
+ align="left"
78
+ avatar
79
+ avatarUrl={user.imageUrl}
80
+ key={user.value}
81
+ marginBottom="md"
82
+ name={user.label}
83
+ orientation="horizontal"
84
+ {...props}
85
+ />
86
+ </For>
87
+ </If>
88
+ <Typeahead
89
+ async
90
+ isMulti
91
+ label="Github Users"
92
+ loadOptions={promiseOptions}
93
+ onChange={handleOnChange}
94
+ onMultiValueClick={handleOnMultiValueClick}
95
+ placeholder="type the name of a Github user"
96
+ valueComponent={(props: UserProps) => (
97
+ <User
98
+ avatar
99
+ avatarUrl={props.imageUrl}
100
+ name={props.label}
101
+ territory={props.territory}
102
+ title={props.type}
103
+ />
104
+ )}
105
+ {...props}
106
+ />
107
+ </>
108
+ )
109
+ }
110
+
111
+ export default TypeaheadWithPillsAsyncCustomOptions
@@ -0,0 +1 @@
1
+ Use `valueComponent` props to pass your desire custom options. `valueComponent` will be displayed if present.
@@ -75,6 +75,7 @@ const TypeaheadWithPillsAsyncUsers = (props) => {
75
75
  >
76
76
  <User
77
77
  align="left"
78
+ avatar
78
79
  avatarUrl={user.imageUrl}
79
80
  key={user.value}
80
81
  marginBottom="md"
@@ -1,7 +1,7 @@
1
1
  examples:
2
2
  rails:
3
3
  - typeahead_default: Default
4
- - typeahead_with_context_dark: With Context
4
+ - typeahead_with_context: With Context
5
5
  - typeahead_with_pills: With Pills
6
6
  - typeahead_with_pills_async: With Pills (Async Data)
7
7
  - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
@@ -10,4 +10,5 @@ examples:
10
10
  - typeahead_default: Default
11
11
  - typeahead_with_pills: With Pills
12
12
  - typeahead_with_pills_async: With Pills (Async Data)
13
- - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
13
+ - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
14
+ - typeahead_with_pills_async_custom_options: With Pills (Async Data w/ Custom Options)
@@ -2,3 +2,4 @@ export { default as TypeaheadDefault } from './_typeahead_default'
2
2
  export { default as TypeaheadWithPills } from './_typeahead_with_pills'
3
3
  export { default as TypeaheadWithPillsAsync } from './_typeahead_with_pills_async'
4
4
  export { default as TypeaheadWithPillsAsyncUsers } from './_typeahead_with_pills_async_users'
5
+ export { default as TypeaheadWithPillsAsyncCustomOptions } from './_typeahead_with_pills_async_custom_options'
@@ -39,12 +39,13 @@ module Playbook
39
39
 
40
40
  def typeahead_with_pills_options
41
41
  base_options = {
42
+ dark: dark,
42
43
  defaultValue: default_options,
43
44
  id: id,
44
45
  isMulti: true,
45
46
  label: label,
46
47
  options: options,
47
- placeholder: placeholder
48
+ placeholder: placeholder,
48
49
  }
49
50
 
50
51
  base_options.merge!({getOptionLabel: get_option_label}) if get_option_label.present?
@@ -9,14 +9,28 @@ $border_rad_heavy: 5px;
9
9
  $border_rad_heavier: 6px;
10
10
  $border_rad_heaviest: 7px;
11
11
  $border_rad_mega: 1000px;
12
+ $border_radius_xs: 4px;
13
+ $border_radius_sm: 4px;
14
+ $border_radius_md: 6px;
15
+ $border_radius_lg: 8px;
16
+ $border_radius_xl: 16px;
17
+ $border_radius_rounded: 1000px;
18
+ $border_radius_none: 0;
12
19
  $border_radius: (
13
- lightest: $border_rad_lightest,
14
- lighter: $border_rad_lighter,
15
- light: $border_rad_light,
16
- normal: $border_rad_normal,
17
- heavy: $border_rad_heavy,
18
- heavier: $border_rad_heavier,
19
- heaviest: $border_rad_heaviest
20
+ lightest: $border_rad_lightest,
21
+ lighter: $border_rad_lighter,
22
+ light: $border_rad_light,
23
+ normal: $border_rad_normal,
24
+ heavy: $border_rad_heavy,
25
+ heavier: $border_rad_heavier,
26
+ heaviest: $border_rad_heaviest,
27
+ border_radius_xs: $border_radius_xs,
28
+ border_radius_sm: $border_radius_sm,
29
+ border_radius_md: $border_radius_md,
30
+ border_radius_lg: $border_radius_lg,
31
+ border_radius_xl: $border_radius_xl,
32
+ border_radius_none: $border_radius_none,
33
+ border_radius_rounded: $border_radius_rounded
20
34
  );
21
35
 
22
36