playbook_ui 2.8.3 → 2.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/packs/examples.js +15 -0
  3. data/app/pb_kits/playbook/packs/kits.js +5 -0
  4. data/app/pb_kits/playbook/packs/pb_label_pill.js +4 -0
  5. data/app/pb_kits/playbook/packs/pb_owner.js +4 -0
  6. data/app/pb_kits/playbook/packs/pb_owner_phone.js +4 -0
  7. data/app/pb_kits/playbook/packs/pb_phone.js +4 -0
  8. data/app/pb_kits/playbook/packs/pb_toggle.js +4 -0
  9. data/app/pb_kits/playbook/packs/site_styles/_kit_style_index.scss +5 -0
  10. data/app/pb_kits/playbook/pb_label_pill/_label_pill.html.erb +7 -0
  11. data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +21 -0
  12. data/app/pb_kits/playbook/pb_label_pill/_label_pill.scss +11 -0
  13. data/app/pb_kits/playbook/pb_label_pill/docs/_label_pill_default.html.erb +34 -0
  14. data/app/pb_kits/playbook/pb_label_pill/docs/_label_pill_default.jsx +12 -0
  15. data/app/pb_kits/playbook/pb_label_pill/docs/example.yml +9 -0
  16. data/app/pb_kits/playbook/pb_label_pill/docs/index.js +1 -0
  17. data/app/pb_kits/playbook/pb_label_pill/label_pill.rb +58 -0
  18. data/app/pb_kits/playbook/pb_list/_list.html.erb +1 -1
  19. data/app/pb_kits/playbook/pb_list/_list.jsx +3 -3
  20. data/app/pb_kits/playbook/pb_list/_list.scss +1 -1
  21. data/app/pb_kits/playbook/pb_list/docs/_list_dark_lg.html.erb +1 -1
  22. data/app/pb_kits/playbook/pb_list/docs/_list_lg.html.erb +1 -1
  23. data/app/pb_kits/playbook/pb_list/list.rb +8 -7
  24. data/app/pb_kits/playbook/pb_owner/_owner.html.erb +7 -0
  25. data/app/pb_kits/playbook/pb_owner/_owner.jsx +21 -0
  26. data/app/pb_kits/playbook/pb_owner/_owner.scss +11 -0
  27. data/app/pb_kits/playbook/pb_owner/docs/_owner_default.html.erb +1 -0
  28. data/app/pb_kits/playbook/pb_owner/docs/_owner_default.jsx +12 -0
  29. data/app/pb_kits/playbook/pb_owner/docs/example.yml +9 -0
  30. data/app/pb_kits/playbook/pb_owner/docs/index.js +1 -0
  31. data/app/pb_kits/playbook/pb_owner/owner.rb +52 -0
  32. data/app/pb_kits/playbook/pb_owner_phone/_owner_phone.html.erb +7 -0
  33. data/app/pb_kits/playbook/pb_owner_phone/_owner_phone.jsx +21 -0
  34. data/app/pb_kits/playbook/pb_owner_phone/_owner_phone.scss +9 -0
  35. data/app/pb_kits/playbook/pb_owner_phone/docs/_owner_phone_default.html.erb +6 -0
  36. data/app/pb_kits/playbook/pb_owner_phone/docs/_owner_phone_default.jsx +12 -0
  37. data/app/pb_kits/playbook/pb_owner_phone/docs/example.yml +9 -0
  38. data/app/pb_kits/playbook/pb_owner_phone/docs/index.js +1 -0
  39. data/app/pb_kits/playbook/pb_owner_phone/owner_phone.rb +64 -0
  40. data/app/pb_kits/playbook/pb_phone/_phone.html.erb +6 -0
  41. data/app/pb_kits/playbook/pb_phone/_phone.jsx +21 -0
  42. data/app/pb_kits/playbook/pb_phone/_phone.scss +2 -0
  43. data/app/pb_kits/playbook/pb_phone/docs/_phone_default.html.erb +4 -0
  44. data/app/pb_kits/playbook/pb_phone/docs/_phone_default.jsx +12 -0
  45. data/app/pb_kits/playbook/pb_phone/docs/example.yml +9 -0
  46. data/app/pb_kits/playbook/pb_phone/docs/index.js +1 -0
  47. data/app/pb_kits/playbook/pb_phone/phone.rb +69 -0
  48. data/app/pb_kits/playbook/pb_toggle/_toggle.html.erb +12 -0
  49. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +21 -0
  50. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +57 -0
  51. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_checked.html.erb +11 -0
  52. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_default.html.erb +11 -0
  53. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_default.jsx +13 -0
  54. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +9 -0
  55. data/app/pb_kits/playbook/pb_toggle/docs/index.js +1 -0
  56. data/app/pb_kits/playbook/pb_toggle/toggle.rb +59 -0
  57. data/lib/generators/kit/kit_generator.rb +13 -9
  58. data/lib/generators/kit/templates/kit_ruby.erb.tt +3 -1
  59. data/lib/playbook/engine.rb +1 -0
  60. data/lib/playbook/version.rb +1 -1
  61. data/lib/tasks/pb_release.rake +69 -0
  62. metadata +92 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88af885a58e4ee6538f8a527e4f69ae4c334cc66990c400b50833c0ac1ed4ebc
4
- data.tar.gz: a7353385a886a78bf220c8b00392d70e302c5b5d2c483383ef27fdabf6d8abba
3
+ metadata.gz: 8103129ad1d322c76959bc5b98dbc4a3095e6ab93f8b6ce108c3397d99d3e7da
4
+ data.tar.gz: 39bfc2b2780273550f8ad5038e51f561d695fafecf2785a49631932c9ed06bb0
5
5
  SHA512:
6
- metadata.gz: 2eba9841644ec01148f9e3ac33eb0d1188072b0a5d923824de41dc4c5cc5bc30b4b0a4302add5efff96077cfa51b54ec2a755c7c8dc91152f90a8cf0adc8c81b
7
- data.tar.gz: 20ddce91e64c88df034ba328468bd660a77d1de6106b08ff060a92aa563159f70335305b2aefdf766a20755f747eded6896a75739879f1d7e9aa030dbfc0562d
6
+ metadata.gz: c1af634076f6e690736128754f66c197790f27a4db4b58f7afe0e8f3bb0e22e43b1c3f822fdbfb607466c47e7652a40c00319499146e6f6f06191e7029a30098
7
+ data.tar.gz: aee625c328eb90beec7784d2de3169da58c3ff6c73492e728a0bb605b06ba04a7e9eec1882468f19a7452723d8ad216a89d94baf5f01a0a5d51327a0846a731f
@@ -95,3 +95,18 @@ WebpackerReact.setup (Timestamp);
95
95
 
96
96
  import * as OnlineStatus from "pb_online_status/docs";
97
97
  WebpackerReact.setup (OnlineStatus);
98
+
99
+ import * as LabelPill from "pb_label_pill/docs";
100
+ WebpackerReact.setup (LabelPill);
101
+
102
+ import * as Phone from "pb_phone/docs";
103
+ WebpackerReact.setup (Phone);
104
+
105
+ import * as OwnerPhone from "pb_owner_phone/docs";
106
+ WebpackerReact.setup (OwnerPhone);
107
+
108
+ import * as Owner from "pb_owner/docs";
109
+ WebpackerReact.setup (Owner);
110
+
111
+ import * as Toggle from "pb_toggle/docs";
112
+ WebpackerReact.setup (Toggle);
@@ -27,3 +27,8 @@ import "./pb_label_value.js";
27
27
  import "./pb_message.js";
28
28
  import "./pb_timestamp.js";
29
29
  import "./pb_online_status.js";
30
+ import "./pb_label_pill.js";
31
+ import "./pb_phone.js";
32
+ import "./pb_owner_phone.js";
33
+ import "./pb_owner.js";
34
+ import "./pb_toggle.js";
@@ -0,0 +1,4 @@
1
+ import LabelPill from "pb_label_pill/_label_pill.jsx";
2
+
3
+ import WebpackerReact from "webpacker-react";
4
+ WebpackerReact.setup({ LabelPill });
@@ -0,0 +1,4 @@
1
+ import Owner from "pb_owner/_owner.jsx";
2
+
3
+ import WebpackerReact from "webpacker-react";
4
+ WebpackerReact.setup({ Owner });
@@ -0,0 +1,4 @@
1
+ import OwnerPhone from "pb_owner_phone/_owner_phone.jsx";
2
+
3
+ import WebpackerReact from "webpacker-react";
4
+ WebpackerReact.setup({ OwnerPhone });
@@ -0,0 +1,4 @@
1
+ import Phone from "pb_phone/_phone.jsx";
2
+
3
+ import WebpackerReact from "webpacker-react";
4
+ WebpackerReact.setup({ Phone });
@@ -0,0 +1,4 @@
1
+ import Toggle from "pb_toggle/_toggle.jsx";
2
+
3
+ import WebpackerReact from "webpacker-react";
4
+ WebpackerReact.setup({ Toggle });
@@ -29,3 +29,8 @@
29
29
  @import '../../pb_message/message';
30
30
  @import '../../pb_timestamp/timestamp';
31
31
  @import '../../pb_online_status/online_status';
32
+ @import '../../pb_label_pill/label_pill';
33
+ @import '../../pb_phone/phone';
34
+ @import '../../pb_owner_phone/owner_phone';
35
+ @import '../../pb_owner/owner';
36
+ @import '../../pb_toggle/toggle';
@@ -0,0 +1,7 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname("pb_label_pill")) do %>
5
+ <%= object.label %>
6
+ <%= object.pill %>
7
+ <% end %>
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import PropTypes from "prop-types";
3
+
4
+ const propTypes = {
5
+ className: PropTypes.string,
6
+ id: PropTypes.string
7
+ };
8
+
9
+ class LabelPill extends React.Component {
10
+ render() {
11
+ return (
12
+ <div className="pb_label_pill">
13
+ <span>LABEL PILL CONTENT</span>
14
+ </div>
15
+ )
16
+ }
17
+ }
18
+
19
+ LabelPill.propTypes = propTypes;
20
+
21
+ export default LabelPill;
@@ -0,0 +1,11 @@
1
+ @import "../pb_caption/caption";
2
+ @import "../pb_pill/pill";
3
+
4
+ .pb_label_pill {
5
+ display: flex;
6
+ justify-content: flex-start;
7
+ align-items: center;
8
+ &_label {
9
+ margin-right: $space-xs;
10
+ }
11
+ }
@@ -0,0 +1,34 @@
1
+ <%= pb_rails("label_pill", props: {
2
+ label: "Service Needed",
3
+ pill_value: "76",
4
+ }) %>
5
+
6
+ <%= pb_rails("label_pill", props: {
7
+ label: "Waiting",
8
+ pill_value: "69",
9
+ variant: "success"
10
+ }) %>
11
+
12
+ <%= pb_rails("label_pill", props: {
13
+ label: "In Service",
14
+ pill_value: "28",
15
+ variant: "error"
16
+ }) %>
17
+
18
+ <%= pb_rails("label_pill", props: {
19
+ label: "Fully Serviced",
20
+ pill_value: "198",
21
+ variant: "warning"
22
+ }) %>
23
+
24
+ <%= pb_rails("label_pill", props: {
25
+ label: "Inbox",
26
+ pill_value: "198",
27
+ variant: "info"
28
+ }) %>
29
+
30
+ <%= pb_rails("label_pill", props: {
31
+ label: "Outbox",
32
+ pill_value: "198",
33
+ variant: "neutral"
34
+ }) %>
@@ -0,0 +1,12 @@
1
+ import React from "react"
2
+ import LabelPill from "../_label_pill.jsx"
3
+
4
+ function LabelPillDefault() {
5
+ return (
6
+ <div>
7
+ <LabelPill />
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default LabelPillDefault;
@@ -0,0 +1,9 @@
1
+ examples:
2
+
3
+ rails:
4
+ - label_pill_default: Default
5
+
6
+
7
+ react:
8
+ - label_pill_default: Default
9
+
@@ -0,0 +1 @@
1
+ export {default as LabelPillDefault} from './_label_pill_default.jsx';
@@ -0,0 +1,58 @@
1
+ module Playbook
2
+ module PbLabelPill
3
+ class LabelPill < Playbook::PbKit::Base
4
+ PROPS = [:configured_classname,
5
+ :configured_data,
6
+ :configured_id,
7
+ :configured_label,
8
+ :configured_pill_value,
9
+ :configured_variant].freeze
10
+
11
+ def initialize(classname: default_configuration,
12
+ data: default_configuration,
13
+ id: default_configuration,
14
+ label: default_configuration,
15
+ pill_value: default_configuration,
16
+ variant: default_configuration
17
+ )
18
+ self.configured_classname = classname
19
+ self.configured_data = data
20
+ self.configured_id = id
21
+ self.configured_label = label
22
+ self.configured_pill_value = pill_value
23
+ self.configured_variant = variant
24
+ end
25
+
26
+ def label
27
+ if is_set? configured_label
28
+ pb_caption = Playbook::PbCaption::Caption.new(text: configured_label, classname: "pb_label_pill_label")
29
+ ApplicationController.renderer.render(partial: pb_caption, as: :object)
30
+ end
31
+ end
32
+
33
+ def pill
34
+ if is_set? configured_pill_value
35
+ pb_pill = Playbook::PbPill::Pill.new(text: configured_pill_value, variant: variant, classname: "pb_label_pill_pill")
36
+ ApplicationController.renderer.render(partial: pb_pill, as: :object)
37
+ end
38
+ end
39
+
40
+ def variant
41
+ default_value(configured_variant, "")
42
+ end
43
+
44
+ def to_partial_path
45
+ "pb_label_pill/label_pill"
46
+ end
47
+
48
+ private
49
+
50
+ DEFAULT = Object.new
51
+ private_constant :DEFAULT
52
+ def default_configuration
53
+ DEFAULT
54
+ end
55
+ attr_accessor(*PROPS)
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,5 @@
1
1
  <%= content_tag(:div,
2
- class: "pb_list#{object.xpadding}#{object.borderless}#{object.dark}#{object.lg}#{object.layout}") do %>
2
+ class: "pb_list#{object.xpadding}#{object.borderless}#{object.dark}#{object.size}#{object.layout}") do %>
3
3
  <%= content_tag(:"#{object.ordered}",
4
4
  id: object.id,
5
5
  data: object.data,
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
4
4
  const propTypes = {
5
5
  dark:PropTypes.bool,
6
6
  borderless:PropTypes.bool,
7
- size:PropTypes.bool,
7
+ size:PropTypes.oneOf(["", "large"]),
8
8
  ordered:PropTypes.bool,
9
9
  layout: PropTypes.oneOf(["", "left", "right"]),
10
10
  xpadding:PropTypes.bool,
@@ -17,7 +17,7 @@ const propTypes = {
17
17
  const defaultProps = {
18
18
  dark:false,
19
19
  borderless:false,
20
- size:false,
20
+ size:"",
21
21
  ordered:false,
22
22
  layout:"",
23
23
  xpadding:false
@@ -36,7 +36,7 @@ class List extends Component {
36
36
  } = this.props;
37
37
  const dark_class = dark === true ? "_dark" : ""
38
38
  const borderless_class = borderless === true ? "list_borderless" : ""
39
- const size_class = size === true ? "_lg" : ""
39
+ const size_class = "_" + size
40
40
  const ordered_class = ordered === true ? "_ordered" : ""
41
41
  const layout_class = "_"+ layout
42
42
  const xpadding_class = xpadding === true ? "_xpadding" : ""
@@ -9,7 +9,7 @@
9
9
  @include pb_list_dark;
10
10
  }
11
11
 
12
- &[class*=_lg] li {
12
+ &[class*=_large] li {
13
13
  @include pb_list_large;
14
14
  }
15
15
 
@@ -1,4 +1,4 @@
1
- <%= pb_rails("list", props: {ordered: false, dark: true, borderless: false, lg: true}) do %>
1
+ <%= pb_rails("list", props: {ordered: false, dark: true, borderless: false, size: "large"}) do %>
2
2
  <%= pb_rails("list/item") do %> List Item <% end %>
3
3
  <%= pb_rails("list/item") do %> List Item <% end %>
4
4
  <%= pb_rails("list/item") do %> List Item <% end %>
@@ -1,4 +1,4 @@
1
- <%= pb_rails("list", props: {ordered: false, dark: false, borderless: false, lg: true}) do %>
1
+ <%= pb_rails("list", props: {ordered: false, dark: false, borderless: false, size: "large"}) do %>
2
2
  <%= pb_rails("list/item") do %> List Item <% end %>
3
3
  <%= pb_rails("list/item") do %> List Item <% end %>
4
4
  <%= pb_rails("list/item") do %> List Item <% end %>
@@ -9,7 +9,7 @@ module Playbook
9
9
  configured_data
10
10
  configured_id
11
11
  configured_layout
12
- configured_lg
12
+ configured_size
13
13
  configured_ordered
14
14
  configured_xpadding
15
15
  block].freeze
@@ -20,7 +20,7 @@ module Playbook
20
20
  data: default_configuration,
21
21
  id: default_configuration,
22
22
  layout: default_configuration,
23
- lg: default_configuration,
23
+ size: default_configuration,
24
24
  ordered: default_configuration,
25
25
  xpadding: default_configuration,
26
26
  &block)
@@ -30,7 +30,7 @@ module Playbook
30
30
  self.configured_data = data
31
31
  self.configured_id = id
32
32
  self.configured_layout = layout
33
- self.configured_lg = lg
33
+ self.configured_size = size
34
34
  self.configured_ordered = ordered
35
35
  self.configured_xpadding = xpadding
36
36
  self.block = block_given? ? block : nil
@@ -62,11 +62,12 @@ module Playbook
62
62
  end
63
63
  end
64
64
 
65
- def lg
66
- if configured_lg == default_configuration
65
+ def size
66
+ case configured_size
67
+ when default_configuration
67
68
  ""
68
- elsif configured_lg == true
69
- "_lg"
69
+ when "large"
70
+ "_large"
70
71
  end
71
72
  end
72
73
 
@@ -0,0 +1,7 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname("pb_owner")) do %>
5
+ <%= object.first_name %>
6
+ <%= object.last_name %>
7
+ <% end %>
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import PropTypes from "prop-types";
3
+
4
+ const propTypes = {
5
+ className: PropTypes.string,
6
+ id: PropTypes.string
7
+ };
8
+
9
+ class Owner extends React.Component {
10
+ render() {
11
+ return (
12
+ <div className="pb_owner">
13
+ <span>OWNER CONTENT</span>
14
+ </div>
15
+ )
16
+ }
17
+ }
18
+
19
+ Owner.propTypes = propTypes;
20
+
21
+ export default Owner;
@@ -0,0 +1,11 @@
1
+ @import "../pb_title/title";
2
+ @import "../pb_body/body";
3
+ @import "../tokens/spacing";
4
+
5
+ .pb_owner {
6
+ display: flex;
7
+ align-items: baseline;
8
+ &_first {
9
+ margin: 0 ($space_xs - 4px) 0 0;
10
+ }
11
+ }
@@ -0,0 +1 @@
1
+ <%= pb_rails("owner", props: { first_name: "Kyle", last_name: "Fadigan" }) %>
@@ -0,0 +1,12 @@
1
+ import React from "react"
2
+ import Owner from "../_owner.jsx"
3
+
4
+ function OwnerDefault() {
5
+ return (
6
+ <div>
7
+ <Owner />
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default OwnerDefault;
@@ -0,0 +1,9 @@
1
+ examples:
2
+
3
+ rails:
4
+ - owner_default: Default
5
+
6
+
7
+ react:
8
+ - owner_default: Default
9
+
@@ -0,0 +1 @@
1
+ export {default as OwnerDefault} from './_owner_default.jsx';
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbOwner
5
+ class Owner < Playbook::PbKit::Base
6
+ PROPS = [:configured_classname,
7
+ :configured_data,
8
+ :configured_id,
9
+ :configured_first_name,
10
+ :configured_last_name].freeze
11
+
12
+ def initialize(classname: default_configuration,
13
+ data: default_configuration,
14
+ id: default_configuration,
15
+ first_name: default_configuration,
16
+ last_name: default_configuration)
17
+ self.configured_classname = classname
18
+ self.configured_data = data
19
+ self.configured_id = id
20
+ self.configured_first_name = first_name
21
+ self.configured_last_name = last_name
22
+ end
23
+
24
+ def first_name
25
+ pb_first_name = Playbook::PbBody::Body.new(classname: "pb_owner_first") do
26
+ default_value(configured_first_name, "")
27
+ end
28
+ ApplicationController.renderer.render(partial: pb_first_name, as: :object)
29
+ end
30
+
31
+ def last_name
32
+ if is_set? configured_last_name
33
+ pb_last_name = Playbook::PbTitle::Title.new(text: configured_last_name, size: 4)
34
+ ApplicationController.renderer.render(partial: pb_last_name, as: :object)
35
+ end
36
+ end
37
+
38
+ def to_partial_path
39
+ "pb_owner/owner"
40
+ end
41
+
42
+ private
43
+
44
+ DEFAULT = Object.new
45
+ private_constant :DEFAULT
46
+ def default_configuration
47
+ DEFAULT
48
+ end
49
+ attr_accessor(*PROPS)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,7 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname("pb_owner_phone")) do %>
5
+ <%= object.name %>
6
+ <%= object.phone %>
7
+ <% end %>
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import PropTypes from "prop-types";
3
+
4
+ const propTypes = {
5
+ className: PropTypes.string,
6
+ id: PropTypes.string
7
+ };
8
+
9
+ class OwnerPhone extends React.Component {
10
+ render() {
11
+ return (
12
+ <div className="pb_owner_phone">
13
+ <span>OWNER PHONE CONTENT</span>
14
+ </div>
15
+ )
16
+ }
17
+ }
18
+
19
+ OwnerPhone.propTypes = propTypes;
20
+
21
+ export default OwnerPhone;
@@ -0,0 +1,9 @@
1
+ @import "../tokens/spacing";
2
+
3
+ .pb_owner_phone {
4
+ display: flex;
5
+ justify-content: flex-start;
6
+ align-items: flex-start;
7
+ flex-direction: column;
8
+
9
+ }
@@ -0,0 +1,6 @@
1
+ <%= pb_rails("owner_phone", props: {
2
+ icon: "mobile",
3
+ first_name: "Pauline",
4
+ last_name: "Smith",
5
+ number: "(610) 234-5678"
6
+ }) %>
@@ -0,0 +1,12 @@
1
+ import React from "react"
2
+ import OwnerPhone from "../_owner_phone.jsx"
3
+
4
+ function OwnerPhoneDefault() {
5
+ return (
6
+ <div>
7
+ <OwnerPhone />
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default OwnerPhoneDefault;
@@ -0,0 +1,9 @@
1
+ examples:
2
+
3
+ rails:
4
+ - owner_phone_default: Default
5
+
6
+
7
+ react:
8
+ - owner_phone_default: Default
9
+
@@ -0,0 +1 @@
1
+ export {default as OwnerPhoneDefault} from './_owner_phone_default.jsx';
@@ -0,0 +1,64 @@
1
+ module Playbook
2
+ module PbOwnerPhone
3
+ class OwnerPhone < Playbook::PbKit::Base
4
+ PROPS = [:configured_classname,
5
+ :configured_data,
6
+ :configured_id,
7
+ :configured_first_name,
8
+ :configured_last_name,
9
+ :configured_number,
10
+ :configured_icon].freeze
11
+
12
+ def initialize(classname: default_configuration,
13
+ data: default_configuration,
14
+ id: default_configuration,
15
+ first_name: default_configuration,
16
+ last_name: default_configuration,
17
+ number: default_configuration,
18
+ icon: default_configuration)
19
+ self.configured_classname = classname
20
+ self.configured_data = data
21
+ self.configured_id = id
22
+ self.configured_first_name = first_name
23
+ self.configured_last_name = last_name
24
+ self.configured_number = number
25
+ self.configured_icon = icon
26
+ end
27
+
28
+ def icon
29
+ if is_set? configured_icon
30
+ configured_icon
31
+ end
32
+ end
33
+
34
+ def phone
35
+ phone = Playbook::PbPhone::Phone.new({ icon: configured_icon, number: configured_number })
36
+ ApplicationController.renderer.render(partial: phone, as: :object)
37
+ end
38
+
39
+ def name
40
+ owner = Playbook::PbOwner::Owner.new({ first_name: configured_first_name, last_name: configured_last_name })
41
+ ApplicationController.renderer.render(partial: owner, as: :object)
42
+ end
43
+
44
+ def number
45
+ if is_set? configured_number
46
+ configured_number
47
+ end
48
+ end
49
+
50
+ def to_partial_path
51
+ "pb_owner_phone/owner_phone"
52
+ end
53
+
54
+ private
55
+
56
+ DEFAULT = Object.new
57
+ private_constant :DEFAULT
58
+ def default_configuration
59
+ DEFAULT
60
+ end
61
+ attr_accessor(*PROPS)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,6 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname("pb_phone")) do %>
5
+ <span><%= object.value %></span>
6
+ <% end %>
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import PropTypes from "prop-types";
3
+
4
+ const propTypes = {
5
+ className: PropTypes.string,
6
+ id: PropTypes.string
7
+ };
8
+
9
+ class Phone extends React.Component {
10
+ render() {
11
+ return (
12
+ <div className="pb_phone">
13
+ <span>PHONE CONTENT</span>
14
+ </div>
15
+ )
16
+ }
17
+ }
18
+
19
+ Phone.propTypes = propTypes;
20
+
21
+ export default Phone;
@@ -0,0 +1,2 @@
1
+ @import "../pb_body/body";
2
+ @import "../pb_icon/icon";
@@ -0,0 +1,4 @@
1
+ <%= pb_rails("phone", props: {
2
+ icon: "mobile-android",
3
+ number: 3491859988
4
+ }) %>