playbook_ui 10.25.0.pre.alpha3 → 10.26.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/data/menu.yml +1 -0
- data/app/pb_kits/playbook/index.js +2 -1
- data/app/pb_kits/playbook/pb_body/{_body.jsx → _body.tsx} +24 -19
- data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_caption/{_caption.jsx → _caption.tsx} +7 -8
- data/app/pb_kits/playbook/pb_card/_card.jsx +4 -2
- data/app/pb_kits/playbook/pb_card/_card.scss +3 -1
- data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_header.html.erb +30 -4
- data/app/pb_kits/playbook/pb_card/docs/_card_header.jsx +52 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +2 -2
- data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +37 -0
- data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +37 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_custom_description.jsx +38 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_custom_description.md +1 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +1 -1
- data/app/pb_kits/playbook/pb_highlight/{_highlight.jsx → _highlight.tsx} +14 -12
- data/app/pb_kits/playbook/pb_highlight/docs/_highlight_default.jsx +2 -2
- data/app/pb_kits/playbook/pb_kit/dateTime.js +1 -2
- data/app/pb_kits/playbook/pb_pill/_pill.jsx +1 -1
- data/app/pb_kits/playbook/pb_radio/_radio.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/{_title.jsx → _title.tsx} +10 -12
- data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +79 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +5 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +37 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +48 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +2 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +37 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +47 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +3 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +79 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +90 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +1 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +54 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +65 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +3 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +37 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +48 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +3 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +15 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +5 -0
- data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +1 -0
- data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +43 -0
- data/app/pb_kits/playbook/playbook-doc.js +2 -0
- data/app/pb_kits/playbook/playbook-rails-react-bindings.js +2 -0
- data/app/pb_kits/playbook/plugins/pb_chart.js +34 -0
- data/app/pb_kits/playbook/utilities/_background_colors.scss +1 -1
- data/app/pb_kits/playbook/utilities/_colors.scss +8 -0
- data/app/pb_kits/playbook/utilities/_flex_direction.scss +28 -15
- data/app/pb_kits/playbook/utilities/globalProps.ts +94 -110
- data/app/pb_kits/playbook/utilities/text.ts +22 -0
- data/dist/reset.css +60 -1
- data/lib/playbook/flex_direction.rb +7 -1
- data/lib/playbook/version.rb +2 -2
- metadata +32 -9
- data/app/pb_kits/playbook/utilities/text.js +0 -15
@@ -0,0 +1 @@
|
|
1
|
+
<%= react_component('TreemapChart', object.chart_options) %>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbTreemapChart
|
5
|
+
class TreemapChart < Playbook::KitBase
|
6
|
+
prop :chart_data, type: Playbook::Props::Array,
|
7
|
+
default: []
|
8
|
+
prop :colors, type: Playbook::Props::Array,
|
9
|
+
default: []
|
10
|
+
prop :drillable, type: Playbook::Props::Boolean, default: false
|
11
|
+
prop :grouped, type: Playbook::Props::Boolean, default: false
|
12
|
+
prop :height
|
13
|
+
prop :title, default: ""
|
14
|
+
prop :tooltip_html, default: '<span style="font-weight: bold; color:{point.color};">● </span>
|
15
|
+
{point.name}: ' + '<b>{point.value}
|
16
|
+
</b>'
|
17
|
+
|
18
|
+
def chart_type
|
19
|
+
"treemap"
|
20
|
+
end
|
21
|
+
|
22
|
+
def chart_options
|
23
|
+
{
|
24
|
+
chartData: chart_data,
|
25
|
+
className: classname,
|
26
|
+
colors: colors,
|
27
|
+
dark: dark ? "dark" : "",
|
28
|
+
drillable: drillable,
|
29
|
+
grouped: grouped,
|
30
|
+
height: height,
|
31
|
+
id: id,
|
32
|
+
title: title,
|
33
|
+
tooltipHtml: tooltip_html,
|
34
|
+
type: chart_type,
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def classname
|
39
|
+
generate_classname("pb_treemap_chart")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -91,6 +91,7 @@ import * as Title from 'pb_title/docs'
|
|
91
91
|
import * as TitleCount from 'pb_title_count/docs'
|
92
92
|
import * as TitleDetail from 'pb_title_detail/docs'
|
93
93
|
import * as Toggle from 'pb_toggle/docs'
|
94
|
+
import * as TreemapChart from 'pb_treemap_chart/docs'
|
94
95
|
import * as Typeahead from 'pb_typeahead/docs'
|
95
96
|
import * as User from 'pb_user/docs'
|
96
97
|
import * as UserBadge from 'pb_user_badge/docs'
|
@@ -185,6 +186,7 @@ WebpackerReact.setup({
|
|
185
186
|
...TitleCount,
|
186
187
|
...TitleDetail,
|
187
188
|
...Toggle,
|
189
|
+
...TreemapChart,
|
188
190
|
...Typeahead,
|
189
191
|
...User,
|
190
192
|
...UserBadge,
|
@@ -13,6 +13,7 @@ import Legend from './pb_legend/_legend'
|
|
13
13
|
import LineGraph from './pb_line_graph/_line_graph'
|
14
14
|
import Passphrase from './pb_passphrase/_passphrase'
|
15
15
|
import RichTextEditor from './pb_rich_text_editor/_rich_text_editor'
|
16
|
+
import TreemapChart from './pb_treemap_chart/_treemap_chart'
|
16
17
|
import Typeahead from './pb_typeahead/_typeahead'
|
17
18
|
|
18
19
|
WebpackerReact.registerComponents({
|
@@ -26,6 +27,7 @@ WebpackerReact.registerComponents({
|
|
26
27
|
LineGraph,
|
27
28
|
Passphrase,
|
28
29
|
RichTextEditor,
|
30
|
+
TreemapChart,
|
29
31
|
Typeahead,
|
30
32
|
})
|
31
33
|
|
@@ -7,6 +7,7 @@ import colors from '../tokens/exports/_colors.scss'
|
|
7
7
|
import pie from 'highcharts/modules/variable-pie'
|
8
8
|
import highchartsMore from 'highcharts/highcharts-more'
|
9
9
|
import solidGauge from 'highcharts/modules/solid-gauge'
|
10
|
+
import treemap from 'highcharts/modules/treemap'
|
10
11
|
|
11
12
|
pie(Highcharts)
|
12
13
|
|
@@ -63,6 +64,8 @@ class pbChart {
|
|
63
64
|
this.setupPieChart(options)
|
64
65
|
} else if (this.options.type == 'gauge') {
|
65
66
|
this.setupGauge(options)
|
67
|
+
} else if (this.options.type == 'treemap') {
|
68
|
+
this.setupTreemap(options)
|
66
69
|
} else {
|
67
70
|
this.setupChart(options)
|
68
71
|
}
|
@@ -191,6 +194,37 @@ class pbChart {
|
|
191
194
|
})
|
192
195
|
}
|
193
196
|
|
197
|
+
setupTreemap(options) {
|
198
|
+
treemap(Highcharts)
|
199
|
+
this.setupTheme()
|
200
|
+
options.dark ? Highcharts.setOptions(highchartsDarkTheme) : Highcharts.setOptions(highchartsTheme)
|
201
|
+
|
202
|
+
Highcharts.chart(this.defaults.id, {
|
203
|
+
title: {
|
204
|
+
text: this.defaults.title,
|
205
|
+
},
|
206
|
+
chart: {
|
207
|
+
height: this.defaults.height,
|
208
|
+
type: this.defaults.type,
|
209
|
+
},
|
210
|
+
credits: false,
|
211
|
+
series: [{
|
212
|
+
data: this.defaults.chartData,
|
213
|
+
}],
|
214
|
+
plotOptions: {
|
215
|
+
treemap: {
|
216
|
+
allowTraversingTree: this.defaults.drillable,
|
217
|
+
colorByPoint: !this.defaults.grouped,
|
218
|
+
colors: options.colors !== undefined && options.colors.length > 0 ? mapColors(options.colors) : highchartsTheme.colors,
|
219
|
+
},
|
220
|
+
},
|
221
|
+
tooltip: {
|
222
|
+
pointFormat: this.defaults.tooltipHtml,
|
223
|
+
useHTML: true,
|
224
|
+
},
|
225
|
+
})
|
226
|
+
}
|
227
|
+
|
194
228
|
setupChart(options) {
|
195
229
|
this.setupTheme()
|
196
230
|
const configOptions = {
|
@@ -6,6 +6,14 @@
|
|
6
6
|
@return mix($bg_dark, $color, $percentage);
|
7
7
|
}
|
8
8
|
|
9
|
+
@function lightenText($color, $threshold: 47) {
|
10
|
+
$text_color: $text_lt_default;
|
11
|
+
@if ((type-of($color) == color) and (lightness($color) < $threshold)) {
|
12
|
+
$text_color: $text_dk_default;
|
13
|
+
}
|
14
|
+
@return $text_color;
|
15
|
+
}
|
16
|
+
|
9
17
|
@mixin background-color($colors-list) {
|
10
18
|
@each $name, $color in $colors-list {
|
11
19
|
.#{$name} {
|
@@ -1,19 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
$flex_direction_values: (
|
2
|
+
row: row,
|
3
|
+
column: column,
|
4
|
+
row_reverse: row-reverse,
|
5
|
+
column_reverse: column-reverse
|
6
|
+
);
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
$media-query-breakpoints: (
|
9
|
+
xs: "xs",
|
10
|
+
sm: "sm",
|
11
|
+
md: "md",
|
12
|
+
lg: "lg",
|
13
|
+
xl: "xl"
|
14
|
+
);
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
16
|
+
@each $flex-direction, $flex-direction-value in $flex_direction_values {
|
17
|
+
.flex_direction_#{$flex-direction} {
|
18
|
+
display: flex;
|
19
|
+
flex-direction: #{$flex-direction-value} !important;
|
20
|
+
}
|
14
21
|
}
|
15
22
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
@each $flex-direction, $flex-direction-value in $flex_direction_values {
|
24
|
+
@each $breakpoint, $breakpoint-value in $media-query-breakpoints {
|
25
|
+
.flex_direction_#{$breakpoint}_#{$flex-direction} {
|
26
|
+
display: flex;
|
27
|
+
@include break_at( breakpoint($breakpoint-value)) {
|
28
|
+
flex-direction: #{$flex-direction-value} !important;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
@@ -1,74 +1,54 @@
|
|
1
|
+
// Please keep these in alphabetical order
|
1
2
|
import { omit } from 'lodash'
|
3
|
+
import { camelToSnakeCase } from './text'
|
2
4
|
|
3
|
-
type
|
4
|
-
type None = "none"
|
5
|
-
|
6
|
-
type AllSizes = None & Sizes
|
7
|
-
|
8
|
-
type Margin = {
|
9
|
-
marginRight?: AllSizes,
|
10
|
-
marginLeft?: AllSizes,
|
11
|
-
marginTop?: AllSizes,
|
12
|
-
marginBottom?: AllSizes,
|
13
|
-
marginX?: AllSizes,
|
14
|
-
marginY?: AllSizes,
|
15
|
-
margin?: AllSizes,
|
16
|
-
}
|
17
|
-
|
18
|
-
type Padding = {
|
19
|
-
paddingRight?: AllSizes,
|
20
|
-
paddingLeft?: AllSizes,
|
21
|
-
paddingTop?: AllSizes,
|
22
|
-
paddingBottom?: AllSizes,
|
23
|
-
paddingX?: AllSizes,
|
24
|
-
paddingY?: AllSizes,
|
25
|
-
padding?: AllSizes,
|
26
|
-
}
|
5
|
+
type Alignment = "start" | "end" | "center"
|
27
6
|
|
28
|
-
type
|
29
|
-
|
7
|
+
type AlignContent = {
|
8
|
+
alignContent?: Alignment & Space
|
30
9
|
}
|
31
10
|
|
32
|
-
type
|
33
|
-
|
11
|
+
type AlignItems = {
|
12
|
+
alignItems?: Alignment & ("flexStart" | "flexEnd" | "stretch" | "baseline")
|
34
13
|
}
|
35
14
|
|
36
|
-
type
|
37
|
-
|
15
|
+
type AlignSelf = {
|
16
|
+
alignSelf?: Alignment & ("auto" | "stretch" | "baseline")
|
38
17
|
}
|
18
|
+
type AllSizes = None & Sizes
|
39
19
|
|
40
|
-
type
|
41
|
-
|
20
|
+
type BorderRadius = {
|
21
|
+
borderRadius?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "rounded",
|
42
22
|
}
|
43
23
|
|
44
|
-
type
|
45
|
-
|
24
|
+
type Cursor = {
|
25
|
+
cursor?: "pointer",
|
46
26
|
}
|
47
27
|
|
48
|
-
type
|
49
|
-
|
28
|
+
type Dark = {
|
29
|
+
dark?: boolean,
|
50
30
|
}
|
51
31
|
|
52
32
|
type Display = {
|
53
33
|
display?: "block" | "flex" | "hidden" | "inline_block" | "inline" | "inline_flex",
|
54
34
|
}
|
55
35
|
|
56
|
-
type Cursor = {
|
57
|
-
cursor?: "pointer",
|
58
|
-
}
|
59
|
-
|
60
|
-
type BorderRadius = {
|
61
|
-
borderRadius?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "rounded",
|
62
|
-
}
|
63
|
-
|
64
36
|
type Flex = {
|
65
37
|
flex?: "none" | "initial" | "auto" | 1
|
66
38
|
}
|
67
39
|
|
68
40
|
type FlexDirection = {
|
69
|
-
flexDirection?:
|
41
|
+
flexDirection?: {
|
42
|
+
xs?: FlexDirectionOptions,
|
43
|
+
sm?: FlexDirectionOptions,
|
44
|
+
md?: FlexDirectionOptions,
|
45
|
+
lg?: FlexDirectionOptions,
|
46
|
+
xl?: FlexDirectionOptions,
|
47
|
+
}
|
70
48
|
}
|
71
49
|
|
50
|
+
type FlexDirectionOptions = "row" | "column" | "row_reverse" | "column_reverse"
|
51
|
+
|
72
52
|
type FlexGrow = {
|
73
53
|
flexGrow?: 0 | 1
|
74
54
|
}
|
@@ -78,13 +58,9 @@ type FlexShrink = {
|
|
78
58
|
}
|
79
59
|
|
80
60
|
type FlexWrap = {
|
81
|
-
flexWrap?: "wrap" | "nowrap" | "
|
61
|
+
flexWrap?: "wrap" | "nowrap" | "reverse",
|
82
62
|
}
|
83
63
|
|
84
|
-
type Alignment = "start" | "end" | "center"
|
85
|
-
|
86
|
-
type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
|
87
|
-
|
88
64
|
type JustifyContent = {
|
89
65
|
justifyContent?: Alignment & Space
|
90
66
|
}
|
@@ -93,22 +69,57 @@ type JustifySelf = {
|
|
93
69
|
justifySelf?: Alignment & ("auto" | "stretch")
|
94
70
|
}
|
95
71
|
|
96
|
-
type
|
97
|
-
|
72
|
+
type LineHeight = {
|
73
|
+
lineHeight?: "loosest" | "looser" | "loose" | "normal" | "tight" | "tighter" | "tightest",
|
98
74
|
}
|
99
75
|
|
100
|
-
type
|
101
|
-
|
76
|
+
type Margin = {
|
77
|
+
marginRight?: AllSizes,
|
78
|
+
marginLeft?: AllSizes,
|
79
|
+
marginTop?: AllSizes,
|
80
|
+
marginBottom?: AllSizes,
|
81
|
+
marginX?: AllSizes,
|
82
|
+
marginY?: AllSizes,
|
83
|
+
margin?: AllSizes,
|
102
84
|
}
|
103
85
|
|
104
|
-
type
|
105
|
-
|
86
|
+
type MaxWidth = {
|
87
|
+
maxWidth?: Sizes,
|
88
|
+
}
|
89
|
+
|
90
|
+
type None = "none"
|
91
|
+
|
92
|
+
type NumberSpacing = {
|
93
|
+
numberSpacing?: "tabular",
|
106
94
|
}
|
107
95
|
|
108
96
|
type Order = {
|
109
97
|
order?: "none" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
|
110
98
|
}
|
111
99
|
|
100
|
+
type Padding = {
|
101
|
+
paddingRight?: AllSizes,
|
102
|
+
paddingLeft?: AllSizes,
|
103
|
+
paddingTop?: AllSizes,
|
104
|
+
paddingBottom?: AllSizes,
|
105
|
+
paddingX?: AllSizes,
|
106
|
+
paddingY?: AllSizes,
|
107
|
+
padding?: AllSizes,
|
108
|
+
}
|
109
|
+
|
110
|
+
type Shadow = {
|
111
|
+
shadow?: "none" | "deep" | "deeper" | "deepest",
|
112
|
+
}
|
113
|
+
|
114
|
+
type Sizes = "xs" | "sm" | "md" | "lg" | "xl"
|
115
|
+
|
116
|
+
type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
|
117
|
+
|
118
|
+
type ZIndex = {
|
119
|
+
zIndex?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
|
120
|
+
}
|
121
|
+
|
122
|
+
// keep this as the last type definition
|
112
123
|
export type GlobalProps = AlignContent & AlignItems & AlignSelf &
|
113
124
|
BorderRadius & Cursor & Dark & Display & Flex & FlexDirection &
|
114
125
|
FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
|
@@ -190,76 +201,49 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
190
201
|
css += cursor ? `cursor_${cursor} ` : ''
|
191
202
|
return css
|
192
203
|
},
|
193
|
-
flexDirectionProps: ({ flexDirection }: FlexDirection) => {
|
194
|
-
let css = ''
|
195
|
-
css += flexDirection == 'columnReverse' ? 'flex_direction_column_reverse' :
|
196
|
-
flexDirection == 'rowReverse' ? 'flex_direction_row_reverse' :
|
197
|
-
flexDirection ? `flex_direction_${flexDirection} ` : ''
|
198
|
-
return css
|
199
|
-
},
|
200
|
-
flexWrapProps: ({ flexWrap }: FlexWrap) => {
|
201
|
-
let css = ''
|
202
|
-
css += flexWrap == 'wrapReverse' ? 'flex_wrap_reverse' :
|
203
|
-
flexWrap == 'nowrap' ? 'flex_nowrap' :
|
204
|
-
flexWrap ? `flex_wrap_${flexWrap} ` : ''
|
205
|
-
return css
|
206
|
-
},
|
207
|
-
justifyContentProps: ({ justifyContent }: JustifyContent) => {
|
208
|
-
let css = ''
|
209
|
-
css += justifyContent == 'spaceBetween' ? 'justify_content_space_between' :
|
210
|
-
justifyContent == 'spaceEvenly' ? 'justify_content_space_evenly' :
|
211
|
-
justifyContent == 'spaceAround' ? 'justify_content_space_around' :
|
212
|
-
justifyContent ? `justify_content_${justifyContent}` : ''
|
213
|
-
return css
|
214
|
-
},
|
215
|
-
justifySelfProps: ({ justifySelf }: JustifySelf) => {
|
216
|
-
let css = ''
|
217
|
-
css += justifySelf ? `justify_self_${justifySelf}` : ''
|
218
|
-
return css
|
219
|
-
},
|
220
204
|
alignItemsProps: ({ alignItems }: AlignItems) => {
|
221
|
-
|
222
|
-
css += alignItems == 'flexStart' ? 'align_items_flex_start' :
|
223
|
-
alignItems == 'flexEnd' ? 'align_items_flex_end' :
|
224
|
-
alignItems ? `align_items_${alignItems}` : ''
|
225
|
-
return css
|
205
|
+
return alignItems ? `align_items_${camelToSnakeCase(alignItems)}` : ''
|
226
206
|
},
|
227
207
|
alignContentProps: ({ alignContent }: AlignContent) => {
|
228
|
-
|
229
|
-
css += alignContent == 'spaceBetween' ? 'align_content_space_between' :
|
230
|
-
alignContent == 'spaceEvenly' ? 'align_content_space_evenly' :
|
231
|
-
alignContent == 'spaceAround' ? 'align_content_space_around' :
|
232
|
-
alignContent ? `align_content_${alignContent}` : ''
|
233
|
-
return css
|
208
|
+
return alignContent ? `align_content_${camelToSnakeCase(alignContent)}` : ''
|
234
209
|
},
|
235
210
|
alignSelfProps: ({ alignSelf }: AlignSelf) => {
|
236
|
-
|
237
|
-
|
238
|
-
|
211
|
+
return alignSelf ? `align_self_${alignSelf}` : ''
|
212
|
+
},
|
213
|
+
flexDirectionProps: ({ flexDirection }: FlexDirection) => {
|
214
|
+
if (typeof flexDirection !== 'object') return
|
215
|
+
|
216
|
+
const flexKeys: string[] = Object.keys(flexDirection)
|
217
|
+
|
218
|
+
return flexKeys.map((key: Sizes) => {
|
219
|
+
const flexDirectionValue: string = flexDirection[key]
|
220
|
+
return `flex_direction_${key}_${flexDirectionValue}`
|
221
|
+
}).join(" ")
|
222
|
+
},
|
223
|
+
flexWrapProps: ({ flexWrap }: FlexWrap) => {
|
224
|
+
return flexWrap ? `flex_wrap_${flexWrap} ` : ''
|
239
225
|
},
|
240
226
|
flexProps: ({ flex }: Flex) => {
|
241
|
-
|
242
|
-
css += flex ? `flex_${flex}` : ''
|
243
|
-
return css
|
227
|
+
return flex ? `flex_${flex}` : ''
|
244
228
|
},
|
245
229
|
flexGrowProps: ({ flexGrow }: FlexGrow) => {
|
246
|
-
|
247
|
-
css += flexGrow ? `flex_grow_${flexGrow}` : ''
|
248
|
-
return css
|
230
|
+
return typeof(flexGrow) !== undefined ? `flex_grow_${flexGrow}` : ''
|
249
231
|
},
|
250
232
|
flexShrinkProps: ({ flexShrink }: FlexShrink) => {
|
251
|
-
|
252
|
-
|
253
|
-
|
233
|
+
return typeof(flexShrink) !== undefined ? `flex_shrink_${flexShrink}` : ''
|
234
|
+
},
|
235
|
+
justifyContentProps: ({ justifyContent }: JustifyContent) => {
|
236
|
+
return justifyContent ? `justify_content_${camelToSnakeCase(justifyContent)}` : ''
|
237
|
+
},
|
238
|
+
justifySelfProps: ({ justifySelf }: JustifySelf) => {
|
239
|
+
return justifySelf ? `justify_self_${justifySelf}` : ''
|
254
240
|
},
|
255
241
|
orderProps: ({ order }: Order) => {
|
256
|
-
|
257
|
-
css += order ? `order_${order}` : ''
|
258
|
-
return css
|
242
|
+
return order ? `order_${order}` : ''
|
259
243
|
}
|
260
244
|
}
|
261
245
|
|
262
|
-
export const globalProps = (props: GlobalProps, defaultProps: {[key: string]: string} |
|
246
|
+
export const globalProps = (props: GlobalProps, defaultProps: {[key: string]: string} | Record<string, never> = {}): string => {
|
263
247
|
const allProps = { ...props, ...defaultProps }
|
264
248
|
return Object.keys(PROP_CATEGORIES).map((key) => {
|
265
249
|
return PROP_CATEGORIES[key](allProps)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { filter, isEmpty } from 'lodash'
|
2
|
+
|
3
|
+
const titleizedWord = (word: string): string => (
|
4
|
+
word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
5
|
+
)
|
6
|
+
|
7
|
+
export const titleize = (sentence: string): string => (
|
8
|
+
isEmpty(sentence) ? sentence : sentence.split(' ').map(titleizedWord).join(' ')
|
9
|
+
)
|
10
|
+
|
11
|
+
const notEmpty = (value: string | Record<string, unknown>): boolean => !isEmpty(value)
|
12
|
+
|
13
|
+
export const joinPresent = (array: [], separator: string): string => (
|
14
|
+
filter(array, notEmpty).join(separator)
|
15
|
+
)
|
16
|
+
|
17
|
+
export const camelToSnakeCase = (word: string): string => {
|
18
|
+
return word.split(/([A-Z])/g).map((w, i) => {
|
19
|
+
const prefix = i > 0 ? '_' : ''
|
20
|
+
return w === w.toLowerCase() ? w : prefix + w.toLowerCase()
|
21
|
+
}).join("")
|
22
|
+
}
|
data/dist/reset.css
CHANGED
@@ -1,2 +1,61 @@
|
|
1
|
-
|
1
|
+
/* CLEAN UP AND REMOVE */
|
2
|
+
/* Headings */
|
3
|
+
/* Standard Font Weights */
|
4
|
+
/* Non_Standard Font Weights */
|
5
|
+
/*=====================================
|
6
|
+
Base colors should not be documented.
|
7
|
+
Only document color use.
|
8
|
+
|
9
|
+
Colors -----------------------------*/
|
10
|
+
/* Specialty Gradient -----------------*/
|
11
|
+
/* Interface colors -------------------*/
|
12
|
+
/* Main colors ------------------------*/
|
13
|
+
/*=====================================
|
14
|
+
|
15
|
+
Background colors ------------------*/
|
16
|
+
/* Card colors ------------------*/
|
17
|
+
/* Active colors ----------------------*/
|
18
|
+
/* Hover colors -----------------------*/
|
19
|
+
/* Focus colors -----------------------*/
|
20
|
+
/* Border colors ----------------------*/
|
21
|
+
/* Shadow colors ----------------------*/
|
22
|
+
/* Text colors ------------------------*/
|
23
|
+
/* Data colors ------------------------*/
|
24
|
+
/* Status colors ----------------------*/
|
25
|
+
/* Link colors ------------------------*/
|
26
|
+
/* Product colors ---------------------*/
|
27
|
+
/* Category colors ---------------------*/
|
28
|
+
* {
|
29
|
+
box-sizing: border-box;
|
30
|
+
margin: 0;
|
31
|
+
padding: 0; }
|
32
|
+
*:before, *:after {
|
33
|
+
box-sizing: border-box; }
|
34
|
+
|
35
|
+
html {
|
36
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
37
|
+
height: 100vh;
|
38
|
+
overflow-x: hidden; }
|
39
|
+
|
40
|
+
body {
|
41
|
+
font-family: "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans_serif;
|
42
|
+
font-size: 16px;
|
43
|
+
line-height: 1.5;
|
44
|
+
background-color: #F3F7FB;
|
45
|
+
height: 100%;
|
46
|
+
letter-spacing: 0;
|
47
|
+
font-weight: 400;
|
48
|
+
font-style: normal;
|
49
|
+
text-rendering: optimizeLegibility;
|
50
|
+
-moz-font-feature-settings: "liga" on;
|
51
|
+
color: #242B42;
|
52
|
+
margin: 0 !important;
|
53
|
+
padding: 0 !important;
|
54
|
+
box-sizing: border-box;
|
55
|
+
min-height: 100vh;
|
56
|
+
padding: 50px; }
|
57
|
+
|
58
|
+
a {
|
59
|
+
text-decoration: none;
|
60
|
+
color: #0056CF; }
|
2
61
|
|
@@ -12,7 +12,13 @@ module Playbook
|
|
12
12
|
|
13
13
|
selected_props.map do |k|
|
14
14
|
flex_direction_value = send(k)
|
15
|
-
|
15
|
+
if flex_direction_value.is_a?(Hash)
|
16
|
+
flex_direction_value.map do |media_size, flex_value|
|
17
|
+
"flex_direction_#{media_size}_#{flex_value}"
|
18
|
+
end
|
19
|
+
else
|
20
|
+
"flex_direction_#{flex_direction_value}" unless flex_direction_value.nil?
|
21
|
+
end
|
16
22
|
end.compact.join(" ")
|
17
23
|
end
|
18
24
|
|
data/lib/playbook/version.rb
CHANGED