playbook_ui 13.22.0 → 13.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +8 -4
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +1 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +1 -1
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +1 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +6 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md +2 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +1 -1
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +1 -1
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +1 -1
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -1
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data.json +278 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -1
  16. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.html.erb +0 -7
  17. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.jsx +0 -7
  18. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.html.erb +7 -0
  19. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.jsx +7 -0
  20. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -2
  21. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +1 -1
  22. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +2 -2
  23. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +2 -0
  24. data/app/pb_kits/playbook/pb_form_group/_form_group.scss +34 -0
  25. data/app/pb_kits/playbook/pb_form_group/docs/_form_group_select.html.erb +17 -1
  26. data/app/pb_kits/playbook/pb_form_group/docs/_form_group_select.jsx +18 -2
  27. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +14 -0
  28. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +1 -1
  29. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes.html.erb +5 -0
  30. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes.jsx +6 -0
  31. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.rb +1 -1
  32. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.test.js +1 -0
  33. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +0 -2
  34. data/app/pb_kits/playbook/pb_list/list.rb +0 -2
  35. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.md +2 -2
  36. data/app/pb_kits/playbook/pb_multi_level_select/docs/{_multi_level_select_selected_ids.jsx → _multi_level_select_selected_ids_react.jsx} +2 -2
  37. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids_react.md +5 -0
  38. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -1
  39. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -1
  40. data/app/pb_kits/playbook/pb_online_status/_online_status.scss +1 -10
  41. data/app/pb_kits/playbook/pb_online_status/_online_status.tsx +1 -1
  42. data/app/pb_kits/playbook/pb_online_status/_online_status_mixins.scss +7 -13
  43. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_default.html.erb +6 -9
  44. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_default.jsx +18 -7
  45. data/app/pb_kits/playbook/pb_online_status/online_status.rb +1 -1
  46. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.html.erb +2 -1
  47. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +2 -2
  48. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +39 -6
  49. data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +17 -12
  50. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_disabled.html.erb +11 -0
  51. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_disabled.jsx +21 -0
  52. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +3 -1
  53. data/app/pb_kits/playbook/pb_toggle/docs/index.js +1 -0
  54. data/app/pb_kits/playbook/pb_toggle/toggle.rb +2 -1
  55. data/app/pb_kits/playbook/pb_toggle/toggle.test.js +7 -0
  56. data/app/pb_kits/playbook/utilities/_positioning.scss +23 -10
  57. data/app/pb_kits/playbook/utilities/globalProps.ts +26 -8
  58. data/dist/menu.yml +4 -0
  59. data/dist/playbook-rails.js +7 -7
  60. data/lib/playbook/bottom.rb +6 -3
  61. data/lib/playbook/kit_base.rb +1 -1
  62. data/lib/playbook/left.rb +6 -3
  63. data/lib/playbook/pb_doc_helper.rb +1 -1
  64. data/lib/playbook/position_props_css.rb +17 -0
  65. data/lib/playbook/props/percentage.rb +2 -2
  66. data/lib/playbook/right.rb +6 -3
  67. data/lib/playbook/top.rb +6 -3
  68. data/lib/playbook/version.rb +2 -2
  69. metadata +38 -38
  70. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +0 -278
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
 
3
3
  import FormGroup from '../_form_group'
4
-
4
+ import PhoneNumberInput from '../../pb_phone_number_input/_phone_number_input'
5
5
  import Select from '../../pb_select/_select'
6
6
  import TextInput from '../../pb_text_input/_text_input'
7
7
 
@@ -18,11 +18,16 @@ const FormGroupSelect = (props) => {
18
18
  { value: 'Other' },
19
19
  ]
20
20
 
21
+ const phoneOptions = [
22
+ { value: 'Cell' },
23
+ { value: 'Work' },
24
+ { value: 'Home' },
25
+ ]
26
+
21
27
  return (
22
28
  <div>
23
29
  <FormGroup>
24
30
  <TextInput
25
- label="Artist"
26
31
  placeholder="Enter Artist Name"
27
32
  {...props}
28
33
  />
@@ -32,6 +37,17 @@ const FormGroupSelect = (props) => {
32
37
  {...props}
33
38
  />
34
39
  </FormGroup>
40
+ <br />
41
+ <br />
42
+ <FormGroup>
43
+ <Select
44
+ blankSelection="Phone"
45
+ options={phoneOptions}
46
+ />
47
+ <PhoneNumberInput
48
+ id='default'
49
+ />
50
+ </FormGroup>
35
51
  </div>
36
52
  )
37
53
  }
@@ -5,6 +5,7 @@
5
5
  @import "../pb_icon/icon";
6
6
 
7
7
  $pb_icon_circle_sizes: (
8
+ "xxs": 16px,
8
9
  "xs": 28px,
9
10
  "sm": 38px,
10
11
  "md": 60px,
@@ -13,6 +14,16 @@ $pb_icon_circle_sizes: (
13
14
  "xl": 100px,
14
15
  );
15
16
 
17
+ @mixin svg_size($name, $match, $adjust) {
18
+ @if $name == $match {
19
+ $svg_xy: $adjust;
20
+ & > svg {
21
+ width: #{$svg_xy};
22
+ height: #{$svg_xy};
23
+ }
24
+ }
25
+ }
26
+
16
27
  [class^=pb_icon_circle_kit] {
17
28
  display: flex;
18
29
  justify-content: center;
@@ -51,6 +62,8 @@ $pb_icon_circle_sizes: (
51
62
  flex-shrink: 0;
52
63
  flex-grow: 0;
53
64
  flex-basis: $size;
65
+
66
+ @include svg_size($name, "xxs", $size - 6px);
54
67
  }
55
68
  }
56
69
 
@@ -64,3 +77,4 @@ $pb_icon_circle_sizes: (
64
77
  }
65
78
  }
66
79
  }
80
+
@@ -15,7 +15,7 @@ type IconCircleProps = {
15
15
  icon: string,
16
16
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
17
17
  id?: string,
18
- size?: "base" | "xs" | "sm" | "md" | "lg" | "xl",
18
+ size?: "base" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
19
19
  variant?: | "default"
20
20
  | "royal"
21
21
  | "blue"
@@ -1,3 +1,8 @@
1
+ <%= pb_rails("icon_circle", props: {
2
+ icon: "rocket",
3
+ size: "xxs"
4
+ }) %>
5
+ <br />
1
6
  <%= pb_rails("icon_circle", props: {
2
7
  icon: "rocket",
3
8
  size: "xs"
@@ -4,6 +4,12 @@ import { IconCircle } from '../..'
4
4
  const IconCircleSizes = (props) => {
5
5
  return (
6
6
  <div>
7
+ <IconCircle
8
+ icon="rocket"
9
+ size="xxs"
10
+ {...props}
11
+ />
12
+ <br />
7
13
  <IconCircle
8
14
  icon="rocket"
9
15
  size="xs"
@@ -7,7 +7,7 @@ module Playbook
7
7
  prop :emoji, type: Playbook::Props::String,
8
8
  default: ""
9
9
  prop :size, type: Playbook::Props::Enum,
10
- values: %w[xs sm md base lg xl],
10
+ values: %w[xxs xs sm md base lg xl],
11
11
  default: "md"
12
12
  prop :variant, type: Playbook::Props::Enum,
13
13
  values: %w[default royal blue orange purple teal red yellow green orange],
@@ -74,6 +74,7 @@ describe("IconCircle Kit", () => {
74
74
 
75
75
  test('displays size as expected', () => {
76
76
  [
77
+ "xxs",
77
78
  "xs",
78
79
  "sm",
79
80
  "md",
@@ -33,7 +33,6 @@ module Playbook
33
33
  end
34
34
 
35
35
  def title_size
36
- # rubocop:disable Style/CaseLikeIf
37
36
  if size == "lg"
38
37
  1
39
38
  elsif size == "md"
@@ -41,7 +40,6 @@ module Playbook
41
40
  else
42
41
  3
43
42
  end
44
- # rubocop:enable Style/CaseLikeIf
45
43
  end
46
44
  end
47
45
  end
@@ -41,7 +41,6 @@ module Playbook
41
41
  dark ? "dark" : nil
42
42
  end
43
43
 
44
- # rubocop:disable Style/CaseLikeIf
45
44
  def layout_class
46
45
  if layout == "right"
47
46
  "layout_right"
@@ -51,7 +50,6 @@ module Playbook
51
50
  ""
52
51
  end
53
52
  end
54
- # rubocop:enable Style/CaseLikeIf
55
53
 
56
54
  def size_class
57
55
  size ? "large" : nil
@@ -1,5 +1,5 @@
1
- `selected_ids` (Rails) / `selectedIds` (React) is an optional prop that accepts an array of ids that, if present, will mark the corresponding nodes on the treeData as checked on page load.
1
+ `selected_ids` is an optional prop that accepts an array of ids that, if present, will mark the corresponding nodes on the treeData as checked on page load.
2
2
 
3
3
  Items that include `checked:true` on the treeData itself will also be selected on page load, even without being passed to `selectedIds`.
4
4
 
5
- When an item is marked as checked on page load by any means, the dropdown will expand to show the checked items for easier accessibility.
5
+ When an item is marked as checked on page load by any means, the dropdown will expand to show the checked items for easier accessibility.
@@ -68,7 +68,7 @@ const treeData = [
68
68
  },
69
69
  ];
70
70
 
71
- const MultiLevelSelectSelectedIds = (props) => {
71
+ const MultiLevelSelectSelectedIdsReact = (props) => {
72
72
  return (
73
73
  <div>
74
74
  <MultiLevelSelect
@@ -85,4 +85,4 @@ const MultiLevelSelectSelectedIds = (props) => {
85
85
  );
86
86
  };
87
87
 
88
- export default MultiLevelSelectSelectedIds;
88
+ export default MultiLevelSelectSelectedIdsReact;
@@ -0,0 +1,5 @@
1
+ `selected_ids` is an optional prop that accepts an array of ids and controls the selected state of the tree nodes that match the values passed. When used within react-hook-form, this prop can be used to manage the selected state of any ids passed to it.
2
+
3
+ Items that include `checked:true` on the treeData itself will also be selected on page load, even without being passed to `selectedIds`.
4
+
5
+ When an item is marked as checked on page load by any means, the dropdown will expand to show the checked items for easier accessibility.
@@ -12,4 +12,4 @@ examples:
12
12
  - multi_level_select_single: Single Select
13
13
  - multi_level_select_single_children_only: Single Select w/ Hidden Radios
14
14
  - multi_level_select_return_all_selected: Return All Selected
15
- - multi_level_select_selected_ids: Selected Ids
15
+ - multi_level_select_selected_ids_react: Selected Ids
@@ -2,4 +2,4 @@ export { default as MultiLevelSelectDefault } from './_multi_level_select_defaul
2
2
  export { default as MultiLevelSelectSingle } from './_multi_level_select_single.jsx'
3
3
  export { default as MultiLevelSelectSingleChildrenOnly } from './_multi_level_select_single_children_only.jsx'
4
4
  export { default as MultiLevelSelectReturnAllSelected } from './_multi_level_select_return_all_selected.jsx'
5
- export { default as MultiLevelSelectSelectedIds } from "./_multi_level_select_selected_ids.jsx"
5
+ export { default as MultiLevelSelectSelectedIdsReact } from "./_multi_level_select_selected_ids_react.jsx"
@@ -5,16 +5,7 @@
5
5
 
6
6
  @each $status_name, $status_value in $pb_online_status_statuses {
7
7
  &[class*=_#{$status_name}] {
8
- background: $status_value;
8
+ @include pb_online_status($status_value);
9
9
  }
10
10
  }
11
- &[class*=_online] {
12
- @include pb_online_status_online;
13
- }
14
- &[class*=_away] {
15
- @include pb_online_status_away;
16
- }
17
- &[class*=_offline] {
18
- @include pb_online_status_offline;
19
- }
20
11
  }
@@ -10,7 +10,7 @@ type OnlineStatusProps = {
10
10
  data?: {[key: string]: string | number},
11
11
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
12
12
  id?: string,
13
- status?: "online" | "offline" | "away",
13
+ status?: "away" | "error" | "info" | "neutral" | "offline" |"online" | "primary"| "success" | "warning",
14
14
  } & GlobalProps
15
15
 
16
16
  const OnlineStatus = (props: OnlineStatusProps) => {
@@ -7,6 +7,12 @@ $pb_online_status_statuses: (
7
7
  online: $success,
8
8
  away: $warning,
9
9
  offline: $neutral,
10
+ success: $success,
11
+ warning: $warning,
12
+ error: $error,
13
+ info: $info,
14
+ neutral: $neutral,
15
+ primary: $primary,
10
16
  );
11
17
 
12
18
  @mixin pb_online_status($background: $neutral) {
@@ -23,16 +29,4 @@ $pb_online_status_statuses: (
23
29
  border-style: solid;
24
30
  border-radius: 50%;
25
31
  background: $background;
26
- }
27
-
28
- @mixin pb_online_status_away {
29
- @include pb_online_status($warning);
30
- }
31
-
32
- @mixin pb_online_status_online {
33
- @include pb_online_status($success);
34
- }
35
-
36
- @mixin pb_online_status_offline {
37
- @include pb_online_status($neutral);
38
- }
32
+ }
@@ -1,9 +1,6 @@
1
- <%= pb_rails("online_status", props: { status: "offline" }) %>
2
-
3
- <br>
4
-
5
- <%= pb_rails("online_status", props: { status: "online" }) %>
6
-
7
- <br>
8
-
9
- <%= pb_rails("online_status", props: { status: "away" }) %>
1
+ <%= pb_rails("online_status", props: { status: "offline", margin_y: "xs" }) %>
2
+ <%= pb_rails("online_status", props: { status: "online", margin_y: "xs" }) %>
3
+ <%= pb_rails("online_status", props: { status: "away", margin_y: "xs" }) %>
4
+ <%= pb_rails("online_status", props: { status: "error", margin_y: "xs" }) %>
5
+ <%= pb_rails("online_status", props: { status: "info", margin_y: "xs" }) %>
6
+ <%= pb_rails("online_status", props: { status: "primary", margin_y: "xs" }) %>
@@ -5,24 +5,35 @@ import OnlineStatus from '../_online_status'
5
5
  const OnlineStatusDefault = (props) => (
6
6
  <>
7
7
  <OnlineStatus
8
+ marginY="xs"
8
9
  status="offline"
9
10
  {...props}
10
11
  />
11
-
12
- <br />
13
-
14
12
  <OnlineStatus
13
+ marginY="xs"
15
14
  status="online"
16
15
  {...props}
17
16
  />
18
-
19
- <br />
20
-
21
17
  <OnlineStatus
18
+ marginY="xs"
22
19
  status="away"
23
20
  {...props}
24
21
  />
25
-
22
+ <OnlineStatus
23
+ marginY="xs"
24
+ status="error"
25
+ {...props}
26
+ />
27
+ <OnlineStatus
28
+ marginY="xs"
29
+ status="info"
30
+ {...props}
31
+ />
32
+ <OnlineStatus
33
+ marginY="xs"
34
+ status="primary"
35
+ {...props}
36
+ />
26
37
  </>
27
38
  )
28
39
 
@@ -4,7 +4,7 @@ module Playbook
4
4
  module PbOnlineStatus
5
5
  class OnlineStatus < Playbook::KitBase
6
6
  prop :status, type: Playbook::Props::Enum,
7
- values: %w[online offline away],
7
+ values: %w[online offline away success warning error info neutral primary],
8
8
  default: "offline"
9
9
 
10
10
  def classname
@@ -1 +1,2 @@
1
- <%= pb_rails("pagination", props: { model: @users, view: self}) %>
1
+ <%= pb_rails("pagination", props: { model: @users, view: self}) %>
2
+
@@ -1,5 +1,5 @@
1
1
  <form id="example-form-validation" action="" method="get">
2
- <%= pb_rails("phone_number_input", props: { error: "Missing phone number.", id: "validation", initial_country: "af", value: "", required: true }) %>
2
+ <%= pb_rails("phone_number_input", props: { error: "Missing phone number", id: "validation", initial_country: "af", value: "", required: true }) %>
3
3
  <%= pb_rails("button", props: {html_type: "submit", text: "Save Phone Number"}) %>
4
4
  </form>
5
5
 
@@ -9,4 +9,4 @@
9
9
  if (e.target.querySelectorAll('[error]:not([error=""])').length > 0) e.preventDefault();
10
10
  })
11
11
  })
12
- <% end %>
12
+ <% end %>
@@ -2,16 +2,16 @@
2
2
 
3
3
  $color_checkbox_success: $data_1;
4
4
  $color_checkbox_default: $border_light;
5
+ $color_disabled: darken($border_light, 20%);
5
6
  $transition: .2s ease-in-out;
6
7
 
7
8
  [class^=pb_toggle_kit] {
8
9
  position: relative;
9
10
  $width: 44px;
10
- $height: $width/2;
11
+ $height: $width / 2;
11
12
  $border_success: 3px solid $color_checkbox_success;
12
13
  $border_default: 3px solid $color_checkbox_default;
13
14
 
14
-
15
15
  .pb_toggle_wrapper {
16
16
  .pb_toggle_control {
17
17
  cursor: pointer;
@@ -23,10 +23,11 @@ $transition: .2s ease-in-out;
23
23
  border: $border_default;
24
24
  position: relative;
25
25
  box-sizing: content-box;
26
+
26
27
  &:after {
27
28
  transition: $transition;
28
29
  content: "";
29
- width: $width/2 - 4px;
30
+ width: $width / 2 - 4px;
30
31
  height: $height - 4px;
31
32
  background-color: $color_checkbox_default;
32
33
  border-radius: 50%;
@@ -34,23 +35,55 @@ $transition: .2s ease-in-out;
34
35
  top: 2px;
35
36
  left: 2px;
36
37
  }
38
+
37
39
  &:hover {
38
40
  border: $border_success;
39
- &:after{
41
+
42
+ &:after {
40
43
  background-color: $color_checkbox_success;
41
44
  }
42
45
  }
43
46
  }
47
+
44
48
  input {
45
49
  display: none;
50
+
51
+ &:disabled + .pb_toggle_control {
52
+ cursor: not-allowed;
53
+ opacity: 0.5;
54
+ border: 3px solid $border_light;
55
+ background-color: $border_light;
56
+
57
+ &:after {
58
+ background-color: darken($neutral, 15%);
59
+ }
60
+ }
61
+ }
62
+
63
+ input:checked {
64
+ display: none;
65
+
46
66
  &:checked + .pb_toggle_control {
47
67
  border: $border_success;
48
68
  background-color: $color_checkbox_success;
49
- &:after{
50
- left: $width/2 + 2px;
69
+
70
+ &:after {
71
+ left: $width / 2 + 2px;
51
72
  background-color: $white;
52
73
  }
53
74
  }
75
+
76
+ &:disabled + .pb_toggle_control {
77
+ cursor: not-allowed;
78
+ opacity: 0.5;
79
+ border: 3px solid $text_lt_light;
80
+ background-color: $text_lt_light;
81
+
82
+ &:after {
83
+ background-color: $neutral;
84
+ }
85
+ }
54
86
  }
55
87
  }
56
88
  }
89
+
@@ -17,6 +17,7 @@ type Props = {
17
17
  children?: React.ReactNode | React.ReactNode[],
18
18
  className?: string,
19
19
  data?: { [key: string]: string },
20
+ disabled?: boolean,
20
21
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
21
22
  id?: string,
22
23
  name?: string,
@@ -31,10 +32,13 @@ const Toggle = ({
31
32
  children,
32
33
  className,
33
34
  data = {},
35
+ disabled = false,
34
36
  id,
35
37
  htmlOptions = {},
36
38
  name,
37
- onChange = () => { },
39
+ onChange = (): void => {
40
+ // Function body here
41
+ },
38
42
  size = 'sm',
39
43
  value,
40
44
  ...props
@@ -53,23 +57,24 @@ const Toggle = ({
53
57
 
54
58
  return (
55
59
  <div
56
- {...ariaProps}
57
- {...dataProps}
58
- {...htmlProps}
59
- className={classnames(css, globalProps(props), className)}
60
- id={id}
60
+ {...ariaProps}
61
+ {...dataProps}
62
+ {...htmlProps}
63
+ className={classnames(css, globalProps(props), className)}
64
+ id={id}
61
65
  >
62
66
  <label className="pb_toggle_wrapper">
63
67
  {children && children}
64
68
 
65
69
  {!children &&
66
70
  <input
67
- {...props}
68
- defaultChecked={checked}
69
- name={name}
70
- onChange={onChange}
71
- type="checkbox"
72
- value={value}
71
+ {...props}
72
+ defaultChecked={checked}
73
+ disabled={disabled}
74
+ name={name}
75
+ onChange={onChange}
76
+ type="checkbox"
77
+ value={value}
73
78
  />
74
79
  }
75
80
  <div className="pb_toggle_control" />
@@ -0,0 +1,11 @@
1
+ <%= pb_rails("toggle", props: {
2
+ checked: true,
3
+ disabled: true
4
+ }) %>
5
+
6
+ <br>
7
+
8
+ <%= pb_rails("toggle", props: {
9
+ checked: false,
10
+ disabled: true
11
+ }) %>
@@ -0,0 +1,21 @@
1
+ // @flow
2
+
3
+ import React from 'react'
4
+ import { Toggle } from '../..'
5
+
6
+ const ToggleDisabled= () => {
7
+ return (
8
+ <>
9
+ <Toggle
10
+ checked
11
+ disabled
12
+ />
13
+
14
+ <br />
15
+
16
+ <Toggle disabled />
17
+ </>
18
+ )
19
+ }
20
+
21
+ export default ToggleDisabled
@@ -2,6 +2,7 @@ examples:
2
2
 
3
3
  rails:
4
4
  - toggle_default: Default State
5
+ - toggle_disabled: Disabled
5
6
  - toggle_name: Name and Value
6
7
  - toggle_custom: Custom checkbox input
7
8
  - toggle_custom_radio: Custom radio inputs
@@ -9,6 +10,7 @@ examples:
9
10
 
10
11
  react:
11
12
  - toggle_default: Default State
13
+ - toggle_disabled: Disabled
12
14
  - toggle_name: Name and Value
13
15
  - toggle_custom: Custom checkbox input
14
16
  - toggle_custom_radio: Custom radio inputs
@@ -16,4 +18,4 @@ examples:
16
18
  swift:
17
19
  - toggle_default_swift: Default State
18
20
  - toggle_name_swift: Name and Value
19
- - toggle_props_swift: ""
21
+ - toggle_props_swift: ""
@@ -1,4 +1,5 @@
1
1
  export { default as ToggleDefault } from './_toggle_default'
2
+ export { default as ToggleDisabled } from './_toggle_disabled'
2
3
  export { default as ToggleCustom } from './_toggle_custom'
3
4
  export { default as ToggleName } from './_toggle_name'
4
5
  export { default as ToggleCustomRadio } from './_toggle_custom_radio'
@@ -15,13 +15,14 @@ module Playbook
15
15
  values: %w[sm md],
16
16
  default: "sm"
17
17
  prop :value
18
+ prop :disabled, type: Playbook::Props::Boolean, default: false
18
19
 
19
20
  def classname
20
21
  generate_classname("pb_toggle_kit", size, checked_class)
21
22
  end
22
23
 
23
24
  def input
24
- check_box_tag(name, value, checked, input_options)
25
+ check_box_tag(name, value, checked, input_options.merge(disabled: disabled))
25
26
  end
26
27
 
27
28
  private
@@ -60,6 +60,13 @@ test('should have sm size by default', () => {
60
60
  expect(kit).toHaveClass('pb_toggle_kit_sm_off')
61
61
  })
62
62
 
63
+ test('should pass disabled prop', () => {
64
+ render(<ToggleDefault disabled />)
65
+ const kit = screen.getByTestId(testId)
66
+ const input = kit.querySelector('input')
67
+ expect(input).toHaveAttribute('disabled')
68
+ })
69
+
63
70
  test('should pass size prop', () => {
64
71
  render(<ToggleDefault size='md' />)
65
72
  const kit = screen.getByTestId(testId)
@@ -88,18 +88,31 @@ $space_classes: (
88
88
 
89
89
  $positions: "top", "right", "bottom", "left";
90
90
 
91
+
92
+ @mixin position-property($position, $space_name, $space, $is_inset: false) {
93
+ @if $space_name == "0" {
94
+ #{$position}: 0 !important;
95
+ }
96
+ @else if $space_name == "auto" or $space_name == "initial" or $space_name == "inherit" {
97
+ #{$position}: #{$space} !important;
98
+ }
99
+ @else {
100
+ @if $is_inset {
101
+ #{$position}: #{$space} !important;
102
+ } @else {
103
+ #{$position}: #{-$space} !important;
104
+ }
105
+ }
106
+ }
107
+
91
108
  @each $position in $positions {
92
109
  @each $space_name, $space in $space_classes {
93
- .#{$position}_#{$space_name} {
94
- @if $space_name == "0" {
95
- #{$position}: 0 !important;
96
- }
97
- @else if $space_name == "auto" or $space_name == "initial" or $space_name == "inherit" {
98
- #{$position}: #{$space} !important;
99
- }
100
- @else {
101
- #{$position}: #{-$space} !important;
102
- }
110
+ $space_name_str: "#{ $space_name }";
111
+ .#{$position}_#{$space_name_str} {
112
+ @include position-property($position, $space_name_str, $space)
113
+ }
114
+ .#{$position}_#{$space_name_str}_inset {
115
+ @include position-property($position, $space_name_str, $space, true)
103
116
  }
104
117
  }
105
118
  }