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
@@ -2,92 +2,47 @@
2
2
 
3
3
  module Playbook
4
4
  module PbLayout
5
- class Layout < Playbook::PbKit::Base
6
- PROPS = %i[configured_classname
7
- configured_collapse
8
- configured_dark
9
- configured_data
10
- configured_full
11
- configured_id
12
- configured_position
13
- configured_transparent
14
- configured_size
15
- block].freeze
16
-
17
- def initialize(classname: default_configuration,
18
- collapse: default_configuration,
19
- dark: default_configuration,
20
- data: default_configuration,
21
- full: default_configuration,
22
- id: default_configuration,
23
- position: default_configuration,
24
- transparent: default_configuration,
25
- size: default_configuration,
26
- &block)
27
- self.configured_classname = classname
28
- self.configured_collapse = collapse
29
- self.configured_dark = dark
30
- self.configured_data = data
31
- self.configured_full = full
32
- self.configured_id = id
33
- self.configured_position = position
34
- self.configured_transparent = transparent
35
- self.configured_size = size
36
- self.block = block_given? ? block : nil
37
- end
38
-
39
- def position
40
- if configured_position == default_configuration
41
- "_left"
42
- else
43
- "_#{configured_position}"
44
- end
45
- end
46
-
47
- def transparent
48
- true_value(configured_transparent, "_transparent", "")
49
- end
50
-
51
- def size
52
- if configured_size == default_configuration
53
- "md"
54
- else
55
- configured_size
56
- end
5
+ class Layout
6
+ include Playbook::Props
7
+
8
+ partial "pb_layout/layout"
9
+
10
+ prop :collapse, type: Playbook::Props::Enum,
11
+ values: %w[xs sm md lg xl],
12
+ default: "xs"
13
+ prop :dark, type: Playbook::Props::Boolean, default: false
14
+ prop :full, type: Playbook::Props::Boolean, default: false
15
+ prop :position, type: Playbook::Props::Enum,
16
+ values: %w[left right],
17
+ default: "left"
18
+ prop :transparent, type: Playbook::Props::Boolean, default: false
19
+ prop :size, type: Playbook::Props::Enum,
20
+ values: %w[xs sm md lg xl],
21
+ default: "md"
22
+
23
+ def classname
24
+ first_class = generate_classname("pb_layout", size, position, dark_class, transparent_class)
25
+ classname = first_class + full_class + collapse_class
26
+ [first_class, full_class, collapse_class].reject(&:empty?).join(" ")
57
27
  end
58
28
 
59
- def collapse
60
- if configured_collapse == default_configuration
61
- " layout#{position}_collapse_xs"
62
- else
63
- " layout#{position}_collapse_#{configured_collapse}"
64
- end
65
- end
66
-
67
- def full
68
- true_value(configured_full, " full", "")
69
- end
29
+ private
70
30
 
71
- def dark
72
- true_value(configured_dark, "_dark", "")
31
+ def dark_class
32
+ dark ? "dark" : nil
73
33
  end
74
34
 
75
- def yield(context:)
76
- context.capture(&block)
35
+ def full_class
36
+ full ? "full" : ""
77
37
  end
78
38
 
79
- def to_partial_path
80
- "pb_layout/layout"
39
+ def transparent_class
40
+ transparent ? "transparent" : nil
81
41
  end
82
42
 
83
- private
84
-
85
- DEFAULT = Object.new
86
- private_constant :DEFAULT
87
- def default_configuration
88
- DEFAULT
43
+ def collapse_class
44
+ "layout_#{position}_collapse_#{collapse}"
89
45
  end
90
- attr_accessor(*PROPS)
91
46
  end
92
47
  end
93
48
  end
@@ -2,38 +2,14 @@
2
2
 
3
3
  module Playbook
4
4
  module PbLayout
5
- class Sidebar < Playbook::PbKit::Base
6
- PROPS = %i[configured_classname
7
- configured_data
8
- configured_id
9
- block].freeze
5
+ class Sidebar
6
+ include Playbook::Props
10
7
 
11
- def initialize(classname: default_configuration,
12
- data: default_configuration,
13
- id: default_configuration,
14
- &block)
15
- self.configured_classname = classname
16
- self.configured_data = data
17
- self.configured_id = id
18
- self.block = block_given? ? block : nil
19
- end
20
-
21
- def yield(context:)
22
- context.capture(&block)
23
- end
24
-
25
- def to_partial_path
26
- "pb_layout/sidebar"
27
- end
28
-
29
- private
8
+ partial "pb_layout/sidebar"
30
9
 
31
- DEFAULT = Object.new
32
- private_constant :DEFAULT
33
- def default_configuration
34
- DEFAULT
10
+ def classname
11
+ generate_classname("layout_sidebar")
35
12
  end
36
- attr_accessor(*PROPS)
37
13
  end
38
14
  end
39
15
  end
@@ -2,5 +2,5 @@
2
2
  id: object.id,
3
3
  data: object.data,
4
4
  class: object.classname) do %>
5
- <%= object.yield(context: self) %>
5
+ <%= capture(&object.children) %>
6
6
  <% end %>
@@ -1,9 +1,8 @@
1
- <%= content_tag(:div,
2
- class: "pb_list_kit#{object.xpadding}#{object.borderless}#{object.dark}#{object.size}#{object.layout}") do %>
3
- <%= content_tag(:"#{object.ordered}",
1
+ <%= content_tag(:div, class: object.list_classname) do %>
2
+ <%= content_tag(:"#{object.ordered_class}",
4
3
  id: object.id,
5
4
  data: object.data,
6
5
  class: object.classname) do %>
7
- <%= object.yield(context: self) %>
6
+ <%= capture(&object.children) %>
8
7
  <% end %>
9
8
  <% end %>
@@ -2,38 +2,14 @@
2
2
 
3
3
  module Playbook
4
4
  module PbList
5
- class Item < Playbook::PbKit::Base
6
- PROPS = %i[configured_classname
7
- configured_data
8
- configured_id
9
- block].freeze
5
+ class Item
6
+ include Playbook::Props
10
7
 
11
- def initialize(classname: default_configuration,
12
- data: default_configuration,
13
- id: default_configuration,
14
- &block)
15
- self.configured_classname = classname
16
- self.configured_data = data
17
- self.configured_id = id
18
- self.block = block_given? ? block : nil
19
- end
20
-
21
- def to_partial_path
22
- "pb_list/item"
23
- end
24
-
25
- def yield(context:)
26
- context.capture(&block)
27
- end
28
-
29
- private
8
+ partial "pb_list/item"
30
9
 
31
- DEFAULT = Object.new
32
- private_constant :DEFAULT
33
- def default_configuration
34
- DEFAULT
10
+ def classname
11
+ generate_classname("pb_item_kit")
35
12
  end
36
- attr_accessor(*PROPS)
37
13
  end
38
14
  end
39
15
  end
@@ -2,115 +2,66 @@
2
2
 
3
3
  module Playbook
4
4
  module PbList
5
- class List < Playbook::PbKit::Base
6
- PROPS = %i[configured_borderless
7
- configured_classname
8
- configured_dark
9
- configured_data
10
- configured_id
11
- configured_layout
12
- configured_size
13
- configured_ordered
14
- configured_xpadding
15
- block].freeze
5
+ class List
6
+ include Playbook::Props
16
7
 
17
- def initialize(borderless: default_configuration,
18
- classname: default_configuration,
19
- dark: default_configuration,
20
- data: default_configuration,
21
- id: default_configuration,
22
- layout: default_configuration,
23
- size: default_configuration,
24
- ordered: default_configuration,
25
- xpadding: default_configuration,
26
- &block)
27
- self.configured_borderless = borderless
28
- self.configured_classname = classname
29
- self.configured_dark = dark
30
- self.configured_data = data
31
- self.configured_id = id
32
- self.configured_layout = layout
33
- self.configured_size = size
34
- self.configured_ordered = ordered
35
- self.configured_xpadding = xpadding
36
- self.block = block_given? ? block : nil
37
- end
8
+ partial "pb_list/list"
38
9
 
39
- def class
40
- if configured_class == default_configuration
41
- ""
42
- else
43
- configured_class
44
- end
45
- end
10
+ prop :borderless, type: Playbook::Props::Boolean,
11
+ default: false
12
+ prop :dark, type: Playbook::Props::Boolean,
13
+ default: false
14
+ prop :layout, type: Playbook::Props::Enum,
15
+ values: ["left", "right", ""],
16
+ default: ""
17
+ prop :size
18
+ prop :ordered, type: Playbook::Props::Boolean,
19
+ default: false
20
+ prop :xpadding, type: Playbook::Props::Boolean,
21
+ default: false
46
22
 
47
- def dark
48
- if configured_dark == default_configuration
49
- ""
50
- elsif configured_dark == true
51
- "_dark"
52
- end
23
+ def list_classname
24
+ [
25
+ "pb_list_kit",
26
+ xpadding_class,
27
+ borderless_class,
28
+ dark_class,
29
+ size_class,
30
+ layout_class,
31
+ ].compact.join("_")
53
32
  end
54
33
 
55
- def layout
56
- if configured_layout == default_configuration
57
- ""
58
- elsif configured_layout == "left"
59
- "_layout_left"
60
- elsif configured_layout == "right"
61
- "_layout_right"
62
- end
34
+ def ordered_class
35
+ ordered ? "ol" : "ul"
63
36
  end
64
37
 
65
- def size
66
- case configured_size
67
- when default_configuration
68
- ""
69
- when "large"
70
- "_large"
71
- end
72
- end
38
+ private
73
39
 
74
- def ordered
75
- if configured_ordered == false
76
- "ul"
77
- else
78
- "ol"
79
- end
40
+ def borderless_class
41
+ borderless ? "borderless" : nil
80
42
  end
81
43
 
82
- def xpadding
83
- if configured_xpadding == default_configuration
84
- ""
85
- elsif configured_xpadding == true
86
- "_xpadding"
87
- end
44
+ def dark_class
45
+ dark ? "dark" : nil
88
46
  end
89
47
 
90
- def borderless
91
- if configured_borderless == false
92
- ""
48
+ def layout_class
49
+ if layout == "right"
50
+ "layout_right"
51
+ elsif layout == "left"
52
+ "layout_left"
93
53
  else
94
- "_borderless"
54
+ ""
95
55
  end
96
56
  end
97
57
 
98
- def yield(context:)
99
- context.capture(&block)
100
- end
101
-
102
- def to_partial_path
103
- "pb_list/list"
58
+ def size_class
59
+ size ? "large" : nil
104
60
  end
105
61
 
106
- private
107
-
108
- DEFAULT = Object.new
109
- private_constant :DEFAULT
110
- def default_configuration
111
- DEFAULT
62
+ def xpadding_class
63
+ xpadding ? "xpadding" : nil
112
64
  end
113
- attr_accessor(*PROPS)
114
65
  end
115
66
  end
116
67
  end
@@ -1,11 +1,24 @@
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.valid? %>
6
+ <%= pb_rails("avatar", props: {
7
+ name: object.avatar_name,
8
+ size: "sm",
9
+ image_url: object.avatar_url,
10
+ status: object.avatar_status
11
+ }) %>
12
+ <% end %>
6
13
  <div class="content_wrapper">
7
- <%= object.label %>
8
- <%= object.message %>
9
- <%= object.timestamp %>
14
+ <%= pb_rails("caption", props: {
15
+ text: object.label
16
+ }) %>
17
+ <%= pb_rails("body", props: {
18
+ text: object.message
19
+ }) %>
20
+ <%= pb_rails("timestamp", props: {
21
+ text: object.timestamp
22
+ }) %>
10
23
  </div>
11
24
  <% end %>
@@ -2,11 +2,9 @@
2
2
  label: "Message",
3
3
  message: "How can we assist you today?",
4
4
  timestamp: "20 seconds ago",
5
- avatar: {
6
- name: "Mike Bishop",
7
- image: { url: "https://randomuser.me/api/portraits/men/50.jpg" },
8
- status: "online"
9
- }
5
+ avatar_name: "Mike Bishop",
6
+ avatar_url: "https://randomuser.me/api/portraits/men/50.jpg",
7
+ avatar_status: "online"
10
8
  }) %>
11
9
 
12
10
  <br><br>
@@ -15,10 +13,8 @@
15
13
  label: "Support",
16
14
  message: "We'll escalate this issue to a Senior Support agent.",
17
15
  timestamp: "9 minutes ago",
18
- avatar: {
19
- name: "Wade Winningham",
20
- image: { url: "https://randomuser.me/api/portraits/men/14.jpg" }
21
- }
16
+ avatar_name:"Wade Winningham",
17
+ avatar_url: "https://randomuser.me/api/portraits/men/14.jpg"
22
18
  }) %>
23
19
 
24
20
  <br><br>
@@ -26,10 +22,8 @@
26
22
  <%= pb_rails("message", props: {
27
23
  message: "To processs your order, I'll need your full name.",
28
24
  timestamp: "4 hours ago",
29
- avatar: {
30
- name: "Lisa Thompson",
31
- image: { url: "https://randomuser.me/api/portraits/women/39.jpg" }
32
- }
25
+ avatar_name: "Lisa Thompson",
26
+ avatar_url: "https://randomuser.me/api/portraits/women/39.jpg"
33
27
  }) %>
34
28
 
35
29
  <br><br>
@@ -37,10 +31,8 @@
37
31
  <%= pb_rails("message", props: {
38
32
  label: "Application",
39
33
  message: "Application for Kate Smith is waiting for your approval",
40
- avatar: {
41
- name: "Becca Jacobs",
42
- image: { url: "https://randomuser.me/api/portraits/women/50.jpg" }
43
- }
34
+ avatar_name: "Becca Jacobs",
35
+ avatar_url: "https://randomuser.me/api/portraits/women/50.jpg"
44
36
  }) %>
45
37
 
46
38
  <br><br>
@@ -49,9 +41,7 @@
49
41
  label: "Complaint",
50
42
  message: "We're so sorry you had a bad experience!",
51
43
  timestamp: "2 days ago",
52
- avatar: {
53
- name: "Tim Wenhold"
54
- }
44
+ avatar_name: "Tim Wenhold"
55
45
  }) %>
56
46
 
57
47
  <br><br>