playbook_ui 2.9.6 → 2.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar/_avatar.html.erb +1 -1
  3. data/app/pb_kits/playbook/pb_avatar/avatar.rb +1 -1
  4. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.html.erb +5 -5
  5. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_status.html.erb +4 -4
  6. data/app/pb_kits/playbook/pb_button/_button.html.erb +3 -21
  7. data/app/pb_kits/playbook/pb_button/button.rb +47 -124
  8. data/app/pb_kits/playbook/pb_caption/caption.rb +1 -1
  9. data/app/pb_kits/playbook/pb_contact/_contact.html.erb +1 -1
  10. data/app/pb_kits/playbook/pb_contact/_contact.jsx +18 -8
  11. data/app/pb_kits/playbook/pb_contact/contact.rb +11 -2
  12. data/app/pb_kits/playbook/pb_contact/docs/_contact_default.html.erb +4 -1
  13. data/app/pb_kits/playbook/pb_contact/docs/_contact_default.jsx +3 -0
  14. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.html.erb +12 -4
  15. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +2 -4
  16. data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb +13 -70
  17. data/app/pb_kits/playbook/pb_dashboard_value/docs/_dashboard_value_align.html.erb +6 -6
  18. data/app/pb_kits/playbook/pb_dashboard_value/docs/_dashboard_value_align.jsx +6 -6
  19. data/app/pb_kits/playbook/pb_dashboard_value/docs/_dashboard_value_default.html.erb +6 -6
  20. data/app/pb_kits/playbook/pb_dashboard_value/docs/_dashboard_value_default.jsx +6 -6
  21. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.html.erb +3 -3
  22. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb +12 -33
  23. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.html.erb +4 -2
  24. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_modified.html.erb +0 -1
  25. data/app/pb_kits/playbook/pb_layout/_body.html.erb +2 -2
  26. data/app/pb_kits/playbook/pb_layout/_layout.html.erb +2 -2
  27. data/app/pb_kits/playbook/pb_layout/_sidebar.html.erb +2 -2
  28. data/app/pb_kits/playbook/pb_layout/body.rb +5 -29
  29. data/app/pb_kits/playbook/pb_layout/layout.rb +31 -76
  30. data/app/pb_kits/playbook/pb_layout/sidebar.rb +5 -29
  31. data/app/pb_kits/playbook/pb_list/_item.html.erb +1 -1
  32. data/app/pb_kits/playbook/pb_list/_list.html.erb +3 -4
  33. data/app/pb_kits/playbook/pb_list/item.rb +5 -29
  34. data/app/pb_kits/playbook/pb_list/list.rb +41 -90
  35. data/app/pb_kits/playbook/pb_message/_message.html.erb +18 -5
  36. data/app/pb_kits/playbook/pb_message/docs/_message_default.html.erb +10 -20
  37. data/app/pb_kits/playbook/pb_message/message.rb +15 -72
  38. data/app/pb_kits/playbook/pb_person_contact/_person_contact.html.erb +1 -0
  39. data/app/pb_kits/playbook/pb_person_contact/_person_contact.jsx +2 -1
  40. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_default.html.erb +4 -1
  41. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_default.jsx +4 -1
  42. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_single_person.html.erb +4 -1
  43. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_single_person.jsx +4 -1
  44. data/app/pb_kits/playbook/pb_section_separator/_section_separator.html.erb +2 -2
  45. data/app/pb_kits/playbook/pb_section_separator/section_separator.rb +6 -35
  46. data/app/pb_kits/playbook/pb_star_rating/_star_rating.html.erb +11 -11
  47. data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +5 -5
  48. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +9 -51
  49. data/app/pb_kits/playbook/pb_stat_change/_stat_change.html.erb +5 -2
  50. data/app/pb_kits/playbook/pb_stat_change/_stat_change.jsx +1 -1
  51. data/app/pb_kits/playbook/pb_stat_change/docs/_stat_change_default.html.erb +3 -3
  52. data/app/pb_kits/playbook/pb_stat_change/docs/_stat_change_default.jsx +3 -3
  53. data/app/pb_kits/playbook/pb_stat_change/stat_change.rb +10 -60
  54. data/app/pb_kits/playbook/pb_timestamp/_timestamp.html.erb +2 -2
  55. data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +6 -39
  56. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +1 -1
  57. data/app/pb_kits/playbook/pb_user/_user.html.erb +13 -4
  58. data/app/pb_kits/playbook/pb_user/docs/_user_default.html.erb +3 -6
  59. data/app/pb_kits/playbook/pb_user/docs/_user_size.html.erb +3 -6
  60. data/app/pb_kits/playbook/pb_user/docs/_user_vertical_size.html.erb +3 -6
  61. data/app/pb_kits/playbook/pb_user/user.rb +23 -95
  62. data/app/pb_kits/playbook/pb_user_badge/_user_badge.html.erb +1 -1
  63. data/app/pb_kits/playbook/pb_user_badge/user_badge.rb +13 -49
  64. data/app/pb_kits/playbook/pb_vertical_nav/_item.html.erb +4 -2
  65. data/app/pb_kits/playbook/pb_vertical_nav/_vertical_nav.html.erb +9 -5
  66. data/app/pb_kits/playbook/pb_vertical_nav/item.rb +10 -49
  67. data/app/pb_kits/playbook/pb_vertical_nav/vertical_nav.rb +7 -58
  68. data/app/pb_kits/playbook/props.rb +1 -0
  69. data/app/pb_kits/playbook/props/date.rb +11 -0
  70. data/lib/playbook/version.rb +1 -1
  71. metadata +3 -2
@@ -1,18 +1,18 @@
1
1
  <%= pb_rails("stat_change", props: {
2
2
  change: "increase",
3
- value: "28.4%"
3
+ value: 28.4
4
4
  }) %>
5
5
 
6
6
  <br>
7
7
 
8
8
  <%= pb_rails("stat_change", props: {
9
9
  change: "decrease",
10
- value: "6.1%"
10
+ value: 6.1
11
11
  }) %>
12
12
 
13
13
  <br>
14
14
 
15
15
  <%= pb_rails("stat_change", props: {
16
16
  change: "neutral",
17
- value: "98%"
17
+ value: 98
18
18
  }) %>
@@ -4,15 +4,15 @@ import {StatChange} from "../../"
4
4
  function StatChangeDefault() {
5
5
  return (
6
6
  <div>
7
- <StatChange change="increase" value="28.4%" />
7
+ <StatChange change="increase" value="28.4" />
8
8
 
9
9
  <br/>
10
10
 
11
- <StatChange change="decrease" value="6.1%" />
11
+ <StatChange change="decrease" value={6.1} />
12
12
 
13
13
  <br/>
14
14
 
15
- <StatChange change="neutral" value="98%" />
15
+ <StatChange change="neutral" value={98} />
16
16
  </div>
17
17
  )
18
18
  }
@@ -2,29 +2,15 @@
2
2
 
3
3
  module Playbook
4
4
  module PbStatChange
5
- class StatChange < Playbook::PbKit::Base
6
- PROPS = %i[configured_change
7
- configured_classname
8
- configured_data
9
- configured_id
10
- configured_value].freeze
5
+ class StatChange
6
+ include Playbook::Props
11
7
 
12
- def initialize(change: default_configuration,
13
- classname: default_configuration,
14
- data: default_configuration,
15
- id: default_configuration,
16
- value: default_configuration)
17
- self.configured_change = change
18
- self.configured_classname = classname
19
- self.configured_data = data
20
- self.configured_id = id
21
- self.configured_value = value
22
- end
8
+ partial "pb_stat_change/stat_change"
23
9
 
24
- def change
25
- change_options = %w[neutral increase decrease]
26
- one_of_value(configured_change, change_options, "neutral")
27
- end
10
+ prop :change, type: Playbook::Props::Enum,
11
+ values: %w[neutral increase decrease],
12
+ default: "neutral"
13
+ prop :value, type: Playbook::Props::Percentage
28
14
 
29
15
  def status
30
16
  case change
@@ -43,50 +29,14 @@ module Playbook
43
29
  "arrow-up"
44
30
  when "decrease"
45
31
  "arrow-down"
46
- end
47
- end
48
-
49
- def display_icon
50
- if !icon.nil?
51
- pb_icon = Playbook::PbIcon::Icon.new(icon: icon, fixed_width: true)
52
- ApplicationController.renderer.render(partial: pb_icon, as: :object)
53
32
  else
54
- ""
33
+ false
55
34
  end
56
35
  end
57
36
 
58
- def value
59
- default_value(configured_value, "")
60
- end
61
-
62
- def display_value
63
- pb_icon_element = Playbook::PbBody::Body.new(status: status) do
64
- display_icon +
65
- value
66
- end
67
- ApplicationController.renderer.render(partial: pb_icon_element, as: :object)
68
- end
69
-
70
- def kit_class
71
- stat_options = [
72
- "pb_stat_change_kit",
73
- status,
74
- ]
75
- stat_options.join("_")
76
- end
77
-
78
- def to_partial_path
79
- "pb_stat_change/stat_change"
80
- end
81
-
82
- private
83
-
84
- DEFAULT = Object.new
85
- private_constant :DEFAULT
86
- def default_configuration
87
- DEFAULT
37
+ def classname
38
+ generate_classname("pb_stat_change_kit", status)
88
39
  end
89
- attr_accessor(*PROPS)
90
40
  end
91
41
  end
92
42
  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.yield(context: self) %>
4
+ class: object.classname) do %>
5
+ <%= !object.children.nil? ? capture(&object.children) : object.text %>
6
6
  <% end %>
@@ -2,49 +2,16 @@
2
2
 
3
3
  module Playbook
4
4
  module PbTimestamp
5
- class Timestamp < Playbook::PbKit::Base
6
- PROPS = %i[configured_classname
7
- configured_data
8
- configured_id
9
- configured_text
10
- block].freeze
5
+ class Timestamp
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
- &block)
17
- self.configured_classname = classname
18
- self.configured_data = data
19
- self.configured_id = id
20
- self.configured_text = text
21
- self.block = block_given? ? block : nil
22
- end
23
-
24
- def text
25
- default_value(configured_text, "")
26
- end
27
-
28
- def yield(context:)
29
- !block.nil? ? context.capture(&block) : text
30
- end
31
-
32
- def kit_class
33
- "pb_timestamp_kit"
34
- end
35
-
36
- def to_partial_path
37
- "pb_timestamp/timestamp"
38
- end
8
+ partial "pb_timestamp/timestamp"
39
9
 
40
- private
10
+ prop :text
41
11
 
42
- DEFAULT = Object.new
43
- private_constant :DEFAULT
44
- def default_configuration
45
- DEFAULT
12
+ def classname
13
+ generate_classname("pb_timestamp_kit")
46
14
  end
47
- attr_accessor(*PROPS)
48
15
  end
49
16
  end
50
17
  end
@@ -31,7 +31,7 @@ const Toggle = ({
31
31
  onCheck = noop,
32
32
  onUncheck = noop,
33
33
  size = 'md',
34
- ...props,
34
+ ...props
35
35
  }: Props) =>{
36
36
  const ariaProps = buildAriaProps(aria)
37
37
  const dataProps = buildDataProps(data)
@@ -1,11 +1,20 @@
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.avatar %>
4
+ class: object.classname) do %>
5
+ <% if object.avatar_url.present? || object.avatar %>
6
+ <%= pb_rails("avatar", props: {
7
+ name: object.name,
8
+ size: object.avatar_size,
9
+ image_url: object.avatar_url
10
+ }) %>
11
+ <% end %>
6
12
  <%= content_tag(:div,
7
13
  class: "content_wrapper") do %>
8
- <%= object.name %>
9
- <%= object.title %>
14
+ <%= pb_rails("title", props: { text: object.name, size: object.title_size }) %>
15
+ <%= pb_rails("body", props: {
16
+ text: object.title,
17
+ color: "light"
18
+ }) %>
10
19
  <% end %>
11
20
  <% end %>
@@ -6,8 +6,7 @@
6
6
  orientation: "vertical",
7
7
  align: "center",
8
8
  size: "lg",
9
- avatar: {
10
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
9
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
11
10
  }) %>
12
11
  </div>
13
12
  <div>
@@ -16,8 +15,7 @@
16
15
  title: "Remodeling Consultant",
17
16
  orientation: "horizontal",
18
17
  align: "left",
19
- avatar: {
20
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
18
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
21
19
  }) %>
22
20
  </div>
23
21
  <div>
@@ -25,8 +23,7 @@
25
23
  name: "Anna Black",
26
24
  orientation: "horizontal",
27
25
  align: "left",
28
- avatar: {
29
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
26
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
30
27
  }) %>
31
28
 
32
29
  <br>
@@ -6,8 +6,7 @@
6
6
  orientation: "horizontal",
7
7
  align: "left",
8
8
  size: "sm",
9
- avatar: {
10
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
9
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
11
10
  }) %>
12
11
  </div>
13
12
  <div>
@@ -17,8 +16,7 @@
17
16
  orientation: "horizontal",
18
17
  align: "left",
19
18
  size: "md",
20
- avatar: {
21
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
19
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
22
20
  }) %>
23
21
  </div>
24
22
  <div>
@@ -28,8 +26,7 @@
28
26
  orientation: "horizontal",
29
27
  align: "left",
30
28
  size: "lg",
31
- avatar: {
32
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
29
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
33
30
  }) %>
34
31
  </div>
35
32
  </div>
@@ -4,8 +4,7 @@
4
4
  orientation: "vertical",
5
5
  align: "center",
6
6
  size: "sm",
7
- avatar: {
8
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
7
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
9
8
  }) %>
10
9
 
11
10
  <br><br>
@@ -16,8 +15,7 @@
16
15
  orientation: "vertical",
17
16
  align: "center",
18
17
  size: "md",
19
- avatar: {
20
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
18
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
21
19
  }) %>
22
20
 
23
21
  <br><br>
@@ -28,6 +26,5 @@
28
26
  orientation: "vertical",
29
27
  align: "center",
30
28
  size: "lg",
31
- avatar: {
32
- image: { url: "https://randomuser.me/api/portraits/women/44.jpg"} }
29
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg"
33
30
  }) %>
@@ -2,40 +2,28 @@
2
2
 
3
3
  module Playbook
4
4
  module PbUser
5
- class User < Playbook::PbKit::Base
6
- PROPS = %i[configured_align
7
- configured_avatar
8
- configured_classname
9
- configured_data
10
- configured_id
11
- configured_name
12
- configured_orientation
13
- configured_size
14
- configured_title].freeze
15
-
16
- def initialize(align: default_configuration,
17
- avatar: default_configuration,
18
- classname: default_configuration,
19
- data: default_configuration,
20
- id: default_configuration,
21
- name: default_configuration,
22
- orientation: default_configuration,
23
- size: default_configuration,
24
- title: default_configuration)
25
- self.configured_align = align
26
- self.configured_avatar = avatar
27
- self.configured_classname = classname
28
- self.configured_data = data
29
- self.configured_id = id
30
- self.configured_name = name
31
- self.configured_orientation = orientation
32
- self.configured_size = size
33
- self.configured_title = title
34
- end
35
-
36
- def align
37
- align_options = %w[left center right]
38
- one_of_value(configured_align, align_options, "left")
5
+ class User
6
+ include Playbook::Props
7
+
8
+ partial "pb_user/user"
9
+
10
+ prop :align, type: Playbook::Props::Enum,
11
+ values: %w[left center right],
12
+ default: "left"
13
+ prop :avatar, type: Playbook::Props::Boolean,
14
+ default: false
15
+ prop :avatar_url
16
+ prop :name
17
+ prop :orientation, type: Playbook::Props::Enum,
18
+ values: %w[vertical horizontal],
19
+ default: "horizontal"
20
+ prop :size, type: Playbook::Props::Enum,
21
+ values: %w[lg md sm],
22
+ default: "sm"
23
+ prop :title
24
+
25
+ def classname
26
+ generate_classname("pb_user_kit", align, orientation, size)
39
27
  end
40
28
 
41
29
  def avatar_size
@@ -49,69 +37,9 @@ module Playbook
49
37
  end
50
38
  end
51
39
 
52
- def avatar
53
- if is_set? configured_avatar
54
- avatar_obj = configured_avatar == true ? {} : configured_avatar
55
- avatar_obj[:size] = avatar_size
56
- avatar_obj[:name] = configured_name if is_set? configured_name
57
- pb_avatar = Playbook::PbAvatar::Avatar.new(avatar_obj)
58
- ApplicationController.renderer.render(partial: pb_avatar, as: :object)
59
- end
60
- end
61
-
62
- def name_size
40
+ def title_size
63
41
  size == "lg" ? 3 : 4
64
42
  end
65
-
66
- def name
67
- if is_set? configured_name
68
- title_props = { text: configured_name, size: name_size }
69
- pb_name = Playbook::PbTitle::Title.new(title_props)
70
- ApplicationController.renderer.render(partial: pb_name, as: :object)
71
- end
72
- end
73
-
74
- def orientation
75
- orientation_options = %w[vertical horizontal]
76
- one_of_value(configured_orientation, orientation_options, "horizontal")
77
- end
78
-
79
- def size
80
- size_options = %w[lg md sm]
81
- one_of_value(configured_size, size_options, "sm")
82
- end
83
-
84
- def title
85
- if is_set? configured_title
86
- pb_icon_element = Playbook::PbBody::Body.new(color: "light") do
87
- configured_title
88
- end
89
- ApplicationController.renderer.render(partial: pb_icon_element, as: :object)
90
- end
91
- end
92
-
93
- def kit_class
94
- kit_options = [
95
- "pb_user_kit",
96
- align,
97
- orientation,
98
- size,
99
- ]
100
- kit_options.join("_")
101
- end
102
-
103
- def to_partial_path
104
- "pb_user/user"
105
- end
106
-
107
- private
108
-
109
- DEFAULT = Object.new
110
- private_constant :DEFAULT
111
- def default_configuration
112
- DEFAULT
113
- end
114
- attr_accessor(*PROPS)
115
43
  end
116
44
  end
117
45
  end