playbook_ui 10.26.0.pre.alpha.sticky1 → 10.26.1
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/_playbook.scss +1 -0
- 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_avatar/_avatar.tsx +3 -3
- data/app/pb_kits/playbook/pb_background/{_background.jsx → _background.tsx} +20 -13
- data/app/pb_kits/playbook/pb_badge/{_badge.jsx → _badge.tsx} +14 -15
- data/app/pb_kits/playbook/pb_badge/docs/_badge_colors.jsx +1 -1
- data/app/pb_kits/playbook/pb_badge/docs/_badge_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded.jsx +1 -1
- data/app/pb_kits/playbook/pb_badge/docs/index.js +3 -3
- data/app/pb_kits/playbook/pb_body/_body.tsx +9 -9
- data/app/pb_kits/playbook/pb_button/{_button.jsx → _button.tsx} +65 -46
- data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_options.jsx +1 -1
- data/app/pb_kits/playbook/pb_caption/{_caption.jsx → _caption.tsx} +7 -8
- data/app/pb_kits/playbook/pb_card/{_card.jsx → _card.tsx} +20 -18
- data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_background.jsx +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_border_none.jsx +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.jsx +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_light.jsx +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_selected.jsx +1 -1
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +4 -2
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
- 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_flex/{_flex.jsx → _flex.tsx} +5 -5
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
- data/app/pb_kits/playbook/pb_highlight/_highlight.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon/{_icon.jsx → _icon.tsx} +40 -30
- data/app/pb_kits/playbook/pb_image/_image.tsx +1 -1
- data/app/pb_kits/playbook/pb_pill/{_pill.jsx → _pill.tsx} +6 -8
- data/app/pb_kits/playbook/pb_pill/docs/_pill_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_pill/docs/_pill_variants.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/pb_user/{_user.jsx → _user.tsx} +20 -24
- 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/tokens/_colors.scss +2 -1
- data/app/pb_kits/playbook/tokens/_display.scss +13 -0
- data/app/pb_kits/playbook/tokens/_screen_sizes.scss +36 -0
- data/app/pb_kits/playbook/utilities/_align_content.scss +10 -29
- data/app/pb_kits/playbook/utilities/_align_items.scss +11 -35
- data/app/pb_kits/playbook/utilities/_align_self.scss +10 -29
- data/app/pb_kits/playbook/utilities/_display.scss +26 -2
- data/app/pb_kits/playbook/utilities/_flex.scss +19 -14
- data/app/pb_kits/playbook/utilities/_flex_direction.scss +7 -18
- data/app/pb_kits/playbook/utilities/_flex_grow.scss +5 -8
- data/app/pb_kits/playbook/utilities/_flex_shrink.scss +5 -8
- data/app/pb_kits/playbook/utilities/_flex_wrap.scss +6 -13
- data/app/pb_kits/playbook/utilities/_justify_content.scss +10 -23
- data/app/pb_kits/playbook/utilities/_justify_self.scss +9 -19
- data/app/pb_kits/playbook/utilities/_mixins.scss +26 -0
- data/app/pb_kits/playbook/utilities/_order.scss +17 -55
- data/app/pb_kits/playbook/utilities/globalProps.ts +150 -121
- data/app/pb_kits/playbook/utilities/props.ts +2 -2
- data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +37 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +36 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +37 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +38 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +64 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +37 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +35 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +35 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +37 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +37 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +37 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +35 -0
- data/app/pb_kits/playbook/utilities/test-utils.js +2 -0
- data/app/pb_kits/playbook/utilities/text.ts +22 -0
- data/dist/reset.css +1 -60
- data/lib/playbook/align_content.rb +11 -3
- data/lib/playbook/align_items.rb +10 -2
- data/lib/playbook/align_self.rb +9 -1
- data/lib/playbook/display.rb +19 -7
- data/lib/playbook/flex.rb +9 -1
- data/lib/playbook/flex_direction.rb +10 -2
- data/lib/playbook/flex_grow.rb +9 -1
- data/lib/playbook/flex_shrink.rb +9 -1
- data/lib/playbook/flex_wrap.rb +10 -2
- data/lib/playbook/justify_content.rb +10 -2
- data/lib/playbook/justify_self.rb +9 -1
- data/lib/playbook/order.rb +10 -2
- data/lib/playbook/pb_kit_helper.rb +6 -1
- data/lib/playbook/version.rb +2 -2
- metadata +52 -17
- data/app/pb_kits/playbook/utilities/text.js +0 -15
@@ -1,68 +1,43 @@
|
|
1
1
|
import { omit } from 'lodash'
|
2
|
+
import { camelToSnakeCase } from './text'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
import {
|
5
|
+
Binary,
|
6
|
+
Display,
|
7
|
+
DisplaySizes,
|
8
|
+
None,
|
9
|
+
Sizes,
|
10
|
+
} from '../types'
|
5
11
|
|
6
|
-
type
|
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
|
-
}
|
27
|
-
|
28
|
-
type Dark = {
|
29
|
-
dark?: boolean,
|
30
|
-
}
|
31
|
-
|
32
|
-
type NumberSpacing = {
|
33
|
-
numberSpacing?: "tabular",
|
34
|
-
}
|
35
|
-
|
36
|
-
type MaxWidth = {
|
37
|
-
maxWidth?: Sizes,
|
38
|
-
}
|
12
|
+
type Alignment = "start" | "end" | "center"
|
39
13
|
|
40
|
-
type
|
41
|
-
|
14
|
+
type AlignContent = {
|
15
|
+
alignContent?: Alignment & Space
|
42
16
|
}
|
43
17
|
|
44
|
-
type
|
45
|
-
|
18
|
+
type AlignItems = {
|
19
|
+
alignItems?: Alignment & ("flexStart" | "flexEnd" | "stretch" | "baseline")
|
46
20
|
}
|
47
21
|
|
48
|
-
type
|
49
|
-
|
22
|
+
type AlignSelf = {
|
23
|
+
alignSelf?: Alignment & ("auto" | "stretch" | "baseline")
|
50
24
|
}
|
25
|
+
type AllSizes = None & Sizes
|
51
26
|
|
52
|
-
type
|
53
|
-
|
27
|
+
type BorderRadius = {
|
28
|
+
borderRadius?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "rounded",
|
54
29
|
}
|
55
30
|
|
56
31
|
type Cursor = {
|
57
32
|
cursor?: "pointer",
|
58
33
|
}
|
59
34
|
|
60
|
-
type
|
61
|
-
|
35
|
+
type Dark = {
|
36
|
+
dark?: boolean,
|
62
37
|
}
|
63
38
|
|
64
39
|
type Flex = {
|
65
|
-
flex?: "
|
40
|
+
flex?: "auto" | "initial" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "none",
|
66
41
|
}
|
67
42
|
|
68
43
|
type FlexDirection = {
|
@@ -74,17 +49,13 @@ type FlexGrow = {
|
|
74
49
|
}
|
75
50
|
|
76
51
|
type FlexShrink = {
|
77
|
-
flexShrink?:
|
52
|
+
flexShrink?: Binary
|
78
53
|
}
|
79
54
|
|
80
55
|
type FlexWrap = {
|
81
56
|
flexWrap?: "wrap" | "nowrap" | "wrapReverse"
|
82
57
|
}
|
83
58
|
|
84
|
-
type Alignment = "start" | "end" | "center"
|
85
|
-
|
86
|
-
type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
|
87
|
-
|
88
59
|
type JustifyContent = {
|
89
60
|
justifyContent?: Alignment & Space
|
90
61
|
}
|
@@ -93,28 +64,67 @@ type JustifySelf = {
|
|
93
64
|
justifySelf?: Alignment & ("auto" | "stretch")
|
94
65
|
}
|
95
66
|
|
96
|
-
type
|
97
|
-
|
67
|
+
type LineHeight = {
|
68
|
+
lineHeight?: "loosest" | "looser" | "loose" | "normal" | "tight" | "tighter" | "tightest",
|
98
69
|
}
|
99
70
|
|
100
|
-
type
|
101
|
-
|
71
|
+
type Margin = {
|
72
|
+
marginRight?: AllSizes,
|
73
|
+
marginLeft?: AllSizes,
|
74
|
+
marginTop?: AllSizes,
|
75
|
+
marginBottom?: AllSizes,
|
76
|
+
marginX?: AllSizes,
|
77
|
+
marginY?: AllSizes,
|
78
|
+
margin?: AllSizes,
|
102
79
|
}
|
103
80
|
|
104
|
-
type
|
105
|
-
|
81
|
+
type MaxWidth = {
|
82
|
+
maxWidth?: Sizes,
|
83
|
+
}
|
84
|
+
|
85
|
+
type NumberSpacing = {
|
86
|
+
numberSpacing?: "tabular",
|
106
87
|
}
|
107
88
|
|
108
89
|
type Order = {
|
109
|
-
order?: "
|
90
|
+
order?: None| "first" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
|
110
91
|
}
|
111
92
|
|
93
|
+
type Padding = {
|
94
|
+
paddingRight?: AllSizes,
|
95
|
+
paddingLeft?: AllSizes,
|
96
|
+
paddingTop?: AllSizes,
|
97
|
+
paddingBottom?: AllSizes,
|
98
|
+
paddingX?: AllSizes,
|
99
|
+
paddingY?: AllSizes,
|
100
|
+
padding?: AllSizes,
|
101
|
+
}
|
102
|
+
|
103
|
+
type Shadow = {
|
104
|
+
shadow?: "none" | "deep" | "deeper" | "deepest",
|
105
|
+
}
|
106
|
+
|
107
|
+
type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
|
108
|
+
|
109
|
+
type ZIndex = {
|
110
|
+
zIndex?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
|
111
|
+
}
|
112
|
+
|
113
|
+
// keep this as the last type definition
|
112
114
|
export type GlobalProps = AlignContent & AlignItems & AlignSelf &
|
113
|
-
BorderRadius & Cursor & Dark & Display & Flex & FlexDirection &
|
115
|
+
BorderRadius & Cursor & Dark & Display & DisplaySizes & Flex & FlexDirection &
|
114
116
|
FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
|
115
117
|
LineHeight & Margin & MaxWidth & NumberSpacing & Order & Padding &
|
116
118
|
Shadow & ZIndex
|
117
119
|
|
120
|
+
const getResponsivePropClasses = (prop: {[key: string]: string}, classPrefix: string) => {
|
121
|
+
const keys: string[] = Object.keys(prop)
|
122
|
+
return keys.map((size: Sizes) => {
|
123
|
+
const propValue: string = typeof(prop[size]) === 'string' ? camelToSnakeCase(prop[size]) : prop[size]
|
124
|
+
return `${classPrefix}_${size}_${propValue}`
|
125
|
+
}).join(" ")
|
126
|
+
}
|
127
|
+
|
118
128
|
// Prop categories
|
119
129
|
const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} = {
|
120
130
|
spacingProps: ({
|
@@ -150,11 +160,7 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
150
160
|
css += padding ? `p_${padding} ` : ''
|
151
161
|
return css
|
152
162
|
},
|
153
|
-
darkProps: ({ dark }: Dark) =>
|
154
|
-
let css = ''
|
155
|
-
css += dark ? 'dark' : ''
|
156
|
-
return css
|
157
|
-
},
|
163
|
+
darkProps: ({ dark }: Dark) => dark ? 'dark' : '',
|
158
164
|
numberSpacingProps: ({ numberSpacing }: NumberSpacing) => {
|
159
165
|
let css = ''
|
160
166
|
css += numberSpacing ? `ns_${numberSpacing} ` : ''
|
@@ -180,9 +186,21 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
180
186
|
css += lineHeight ? `line_height_${lineHeight} ` : ''
|
181
187
|
return css
|
182
188
|
},
|
183
|
-
displayProps: (
|
189
|
+
displayProps: (display: Display ) => {
|
184
190
|
let css = ''
|
185
|
-
|
191
|
+
Object.entries(display).forEach((displayEntry) => {
|
192
|
+
if (displayEntry[0] == "display") {
|
193
|
+
if (typeof displayEntry[1] == "string") {
|
194
|
+
css += `display_${displayEntry[1]} `
|
195
|
+
} else if (typeof displayEntry[1] == "object") {
|
196
|
+
Object.entries(displayEntry[1]).forEach((displayObj) => {
|
197
|
+
css += `display_${displayObj[0]}_${displayObj[1]} `
|
198
|
+
})
|
199
|
+
} else {
|
200
|
+
' '
|
201
|
+
}
|
202
|
+
}
|
203
|
+
})
|
186
204
|
return css
|
187
205
|
},
|
188
206
|
cursorProps: ({ cursor }: Cursor) => {
|
@@ -190,76 +208,87 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
190
208
|
css += cursor ? `cursor_${cursor} ` : ''
|
191
209
|
return css
|
192
210
|
},
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
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
|
211
|
+
alignContentProps: ({ alignContent }: AlignContent) => {
|
212
|
+
if (typeof alignContent === 'object') {
|
213
|
+
return getResponsivePropClasses(alignContent, 'align_content')
|
214
|
+
}
|
215
|
+
return alignContent ? `align_content_${camelToSnakeCase(alignContent)}` : ''
|
219
216
|
},
|
220
217
|
alignItemsProps: ({ alignItems }: AlignItems) => {
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
},
|
227
|
-
alignContentProps: ({ alignContent }: AlignContent) => {
|
228
|
-
let css = ''
|
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
|
218
|
+
if (typeof alignItems === 'object') {
|
219
|
+
return getResponsivePropClasses(alignItems, 'align_items')
|
220
|
+
} else {
|
221
|
+
return alignItems ? `align_items_${camelToSnakeCase(alignItems)}` : ''
|
222
|
+
}
|
234
223
|
},
|
235
224
|
alignSelfProps: ({ alignSelf }: AlignSelf) => {
|
236
|
-
|
237
|
-
|
238
|
-
|
225
|
+
if (typeof alignSelf === 'object') {
|
226
|
+
return getResponsivePropClasses(alignSelf, 'align_self')
|
227
|
+
} else {
|
228
|
+
return alignSelf ? `align_self_${alignSelf}` : ''
|
229
|
+
}
|
230
|
+
},
|
231
|
+
flexDirectionProps: ({ flexDirection }: FlexDirection) => {
|
232
|
+
if (typeof flexDirection == 'object') {
|
233
|
+
return getResponsivePropClasses(flexDirection, 'flex_direction')
|
234
|
+
} else {
|
235
|
+
return flexDirection ? `flex_direction_${camelToSnakeCase(flexDirection)}` : ''
|
236
|
+
}
|
237
|
+
},
|
238
|
+
flexWrapProps: ({ flexWrap }: FlexWrap) => {
|
239
|
+
if (typeof flexWrap == 'object') {
|
240
|
+
return getResponsivePropClasses(flexWrap, 'flex_wrap')
|
241
|
+
} else {
|
242
|
+
return flexWrap ? `flex_wrap_${camelToSnakeCase(flexWrap)}` : ''
|
243
|
+
}
|
239
244
|
},
|
240
245
|
flexProps: ({ flex }: Flex) => {
|
241
|
-
|
242
|
-
|
243
|
-
|
246
|
+
if (typeof flex === 'object') {
|
247
|
+
return getResponsivePropClasses(flex, 'flex')
|
248
|
+
} else {
|
249
|
+
return flex ? `flex_${flex}` : ''
|
250
|
+
}
|
244
251
|
},
|
245
252
|
flexGrowProps: ({ flexGrow }: FlexGrow) => {
|
246
|
-
|
247
|
-
|
248
|
-
|
253
|
+
if (typeof flexGrow == 'object') {
|
254
|
+
return getResponsivePropClasses(flexGrow, 'flex_grow')
|
255
|
+
} else {
|
256
|
+
return flexGrow ? `flex_grow_${flexGrow}` : ''
|
257
|
+
}
|
249
258
|
},
|
250
259
|
flexShrinkProps: ({ flexShrink }: FlexShrink) => {
|
251
|
-
|
252
|
-
|
253
|
-
|
260
|
+
if (typeof flexShrink == 'object') {
|
261
|
+
return getResponsivePropClasses(flexShrink, 'flex_shrink')
|
262
|
+
} else {
|
263
|
+
return flexShrink ? `flex_shrink_${flexShrink}` : ''
|
264
|
+
}
|
265
|
+
},
|
266
|
+
justifyContentProps: ({ justifyContent }: JustifyContent) => {
|
267
|
+
if (typeof justifyContent === 'object') {
|
268
|
+
return getResponsivePropClasses(justifyContent, 'justify_content')
|
269
|
+
} else {
|
270
|
+
return justifyContent ? `justify_content_${camelToSnakeCase(justifyContent)}` : ''
|
271
|
+
}
|
272
|
+
},
|
273
|
+
justifySelfProps: ({ justifySelf }: JustifySelf) => {
|
274
|
+
if (typeof justifySelf === 'object') {
|
275
|
+
return getResponsivePropClasses(justifySelf, 'justify_self')
|
276
|
+
} else {
|
277
|
+
return justifySelf ? `justify_self_${justifySelf}` : ''
|
278
|
+
}
|
254
279
|
},
|
255
280
|
orderProps: ({ order }: Order) => {
|
256
|
-
|
257
|
-
|
258
|
-
|
281
|
+
if (typeof order === 'object') {
|
282
|
+
return getResponsivePropClasses(order, 'flex_order')
|
283
|
+
} else {
|
284
|
+
return order ? `flex_order_${order}` : ''
|
285
|
+
}
|
259
286
|
}
|
260
287
|
}
|
261
288
|
|
262
|
-
|
289
|
+
type DefaultProps = {[key: string]: string} | Record<string, unknown>
|
290
|
+
|
291
|
+
export const globalProps = (props: GlobalProps, defaultProps: DefaultProps = {}): string => {
|
263
292
|
const allProps = { ...props, ...defaultProps }
|
264
293
|
return Object.keys(PROP_CATEGORIES).map((key) => {
|
265
294
|
return PROP_CATEGORIES[key](allProps)
|
@@ -22,7 +22,7 @@ const buildPrefixedProps = (prefix: string, data: {[key: string]: any}) =>
|
|
22
22
|
*
|
23
23
|
* @returns {() => {}} the noop function.
|
24
24
|
*/
|
25
|
-
export const noop = () => {}
|
25
|
+
export const noop = (): void => { void 0 }
|
26
26
|
|
27
27
|
/**
|
28
28
|
* Maps a given aria object into HTML valid aria attribtues and their values.
|
@@ -47,5 +47,5 @@ export const buildDataProps = (data: {[key: string]: any}) => buildPrefixedProps
|
|
47
47
|
* @param {Object} rules a 'classnames' compliant rules object, used to derive the root className.
|
48
48
|
* @returns {String} the derived root className value.
|
49
49
|
*/
|
50
|
-
export const buildCss = (...rules: string[]) => classnames(rules).replace(/\s/g, '_')
|
50
|
+
export const buildCss = (...rules: (string | { [x: string]: string; })[]): string => classnames(rules).replace(/\s/g, '_')
|
51
51
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../../test-utils'
|
3
|
+
|
4
|
+
import Body from '../../../pb_body/_body'
|
5
|
+
import { camelToSnakeCase } from '../../../utilities/text'
|
6
|
+
import { SCREEN_SIZES } from '../../test-utils'
|
7
|
+
|
8
|
+
const testSubject = 'body'
|
9
|
+
|
10
|
+
test('Global Props: returns proper class name', () => {
|
11
|
+
const propValues = ["start", "center", "end", "spaceBetween", "spaceAround", "spaceEvenly"]
|
12
|
+
for(let x = 0, y = propValues.length; x < y; ++x) {
|
13
|
+
const testId = `${testSubject}-${propValues[x]}`
|
14
|
+
render(
|
15
|
+
<Body
|
16
|
+
alignContent={`${propValues[x]}`}
|
17
|
+
data={{ testid: testId }}
|
18
|
+
text="Hi"
|
19
|
+
/>
|
20
|
+
)
|
21
|
+
const kit = screen.getByTestId(testId)
|
22
|
+
expect(kit).toHaveClass(`align_content_${camelToSnakeCase(propValues[x])}`)
|
23
|
+
|
24
|
+
SCREEN_SIZES.forEach((size) => {
|
25
|
+
const testId = `${testSubject}-${propValues[x]}-${size}`
|
26
|
+
render(
|
27
|
+
<Body
|
28
|
+
alignContent={{ [size]: propValues[x] }}
|
29
|
+
data={{ testid: testId }}
|
30
|
+
text="Hi"
|
31
|
+
/>
|
32
|
+
)
|
33
|
+
const kit = screen.getByTestId(testId)
|
34
|
+
expect(kit).toHaveClass(`align_content_${size}_${camelToSnakeCase(propValues[x])}`)
|
35
|
+
})
|
36
|
+
}
|
37
|
+
})
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../../test-utils'
|
3
|
+
|
4
|
+
import Body from '../../../pb_body/_body'
|
5
|
+
import { camelToSnakeCase } from '../../../utilities/text'
|
6
|
+
import { SCREEN_SIZES } from '../../test-utils'
|
7
|
+
|
8
|
+
const testSubject = 'body'
|
9
|
+
|
10
|
+
test('Global Props: returns proper class name', () => {
|
11
|
+
const propValues = ["start", "center", "end", "baseline", "stretch", "flexStart", "flexEnd"]
|
12
|
+
for(let x = 0, y = propValues.length; x < y; ++x) {
|
13
|
+
const testId = `${testSubject}-${propValues[x]}`
|
14
|
+
render(
|
15
|
+
<Body
|
16
|
+
alignItems={`${propValues[x]}`}
|
17
|
+
data={{ testid: testId }}
|
18
|
+
text="Hi"
|
19
|
+
/>
|
20
|
+
)
|
21
|
+
const kit = screen.getByTestId(testId)
|
22
|
+
expect(kit).toHaveClass(`align_items_${camelToSnakeCase(propValues[x])}`)
|
23
|
+
SCREEN_SIZES.forEach((size) => {
|
24
|
+
const testId = `${testSubject}-${propValues[x]}-${size}`
|
25
|
+
render(
|
26
|
+
<Body
|
27
|
+
alignItems={{ [size]: propValues[x] }}
|
28
|
+
data={{ testid: testId }}
|
29
|
+
text="Hi"
|
30
|
+
/>
|
31
|
+
)
|
32
|
+
const kit = screen.getByTestId(testId)
|
33
|
+
expect(kit).toHaveClass(`align_items_${size}_${camelToSnakeCase(propValues[x])}`)
|
34
|
+
})
|
35
|
+
}
|
36
|
+
})
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../../test-utils'
|
3
|
+
|
4
|
+
import Body from '../../../pb_body/_body'
|
5
|
+
import { camelToSnakeCase } from '../../../utilities/text'
|
6
|
+
import { SCREEN_SIZES } from '../../test-utils'
|
7
|
+
|
8
|
+
const testSubject = 'body'
|
9
|
+
|
10
|
+
test('Global Props: returns proper class name', () => {
|
11
|
+
const propValues = ["start", "center", "end", "stretch", "baseline", "auto"]
|
12
|
+
for(let x = 0, y = propValues.length; x < y; ++x) {
|
13
|
+
const testId = `${testSubject}-${propValues[x]}`
|
14
|
+
render(
|
15
|
+
<Body
|
16
|
+
alignSelf={`${propValues[x]}`}
|
17
|
+
data={{ testid: testId }}
|
18
|
+
text="Hi"
|
19
|
+
/>
|
20
|
+
)
|
21
|
+
const kit = screen.getByTestId(testId)
|
22
|
+
expect(kit).toHaveClass(`align_self_${camelToSnakeCase(propValues[x])}`)
|
23
|
+
|
24
|
+
SCREEN_SIZES.forEach((size) => {
|
25
|
+
const testId = `${testSubject}-${propValues[x]}-${size}`
|
26
|
+
render(
|
27
|
+
<Body
|
28
|
+
alignSelf={{ [size]: propValues[x] }}
|
29
|
+
data={{ testid: testId }}
|
30
|
+
text="Hi"
|
31
|
+
/>
|
32
|
+
)
|
33
|
+
const kit = screen.getByTestId(testId)
|
34
|
+
expect(kit).toHaveClass(`align_self_${size}_${camelToSnakeCase(propValues[x])}`)
|
35
|
+
})
|
36
|
+
}
|
37
|
+
})
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../../test-utils'
|
3
|
+
|
4
|
+
import Body from '../../../pb_body/_body'
|
5
|
+
import { camelToSnakeCase } from '../../../utilities/text'
|
6
|
+
import { SCREEN_SIZES } from '../../test-utils'
|
7
|
+
|
8
|
+
const testSubject = 'body'
|
9
|
+
|
10
|
+
// %w[block inline_block inline flex inline_flex none]
|
11
|
+
test('Global Props: returns proper class name', () => {
|
12
|
+
const propValues = ["block", "inline", "inline_block", "flex", "inline_flex", "none"]
|
13
|
+
for(let x = 0, y = propValues.length; x < y; ++x) {
|
14
|
+
const testId = `${testSubject}-${propValues[x]}`
|
15
|
+
render(
|
16
|
+
<Body
|
17
|
+
data={{ testid: testId }}
|
18
|
+
display={`${propValues[x]}`}
|
19
|
+
text="Hi"
|
20
|
+
/>
|
21
|
+
)
|
22
|
+
const kit = screen.getByTestId(testId)
|
23
|
+
expect(kit).toHaveClass(`display_${camelToSnakeCase(propValues[x])}`)
|
24
|
+
|
25
|
+
SCREEN_SIZES.forEach((size) => {
|
26
|
+
const testId = `${testSubject}-${propValues[x]}-${size}`
|
27
|
+
render(
|
28
|
+
<Body
|
29
|
+
data={{ testid: testId }}
|
30
|
+
display={{ [size]: propValues[x] }}
|
31
|
+
text="Hi"
|
32
|
+
/>
|
33
|
+
)
|
34
|
+
const kit = screen.getByTestId(testId)
|
35
|
+
expect(kit).toHaveClass(`display_${size}_${camelToSnakeCase(propValues[x])}`)
|
36
|
+
})
|
37
|
+
}
|
38
|
+
})
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../../test-utils'
|
3
|
+
|
4
|
+
import Body from '../../../pb_body/_body'
|
5
|
+
import { SCREEN_SIZES } from '../../test-utils'
|
6
|
+
|
7
|
+
const testSubject = 'body'
|
8
|
+
|
9
|
+
test('Global Props: Returns ordinal suffixed class name', () => {
|
10
|
+
for(let x = 0, y = 13; x < y; ++x) {
|
11
|
+
const testId = `${testSubject}-${x}`
|
12
|
+
render(
|
13
|
+
<Body
|
14
|
+
data={{ testid: testId }}
|
15
|
+
flex={`${x}`}
|
16
|
+
text="Hi"
|
17
|
+
/>
|
18
|
+
)
|
19
|
+
const kit = screen.getByTestId(testId)
|
20
|
+
expect(kit).toHaveClass(`flex_${x}`)
|
21
|
+
|
22
|
+
SCREEN_SIZES.forEach((size) => {
|
23
|
+
const testId = `${testSubject}-${x}-${size}`
|
24
|
+
render(
|
25
|
+
<Body
|
26
|
+
data={{ testid: testId }}
|
27
|
+
flex={{ [size]: x }}
|
28
|
+
text="Hi"
|
29
|
+
/>
|
30
|
+
)
|
31
|
+
const kit = screen.getByTestId(testId)
|
32
|
+
expect(kit).toHaveClass(`flex_${size}_${x}`)
|
33
|
+
})
|
34
|
+
}
|
35
|
+
})
|
36
|
+
|
37
|
+
test('Global Props: returns proper class name', () => {
|
38
|
+
const propValues = ["auto", "initial", "none"]
|
39
|
+
for(let x = 0, y = propValues.length; x < y; ++x) {
|
40
|
+
const testId = `${testSubject}-${propValues[x]}`
|
41
|
+
render(
|
42
|
+
<Body
|
43
|
+
data={{ testid: testId }}
|
44
|
+
flex={`${propValues[x]}`}
|
45
|
+
text="Hi"
|
46
|
+
/>
|
47
|
+
)
|
48
|
+
const kit = screen.getByTestId(testId)
|
49
|
+
expect(kit).toHaveClass(`flex_${propValues[x]}`)
|
50
|
+
|
51
|
+
SCREEN_SIZES.forEach((size) => {
|
52
|
+
const testId = `${testSubject}-${propValues[x]}-${size}`
|
53
|
+
render(
|
54
|
+
<Body
|
55
|
+
data={{ testid: testId }}
|
56
|
+
flex={{ [size]: propValues[x] }}
|
57
|
+
text="Hi"
|
58
|
+
/>
|
59
|
+
)
|
60
|
+
const kit = screen.getByTestId(testId)
|
61
|
+
expect(kit).toHaveClass(`flex_${size}_${propValues[x]}`)
|
62
|
+
})
|
63
|
+
}
|
64
|
+
})
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../../test-utils'
|
3
|
+
|
4
|
+
import Body from '../../../pb_body/_body'
|
5
|
+
import { camelToSnakeCase } from '../../../utilities/text'
|
6
|
+
import { SCREEN_SIZES } from '../../test-utils'
|
7
|
+
|
8
|
+
const testSubject = 'body'
|
9
|
+
|
10
|
+
test('Global Props: returns proper class name', () => {
|
11
|
+
const propValues = ["row", "column", "columnReverse"]
|
12
|
+
for(let x = 0, y = propValues.length; x < y; ++x) {
|
13
|
+
const testId = `${testSubject}-${propValues[x]}`
|
14
|
+
render(
|
15
|
+
<Body
|
16
|
+
data={{ testid: testId }}
|
17
|
+
flexDirection={`${propValues[x]}`}
|
18
|
+
text="Hi"
|
19
|
+
/>
|
20
|
+
)
|
21
|
+
const kit = screen.getByTestId(testId)
|
22
|
+
expect(kit).toHaveClass(`flex_direction_${camelToSnakeCase(propValues[x])}`)
|
23
|
+
|
24
|
+
SCREEN_SIZES.forEach((size) => {
|
25
|
+
const testId = `${testSubject}-${propValues[x]}-${size}`
|
26
|
+
render(
|
27
|
+
<Body
|
28
|
+
data={{ testid: testId }}
|
29
|
+
flexDirection={{ [size]: propValues[x] }}
|
30
|
+
text="Hi"
|
31
|
+
/>
|
32
|
+
)
|
33
|
+
const kit = screen.getByTestId(testId)
|
34
|
+
expect(kit).toHaveClass(`flex_direction_${size}_${camelToSnakeCase(propValues[x])}`)
|
35
|
+
})
|
36
|
+
}
|
37
|
+
})
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../../test-utils'
|
3
|
+
|
4
|
+
import Body from '../../../pb_body/_body'
|
5
|
+
import { SCREEN_SIZES } from '../../test-utils'
|
6
|
+
|
7
|
+
const testSubject = 'body'
|
8
|
+
|
9
|
+
test('Global Props: Returns ordinal suffixed class name', () => {
|
10
|
+
for(let x = 0, y = 2; x < y; ++x) {
|
11
|
+
const testId = `${testSubject}-${x}`
|
12
|
+
render(
|
13
|
+
<Body
|
14
|
+
data={{ testid: testId }}
|
15
|
+
flexGrow={`${x}`}
|
16
|
+
text="Hi"
|
17
|
+
/>
|
18
|
+
)
|
19
|
+
const kit = screen.getByTestId(testId)
|
20
|
+
expect(kit).toHaveClass(`flex_grow_${x}`)
|
21
|
+
|
22
|
+
SCREEN_SIZES.forEach((size) => {
|
23
|
+
const testId = `${testSubject}-${x}-${size}`
|
24
|
+
render(
|
25
|
+
<Body
|
26
|
+
data={{ testid: testId }}
|
27
|
+
flexGrow={{ [size]: x }}
|
28
|
+
text="Hi"
|
29
|
+
/>
|
30
|
+
)
|
31
|
+
const kit = screen.getByTestId(testId)
|
32
|
+
expect(kit).toHaveClass(`flex_grow_${size}_${x}`)
|
33
|
+
})
|
34
|
+
}
|
35
|
+
})
|