playbook_ui 2.9.0 → 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/helpers/playbook/pb_doc_helper.rb +5 -1
- data/app/pb_kits/playbook/index.js +73 -0
- data/app/pb_kits/playbook/packs/examples.js +24 -0
- data/app/pb_kits/playbook/packs/kits.js +8 -0
- data/app/pb_kits/playbook/packs/pb_badge.js +4 -0
- data/app/pb_kits/playbook/packs/pb_checkbox.js +4 -0
- data/app/pb_kits/playbook/packs/pb_date_range_inline.js +4 -0
- data/app/pb_kits/playbook/packs/pb_date_year_stacked.js +4 -0
- data/app/pb_kits/playbook/packs/pb_distribution_bar.js +4 -0
- data/app/pb_kits/playbook/packs/pb_fixed_confirmation_toast.js +4 -0
- data/app/pb_kits/playbook/packs/pb_home_address_street.js +4 -0
- data/app/pb_kits/playbook/packs/pb_loading_inline.js +4 -0
- data/app/pb_kits/playbook/packs/site_styles/_kit_style_index.scss +8 -0
- data/app/pb_kits/playbook/pb_badge/_badge.html.erb +6 -0
- data/app/pb_kits/playbook/pb_badge/_badge.jsx +34 -0
- data/app/pb_kits/playbook/pb_badge/_badge.scss +37 -0
- data/app/pb_kits/playbook/pb_badge/badge.rb +65 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_colors.html.erb +107 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_colors.jsx +82 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_default.html.erb +16 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_default.jsx +20 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded.html.erb +19 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded.jsx +20 -0
- data/app/pb_kits/playbook/pb_badge/docs/example.yml +10 -0
- data/app/pb_kits/playbook/pb_badge/docs/index.js +3 -0
- data/app/pb_kits/playbook/pb_caption/_caption.html.erb +1 -1
- data/app/pb_kits/playbook/pb_caption/_caption.scss +2 -2
- data/app/pb_kits/playbook/pb_caption/caption.rb +24 -56
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.html.erb +10 -0
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +42 -0
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +66 -0
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +94 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_dark.html.erb +1 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +8 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date/date.rb +14 -23
- data/app/pb_kits/playbook/pb_date/docs/_date_default.html.erb +3 -3
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.html.erb +22 -0
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.jsx +54 -0
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.scss +3 -0
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb +55 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_default.jsx +12 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.html.erb +7 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.jsx +51 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.scss +17 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.rb +75 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_dark.html.erb +5 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_dark.jsx +14 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_default.html.erb +5 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_default.jsx +14 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.html.erb +8 -0
- data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.jsx +52 -0
- data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.scss +31 -0
- data/app/pb_kits/playbook/pb_distribution_bar/distribution_bar.rb +56 -0
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_default.html.erb +9 -0
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_default.jsx +24 -0
- data/app/pb_kits/playbook/pb_distribution_bar/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_distribution_bar/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.html.erb +7 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx +58 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +27 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_default.html.erb +18 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_default.jsx +26 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +74 -0
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.html.erb +25 -0
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.jsx +64 -0
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.scss +20 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_dark.html.erb +9 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_dark.jsx +18 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.html.erb +8 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +11 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +80 -0
- data/app/pb_kits/playbook/pb_kit/dateTime.js +45 -0
- data/app/pb_kits/playbook/pb_kit/pb_date_time.rb +68 -0
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.html.erb +6 -0
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.jsx +31 -0
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.scss +19 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_dark.html.erb +13 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_dark.jsx +14 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_light.html.erb +9 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_light.jsx +14 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/example.yml +11 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.rb +67 -0
- data/app/pb_kits/playbook/pb_time/docs/_time_default.html.erb +3 -3
- data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.html.erb +3 -3
- data/app/pb_kits/playbook/pb_time/time.rb +16 -29
- data/app/pb_kits/playbook/pb_toggle/toggle.rb +2 -0
- data/app/pb_kits/playbook/props.rb +45 -0
- data/app/pb_kits/playbook/props/base.rb +27 -0
- data/app/pb_kits/playbook/props/boolean.rb +11 -0
- data/app/pb_kits/playbook/props/enum.rb +16 -0
- data/app/pb_kits/playbook/props/hash.rb +11 -0
- data/app/pb_kits/playbook/props/string.rb +8 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
- data/app/pb_kits/playbook/tokens/_transition.scss +1 -0
- data/lib/playbook/engine.rb +0 -1
- data/lib/playbook/version.rb +1 -1
- metadata +148 -22
- data/app/pb_kits/playbook/packs/index.js +0 -67
- data/lib/tasks/db.rake +0 -10
- data/stories/basic.js +0 -18
- data/stories/complex.js +0 -15
- data/stories/form.js +0 -2
- data/stories/index.js +0 -29
@@ -0,0 +1,5 @@
|
|
1
|
+
<%= pb_rails "date_year_stacked", props: { date: Date.today, dark: true } %>
|
2
|
+
<br><br>
|
3
|
+
<%= pb_rails "date_year_stacked", props: { date: Date.today, align: 'center', dark: true } %>
|
4
|
+
<br><br>
|
5
|
+
<%= pb_rails "date_year_stacked", props: { date: Date.today, align: 'right', dark: true } %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { DateYearStacked } from "../../"
|
3
|
+
|
4
|
+
function DateYearStackedDark() {
|
5
|
+
return (
|
6
|
+
<div>
|
7
|
+
<DateYearStacked date={new Date() } dark />
|
8
|
+
<DateYearStacked align='center' date={new Date() } dark />
|
9
|
+
<DateYearStacked align='right' date={new Date() } dark />
|
10
|
+
</div>
|
11
|
+
)
|
12
|
+
}
|
13
|
+
|
14
|
+
export default DateYearStackedDark
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { DateYearStacked } from "../../"
|
3
|
+
|
4
|
+
function DateYearStackedDefault() {
|
5
|
+
return (
|
6
|
+
<div>
|
7
|
+
<DateYearStacked date={new Date() } />
|
8
|
+
<DateYearStacked align='center' date={new Date() } />
|
9
|
+
<DateYearStacked align='right' date={new Date() } />
|
10
|
+
</div>
|
11
|
+
)
|
12
|
+
}
|
13
|
+
|
14
|
+
export default DateYearStackedDefault;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/* @flow */
|
2
|
+
/*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
|
3
|
+
|
4
|
+
import React from 'react'
|
5
|
+
|
6
|
+
type DistributionBarProps = {
|
7
|
+
className?: String,
|
8
|
+
data?: String,
|
9
|
+
id?: String,
|
10
|
+
size?: 'lg' | 'sm',
|
11
|
+
values?: Array<Number>,
|
12
|
+
}
|
13
|
+
|
14
|
+
const normalizeCharacters = (values) => {
|
15
|
+
return values.map( value => {
|
16
|
+
return parseInt(value.toString().replace(/[^0-9.]/gi, ''))
|
17
|
+
})
|
18
|
+
}
|
19
|
+
|
20
|
+
const barValues = (normalizedValues) => {
|
21
|
+
let arrSum = value => value.reduce((a,b) => (a + b), 0)
|
22
|
+
let valueSum = arrSum(normalizedValues)
|
23
|
+
return normalizedValues.map((value,i) => {
|
24
|
+
return(
|
25
|
+
<div
|
26
|
+
key={i}
|
27
|
+
className={`pb_distribution_value`}
|
28
|
+
style={{width:`${value*100/valueSum}%`}}
|
29
|
+
/>
|
30
|
+
)
|
31
|
+
})
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
const DistributionBar = ({
|
37
|
+
className,
|
38
|
+
data,
|
39
|
+
id,
|
40
|
+
size='lg',
|
41
|
+
values=[1]
|
42
|
+
}: DistributionBarProps) => {
|
43
|
+
const normalizedValues = normalizeCharacters(values)
|
44
|
+
|
45
|
+
return(
|
46
|
+
<div className={`pb_distribution_bar_${size}`}>
|
47
|
+
{barValues(normalizedValues)}
|
48
|
+
</div>
|
49
|
+
)
|
50
|
+
}
|
51
|
+
|
52
|
+
export default DistributionBar
|
@@ -0,0 +1,31 @@
|
|
1
|
+
@import "../tokens/colors";
|
2
|
+
|
3
|
+
[class^=pb_distribution_bar] {
|
4
|
+
$bar_colors: map-values($data_colors);
|
5
|
+
$small_bar: 8px;
|
6
|
+
$large_bar: 36px;
|
7
|
+
display: flex;
|
8
|
+
.pb_distribution_value {
|
9
|
+
height: 100%;
|
10
|
+
display: inline-block;
|
11
|
+
@for $i from 1 through length($bar_colors) {
|
12
|
+
&:nth-child(#{length($bar_colors)}n+#{$i}) {
|
13
|
+
background-color: nth($bar_colors, $i);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
&:first-child {
|
17
|
+
border-top-left-radius: 18px;
|
18
|
+
border-bottom-left-radius: 18px;
|
19
|
+
}
|
20
|
+
&:last-child {
|
21
|
+
border-top-right-radius: 18px;
|
22
|
+
border-bottom-right-radius: 18px;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
&[class*=_sm] {
|
26
|
+
height: $small_bar;
|
27
|
+
}
|
28
|
+
&[class*=_lg] {
|
29
|
+
height: $large_bar;
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbDistributionBar
|
5
|
+
class DistributionBar < Playbook::PbKit::Base
|
6
|
+
PROPS = %i[configured_classname
|
7
|
+
configured_data
|
8
|
+
configured_id
|
9
|
+
configured_size
|
10
|
+
configured_values].freeze
|
11
|
+
|
12
|
+
def initialize(classname: default_configuration,
|
13
|
+
data: default_configuration,
|
14
|
+
id: default_configuration,
|
15
|
+
size: default_configuration,
|
16
|
+
values: default_configuration)
|
17
|
+
self.configured_classname = classname
|
18
|
+
self.configured_data = data
|
19
|
+
self.configured_id = id
|
20
|
+
self.configured_size = size
|
21
|
+
self.configured_values = values
|
22
|
+
end
|
23
|
+
|
24
|
+
def size
|
25
|
+
size_options = %w[lg sm]
|
26
|
+
one_of_value(configured_size, size_options, "lg")
|
27
|
+
end
|
28
|
+
|
29
|
+
def values
|
30
|
+
default_value(values_to_percents, [1])
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_partial_path
|
34
|
+
"pb_distribution_bar/distribution_bar"
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
DEFAULT = Object.new
|
40
|
+
private_constant :DEFAULT
|
41
|
+
def default_configuration
|
42
|
+
DEFAULT
|
43
|
+
end
|
44
|
+
attr_accessor(*PROPS)
|
45
|
+
|
46
|
+
def normalize_characters(value)
|
47
|
+
return value.to_s.gsub(/(\d\.\d)|[^a-zA-Z\d]/, '\\1').to_i
|
48
|
+
end
|
49
|
+
|
50
|
+
def values_to_percents
|
51
|
+
normalized_values = configured_values.map(&method(:normalize_characters))
|
52
|
+
normalized_values.map { |value| (value.to_f * 100 / normalized_values.sum ).round(2) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import DistributionBar from "../_distribution_bar.jsx"
|
3
|
+
|
4
|
+
function DistributionBarDefault() {
|
5
|
+
return (
|
6
|
+
<React.Fragment>
|
7
|
+
<div>
|
8
|
+
<DistributionBar
|
9
|
+
values={[1,2,3,4,5,3,3,7]}
|
10
|
+
/>
|
11
|
+
</div>
|
12
|
+
<br/>
|
13
|
+
<br/>
|
14
|
+
<div>
|
15
|
+
<DistributionBar
|
16
|
+
size='sm'
|
17
|
+
values={[1,2,3,4,5,3,3,7]}
|
18
|
+
/>
|
19
|
+
</div>
|
20
|
+
</React.Fragment>
|
21
|
+
)
|
22
|
+
}
|
23
|
+
|
24
|
+
export default DistributionBarDefault;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {default as DistributionBarDefault} from './_distribution_bar_default.jsx';
|
@@ -0,0 +1,58 @@
|
|
1
|
+
/* @flow */
|
2
|
+
/*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
|
3
|
+
|
4
|
+
import React from 'react'
|
5
|
+
import classnames from 'classnames'
|
6
|
+
import Title from "../pb_title/_title.jsx"
|
7
|
+
import Icon from "../pb_icon/_icon.jsx"
|
8
|
+
|
9
|
+
type FixedConfirmationToastProps = {
|
10
|
+
className?: String,
|
11
|
+
data?: String,
|
12
|
+
id?: String,
|
13
|
+
status?: 'success' | 'error' | 'neutral',
|
14
|
+
text: String,
|
15
|
+
}
|
16
|
+
|
17
|
+
const FixedConfirmationToast = ({
|
18
|
+
className,
|
19
|
+
data,
|
20
|
+
id,
|
21
|
+
status='neutral',
|
22
|
+
text
|
23
|
+
}: FixedConfirmationToastProps) => {
|
24
|
+
const css = classnames([
|
25
|
+
`pb_fixed_confirmation_toast_kit_${status}`,
|
26
|
+
className,
|
27
|
+
])
|
28
|
+
|
29
|
+
const icon = (function(status) {
|
30
|
+
switch(status) {
|
31
|
+
case "success":
|
32
|
+
return "check";
|
33
|
+
case "error":
|
34
|
+
return "exclamation-triangle";
|
35
|
+
case "neutral":
|
36
|
+
return "info-circle";
|
37
|
+
default:
|
38
|
+
return null;
|
39
|
+
}
|
40
|
+
})(status)
|
41
|
+
|
42
|
+
const displayIcon = function(icon) {
|
43
|
+
if (icon) {
|
44
|
+
return (
|
45
|
+
<Icon icon={icon} fixed_width={true} className="pb_icon"/>
|
46
|
+
)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
return (
|
51
|
+
<div className={css}>
|
52
|
+
{displayIcon(icon)}
|
53
|
+
<Title size={4} className="pb_fixed_confirmation_toast_text" text={text} />
|
54
|
+
</div>
|
55
|
+
)
|
56
|
+
}
|
57
|
+
|
58
|
+
export default FixedConfirmationToast
|
@@ -0,0 +1,27 @@
|
|
1
|
+
@import "../tokens/spacing";
|
2
|
+
@import "../tokens/colors";
|
3
|
+
@import "../pb_body/body";
|
4
|
+
|
5
|
+
$pb_pill_height: 25px;
|
6
|
+
|
7
|
+
[class^=pb_fixed_confirmation_toast_kit] {
|
8
|
+
display: inline-flex;
|
9
|
+
justify-content: center;
|
10
|
+
align-items: center;
|
11
|
+
padding: $space_xs $space-md;
|
12
|
+
border-radius: $pb_pill_height;
|
13
|
+
|
14
|
+
@each $color_name, $color_value in $status_colors {
|
15
|
+
&[class*=_#{$color_name}] {
|
16
|
+
background: $color_value;
|
17
|
+
|
18
|
+
.pb_fixed_confirmation_toast_text {
|
19
|
+
color: $white;
|
20
|
+
margin: 0 $space_md 0 $space_md;
|
21
|
+
}
|
22
|
+
.pb_icon {
|
23
|
+
color: $white;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%= pb_rails("fixed_confirmation_toast", props: {
|
2
|
+
text: "Error Message",
|
3
|
+
status: "error"
|
4
|
+
})%>
|
5
|
+
|
6
|
+
<br><br>
|
7
|
+
|
8
|
+
<%= pb_rails("fixed_confirmation_toast", props: {
|
9
|
+
text: "Items Successfully Moved",
|
10
|
+
status: "success"
|
11
|
+
})%>
|
12
|
+
|
13
|
+
<br><br>
|
14
|
+
|
15
|
+
<%= pb_rails("fixed_confirmation_toast", props: {
|
16
|
+
text: "Scan to Assign Selected Items",
|
17
|
+
status: "neutral"
|
18
|
+
})%>
|
data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_default.jsx
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import FixedConfirmationToast from "../_fixed_confirmation_toast.jsx"
|
3
|
+
|
4
|
+
function FixedConfirmationToastDefault() {
|
5
|
+
return (
|
6
|
+
<div>
|
7
|
+
<div>
|
8
|
+
<FixedConfirmationToast text="Error Message" status="error" />
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<br/><br/>
|
12
|
+
|
13
|
+
<div>
|
14
|
+
<FixedConfirmationToast text="Items Successfully Moved" status="success" />
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<br/><br/>
|
18
|
+
|
19
|
+
<div>
|
20
|
+
<FixedConfirmationToast text="Scan to Assign Selected Items" status="neutral" />
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
)
|
24
|
+
}
|
25
|
+
|
26
|
+
export default FixedConfirmationToastDefault;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {default as FixedConfirmationToastDefault} from './_fixed_confirmation_toast_default.jsx';
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbFixedConfirmationToast
|
5
|
+
class FixedConfirmationToast < Playbook::PbKit::Base
|
6
|
+
PROPS = %i[configured_classname
|
7
|
+
configured_data
|
8
|
+
configured_id
|
9
|
+
configured_status
|
10
|
+
configured_text].freeze
|
11
|
+
|
12
|
+
def initialize(classname: default_configuration,
|
13
|
+
data: default_configuration,
|
14
|
+
id: default_configuration,
|
15
|
+
status: default_configuration,
|
16
|
+
text: default_configuration)
|
17
|
+
self.configured_classname = classname
|
18
|
+
self.configured_data = data
|
19
|
+
self.configured_id = id
|
20
|
+
self.configured_status = status
|
21
|
+
self.configured_text = text
|
22
|
+
end
|
23
|
+
|
24
|
+
def text
|
25
|
+
if is_set? configured_text
|
26
|
+
pb_text = Playbook::PbTitle::Title.new(size: 4, text: configured_text, classname: "pb_fixed_confirmation_toast_text")
|
27
|
+
ApplicationController.renderer.render(partial: pb_text, as: :object)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def kit_class
|
32
|
+
kit_options = [
|
33
|
+
"pb_fixed_confirmation_toast_kit",
|
34
|
+
status,
|
35
|
+
]
|
36
|
+
kit_options.join("_")
|
37
|
+
end
|
38
|
+
|
39
|
+
def status
|
40
|
+
status_options = %w[success error neutral]
|
41
|
+
one_of_value(configured_status, status_options, "neutral")
|
42
|
+
end
|
43
|
+
|
44
|
+
def icon
|
45
|
+
pb_icon = Playbook::PbIcon::Icon.new(icon: icon_value, classname: "pb_icon")
|
46
|
+
ApplicationController.renderer.render(partial: pb_icon, as: :object)
|
47
|
+
end
|
48
|
+
|
49
|
+
def icon_value
|
50
|
+
case status
|
51
|
+
when "success"
|
52
|
+
"check"
|
53
|
+
when "error"
|
54
|
+
"exclamation-triangle"
|
55
|
+
when "neutral"
|
56
|
+
"info-circle"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_partial_path
|
61
|
+
"pb_fixed_confirmation_toast/fixed_confirmation_toast"
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
DEFAULT = Object.new
|
67
|
+
private_constant :DEFAULT
|
68
|
+
def default_configuration
|
69
|
+
DEFAULT
|
70
|
+
end
|
71
|
+
attr_accessor(*PROPS)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|