playbook_ui 2.9.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11ec65aa572925990ddc23d8c9521e99045750e0f967ef7732d54f003eaca22d
|
|
4
|
+
data.tar.gz: 1474fe089227a407b0cd6aebf4ca91d76796f82f8a8b9ee0dc6e959c446c2cbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aaf2117516558be2dd79460a31c6068cf974dfa16b6a79dffd8c685181e3988aa7628778b38c3427782df349b7c41d5881808a328da83256e6c781ee3c076b50
|
|
7
|
+
data.tar.gz: ca26c3f6b7ed8c8a822068661c7169c739ac26c8b9e2a129588db90e9787bd07883d2e9cd4faaee6cdf78458a298c322feb951cb09a28afede5ba3d109c40f3a
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Playbook Design System
|
|
2
2
|
|
|
3
|
-
Playbook is the first design system built for both Rails & React interfaces. Inspired by [Velocity](https://www.invisionapp.com/inside-design/design-resources/design-system-dashboard-ui-kit/), Playbook takes a modern design approach, and applies it in a way that makes it easy to support bleeding edge, or legacy systems. Playbook is built & maintained by the User Experience &
|
|
3
|
+
Playbook is the first design system built for both Rails & React interfaces. Inspired by [Velocity](https://www.invisionapp.com/inside-design/design-resources/design-system-dashboard-ui-kit/), Playbook takes a modern design approach, and applies it in a way that makes it easy to support bleeding edge, or legacy systems. Playbook is built & maintained by the User Experience & Development teams at Power Home Remodeling, the largest home remodeler in the US.
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
@@ -34,7 +34,11 @@ module Playbook
|
|
|
34
34
|
|
|
35
35
|
def pb_kit_api(kit)
|
|
36
36
|
kit_class_obj = get_class_name(kit)
|
|
37
|
-
@kit_api = kit_class_obj
|
|
37
|
+
@kit_api = if kit_class_obj < Playbook::PbKit::Base
|
|
38
|
+
kit_class_obj.instance_method(:initialize).parameters.map(&:last)
|
|
39
|
+
else
|
|
40
|
+
kit_class_obj.props.keys
|
|
41
|
+
end
|
|
38
42
|
render partial: "playbook/config/pb_kit_api"
|
|
39
43
|
end
|
|
40
44
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// React Component JSX Imports from the React Kits
|
|
2
|
+
import Avatar from "./pb_avatar/_avatar.jsx"
|
|
3
|
+
import BarGraph from "./pb_bar_graph/_bar_graph.jsx"
|
|
4
|
+
import Body from "./pb_body/_body.jsx"
|
|
5
|
+
import Button from "./pb_button/_button.jsx"
|
|
6
|
+
import Caption from "./pb_caption/_caption.jsx"
|
|
7
|
+
import Card from "./pb_card/_card.jsx"
|
|
8
|
+
import DashboardValue from "./pb_dashboard_value/_dashboard_value.jsx"
|
|
9
|
+
import DateYearStacked from "./pb_date_year_stacked/_date_year_stacked.jsx"
|
|
10
|
+
import DateRangeInline from "./pb_date_range_inline/_date_range_inline.jsx"
|
|
11
|
+
import DistributionBar from "./pb_distribution_bar/_distribution_bar.jsx"
|
|
12
|
+
import Icon from "./pb_icon/_icon.jsx"
|
|
13
|
+
import Image from "./pb_image/_image.jsx"
|
|
14
|
+
import Input from "./pb_input/_input.jsx"
|
|
15
|
+
import LabelValue from "./pb_label_value/_label_value.jsx"
|
|
16
|
+
import Layout from "./pb_layout/_layout.jsx"
|
|
17
|
+
import LineGraph from "./pb_line_graph/_line_graph.jsx"
|
|
18
|
+
import List from "./pb_list/_list.jsx"
|
|
19
|
+
import Message from "./pb_message/_message.jsx"
|
|
20
|
+
import OnlineStatus from "./pb_online_status/_online_status.jsx"
|
|
21
|
+
import Table from "./pb_table/_table.jsx"
|
|
22
|
+
import TimeStamp from "./pb_timestamp/_timestamp.jsx"
|
|
23
|
+
import Title from "./pb_title/_title.jsx"
|
|
24
|
+
import User from "./pb_user/_user.jsx"
|
|
25
|
+
import VerticalNav from "./pb_vertical_nav/_vertical_nav.jsx"
|
|
26
|
+
import Pill from "./pb_pill/_pill.jsx"
|
|
27
|
+
import Currency from "./pb_currency/_currency.jsx"
|
|
28
|
+
import Toggle from "./pb_toggle/_toggle.jsx"
|
|
29
|
+
|
|
30
|
+
// Dashboard Settings
|
|
31
|
+
import commonSettings from "./pb_dashboard/commonSettings"
|
|
32
|
+
import lineGraphSettings from "./pb_line_graph/lineGraphSettings"
|
|
33
|
+
import barGraphSettings from "./pb_bar_graph/barGraphSettings"
|
|
34
|
+
import dashboardValueSettings from "./pb_dashboard_value/dashboardValueSettings"
|
|
35
|
+
|
|
36
|
+
// Other JS/Plugins
|
|
37
|
+
import pbChart from "./plugins/pb_chart_plugin"
|
|
38
|
+
|
|
39
|
+
// All Exports for Consumption in Nitro
|
|
40
|
+
export {
|
|
41
|
+
Avatar,
|
|
42
|
+
BarGraph,
|
|
43
|
+
Body,
|
|
44
|
+
Button,
|
|
45
|
+
Caption,
|
|
46
|
+
Card,
|
|
47
|
+
DashboardValue,
|
|
48
|
+
DateYearStacked,
|
|
49
|
+
DateRangeInline,
|
|
50
|
+
DistributionBar,
|
|
51
|
+
Icon,
|
|
52
|
+
Image,
|
|
53
|
+
Input,
|
|
54
|
+
LabelValue,
|
|
55
|
+
Layout,
|
|
56
|
+
LineGraph,
|
|
57
|
+
List,
|
|
58
|
+
Message,
|
|
59
|
+
OnlineStatus,
|
|
60
|
+
Table,
|
|
61
|
+
TimeStamp,
|
|
62
|
+
Title,
|
|
63
|
+
User,
|
|
64
|
+
VerticalNav,
|
|
65
|
+
Pill,
|
|
66
|
+
Currency,
|
|
67
|
+
Toggle,
|
|
68
|
+
commonSettings,
|
|
69
|
+
lineGraphSettings,
|
|
70
|
+
barGraphSettings,
|
|
71
|
+
dashboardValueSettings,
|
|
72
|
+
pbChart,
|
|
73
|
+
}
|
|
@@ -128,3 +128,27 @@ WebpackerReact.setup (SectionSeparator);
|
|
|
128
128
|
|
|
129
129
|
import * as Currency from "pb_currency/docs";
|
|
130
130
|
WebpackerReact.setup (Currency);
|
|
131
|
+
|
|
132
|
+
import * as FixedConfirmationToast from "pb_fixed_confirmation_toast/docs";
|
|
133
|
+
WebpackerReact.setup (FixedConfirmationToast);
|
|
134
|
+
|
|
135
|
+
import * as LoadingInline from "pb_loading_inline/docs";
|
|
136
|
+
WebpackerReact.setup (LoadingInline);
|
|
137
|
+
|
|
138
|
+
import * as Checkbox from "pb_checkbox/docs";
|
|
139
|
+
WebpackerReact.setup (Checkbox);
|
|
140
|
+
|
|
141
|
+
import * as HomeAddressStreet from "pb_home_address_street/docs";
|
|
142
|
+
WebpackerReact.setup (HomeAddressStreet);
|
|
143
|
+
|
|
144
|
+
import * as Badge from "pb_badge/docs";
|
|
145
|
+
WebpackerReact.setup (Badge);
|
|
146
|
+
|
|
147
|
+
import * as DateYearStacked from "pb_date_year_stacked/docs";
|
|
148
|
+
WebpackerReact.setup (DateYearStacked);
|
|
149
|
+
|
|
150
|
+
import * as DateRangeInline from "pb_date_range_inline/docs";
|
|
151
|
+
WebpackerReact.setup (DateRangeInline);
|
|
152
|
+
|
|
153
|
+
import * as DistributionBar from "pb_distribution_bar/docs";
|
|
154
|
+
WebpackerReact.setup (DistributionBar);
|
|
@@ -38,3 +38,11 @@ import "./pb_stat_value.js";
|
|
|
38
38
|
import "./pb_stat_change.js";
|
|
39
39
|
import "./pb_section_separator.js";
|
|
40
40
|
import "./pb_currency.js";
|
|
41
|
+
import "./pb_fixed_confirmation_toast.js";
|
|
42
|
+
import "./pb_loading_inline.js";
|
|
43
|
+
import "./pb_checkbox.js";
|
|
44
|
+
import "./pb_home_address_street.js";
|
|
45
|
+
import "./pb_badge.js";
|
|
46
|
+
import "./pb_date_year_stacked.js";
|
|
47
|
+
import "./pb_date_range_inline.js";
|
|
48
|
+
import "./pb_distribution_bar.js";
|
|
@@ -39,3 +39,11 @@
|
|
|
39
39
|
@import '../../pb_stat_change/stat_change';
|
|
40
40
|
@import '../../pb_section_separator/section_separator';
|
|
41
41
|
@import '../../pb_currency/currency';
|
|
42
|
+
@import '../../pb_fixed_confirmation_toast/fixed_confirmation_toast';
|
|
43
|
+
@import '../../pb_loading_inline/loading_inline';
|
|
44
|
+
@import '../../pb_home_address_street/home_address_street';
|
|
45
|
+
@import '../../pb_badge/badge';
|
|
46
|
+
@import '../../pb_checkbox/checkbox';
|
|
47
|
+
@import '../../pb_date_year_stacked/date_year_stacked';
|
|
48
|
+
@import '../../pb_date_range_inline/date_range_inline';
|
|
49
|
+
@import '../../pb_distribution_bar/distribution_bar';
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
|
|
7
|
+
type BadgeProps = {
|
|
8
|
+
className?: String,
|
|
9
|
+
id?: String,
|
|
10
|
+
text?: String,
|
|
11
|
+
variant?: 'success' | 'warning' | 'error' | 'info' | 'neutral',
|
|
12
|
+
rounded?: Boolean
|
|
13
|
+
}
|
|
14
|
+
const Badge = ({
|
|
15
|
+
className,
|
|
16
|
+
id,
|
|
17
|
+
text,
|
|
18
|
+
variant = 'neutral',
|
|
19
|
+
rounded = false
|
|
20
|
+
}: BadgeProps) => {
|
|
21
|
+
const roundedValue = rounded == true ? "rounded" : ""
|
|
22
|
+
const css = classnames([
|
|
23
|
+
`pb_badge_kit_${variant}_${roundedValue}`,
|
|
24
|
+
className,
|
|
25
|
+
])
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div id={id} className={css}>
|
|
29
|
+
<span>{text}</span>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default Badge
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@import "../tokens/border_radius";
|
|
2
|
+
@import "../tokens/colors";
|
|
3
|
+
@import "../tokens/opacity";
|
|
4
|
+
@import "../tokens/spacing";
|
|
5
|
+
@import "../tokens/typography";
|
|
6
|
+
|
|
7
|
+
[class^=pb_badge_kit] {
|
|
8
|
+
$pb_badge_height: 18px;
|
|
9
|
+
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
border-radius: $border_rad_light;
|
|
14
|
+
padding: 0 $space_xs / 2;
|
|
15
|
+
border: 1px solid $white;
|
|
16
|
+
|
|
17
|
+
span {
|
|
18
|
+
transform: translateY(1px);
|
|
19
|
+
display: inline-block;
|
|
20
|
+
font-size: $font_smaller - 2;
|
|
21
|
+
font-weight: $boldest;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@each $color_name, $color_value in $status_colors {
|
|
25
|
+
&[class*=_#{$color_name}] {
|
|
26
|
+
background: rgba($color_value, $opacity-1);
|
|
27
|
+
color: $color_value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&[class*="rounded"] {
|
|
32
|
+
height: $pb_badge_height;
|
|
33
|
+
min-height: $pb_badge_height;
|
|
34
|
+
min-width: $pb_badge_height;
|
|
35
|
+
border-radius: $pb_badge_height / 2;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Playbook
|
|
4
|
+
module PbBadge
|
|
5
|
+
class Badge < Playbook::PbKit::Base
|
|
6
|
+
PROPS = %i[
|
|
7
|
+
configured_classname
|
|
8
|
+
configured_data
|
|
9
|
+
configured_id
|
|
10
|
+
configured_text
|
|
11
|
+
configured_variant
|
|
12
|
+
configured_rounded
|
|
13
|
+
].freeze
|
|
14
|
+
|
|
15
|
+
def initialize(classname: default_configuration,
|
|
16
|
+
data: default_configuration,
|
|
17
|
+
id: default_configuration,
|
|
18
|
+
text: default_configuration,
|
|
19
|
+
variant: default_configuration,
|
|
20
|
+
rounded: default_configuration)
|
|
21
|
+
self.configured_classname = classname
|
|
22
|
+
self.configured_data = data
|
|
23
|
+
self.configured_id = id
|
|
24
|
+
self.configured_text = text
|
|
25
|
+
self.configured_variant = variant
|
|
26
|
+
self.configured_rounded = rounded
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def text
|
|
30
|
+
default_value(configured_text, "")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def rounded
|
|
34
|
+
true_value(configured_rounded, "rounded", nil)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def variant
|
|
38
|
+
variant_options = %w[success warning error info neutral primary]
|
|
39
|
+
one_of_value(configured_variant, variant_options, "neutral")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def kit_class
|
|
43
|
+
kit_options = [
|
|
44
|
+
"pb_badge_kit",
|
|
45
|
+
variant,
|
|
46
|
+
rounded,
|
|
47
|
+
]
|
|
48
|
+
kit_options.compact.join("_")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def to_partial_path
|
|
52
|
+
"pb_badge/badge"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
DEFAULT = Object.new
|
|
58
|
+
private_constant :DEFAULT
|
|
59
|
+
def default_configuration
|
|
60
|
+
DEFAULT
|
|
61
|
+
end
|
|
62
|
+
attr_accessor(*PROPS)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<%= pb_rails("badge", props: {
|
|
3
|
+
text: "+1",
|
|
4
|
+
variant: "primary",
|
|
5
|
+
rounded: true
|
|
6
|
+
}) %>
|
|
7
|
+
|
|
8
|
+
<%= pb_rails("badge", props: {
|
|
9
|
+
text: "+4",
|
|
10
|
+
variant: "primary"
|
|
11
|
+
}) %>
|
|
12
|
+
|
|
13
|
+
<%= pb_rails("badge", props: {
|
|
14
|
+
text: "+1000",
|
|
15
|
+
variant: "primary",
|
|
16
|
+
}) %>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div>
|
|
20
|
+
<%= pb_rails("badge", props: {
|
|
21
|
+
text: "+1",
|
|
22
|
+
variant: "success",
|
|
23
|
+
rounded: true
|
|
24
|
+
}) %>
|
|
25
|
+
|
|
26
|
+
<%= pb_rails("badge", props: {
|
|
27
|
+
text: "+4",
|
|
28
|
+
variant: "success"
|
|
29
|
+
}) %>
|
|
30
|
+
|
|
31
|
+
<%= pb_rails("badge", props: {
|
|
32
|
+
text: "+1000",
|
|
33
|
+
variant: "success"
|
|
34
|
+
}) %>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div>
|
|
38
|
+
<%= pb_rails("badge", props: {
|
|
39
|
+
text: "+1",
|
|
40
|
+
variant: "warning",
|
|
41
|
+
rounded: true
|
|
42
|
+
}) %>
|
|
43
|
+
|
|
44
|
+
<%= pb_rails("badge", props: {
|
|
45
|
+
text: "+4",
|
|
46
|
+
variant: "warning"
|
|
47
|
+
}) %>
|
|
48
|
+
|
|
49
|
+
<%= pb_rails("badge", props: {
|
|
50
|
+
text: "+1000",
|
|
51
|
+
variant: "warning"
|
|
52
|
+
}) %>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div>
|
|
56
|
+
<%= pb_rails("badge", props: {
|
|
57
|
+
text: "+1",
|
|
58
|
+
variant: "error",
|
|
59
|
+
rounded: true
|
|
60
|
+
}) %>
|
|
61
|
+
|
|
62
|
+
<%= pb_rails("badge", props: {
|
|
63
|
+
text: "+4",
|
|
64
|
+
variant: "error"
|
|
65
|
+
}) %>
|
|
66
|
+
|
|
67
|
+
<%= pb_rails("badge", props: {
|
|
68
|
+
text: "+1000",
|
|
69
|
+
variant: "error"
|
|
70
|
+
}) %>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div>
|
|
74
|
+
<%= pb_rails("badge", props: {
|
|
75
|
+
text: "+1",
|
|
76
|
+
variant: "info",
|
|
77
|
+
rounded: true
|
|
78
|
+
}) %>
|
|
79
|
+
|
|
80
|
+
<%= pb_rails("badge", props: {
|
|
81
|
+
text: "+4",
|
|
82
|
+
variant: "info"
|
|
83
|
+
}) %>
|
|
84
|
+
|
|
85
|
+
<%= pb_rails("badge", props: {
|
|
86
|
+
text: "+1000",
|
|
87
|
+
variant: "info"
|
|
88
|
+
}) %>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div>
|
|
92
|
+
<%= pb_rails("badge", props: {
|
|
93
|
+
text: "+1",
|
|
94
|
+
variant: "neutral",
|
|
95
|
+
rounded: true
|
|
96
|
+
}) %>
|
|
97
|
+
|
|
98
|
+
<%= pb_rails("badge", props: {
|
|
99
|
+
text: "+4",
|
|
100
|
+
variant: "neutral"
|
|
101
|
+
}) %>
|
|
102
|
+
|
|
103
|
+
<%= pb_rails("badge", props: {
|
|
104
|
+
text: "+1000",
|
|
105
|
+
variant: "neutral"
|
|
106
|
+
}) %>
|
|
107
|
+
</div>
|