playbook_ui 2.9.3 → 2.9.4

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/playbook/pb_doc_helper.rb +1 -1
  3. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.html.erb +3 -4
  4. data/app/pb_kits/playbook/pb_bar_graph/barGraphSettings.js +4 -3
  5. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +17 -71
  6. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.html.erb +6 -0
  7. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_dark.html.erb +2 -1
  8. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.html.erb +1 -0
  9. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +10 -1
  10. data/app/pb_kits/playbook/pb_label_pill/label_pill.rb +1 -1
  11. data/app/pb_kits/playbook/pb_line_graph/lineGraphSettings.js +1 -0
  12. data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.html.erb +5 -2
  13. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.rb +9 -56
  14. data/app/pb_kits/playbook/pb_online_status/_online_status.html.erb +1 -1
  15. data/app/pb_kits/playbook/pb_online_status/online_status.rb +8 -37
  16. data/app/pb_kits/playbook/pb_person_contact/_person_contact.html.erb +9 -4
  17. data/app/pb_kits/playbook/pb_person_contact/_person_contact.jsx +15 -5
  18. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_default.html.erb +10 -2
  19. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_default.jsx +10 -4
  20. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_single_person.html.erb +21 -0
  21. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_single_person.jsx +32 -0
  22. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_three_people.html.erb +16 -0
  23. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_three_people.jsx +33 -0
  24. data/app/pb_kits/playbook/pb_person_contact/docs/example.yml +4 -0
  25. data/app/pb_kits/playbook/pb_person_contact/docs/index.js +2 -0
  26. data/app/pb_kits/playbook/pb_person_contact/person_contact.rb +7 -44
  27. data/app/pb_kits/playbook/pb_pill/_pill.html.erb +2 -2
  28. data/app/pb_kits/playbook/pb_pill/pill.rb +11 -47
  29. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.html.erb +5 -5
  30. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +1 -1
  31. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +65 -67
  32. data/app/pb_kits/playbook/pb_title/_title.html.erb +1 -1
  33. data/app/pb_kits/playbook/pb_title/title.rb +16 -63
  34. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +65 -18
  35. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_accessibility.jsx +12 -0
  36. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_data.jsx +15 -0
  37. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_default.jsx +39 -6
  38. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +2 -0
  39. data/app/pb_kits/playbook/pb_toggle/docs/index.js +3 -1
  40. data/app/pb_kits/playbook/props.rb +8 -2
  41. data/app/pb_kits/playbook/props/array.rb +11 -0
  42. data/app/pb_kits/playbook/props/hash_array.rb +13 -0
  43. data/app/pb_kits/playbook/props/number_array.rb +1 -1
  44. data/app/pb_kits/playbook/props/percentage.rb +19 -0
  45. data/app/pb_kits/playbook/types.js +4 -0
  46. data/app/pb_kits/playbook/utilities/props.js +48 -0
  47. data/app/views/playbook/pages/kit_show.html.slim +1 -1
  48. data/app/views/playbook/pages/kits.html.slim +1 -1
  49. data/app/views/playbook/pages/tokens.html.slim +2 -2
  50. data/app/views/playbook/pages/tokens/_pb_doc_spacing.html.slim +1 -1
  51. data/app/views/playbook/pages/utilities.html.slim +2 -2
  52. data/app/views/playbook/pages/utilities/_pb_doc_color.html.slim +1 -1
  53. data/lib/generators/kit/kit_generator.rb +3 -2
  54. data/lib/generators/kit/templates/kit_html.erb.tt +1 -1
  55. data/lib/generators/kit/templates/kit_ruby.erb.tt +3 -26
  56. data/lib/generators/kit/templates/kit_ruby_spec.erb.tt +12 -0
  57. data/lib/playbook.rb +3 -0
  58. data/lib/playbook/version.rb +1 -1
  59. metadata +14 -2
@@ -1,6 +1,14 @@
1
1
  <%= pb_rails("person_contact", props: {
2
- first_name: "Pauline",
3
- last_name: "Smith",
2
+ people: [
3
+ {
4
+ first_name: "Pauline",
5
+ last_name: "Smith",
6
+ },
7
+ {
8
+ first_name: "Harvey",
9
+ last_name: "Walters"
10
+ }
11
+ ],
4
12
  contacts: [
5
13
  {
6
14
  contact_type: "email",
@@ -1,14 +1,20 @@
1
1
  import React from "react"
2
2
  import {PersonContact} from "../../"
3
3
 
4
-
5
-
6
4
  function PersonContactDefault() {
7
5
  return (
8
6
  <div>
9
7
  <PersonContact
10
- firstName="Pauline"
11
- lastName="Smith"
8
+ people={[
9
+ {
10
+ firstName: "Pauline",
11
+ lastName: "Smith",
12
+ },
13
+ {
14
+ firstName: "Harvey",
15
+ lastName: "Walters"
16
+ }
17
+ ]}
12
18
  contacts={[
13
19
  {
14
20
  contactType: "email",
@@ -0,0 +1,21 @@
1
+ <%= pb_rails("person_contact", props: {
2
+ people: [
3
+ {
4
+ first_name: "Harvey",
5
+ last_name: "Walters"
6
+ }
7
+ ],
8
+ contacts: [
9
+ {
10
+ contact_type: "email",
11
+ contact_value: "email@example.com"
12
+ },
13
+ {
14
+ contact_value: 5555555555,
15
+ },
16
+ {
17
+ contact_type: "work",
18
+ contact_value: "3245627482",
19
+ }
20
+ ]
21
+ }) %>
@@ -0,0 +1,32 @@
1
+ import React from "react"
2
+ import {PersonContact} from "../../"
3
+
4
+ function PersonContactSinglePerson() {
5
+ return (
6
+ <div>
7
+ <PersonContact
8
+ people={[
9
+ {
10
+ firstName: "Harvey",
11
+ lastName: "Walters"
12
+ }
13
+ ]}
14
+ contacts={[
15
+ {
16
+ contactType: "email",
17
+ contactValue: "email@example.com"
18
+ },
19
+ {
20
+ contactValue: "5555555555",
21
+ },
22
+ {
23
+ contactType: "work",
24
+ contactValue: "3245627482",
25
+ }
26
+ ]}
27
+ />
28
+ </div>
29
+ )
30
+ }
31
+
32
+ export default PersonContactSinglePerson;
@@ -0,0 +1,16 @@
1
+ <%= pb_rails("person_contact", props: {
2
+ people: [
3
+ {
4
+ first_name: "Pauline",
5
+ last_name: "Smith",
6
+ },
7
+ {
8
+ first_name: "Harvey",
9
+ last_name: "Walters"
10
+ },
11
+ {
12
+ first_name: "Bart",
13
+ last_name: "Simpson"
14
+ }
15
+ ]
16
+ }) %>
@@ -0,0 +1,33 @@
1
+ import React from "react"
2
+ import {PersonContact} from "../../"
3
+
4
+ function PersonContactThreePeople() {
5
+ return (
6
+ <div>
7
+ <PersonContact
8
+ people={[
9
+ {
10
+ firstName: "Pauline",
11
+ lastName: "Smith",
12
+ },
13
+ {
14
+ firstName: "Harvey",
15
+ lastName: "Walters"
16
+ },
17
+ {
18
+ firstName: "Bart",
19
+ lastName: "Simpson"
20
+ }
21
+ ]}
22
+ contacts={[
23
+ {
24
+ contactType: "work",
25
+ contactValue: "3245627482",
26
+ }
27
+ ]}
28
+ />
29
+ </div>
30
+ )
31
+ }
32
+
33
+ export default PersonContactThreePeople;
@@ -2,7 +2,11 @@ examples:
2
2
 
3
3
  rails:
4
4
  - person_contact_default: Default
5
+ - person_contact_single_person: One Person
6
+ - person_contact_three_people: Three People
5
7
 
6
8
 
7
9
  react:
8
10
  - person_contact_default: Default
11
+ - person_contact_single_person: One Person
12
+ - person_contact_three_people: Three People
@@ -1 +1,3 @@
1
1
  export {default as PersonContactDefault} from './_person_contact_default.jsx';
2
+ export {default as PersonContactSinglePerson} from './_person_contact_single_person.jsx';
3
+ export {default as PersonContactThreePeople} from './_person_contact_three_people.jsx';
@@ -2,54 +2,17 @@
2
2
 
3
3
  module Playbook
4
4
  module PbPersonContact
5
- class PersonContact < Playbook::PbKit::Base
6
- PROPS = %i[
7
- configured_classname
8
- configured_data
9
- configured_id
10
- configured_first_name
11
- configured_last_name
12
- configured_contacts
13
- ].freeze
5
+ class PersonContact
6
+ include Playbook::Props
14
7
 
15
- def initialize(
16
- classname: default_configuration,
17
- data: default_configuration,
18
- id: default_configuration,
19
- first_name: default_configuration,
20
- last_name: default_configuration,
21
- contacts: default_configuration
22
- )
23
- self.configured_classname = classname
24
- self.configured_data = data
25
- self.configured_id = id
26
- self.configured_first_name = first_name
27
- self.configured_last_name = last_name
28
- self.configured_contacts = contacts
29
- end
30
-
31
-
32
- def name
33
- person = Playbook::PbPerson::Person.new(first_name: configured_first_name, last_name: configured_last_name)
34
- ApplicationController.renderer.render(partial: person, as: :object)
35
- end
36
-
37
- def contacts
38
- configured_contacts if is_set? configured_contacts
39
- end
40
-
41
- def to_partial_path
42
- "pb_person_contact/person_contact"
43
- end
8
+ partial "pb_person_contact/person_contact"
44
9
 
45
- private
10
+ prop :contacts, type: Playbook::Props::HashArray, default: []
11
+ prop :people, type: Playbook::Props::HashArray, default: []
46
12
 
47
- DEFAULT = Object.new
48
- private_constant :DEFAULT
49
- def default_configuration
50
- DEFAULT
13
+ def classname
14
+ generate_classname("pb_person_contact_kit")
51
15
  end
52
- attr_accessor(*PROPS)
53
16
  end
54
17
  end
55
18
  end
@@ -1,6 +1,6 @@
1
1
  <%= content_tag(:div,
2
2
  id: object.id,
3
3
  data: object.data,
4
- class: object.classname(object.kit_class)) do %>
5
- <%= object.display_text %>
4
+ class: object.classname) do %>
5
+ <%= pb_rails("title", props: { text: object.display_text, size: 4, classname: "pb_pill_text" }) %>
6
6
  <% end %>
@@ -2,59 +2,23 @@
2
2
 
3
3
  module Playbook
4
4
  module PbPill
5
- class Pill < Playbook::PbKit::Base
6
- PROPS = %i[configured_classname
7
- configured_data
8
- configured_id
9
- configured_text
10
- configured_variant].freeze
5
+ class Pill
6
+ include Playbook::Props
11
7
 
12
- def initialize(classname: default_configuration,
13
- data: default_configuration,
14
- id: default_configuration,
15
- text: default_configuration,
16
- variant: default_configuration)
17
- self.configured_classname = classname
18
- self.configured_data = data
19
- self.configured_id = id
20
- self.configured_text = text
21
- self.configured_variant = variant
22
- end
23
-
24
- def display_text
25
- pb_text = Playbook::PbTitle::Title.new(size: 4, text: text, classname: "pb_pill_text")
26
- ApplicationController.renderer.render(partial: pb_text, as: :object)
27
- end
8
+ partial "pb_pill/pill"
28
9
 
29
- def kit_class
30
- kit_options = [
31
- "pb_pill_kit",
32
- variant,
33
- ]
34
- kit_options.join("_")
35
- end
10
+ prop :text
11
+ prop :variant, type: Playbook::Props::Enum,
12
+ values: %w[success warning error info neutral],
13
+ default: "neutral"
36
14
 
37
- def to_partial_path
38
- "pb_pill/pill"
15
+ def classname
16
+ generate_classname("pb_pill_kit", variant)
39
17
  end
40
18
 
41
- private
42
-
43
- def variant
44
- variant_options = %w[success warning error info neutral]
45
- one_of_value(configured_variant, variant_options, "neutral")
46
- end
47
-
48
- def text
49
- default_value(configured_text.downcase, "")
50
- end
51
-
52
- DEFAULT = Object.new
53
- private_constant :DEFAULT
54
- def default_configuration
55
- DEFAULT
19
+ def display_text
20
+ text.downcase
56
21
  end
57
- attr_accessor(*PROPS)
58
22
  end
59
23
  end
60
24
  end
@@ -1,11 +1,11 @@
1
- <%= content_tag(:div, class: "pb__progress_simple_wrapper_#{object.align}") do %>
1
+ <%= content_tag(:div, class: object.wrapper_classname) do %>
2
2
  <%= content_tag(:div,
3
3
  id: object.id,
4
- data: object.data({value: object.number_value}),
5
- class: object.classname(object.kit_class),
6
- style: "width:#{object.width};") do %>
4
+ data: object.data_values,
5
+ class: object.classname,
6
+ style: object.style) do %>
7
7
  <%= content_tag(:div, "",
8
8
  class: "progress_simple_value",
9
- style: "width:#{object.percent_value};") %>
9
+ style: object.value_style) %>
10
10
  <% end %>
11
11
  <% end %>
@@ -3,7 +3,7 @@
3
3
 
4
4
  $pb_progress_simple_height: 4px;
5
5
 
6
- [class^=pb__progress_simple_wrapper] {
6
+ [class^=pb_progress_simple_wrapper] {
7
7
  display: flex;
8
8
  justify-content: flex-start;
9
9
  align-items: center;
@@ -2,99 +2,97 @@
2
2
 
3
3
  module Playbook
4
4
  module PbProgressSimple
5
- class ProgressSimple < Playbook::PbKit::Base
6
- PROPS = %i[configured_align
7
- configured_classname
8
- configured_data
9
- configured_id
10
- configured_max
11
- configured_muted
12
- configured_percent
13
- configured_value
14
- configured_width].freeze
15
-
16
- def initialize(align: default_configuration,
17
- classname: default_configuration,
18
- data: default_configuration,
19
- id: default_configuration,
20
- max: default_configuration,
21
- muted: default_configuration,
22
- percent: default_configuration,
23
- value: default_configuration,
24
- width: default_configuration)
25
- self.configured_align = align
26
- self.configured_classname = classname
27
- self.configured_data = data
28
- self.configured_id = id
29
- self.configured_max = max
30
- self.configured_muted = muted
31
- self.configured_percent = percent
32
- self.configured_value = value
33
- self.configured_width = width
34
- end
5
+ class ProgressSimple
6
+ include Playbook::Props
35
7
 
36
- def width
37
- default_value(configured_width, "100%")
38
- end
8
+ class ProgressError < StandardError; end
9
+
10
+ partial "pb_progress_simple/progress_simple"
11
+
12
+ prop :align, type: Playbook::Props::Enum,
13
+ values: %w[left center right],
14
+ default: "left"
15
+ prop :value, type: Playbook::Props::Number
16
+ prop :max, type: Playbook::Props::Number
17
+ prop :muted, type: Playbook::Props::Boolean,
18
+ default: false
19
+ prop :percent, type: Playbook::Props::Percentage
20
+ # :width prop should not probably be a string type
21
+ # Should we be allowing the user to pass this value at all?
22
+ # could this possibly be [sm, md, lg]?
23
+ prop :width, default: "100%"
39
24
 
40
25
  def number_value
41
- if is_set? configured_percent
26
+ validate_required_progress_props
27
+
28
+ if percent
29
+ validate_percent
30
+
42
31
  percent
43
32
  else
44
- calc_value_from_max
33
+ validate_value_max
34
+
35
+ (value * 100) / max
45
36
  end
46
37
  end
47
38
 
48
- def percent_value
49
- format_percent(number_value)
39
+ def data_values
40
+ prop(:data).merge(value: number_value)
50
41
  end
51
42
 
52
- def align
53
- align_options = %w[left center right]
54
- one_of_value(configured_align, align_options, "left")
43
+ def style
44
+ "width:#{width};"
55
45
  end
56
46
 
57
- def kit_class
58
- kit_options = [
59
- "pb_progress_simple_kit",
60
- muted,
61
- align,
62
- ]
63
- kit_options.compact.join("_")
47
+ def value_style
48
+ "width:#{number_value}%;"
64
49
  end
65
50
 
66
- def to_partial_path
67
- "pb_progress_simple/progress_simple"
51
+ def wrapper_classname
52
+ "pb_progress_simple_wrapper_#{align}"
68
53
  end
69
54
 
70
- private
71
-
72
- def percent
73
- default_value(configured_percent, 0)
55
+ def classname
56
+ generate_classname("pb_progress_simple_kit", muted_class, align)
74
57
  end
75
58
 
76
- def format_percent(num)
77
- "#{num}%"
59
+ private
60
+
61
+ def muted_class
62
+ muted ? "muted" : nil
78
63
  end
79
64
 
80
- def calc_value_from_max
81
- if is_set?(configured_value) && is_set?(configured_max)
82
- (configured_value.to_i * 100) / configured_max.to_i
83
- else
84
- 0
65
+ def validate_required_progress_props
66
+ unless percent || value || max
67
+ raise(
68
+ ProgressError,
69
+ "Pass `percent` or pass both `value` and `max` to this kit."
70
+ )
85
71
  end
86
72
  end
87
73
 
88
- def muted
89
- true_value(configured_muted, "muted", nil)
74
+ def validate_percent
75
+ if max || value
76
+ raise(
77
+ ConflictingPropsError,
78
+ "Do not use `value` or `max` props when passing `percent`"
79
+ )
80
+ end
90
81
  end
91
82
 
92
- DEFAULT = Object.new
93
- private_constant :DEFAULT
94
- def default_configuration
95
- DEFAULT
83
+ def validate_value_max
84
+ if !value
85
+ raise(
86
+ MissingPropError,
87
+ "Must pass `value` when passing `max`"
88
+ )
89
+ elsif !max
90
+ raise(
91
+ MissingPropError,
92
+ "Must pass `max` when passing `value`"
93
+ )
94
+ end
96
95
  end
97
- attr_accessor(*PROPS)
98
96
  end
99
97
  end
100
98
  end