playbook_ui 10.26.0.pre.alpha.sticky1 → 10.27.0.pre.datepicker1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/data/menu.yml +1 -0
  4. data/app/pb_kits/playbook/index.js +2 -1
  5. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +3 -3
  6. data/app/pb_kits/playbook/pb_background/{_background.jsx → _background.tsx} +20 -13
  7. data/app/pb_kits/playbook/pb_badge/{_badge.jsx → _badge.tsx} +14 -15
  8. data/app/pb_kits/playbook/pb_badge/docs/_badge_colors.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_badge/docs/_badge_default.jsx +1 -1
  10. data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_badge/docs/index.js +3 -3
  12. data/app/pb_kits/playbook/pb_body/_body.tsx +9 -9
  13. data/app/pb_kits/playbook/pb_button/{_button.jsx → _button.tsx} +65 -46
  14. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +1 -0
  15. data/app/pb_kits/playbook/pb_button/docs/_button_options.jsx +1 -1
  16. data/app/pb_kits/playbook/pb_caption/{_caption.jsx → _caption.tsx} +7 -8
  17. data/app/pb_kits/playbook/pb_card/{_card.jsx → _card.tsx} +24 -22
  18. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -0
  19. data/app/pb_kits/playbook/pb_card/docs/_card_background.jsx +1 -1
  20. data/app/pb_kits/playbook/pb_card/docs/_card_border_none.jsx +1 -1
  21. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius.jsx +1 -1
  22. data/app/pb_kits/playbook/pb_card/docs/_card_light.jsx +1 -1
  23. data/app/pb_kits/playbook/pb_card/docs/_card_selected.jsx +1 -1
  24. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +4 -2
  25. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
  26. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +37 -0
  27. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +37 -0
  28. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +2 -2
  29. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +1 -0
  30. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +3 -2
  31. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +16 -7
  32. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.html.erb +1 -1
  33. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.html.erb +1 -1
  34. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.jsx +1 -1
  35. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.md +1 -1
  36. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.html.erb +5 -0
  37. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.jsx +18 -0
  38. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.md +1 -0
  39. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
  40. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss +127 -0
  42. data/app/pb_kits/playbook/pb_flex/{_flex.jsx → _flex.tsx} +5 -5
  43. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
  44. data/app/pb_kits/playbook/pb_highlight/_highlight.tsx +1 -1
  45. data/app/pb_kits/playbook/pb_icon/{_icon.jsx → _icon.tsx} +40 -30
  46. data/app/pb_kits/playbook/pb_image/_image.tsx +1 -1
  47. data/app/pb_kits/playbook/pb_pill/{_pill.jsx → _pill.tsx} +6 -8
  48. data/app/pb_kits/playbook/pb_pill/docs/_pill_default.jsx +1 -1
  49. data/app/pb_kits/playbook/pb_pill/docs/_pill_variants.jsx +1 -1
  50. data/app/pb_kits/playbook/pb_title/{_title.jsx → _title.tsx} +10 -12
  51. data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
  52. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +79 -0
  53. data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +5 -0
  54. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +37 -0
  55. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +48 -0
  56. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +2 -0
  57. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +37 -0
  58. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +47 -0
  59. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +3 -0
  60. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +79 -0
  61. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +90 -0
  62. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +1 -0
  63. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +54 -0
  64. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +65 -0
  65. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +3 -0
  66. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +37 -0
  67. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +48 -0
  68. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +3 -0
  69. data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +15 -0
  70. data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +5 -0
  71. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +1 -0
  72. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +43 -0
  73. data/app/pb_kits/playbook/pb_user/{_user.jsx → _user.tsx} +20 -24
  74. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  75. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +2 -0
  76. data/app/pb_kits/playbook/plugins/pb_chart.js +34 -0
  77. data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
  78. data/app/pb_kits/playbook/tokens/_display.scss +13 -0
  79. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +36 -0
  80. data/app/pb_kits/playbook/utilities/_align_content.scss +10 -29
  81. data/app/pb_kits/playbook/utilities/_align_items.scss +11 -35
  82. data/app/pb_kits/playbook/utilities/_align_self.scss +10 -29
  83. data/app/pb_kits/playbook/utilities/_display.scss +26 -2
  84. data/app/pb_kits/playbook/utilities/_flex.scss +19 -14
  85. data/app/pb_kits/playbook/utilities/_flex_direction.scss +7 -18
  86. data/app/pb_kits/playbook/utilities/_flex_grow.scss +5 -8
  87. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +5 -8
  88. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +6 -13
  89. data/app/pb_kits/playbook/utilities/_justify_content.scss +10 -23
  90. data/app/pb_kits/playbook/utilities/_justify_self.scss +9 -19
  91. data/app/pb_kits/playbook/utilities/_mixins.scss +26 -0
  92. data/app/pb_kits/playbook/utilities/_order.scss +17 -55
  93. data/app/pb_kits/playbook/utilities/globalProps.ts +150 -121
  94. data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +37 -0
  95. data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +36 -0
  96. data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +37 -0
  97. data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +38 -0
  98. data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +64 -0
  99. data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +37 -0
  100. data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +35 -0
  101. data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +35 -0
  102. data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +37 -0
  103. data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +37 -0
  104. data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +37 -0
  105. data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +35 -0
  106. data/app/pb_kits/playbook/utilities/test-utils.js +2 -0
  107. data/app/pb_kits/playbook/utilities/text.ts +22 -0
  108. data/dist/reset.css +1 -60
  109. data/lib/playbook/align_content.rb +11 -3
  110. data/lib/playbook/align_items.rb +10 -2
  111. data/lib/playbook/align_self.rb +9 -1
  112. data/lib/playbook/display.rb +19 -7
  113. data/lib/playbook/flex.rb +9 -1
  114. data/lib/playbook/flex_direction.rb +10 -2
  115. data/lib/playbook/flex_grow.rb +9 -1
  116. data/lib/playbook/flex_shrink.rb +9 -1
  117. data/lib/playbook/flex_wrap.rb +10 -2
  118. data/lib/playbook/justify_content.rb +10 -2
  119. data/lib/playbook/justify_self.rb +9 -1
  120. data/lib/playbook/order.rb +10 -2
  121. data/lib/playbook/version.rb +2 -2
  122. metadata +52 -13
  123. data/app/pb_kits/playbook/utilities/text.js +0 -15
@@ -1,23 +1,10 @@
1
- .justify_content_start {
2
- justify-content: start !important;
3
- }
4
-
5
- .justify_content_end {
6
- justify-content: end !important;
7
- }
8
-
9
- .justify_content_center {
10
- justify-content: center !important;
11
- }
12
-
13
- .justify_content_space_between {
14
- justify-content: space-between !important;
15
- }
16
-
17
- .justify_content_space_around {
18
- justify-content: space-around !important;
19
- }
20
-
21
- .justify_content_space_evenly {
22
- justify-content: space-evenly !important;
23
- }
1
+ $justify_content_values: (
2
+ start: start,
3
+ center: center,
4
+ end: end,
5
+ space_around: space-around,
6
+ space_between: space-between,
7
+ space_evenly: space-evenly,
8
+ );
9
+
10
+ @include global_props_responsive_css($justify_content_values, 'justify_content', 'justify-content');
@@ -1,19 +1,9 @@
1
- .justify_self_auto {
2
- justify-self: auto !important;
3
- }
4
-
5
- .justify_self_start {
6
- justify-self: start !important;
7
- }
8
-
9
- .justify_self_end {
10
- justify-self: end !important;
11
- }
12
-
13
- .justify_self_center {
14
- justify-self: center !important;
15
- }
16
-
17
- .justify_self_stretch {
18
- justify-self: stretch !important;
19
- }
1
+ $justify_self_values: (
2
+ auto: auto,
3
+ start: start,
4
+ center: center,
5
+ end: end,
6
+ stretch: stretch,
7
+ );
8
+
9
+ @include global_props_responsive_css($justify_self_values, 'justify_self', 'justify-self');
@@ -0,0 +1,26 @@
1
+ @mixin global_props_css($props, $class_prefix, $css_attribute, $responsive) {
2
+ @each $propkey, $propvalue in $props {
3
+ .#{$class_prefix}_#{$propkey} {
4
+ #{$css_attribute}: #{$propvalue} !important;
5
+ @content;
6
+ }
7
+ }
8
+
9
+ @if $responsive {
10
+ @each $size, $size_value in $breakpoints_grid {
11
+ @each $prop_key, $prop_value in $props {
12
+ $min_size: map-get($size_value, "min");
13
+ $max_size: map-get($size_value, "max");
14
+ .#{$class_prefix}_#{$size}_#{$prop_key} {
15
+ @include break_on($min_size, $max_size) {
16
+ #{$css_attribute}: #{$prop_value} !important;
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+
24
+ @mixin global_props_responsive_css($props, $class_prefix, $css_attribute) {
25
+ @include global_props_css($props, $class_prefix, $css_attribute, 1)
26
+ }
@@ -1,55 +1,17 @@
1
- .order_1 {
2
- order: 1 !important;
3
- }
4
-
5
- .order_2 {
6
- order: 2 !important;
7
- }
8
-
9
- .order_3 {
10
- order: 3 !important;
11
- }
12
-
13
- .order_4 {
14
- order: 4 !important;
15
- }
16
-
17
- .order_5 {
18
- order: 5 !important;
19
- }
20
-
21
- .order_6 {
22
- order: 6 !important;
23
- }
24
-
25
- .order_7 {
26
- order: 7 !important;
27
- }
28
-
29
- .order_8 {
30
- order: 8 !important;
31
- }
32
-
33
- .order_9 {
34
- order: 9 !important;
35
- }
36
-
37
- .order_10 {
38
- order: 10 !important;
39
- }
40
-
41
- .order_11 {
42
- order: 11 !important;
43
- }
44
-
45
- .order_12 {
46
- order: 12 !important;
47
- }
48
-
49
- .order_none {
50
- order: none !important;
51
- }
52
-
53
- .order_first {
54
- order: -1 !important;
55
- }
1
+ $order_values: (
2
+ 0: 0,
3
+ 1: 1,
4
+ 2: 2,
5
+ 3: 3,
6
+ 4: 4,
7
+ 5: 5,
8
+ 6: 6,
9
+ 7: 7,
10
+ 8: 8,
11
+ 9: 9,
12
+ 10: 10,
13
+ 11: 11,
14
+ 12: 12,
15
+ );
16
+
17
+ @include global_props_responsive_css($order_values, 'flex_order', 'order');
@@ -1,68 +1,43 @@
1
1
  import { omit } from 'lodash'
2
+ import { camelToSnakeCase } from './text'
2
3
 
3
- type Sizes = "xs" | "sm" | "md" | "lg" | "xl"
4
- type None = "none"
4
+ import {
5
+ Binary,
6
+ Display,
7
+ DisplaySizes,
8
+ None,
9
+ Sizes,
10
+ } from '../types'
5
11
 
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
- }
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 ZIndex = {
41
- zIndex?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
14
+ type AlignContent = {
15
+ alignContent?: Alignment & Space
42
16
  }
43
17
 
44
- type Shadow = {
45
- shadow?: "none" | "deep" | "deeper" | "deepest",
18
+ type AlignItems = {
19
+ alignItems?: Alignment & ("flexStart" | "flexEnd" | "stretch" | "baseline")
46
20
  }
47
21
 
48
- type LineHeight = {
49
- lineHeight?: "loosest" | "looser" | "loose" | "normal" | "tight" | "tighter" | "tightest",
22
+ type AlignSelf = {
23
+ alignSelf?: Alignment & ("auto" | "stretch" | "baseline")
50
24
  }
25
+ type AllSizes = None & Sizes
51
26
 
52
- type Display = {
53
- display?: "block" | "flex" | "hidden" | "inline_block" | "inline" | "inline_flex",
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 BorderRadius = {
61
- borderRadius?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "rounded",
35
+ type Dark = {
36
+ dark?: boolean,
62
37
  }
63
38
 
64
39
  type Flex = {
65
- flex?: "none" | "initial" | "auto" | 1
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?: 0 | 1
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 AlignContent = {
97
- alignContent?: Alignment & Space
67
+ type LineHeight = {
68
+ lineHeight?: "loosest" | "looser" | "loose" | "normal" | "tight" | "tighter" | "tightest",
98
69
  }
99
70
 
100
- type AlignItems = {
101
- alignItems?: Alignment & ("flexStart" | "flexEnd" | "stretch" | "baseline")
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 AlignSelf = {
105
- alignSelf?: Alignment & ("auto" | "stretch" | "baseline")
81
+ type MaxWidth = {
82
+ maxWidth?: Sizes,
83
+ }
84
+
85
+ type NumberSpacing = {
86
+ numberSpacing?: "tabular",
106
87
  }
107
88
 
108
89
  type Order = {
109
- order?: "none" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
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: ({ display }: Display) => {
189
+ displayProps: (display: Display ) => {
184
190
  let css = ''
185
- css += display ? `display_${display} ` : ''
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
- 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
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
- let css = ''
222
- css += alignItems == 'flexStart' ? 'align_items_flex_start' :
223
- alignItems == 'flexEnd' ? 'align_items_flex_end' :
224
- alignItems ? `align_items_${alignItems}` : ''
225
- return css
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
- let css = ''
237
- css += alignSelf ? `align_self_${alignSelf}` : ''
238
- return css
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
- let css = ''
242
- css += flex ? `flex_${flex}` : ''
243
- return css
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
- let css = ''
247
- css += flexGrow ? `flex_grow_${flexGrow}` : ''
248
- return css
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
- let css = ''
252
- css += flexShrink ? `flex_shrink_${flexShrink}` : ''
253
- return css
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
- let css = ''
257
- css += order ? `order_${order}` : ''
258
- return css
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
- export const globalProps = (props: GlobalProps, defaultProps: {[key: string]: string} | {} = {}): string => {
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)
@@ -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
+ })