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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 468316bdb9eaf492b0e250410de1241ffd0ab4c38f8a605ce42665d59924bb8d
4
- data.tar.gz: 7bcf743ce36bfa07ff916bd44be34b84d3de0beb78891292c317c36c5523c91b
3
+ metadata.gz: 4a5f2bd958a96f0dbfd28803cf2985193685e6befec0ee99cc70b88a9b240724
4
+ data.tar.gz: c0431904190cb6d3f70b773becf328aa27b270dbcef67325799f6e22bc174536
5
5
  SHA512:
6
- metadata.gz: 2cc3c3454e5a37b857b03642b4b2b0f2a9667e4ca0b6ca26285bd8be6f89cb0babe6c617ef4cb8b6bedd63fdcbc82f78f4fc8760274e947a0bc1473016913130
7
- data.tar.gz: 1532380e45d62b933b33172925672f560b608e12125901cab907555fe4d4a6e588c11ac61658fe53152e8e1d5895868de400855b8c078b01e8433f7e25d80f58
6
+ metadata.gz: ca568cf8bd38190150704d38a8b209d7732b523162206e8e0900d1e1a34687e1b476a6b02467f2280e8f06337f5b92ceb27716bd383a35abe2924f8dfefbdfbf
7
+ data.tar.gz: 974ccaefbb7da619678d5345f04c1a8be13ae97aacb20342d09eaf4ae3f7c2909dfd88d027fb167f4f49fbafb0121fe7c3e8e5bd8d2d69b622ae010f8915e9ed
@@ -6,7 +6,7 @@
6
6
  <%= content_tag(:div,
7
7
  data: { initials: object.initials },
8
8
  class: "avatar_wrapper") do %>
9
- <%= pb_rails("image", props: object.image) if object.image.present? %>
9
+ <%= pb_rails("image", props: { url: object.image_url }) if object.image_url.present? %>
10
10
  <% end %>
11
11
  <%= pb_rails("online_status", props: object.online_status_props) if object.status %>
12
12
  <% end %>
@@ -7,7 +7,7 @@ module Playbook
7
7
 
8
8
  partial "pb_avatar/avatar"
9
9
 
10
- prop :image, type: Playbook::Props::Hash, default: {}
10
+ prop :image_url
11
11
  prop :name, default: ""
12
12
  prop :size, type: Playbook::Props::Enum,
13
13
  values: %w[xs sm md base lg xl],
@@ -1,7 +1,7 @@
1
1
  <%= pb_rails("avatar", props: {
2
2
  name: "Terry Johnson",
3
3
  size: "xs",
4
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
4
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
5
5
  status: "online"
6
6
  }) %>
7
7
 
@@ -10,7 +10,7 @@
10
10
  <%= pb_rails("avatar", props: {
11
11
  name: "Terry Johnson",
12
12
  size: "sm",
13
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
13
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
14
14
  status: "away"
15
15
  }) %>
16
16
 
@@ -19,7 +19,7 @@
19
19
  <%= pb_rails("avatar", props: {
20
20
  name: "Terry Johnson",
21
21
  size: "md",
22
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
22
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
23
23
  status: "offline"
24
24
  }) %>
25
25
 
@@ -28,7 +28,7 @@
28
28
  <%= pb_rails("avatar", props: {
29
29
  name: "Terry Johnson",
30
30
  size: "lg",
31
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
31
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
32
32
  status: "online"
33
33
  }) %>
34
34
 
@@ -37,6 +37,6 @@
37
37
  <%= pb_rails("avatar", props: {
38
38
  name: "Terry Johnson",
39
39
  size: "xl",
40
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
40
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
41
41
  status: "away"
42
42
  }) %>
@@ -1,7 +1,7 @@
1
1
  <%= pb_rails("avatar", props: {
2
2
  name: "Terry Johnson",
3
3
  size: "sm",
4
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"}
4
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg"
5
5
  }) %>
6
6
 
7
7
  <br>
@@ -9,7 +9,7 @@
9
9
  <%= pb_rails("avatar", props: {
10
10
  name: "Terry Johnson",
11
11
  size: "sm",
12
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
12
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
13
13
  status: "online"
14
14
  }) %>
15
15
 
@@ -18,7 +18,7 @@
18
18
  <%= pb_rails("avatar", props: {
19
19
  name: "Terry Johnson",
20
20
  size: "sm",
21
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
21
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
22
22
  status: "away"
23
23
  }) %>
24
24
 
@@ -27,6 +27,6 @@
27
27
  <%= pb_rails("avatar", props: {
28
28
  name: "Terry Johnson",
29
29
  size: "sm",
30
- image: {url: "https://randomuser.me/api/portraits/men/44.jpg"},
30
+ image_url: "https://randomuser.me/api/portraits/men/44.jpg",
31
31
  status: "offline"
32
32
  }) %>
@@ -1,23 +1,5 @@
1
- <%
2
- # Buttons should not have link options: href, target
3
- options = {
4
- id: object.id,
5
- data: object.data,
6
- class: object.classname(object.kit_class),
7
- disabled: object.disabled,
8
- aria: object.aria,
9
- type: object.type,
10
- value: object.value
11
- }.compact
12
-
13
- link_options = {
14
- href: object.link,
15
- target: object.new_window
16
- }
17
- %>
18
-
19
1
  <%= content_tag(object.tag,
20
- object.tag == "button" ? options : options.merge(link_options)) do %>
21
- <%= object.loading_icon %>
22
- <span class="pb_button_content"><%= object.yield(context: self) %></span>
2
+ object.tag == "button" ? object.options : object.link_options) do %>
3
+ <%= pb_rails("icon", props: { icon: "spinner", pulse: true, fixed_width: true, classname: "loading-icon" }) %>
4
+ <span class="pb_button_content"><%= !object.children.nil? ? capture(&object.children) : object.text %></span>
23
5
  <% end %>
@@ -2,144 +2,67 @@
2
2
 
3
3
  module Playbook
4
4
  module PbButton
5
- class Button < Playbook::PbKit::Base
6
- PROPS = %i[configured_aria
7
- configured_classname
8
- configured_data
9
- configured_disabled
10
- configured_full_width
11
- configured_id
12
- configured_link
13
- configured_loading
14
- configured_new_window
15
- configured_variant
16
- configured_tag
17
- configured_text
18
- configured_type
19
- configured_value
20
- block].freeze
21
-
22
- def initialize(aria: default_configuration,
23
- classname: default_configuration,
24
- data: default_configuration,
25
- disabled: default_configuration,
26
- full_width: default_configuration,
27
- id: default_configuration,
28
- link: default_configuration,
29
- loading: default_configuration,
30
- new_window: default_configuration,
31
- variant: default_configuration,
32
- tag: default_configuration,
33
- text: default_configuration,
34
- type: default_configuration,
35
- value: default_configuration,
36
- &block)
37
- self.configured_aria = aria
38
- self.configured_classname = classname
39
- self.configured_data = data
40
- self.configured_disabled = disabled
41
- self.configured_full_width = full_width
42
- self.configured_id = id
43
- self.configured_link = link
44
- self.configured_loading = loading
45
- self.configured_new_window = new_window
46
- self.configured_variant = variant
47
- self.configured_tag = tag
48
- self.configured_text = text
49
- self.configured_type = type
50
- self.configured_value = value
51
- self.block = block_given? ? block : nil
52
- end
53
-
54
- def disabled
55
- is_true? configured_disabled
5
+ class Button
6
+ include Playbook::Props
7
+
8
+ partial "pb_button/button"
9
+
10
+ prop :disabled, type: Playbook::Props::Boolean,
11
+ default: false
12
+ prop :full_width, type: Playbook::Props::Boolean,
13
+ default: false
14
+ prop :link
15
+ prop :loading, type: Playbook::Props::Boolean,
16
+ default: false
17
+ prop :new_window, type: Playbook::Props::Boolean,
18
+ default: false
19
+ prop :variant, type: Playbook::Props::Enum,
20
+ values: %w[primary secondary link],
21
+ default: "primary"
22
+ prop :text
23
+ prop :type
24
+ prop :value
25
+
26
+ def options
27
+ {
28
+ id: id,
29
+ data: data,
30
+ class: classname,
31
+ disabled: disabled,
32
+ aria: aria,
33
+ type: type,
34
+ value: value,
35
+ }.compact
36
+ end
37
+
38
+ def link_options
39
+ options.merge(
40
+ href: link,
41
+ target: new_window ? "_blank" : "_self"
42
+ )
56
43
  end
57
44
 
58
- def loading
59
- is_true? configured_loading
45
+ def tag
46
+ link ? "a" : "button"
60
47
  end
61
48
 
62
- def loading_class
63
- loading ? "loading" : nil
64
- end
49
+ private
65
50
 
66
- def loading_icon
67
- pb_icon = Playbook::PbIcon::Icon.new(icon: "spinner",
68
- pulse: true,
69
- fixed_width: true,
70
- classname: "loading-icon")
71
- ApplicationController.renderer.render(partial: pb_icon, as: :object)
51
+ def classname
52
+ generate_classname("pb_button_kit", variant, full_width_class, disabled_class, loading_class)
72
53
  end
73
54
 
74
55
  def disabled_class
75
- true_value(disabled, "disabled", "enabled")
56
+ disabled ? "disabled" : "enabled"
76
57
  end
77
58
 
78
59
  def full_width_class
79
- true_value(configured_full_width, "block", "inline")
80
- end
81
-
82
- def link
83
- default_value(configured_link, "")
84
- end
85
-
86
- def variant
87
- variant_options = %w[primary secondary link]
88
- one_of_value(configured_variant, variant_options, "primary")
89
- end
90
-
91
- def tag
92
- tag_options = %w[button a]
93
- if link.empty?
94
- one_of_value(configured_tag, tag_options, "button")
95
- else
96
- "a"
97
- end
98
- end
99
-
100
- def new_window
101
- true_value(configured_new_window, "_blank", "_self")
60
+ full_width ? "block" : "inline"
102
61
  end
103
62
 
104
- def text
105
- default_value(configured_text, "")
106
- end
107
-
108
- def type
109
- default_value(configured_type, "button")
110
- end
111
-
112
- def value
113
- configured_value unless configured_value == DEFAULT
114
- end
115
-
116
- def yield(context:)
117
- !block.nil? ? context.capture(&block) : text
118
- end
119
-
120
- def kit_class
121
- kit_options = [
122
- "pb_button_kit",
123
- variant,
124
- full_width_class,
125
- disabled_class,
126
- loading_class,
127
- ]
128
- kit_options.compact.join("_")
129
- end
130
-
131
- def to_partial_path
132
- "pb_button/button"
133
- end
134
-
135
- private
136
-
137
- DEFAULT = Object.new
138
- private_constant :DEFAULT
139
- def default_configuration
140
- DEFAULT
63
+ def loading_class
64
+ loading ? "loading" : nil
141
65
  end
142
- attr_accessor(*PROPS)
143
66
  end
144
67
  end
145
68
  end
@@ -12,7 +12,7 @@ module Playbook
12
12
  prop :tag, type: Playbook::Props::Enum,
13
13
  values: %w[h1 h2 h3 h4 h5 h6 p span div],
14
14
  default: "div"
15
- prop :text, default: "Caption"
15
+ prop :text
16
16
 
17
17
  def classname
18
18
  generate_classname("pb_caption_kit", large_class, dark_class)
@@ -4,6 +4,6 @@
4
4
  class: object.classname) do %>
5
5
  <%= pb_rails("body", props: { tag: "span", classname: "pb_contact_kit", color: "light" }) do %>
6
6
  <%= pb_rails("icon", props: { icon: object.contact_icon, fixed_width: true }) %>
7
- <%= object.formatted_contact_value if object.contact_value%>
7
+ <%= object.formatted_contact_info if object.contact_value%>
8
8
  <% end %>
9
9
  <% end %>
@@ -14,6 +14,7 @@ type ContactProps = {
14
14
  className?: String | Array<String>,
15
15
  dark?: Boolean,
16
16
  contactValue: String,
17
+ contactDetail?: String,
17
18
  }
18
19
 
19
20
  const kitClasses = ({}: ContactProps) => {
@@ -26,19 +27,28 @@ const Contact = ({
26
27
  className,
27
28
  dark=false,
28
29
  contactValue,
30
+ contactDetail="",
29
31
  }: ContactProps) => {
30
32
 
33
+ const formatDetail = (contactDetail) => {
34
+ if (contactDetail !== undefined) {
35
+ return `\u00b7 ${contactDetail}`
36
+ } else {
37
+ return contactDetail
38
+ }
39
+ }
40
+
31
41
  const css = classnames(kitClasses({contactType}), className)
32
42
 
33
- const formatPhoneNumber = (phoneNumberString, contactType) => {
43
+ const formatContact = (contactString, contactType) => {
34
44
  if (contactType == "email") {
35
- return phoneNumberString
45
+ return contactString
36
46
  } else {
37
- let cleaned = ('' + phoneNumberString).replace(/\D/g, '')
38
- let match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/)
39
- if (match) {
40
- let intlCode = (match[1] ? '+1 ' : '')
41
- return [intlCode, '(', match[2], ') ', match[3], '-', match[4]].join('')
47
+ const cleaned = contactString.replace(/\D/g, '')
48
+ const phoneNumber = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/)
49
+ if (phoneNumber) {
50
+ let intlCode = (phoneNumber[1] ? '+1 ' : '')
51
+ return [intlCode, '(', phoneNumber[2], ') ', phoneNumber[3], '-', phoneNumber[4]].join('')
42
52
  }
43
53
  return null
44
54
  }
@@ -63,7 +73,7 @@ const Contact = ({
63
73
  <div className={css}>
64
74
  <Body dark={dark} color="light" >
65
75
  <Icon icon={contactTypeIcon} fixedWidth="true" />
66
- {` ${formatPhoneNumber(contactValue, contactType)}`}
76
+ {` ${formatContact(contactValue, contactType)} ${formatDetail(contactDetail)}`}
67
77
  </Body>
68
78
  </div>
69
79
  )
@@ -12,6 +12,7 @@ module Playbook
12
12
 
13
13
  prop :contact_type
14
14
  prop :contact_value
15
+ prop :contact_detail
15
16
 
16
17
  def classname
17
18
  generate_classname("pb_contact_kit")
@@ -32,6 +33,12 @@ module Playbook
32
33
  end
33
34
  end
34
35
 
36
+ def formatted_contact_info
37
+ "#{formatted_contact_value} #{separator} #{contact_detail}"
38
+ end
39
+
40
+ private
41
+
35
42
  def formatted_contact_value
36
43
  if contact_type == "email"
37
44
  contact_value
@@ -40,11 +47,13 @@ module Playbook
40
47
  end
41
48
  end
42
49
 
43
- private
44
-
45
50
  def formatted_value
46
51
  contact_value.to_s.gsub(/\D/, "")
47
52
  end
53
+
54
+ def separator
55
+ contact_detail ? "\u00b7" : ""
56
+ end
48
57
  end
49
58
  end
50
59
  end
@@ -1,18 +1,21 @@
1
1
  <%= pb_rails("contact", props: {
2
2
  contact_type: "cell",
3
3
  contact_value: "349-185-9988",
4
+ contact_detail: "John's Cell",
4
5
  }) %>
5
6
 
6
7
  <%= pb_rails("contact", props: {
7
8
  contact_value: 5555555555,
9
+ contact_detail: "Home",
8
10
  }) %>
9
11
 
10
12
  <%= pb_rails("contact", props: {
11
13
  contact_type: "email",
12
- contact_value: "email@example.com",
14
+ contact_value: "email@example.com"
13
15
  }) %>
14
16
 
15
17
  <%= pb_rails("contact", props: {
16
18
  contact_type: "work",
17
19
  contact_value: "3245627482",
20
+ contact_detail: "John's Work",
18
21
  }) %>