playbook_ui 2.9.4 → 2.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_body/_body.html.erb +2 -2
  3. data/app/pb_kits/playbook/pb_body/body.rb +20 -80
  4. data/app/pb_kits/playbook/pb_checkbox/_checkbox.html.erb +4 -2
  5. data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +18 -14
  6. data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +5 -6
  7. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +0 -1
  8. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_checked.html.erb +0 -1
  9. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_dark.html.erb +0 -1
  10. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_dark.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_default.html.erb +0 -1
  12. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_default.jsx +1 -1
  13. data/app/pb_kits/playbook/pb_contact/_contact.html.erb +5 -2
  14. data/app/pb_kits/playbook/pb_contact/contact.rb +22 -50
  15. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.html.erb +3 -3
  16. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +11 -49
  17. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.html.erb +2 -2
  18. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.jsx +20 -3
  19. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_dark.html.erb +6 -5
  20. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_dark.jsx +5 -4
  21. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.html.erb +5 -4
  22. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.jsx +5 -3
  23. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_modified.html.erb +8 -0
  24. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_modified.jsx +17 -0
  25. data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +2 -0
  26. data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +1 -0
  27. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +5 -4
  28. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.html.erb +2 -2
  29. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.rb +12 -56
  30. data/app/pb_kits/playbook/pb_icon_value/_icon_value.html.erb +7 -4
  31. data/app/pb_kits/playbook/pb_icon_value/icon_value.rb +10 -67
  32. data/app/pb_kits/playbook/pb_image/_image.html.erb +2 -2
  33. data/app/pb_kits/playbook/pb_image/image.rb +7 -48
  34. data/app/pb_kits/playbook/pb_person/_person.html.erb +3 -3
  35. data/app/pb_kits/playbook/pb_person/person.rb +7 -45
  36. data/app/pb_kits/playbook/pb_source/_source.html.erb +10 -7
  37. data/app/pb_kits/playbook/pb_source/source.rb +22 -67
  38. data/app/pb_kits/playbook/pb_table/_table.html.erb +2 -2
  39. data/app/pb_kits/playbook/pb_table/_table.jsx +1 -1
  40. data/app/pb_kits/playbook/pb_table/docs/_table_container.html.erb +1 -1
  41. data/app/pb_kits/playbook/pb_table/docs/_table_container.jsx +1 -1
  42. data/app/pb_kits/playbook/pb_table/docs/_table_container_dark.html.erb +1 -1
  43. data/app/pb_kits/playbook/pb_table/docs/_table_container_dark.jsx +1 -1
  44. data/app/pb_kits/playbook/pb_table/docs/_table_dark.html.erb +1 -1
  45. data/app/pb_kits/playbook/pb_table/docs/_table_dark.jsx +1 -1
  46. data/app/pb_kits/playbook/pb_table/docs/_table_disable_hover.html.erb +1 -1
  47. data/app/pb_kits/playbook/pb_table/docs/_table_disable_hover.jsx +1 -1
  48. data/app/pb_kits/playbook/pb_table/docs/_table_lg.html.erb +1 -1
  49. data/app/pb_kits/playbook/pb_table/docs/_table_lg.jsx +1 -1
  50. data/app/pb_kits/playbook/pb_table/docs/_table_md.html.erb +1 -1
  51. data/app/pb_kits/playbook/pb_table/docs/_table_md.jsx +1 -1
  52. data/app/pb_kits/playbook/pb_table/docs/_table_multiline.html.erb +1 -1
  53. data/app/pb_kits/playbook/pb_table/docs/_table_multiline.jsx +1 -1
  54. data/app/pb_kits/playbook/pb_table/docs/_table_single_line.html.erb +1 -1
  55. data/app/pb_kits/playbook/pb_table/docs/_table_single_line.jsx +1 -1
  56. data/app/pb_kits/playbook/pb_table/docs/_table_sm.html.erb +1 -1
  57. data/app/pb_kits/playbook/pb_table/docs/_table_sm.jsx +1 -1
  58. data/app/pb_kits/playbook/pb_table/table.rb +30 -76
  59. data/app/pb_kits/playbook/pb_toggle/_toggle.html.erb +6 -3
  60. data/app/pb_kits/playbook/pb_toggle/toggle.rb +12 -68
  61. data/app/pb_kits/playbook/props.rb +1 -1
  62. data/app/pb_kits/playbook/props/base.rb +1 -1
  63. data/lib/playbook/version.rb +1 -1
  64. metadata +4 -2
@@ -1,7 +1,7 @@
1
1
  <%= content_tag(:div,
2
2
  id: object.id,
3
3
  data: object.data,
4
- class: object.classname("pb_person_kit")) do %>
5
- <%= object.first_name %>
6
- <%= object.last_name %>
4
+ class: object.classname) do %>
5
+ <%= pb_rails("body", props: { tag: "span", classname: "pb_person_first", children: -> { object.first_name } }) %>
6
+ <%= pb_rails("title", props: { text: object.last_name, size: 4 }) if object.last_name %>
7
7
  <% end %>
@@ -2,55 +2,17 @@
2
2
 
3
3
  module Playbook
4
4
  module PbPerson
5
- class Person < Playbook::PbKit::Base
6
- PROPS = %i[
7
- configured_classname
8
- configured_data
9
- configured_id
10
- configured_first_name
11
- configured_last_name
12
- ].freeze
5
+ class Person
6
+ include Playbook::Props
13
7
 
14
- def initialize(
15
- classname: default_configuration,
16
- data: default_configuration,
17
- id: default_configuration,
18
- first_name: default_configuration,
19
- last_name: default_configuration
20
- )
21
- self.configured_classname = classname
22
- self.configured_data = data
23
- self.configured_id = id
24
- self.configured_first_name = first_name
25
- self.configured_last_name = last_name
26
- end
27
-
28
- def first_name
29
- pb_first_name = Playbook::PbBody::Body.new(tag: "span", classname: "pb_person_first") do
30
- default_value(configured_first_name, "")
31
- end
32
- ApplicationController.renderer.render(partial: pb_first_name, as: :object)
33
- end
34
-
35
- def last_name
36
- if is_set? configured_last_name
37
- pb_last_name = Playbook::PbTitle::Title.new(text: configured_last_name, size: 4)
38
- ApplicationController.renderer.render(partial: pb_last_name, as: :object)
39
- end
40
- end
41
-
42
- def to_partial_path
43
- "pb_person/person"
44
- end
8
+ partial "pb_person/person"
45
9
 
46
- private
10
+ prop :first_name
11
+ prop :last_name
47
12
 
48
- DEFAULT = Object.new
49
- private_constant :DEFAULT
50
- def default_configuration
51
- DEFAULT
13
+ def classname
14
+ generate_classname("pb_person_kit")
52
15
  end
53
- attr_accessor(*PROPS)
54
16
  end
55
17
  end
56
18
  end
@@ -1,17 +1,20 @@
1
1
  <%= content_tag(:div,
2
2
  id: object.id,
3
3
  data: object.data,
4
- class: object.classname("pb_source")) do %>
4
+ class: object.classname) do %>
5
5
  <div class="pb__source_layout">
6
- <% if object.hide_icon == false %>
7
- <%= object.type_icon %>
8
- <%= object.avatar %>
6
+ <% if !object.hide_icon %>
7
+ <% if object.show_icon? %>
8
+ <%= pb_rails("icon_circle", props: { icon: object.type_icon_name, size: "sm" }) %>
9
+ <% else %>
10
+ <%= pb_rails("avatar", props: object.avatar) %>
11
+ <% end %>
9
12
  <% end %>
10
13
  <div class="pb__source_content">
11
- <%= object.source %>
14
+ <%= pb_rails("title", props: { text: object.source, tag: "h4", size: 4 }) %>
12
15
  <div class="pb__source_value">
13
- <%= object.type_text %>
14
- <%= object.user_id %>
16
+ <%= pb_rails("body", props: { text: object.type_text, color: "light" }) %>
17
+ <%= pb_rails("caption", props: { text: object.user_id }) if object.user_id %>
15
18
  </div>
16
19
  </div>
17
20
  </div>
@@ -2,81 +2,44 @@
2
2
 
3
3
  module Playbook
4
4
  module PbSource
5
- class Source < Playbook::PbKit::Base
6
- PROPS = %i[configured_classname
7
- configured_data
8
- configured_hide_icon
9
- configured_id
10
- configured_source
11
- configured_type
12
- configured_user].freeze
5
+ class Source
6
+ include Playbook::Props
13
7
 
14
- def initialize(classname: default_configuration,
15
- data: default_configuration,
16
- hide_icon: default_configuration,
17
- id: default_configuration,
18
- source: default_configuration,
19
- type: default_configuration,
20
- user: default_configuration)
21
- self.configured_classname = classname
22
- self.configured_data = data
23
- self.configured_hide_icon = hide_icon
24
- self.configured_id = id
25
- self.configured_source = source
26
- self.configured_type = type
27
- self.configured_user = user
28
- end
8
+ partial "pb_source/source"
29
9
 
30
- def source
31
- pb_source_title = Playbook::PbTitle::Title.new(size: 4, text: configured_source)
32
- ApplicationController.renderer.render(partial: pb_source_title, as: :object)
33
- end
10
+ prop :hide_icon, type: Playbook::Props::Boolean,
11
+ default: false
12
+ prop :source, type: Playbook::Props::String
13
+ prop :type, type: Playbook::Props::Enum,
14
+ values: %w[user retail inbound outbound prospecting events referral],
15
+ default: "inbound"
16
+ prop :user, type: Playbook::Props::Hash, default: {}
34
17
 
35
18
  def type_text
36
- pb_type = Playbook::PbBody::Body.new(color: "light") do
37
- if type == "user" || (type == "referral" && is_set?(configured_user))
38
- configured_user[:name]
39
- else
40
- type.titleize
41
- end
19
+ if type == "user" || (type == "referral" && user.present?)
20
+ user[:name]
21
+ else
22
+ type.titleize
42
23
  end
43
- ApplicationController.renderer.render(partial: pb_type, as: :object)
44
24
  end
45
25
 
46
- def type_icon
47
- if !type_icon_name.nil? && avatar.nil?
48
- pb_type_icon = Playbook::PbIconCircle::IconCircle.new(icon: type_icon_name, size: "sm")
49
- ApplicationController.renderer.render(partial: pb_type_icon, as: :object)
50
- end
26
+ def show_icon?
27
+ !type_icon_name.nil? && avatar.nil?
51
28
  end
52
29
 
53
30
  def avatar
54
- if is_set?(configured_user) && (type == "user" || type == "referral")
55
- avatar_props = configured_user.clone
31
+ if user.present? && (type == "user" || type == "referral")
32
+ avatar_props = user.clone
56
33
  avatar_props[:size] = "sm"
57
34
  avatar_props.delete(:user_id)
58
- pb_avatar = Playbook::PbAvatar::Avatar.new(avatar_props)
59
- ApplicationController.renderer.render(partial: pb_avatar, as: :object)
35
+ avatar_props
60
36
  end
61
37
  end
62
38
 
63
39
  def user_id
64
- if is_set?(configured_user) && configured_user[:user_id].present?
65
- pb_user_id = Playbook::PbCaption::Caption.new(text: configured_user[:user_id])
66
- ApplicationController.renderer.render(partial: pb_user_id, as: :object)
67
- end
68
- end
69
-
70
- def hide_icon
71
- is_true? configured_hide_icon
40
+ user.dig(:user_id)
72
41
  end
73
42
 
74
- def to_partial_path
75
- "pb_source/source"
76
- end
77
-
78
- private
79
-
80
43
  def type_icon_name
81
44
  case type
82
45
  when "retail"
@@ -94,17 +57,9 @@ module Playbook
94
57
  end
95
58
  end
96
59
 
97
- def type
98
- type_options = %w[user retail inbound outbound prospecting events referral]
99
- one_of_value(configured_type, type_options, "inbound")
100
- end
101
-
102
- DEFAULT = Object.new
103
- private_constant :DEFAULT
104
- def default_configuration
105
- DEFAULT
60
+ def classname
61
+ generate_classname("pb_source_kit")
106
62
  end
107
- attr_accessor(*PROPS)
108
63
  end
109
64
  end
110
65
  end
@@ -2,7 +2,7 @@
2
2
  <%= content_tag(:table,
3
3
  id: object.id,
4
4
  data: object.data,
5
- class: object.classname(object.kit_class)) do %>
6
- <%= object.yield(context: self) %>
5
+ class: object.classname) do %>
6
+ <%= capture(&object.children) %>
7
7
  <% end %>
8
8
  <% end %>
@@ -16,7 +16,7 @@ const propTypes = {
16
16
  };
17
17
 
18
18
  const defaultProps = {
19
- container: false,
19
+ container: true,
20
20
  dark: false,
21
21
  disable_hover: false,
22
22
  single_line: false,
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "md", container: true}) do %>
1
+ <%= pb_rails("table", props: { size: "md" }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableContainer() {
5
5
  return (
6
- <Table container
6
+ <Table
7
7
  size="md"
8
8
  >
9
9
  <thead>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "md", container: true, dark: true}) do %>
1
+ <%= pb_rails("table", props: { size: "md", dark: true }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableContainerDark() {
5
5
  return (
6
- <Table container
6
+ <Table
7
7
  dark
8
8
  size="md"
9
9
  >
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "md", dark: true}) do %>
1
+ <%= pb_rails("table", props: { size: "md", container: false, dark: true }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableDark() {
5
5
  return (
6
- <Table dark
6
+ <Table dark container={false}
7
7
  size="md"
8
8
  >
9
9
  <thead>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "md", disable_hover: true}) do %>
1
+ <%= pb_rails("table", props: { size: "md", container: false, disable_hover: true }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableDisableHover() {
5
5
  return (
6
- <Table disable_hover
6
+ <Table disable_hover container={false}
7
7
  size="md"
8
8
  >
9
9
  <thead>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "lg"}) do %>
1
+ <%= pb_rails("table", props: { size: "lg", container: false }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableLg() {
5
5
  return (
6
- <Table size="lg">
6
+ <Table size="lg" container={false}>
7
7
  <thead>
8
8
  <tr>
9
9
  <th>{`Column 1`}</th>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "md"}) do %>
1
+ <%= pb_rails("table", props: { size: "md", container: false }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableMd() {
5
5
  return (
6
- <Table size="md">
6
+ <Table size="md" container={false}>
7
7
  <thead>
8
8
  <tr>
9
9
  <th>{`Column 1`}</th>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "md"}) do %>
1
+ <%= pb_rails("table", props: { size: "md", container: false }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableMultiline() {
5
5
  return (
6
- <Table size="sm">
6
+ <Table size="sm" container={false}>
7
7
  <thead>
8
8
  <tr>
9
9
  <th>{`Column 1`}</th>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "md", single_line: true}) do %>
1
+ <%= pb_rails("table", props: { size: "md", single_line: true, container: false }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableSingleLine() {
5
5
  return (
6
- <Table single_line
6
+ <Table single_line container={false}
7
7
  size="sm"
8
8
  >
9
9
  <thead>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("table", props: {size: "sm"}) do %>
1
+ <%= pb_rails("table", props: { size: "sm", container: false }) do %>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Column 1</th>
@@ -3,7 +3,7 @@ import {Table} from "../../"
3
3
 
4
4
  function TableSm() {
5
5
  return (
6
- <Table size="sm">
6
+ <Table size="sm" container={false}>
7
7
  <thead>
8
8
  <tr>
9
9
  <th>{`Column 1`}</th>
@@ -2,94 +2,48 @@
2
2
 
3
3
  module Playbook
4
4
  module PbTable
5
- class Table < Playbook::PbKit::Base
6
- PROPS = %i[configured_aria
7
- configured_classname
8
- configured_container
9
- configured_dark
10
- configured_data
11
- configured_disable_hover
12
- configured_id
13
- configured_single_line
14
- configured_size
15
- configured_text
16
- block].freeze
17
-
18
- def initialize(aria: default_configuration,
19
- classname: default_configuration,
20
- container: default_configuration,
21
- dark: default_configuration,
22
- data: default_configuration,
23
- disable_hover: default_configuration,
24
- id: default_configuration,
25
- single_line: default_configuration,
26
- size: default_configuration,
27
- &block)
28
- self.configured_aria = aria
29
- self.configured_classname = classname
30
- self.configured_container = container
31
- self.configured_dark = dark
32
- self.configured_data = data
33
- self.configured_disable_hover = disable_hover
34
- self.configured_id = id
35
- self.configured_single_line = single_line
36
- self.configured_size = size
37
- self.block = block_given? ? block : nil
5
+ class Table
6
+ include Playbook::Props
7
+
8
+ partial "pb_table/table"
9
+
10
+ prop :size, type: Playbook::Props::Enum,
11
+ values: %w[sm md lg],
12
+ default: "md"
13
+ prop :single_line, type: Playbook::Props::Boolean,
14
+ default: false
15
+ prop :dark, type: Playbook::Props::Boolean,
16
+ default: false
17
+ prop :disable_hover, type: Playbook::Props::Boolean,
18
+ default: false
19
+ prop :container, type: Playbook::Props::Boolean,
20
+ default: true
21
+ prop :text
22
+
23
+ def classname
24
+ generate_classname(
25
+ "pb_table", "table-#{size}", single_line_class, dark_class,
26
+ disable_hover_class, container_class, separator: " "
27
+ )
38
28
  end
39
29
 
40
- def single_line_class
41
- true_value(configured_single_line, "single-line", nil)
42
- end
43
-
44
- def size
45
- size_options = %w[sm md lg]
46
- one_of_value(configured_size, size_options, default_configuration)
47
- end
30
+ private
48
31
 
49
- def size_class
50
- adjusted_value(configured_size, "table-#{size}", "table-md")
32
+ def dark_class
33
+ dark ? "dark" : nil
51
34
  end
52
35
 
53
- def dark_class
54
- true_value(configured_dark, "table-dark", nil)
36
+ def single_line_class
37
+ single_line ? "single-line" : nil
55
38
  end
56
39
 
57
40
  def disable_hover_class
58
- true_value(configured_disable_hover, "no-hover", nil)
41
+ disable_hover ? "no-hover" : nil
59
42
  end
60
43
 
61
44
  def container_class
62
- true_value(configured_container, "table-card", nil)
63
- end
64
-
65
- def kit_class
66
- table_options = [
67
- "pb_table",
68
- size_class,
69
- single_line_class,
70
- dark_class,
71
- disable_hover_class,
72
- container_class,
73
- ]
74
- table_options.reject(&:nil?).join(" ")
75
- end
76
-
77
- def yield(context:)
78
- context.capture(&block)
79
- end
80
-
81
- def to_partial_path
82
- "pb_table/table"
83
- end
84
-
85
- private
86
-
87
- DEFAULT = Object.new
88
- private_constant :DEFAULT
89
- def default_configuration
90
- DEFAULT
45
+ container ? "table-card" : nil
91
46
  end
92
- attr_accessor(*PROPS)
93
47
  end
94
48
  end
95
49
  end