playbook_ui 10.23.0.pre.cachetest → 10.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/index.js +0 -3
  4. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +2 -2
  5. data/app/pb_kits/playbook/pb_avatar/{_avatar.jsx → _avatar.tsx} +13 -14
  6. data/app/pb_kits/playbook/pb_avatar/avatar.rb +1 -1
  7. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +1 -1
  8. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_background/_background.jsx +8 -3
  10. data/app/pb_kits/playbook/pb_background/_background.scss +24 -8
  11. data/app/pb_kits/playbook/pb_background/background.rb +6 -6
  12. data/app/pb_kits/playbook/pb_background/docs/_background_image.html.erb +50 -2
  13. data/app/pb_kits/playbook/pb_background/docs/_background_image.jsx +71 -28
  14. data/app/pb_kits/playbook/pb_background/docs/_background_image.md +1 -0
  15. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +5 -1
  16. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +1 -0
  17. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumb_item.jsx +1 -1
  18. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.jsx +1 -1
  19. data/app/pb_kits/playbook/pb_button/_button.jsx +8 -4
  20. data/app/pb_kits/playbook/pb_button/_button.scss +18 -1
  21. data/app/pb_kits/playbook/pb_button/button.rb +13 -3
  22. data/app/pb_kits/playbook/pb_button/button.test.js +13 -0
  23. data/app/pb_kits/playbook/pb_button/docs/_button_accessibility.html.erb +1 -1
  24. data/app/pb_kits/playbook/pb_button/docs/_button_form.html.erb +1 -0
  25. data/app/pb_kits/playbook/pb_button/docs/_button_form.jsx +14 -0
  26. data/app/pb_kits/playbook/pb_button/docs/_button_size.html.erb +3 -0
  27. data/app/pb_kits/playbook/pb_button/docs/_button_size.jsx +26 -0
  28. data/app/pb_kits/playbook/pb_button/docs/_button_size.md +1 -0
  29. data/app/pb_kits/playbook/pb_button/docs/example.yml +4 -0
  30. data/app/pb_kits/playbook/pb_button/docs/index.js +2 -0
  31. data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar.jsx +1 -1
  32. data/app/pb_kits/playbook/pb_caption/_caption.jsx +1 -1
  33. data/app/pb_kits/playbook/pb_card/_card.jsx +1 -1
  34. data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
  35. data/app/pb_kits/playbook/pb_card/card.rb +88 -0
  36. data/app/pb_kits/playbook/pb_card/card_body.rb +1 -1
  37. data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +1 -1
  38. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +3 -0
  39. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +1 -0
  40. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.jsx +1 -1
  41. data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +1 -1
  42. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.jsx +1 -1
  43. data/app/pb_kits/playbook/pb_currency/_currency.jsx +24 -3
  44. data/app/pb_kits/playbook/pb_currency/currency.rb +12 -3
  45. data/app/pb_kits/playbook/pb_currency/currency.test.js +35 -0
  46. data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.html.erb +27 -0
  47. data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.jsx +44 -0
  48. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
  49. data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
  50. data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
  51. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +215 -0
  52. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +1 -1
  53. data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +1 -1
  54. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.jsx +1 -1
  55. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.jsx +1 -1
  56. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx +1 -1
  57. data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.jsx +1 -1
  58. data/app/pb_kits/playbook/pb_file_upload/_file_upload.jsx +17 -10
  59. data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +40 -0
  60. data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.jsx +1 -1
  61. data/app/pb_kits/playbook/pb_flex/_flex.jsx +1 -1
  62. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +1 -1
  63. data/app/pb_kits/playbook/pb_flex/docs/_flex_align.jsx +1 -1
  64. data/app/pb_kits/playbook/pb_flex/flex_item.rb +2 -24
  65. data/app/pb_kits/playbook/pb_form_group/_form_group.jsx +1 -1
  66. data/app/pb_kits/playbook/pb_form_group/_form_group.scss +2 -0
  67. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
  68. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +3 -0
  69. data/app/pb_kits/playbook/pb_gauge/gauge.rb +1 -0
  70. data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +1 -1
  71. data/app/pb_kits/playbook/pb_icon/_icon.jsx +1 -1
  72. data/app/pb_kits/playbook/pb_icon/icon.rb +1 -1
  73. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx +1 -1
  74. data/app/pb_kits/playbook/pb_image/_image.scss +3 -3
  75. data/app/pb_kits/playbook/pb_image/{_image.jsx → _image.tsx} +11 -15
  76. data/app/pb_kits/playbook/pb_image/docs/{_default_image.jsx → _default_image.tsx} +1 -1
  77. data/app/pb_kits/playbook/pb_image/docs/index.js +4 -4
  78. data/app/pb_kits/playbook/pb_image/image.rb +1 -1
  79. data/app/pb_kits/playbook/pb_image/image.test.js +1 -1
  80. data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +1 -1
  81. data/app/pb_kits/playbook/pb_layout/_layout.jsx +1 -1
  82. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +5 -1
  83. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.jsx +1 -0
  84. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +1 -0
  85. data/app/pb_kits/playbook/pb_list/_list.jsx +1 -1
  86. data/app/pb_kits/playbook/pb_list/_list_item.jsx +1 -1
  87. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx +1 -1
  88. data/app/pb_kits/playbook/pb_online_status/{_online_status.jsx → _online_status.tsx} +4 -6
  89. data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +2 -1
  90. data/app/pb_kits/playbook/pb_pill/_pill.jsx +1 -1
  91. data/app/pb_kits/playbook/pb_popover/_popover.jsx +3 -5
  92. data/app/pb_kits/playbook/pb_popover/docs/_popover_close.html.erb +7 -7
  93. data/app/pb_kits/playbook/pb_popover/index.js +4 -9
  94. data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -1
  95. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +1 -1
  96. data/app/pb_kits/playbook/pb_progress_step/_progress_step.jsx +1 -1
  97. data/app/pb_kits/playbook/pb_radio/_radio.jsx +1 -1
  98. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +83 -93
  99. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
  100. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.jsx +15 -8
  101. data/app/pb_kits/playbook/pb_table/_table.jsx +1 -1
  102. data/app/pb_kits/playbook/pb_table/_table_row.jsx +1 -1
  103. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +1 -1
  104. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -1
  105. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +14 -0
  106. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +1 -0
  107. data/app/pb_kits/playbook/pb_time/_time.jsx +1 -1
  108. data/app/pb_kits/playbook/pb_title/_title.jsx +1 -1
  109. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +1 -1
  110. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +1 -1
  111. data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +1 -1
  112. data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.jsx +1 -1
  113. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx +1 -1
  114. data/app/pb_kits/playbook/plugins/pb_chart.js +8 -4
  115. data/app/pb_kits/playbook/utilities/_align_content.scss +29 -0
  116. data/app/pb_kits/playbook/utilities/_align_items.scss +35 -0
  117. data/app/pb_kits/playbook/utilities/_align_self.scss +29 -0
  118. data/app/pb_kits/playbook/utilities/_flex.scss +15 -0
  119. data/app/pb_kits/playbook/utilities/_flex_direction.scss +19 -0
  120. data/app/pb_kits/playbook/utilities/_flex_grow.scss +9 -0
  121. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +9 -0
  122. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +14 -0
  123. data/app/pb_kits/playbook/utilities/_flexbox.scss +11 -0
  124. data/app/pb_kits/playbook/utilities/_justify_content.scss +23 -0
  125. data/app/pb_kits/playbook/utilities/_justify_self.scss +19 -0
  126. data/app/pb_kits/playbook/utilities/_order.scss +55 -0
  127. data/app/pb_kits/playbook/utilities/globalProps.ts +274 -0
  128. data/app/pb_kits/playbook/utilities/{props.js → props.ts} +9 -7
  129. data/lib/playbook/align_content.rb +29 -0
  130. data/lib/playbook/align_items.rb +29 -0
  131. data/lib/playbook/align_self.rb +29 -0
  132. data/lib/playbook/classnames.rb +11 -0
  133. data/lib/playbook/flex.rb +29 -0
  134. data/lib/playbook/flex_direction.rb +29 -0
  135. data/lib/playbook/flex_grow.rb +29 -0
  136. data/lib/playbook/flex_shrink.rb +29 -0
  137. data/lib/playbook/flex_wrap.rb +29 -0
  138. data/lib/playbook/justify_content.rb +29 -0
  139. data/lib/playbook/justify_self.rb +29 -0
  140. data/lib/playbook/kit_base.rb +22 -0
  141. data/lib/playbook/order.rb +29 -0
  142. data/lib/playbook/version.rb +2 -2
  143. metadata +44 -11
  144. data/app/pb_kits/playbook/types.js +0 -4
  145. data/app/pb_kits/playbook/utilities/globalProps.js +0 -97
@@ -0,0 +1,274 @@
1
+ type Sizes = "xs" | "sm" | "md" | "lg" | "xl"
2
+ type None = "none"
3
+
4
+ type AllSizes = None & Sizes
5
+
6
+ type Margin = {
7
+ marginRight?: AllSizes,
8
+ marginLeft?: AllSizes,
9
+ marginTop?: AllSizes,
10
+ marginBottom?: AllSizes,
11
+ marginX?: AllSizes,
12
+ marginY?: AllSizes,
13
+ margin?: AllSizes,
14
+ }
15
+
16
+ type Padding = {
17
+ paddingRight?: AllSizes,
18
+ paddingLeft?: AllSizes,
19
+ paddingTop?: AllSizes,
20
+ paddingBottom?: AllSizes,
21
+ paddingX?: AllSizes,
22
+ paddingY?: AllSizes,
23
+ padding?: AllSizes,
24
+ }
25
+
26
+ type Dark = {
27
+ dark?: boolean,
28
+ }
29
+
30
+ type NumberSpacing = {
31
+ numberSpacing?: "tabular",
32
+ }
33
+
34
+ type MaxWidth = {
35
+ maxWidth?: Sizes,
36
+ }
37
+
38
+ type ZIndex = {
39
+ zIndex?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
40
+ }
41
+
42
+ type Shadow = {
43
+ shadow?: "none" | "deep" | "deeper" | "deepest",
44
+ }
45
+
46
+ type LineHeight = {
47
+ lineHeight?: "loosest" | "looser" | "loose" | "normal" | "tight" | "tighter" | "tightest",
48
+ }
49
+
50
+ type Display = {
51
+ display?: "block" | "flex" | "hidden" | "inline_block" | "inline" | "inline_flex",
52
+ }
53
+
54
+ type Cursor = {
55
+ cursor?: "pointer",
56
+ }
57
+
58
+ type BorderRadius = {
59
+ borderRadius?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "rounded",
60
+ }
61
+
62
+ type Flex = {
63
+ flex?: "none" | "initial" | "auto" | 1
64
+ }
65
+
66
+ type FlexDirection = {
67
+ flexDirection?: "row" | "column" | "rowReverse" | "columnReverse"
68
+ }
69
+
70
+ type FlexGrow = {
71
+ flexGrow?: 0 | 1
72
+ }
73
+
74
+ type FlexShrink = {
75
+ flexShrink?: 0 | 1
76
+ }
77
+
78
+ type FlexWrap = {
79
+ flexWrap?: "wrap" | "nowrap" | "wrapReverse"
80
+ }
81
+
82
+ type Alignment = "start" | "end" | "center"
83
+
84
+ type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
85
+
86
+ type JustifyContent = {
87
+ justifyContent?: Alignment & Space
88
+ }
89
+
90
+ type JustifySelf = {
91
+ justifySelf?: Alignment & ("auto" | "stretch")
92
+ }
93
+
94
+ type AlignContent = {
95
+ alignContent?: Alignment & Space
96
+ }
97
+
98
+ type AlignItems = {
99
+ alignItems?: Alignment & ("flexStart" | "flexEnd" | "stretch" | "baseline")
100
+ }
101
+
102
+ type AlignSelf = {
103
+ alignSelf?: Alignment & ("auto" | "stretch" | "baseline")
104
+ }
105
+
106
+ type Order = {
107
+ order?: "none" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
108
+ }
109
+
110
+ export type GlobalProps = AlignContent & AlignItems & AlignSelf &
111
+ BorderRadius & Cursor & Dark & Display & Flex & FlexDirection &
112
+ FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
113
+ LineHeight & Margin & MaxWidth & NumberSpacing & Order & Padding &
114
+ Shadow & ZIndex
115
+
116
+ // Prop categories
117
+ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} = {
118
+ spacingProps: ({
119
+ marginRight,
120
+ marginLeft,
121
+ marginTop,
122
+ marginBottom,
123
+ marginX,
124
+ marginY,
125
+ margin,
126
+ paddingRight,
127
+ paddingLeft,
128
+ paddingTop,
129
+ paddingBottom,
130
+ paddingX,
131
+ paddingY,
132
+ padding,
133
+ }: Margin & Padding) => {
134
+ let css = ''
135
+ css += marginRight ? `mr_${marginRight} ` : ''
136
+ css += marginLeft ? `ml_${marginLeft} ` : ''
137
+ css += marginTop ? `mt_${marginTop} ` : ''
138
+ css += marginBottom ? `mb_${marginBottom} ` : ''
139
+ css += marginX ? `mx_${marginX} ` : ''
140
+ css += marginY ? `my_${marginY} ` : ''
141
+ css += margin ? `m_${margin} ` : ''
142
+ css += paddingRight ? `pr_${paddingRight} ` : ''
143
+ css += paddingLeft ? `pl_${paddingLeft} ` : ''
144
+ css += paddingTop ? `pt_${paddingTop} ` : ''
145
+ css += paddingBottom ? `pb_${paddingBottom} ` : ''
146
+ css += paddingX ? `px_${paddingX} ` : ''
147
+ css += paddingY ? `py_${paddingY} ` : ''
148
+ css += padding ? `p_${padding} ` : ''
149
+ return css
150
+ },
151
+ darkProps: ({ dark }: Dark) => {
152
+ let css = ''
153
+ css += dark ? 'dark' : ''
154
+ return css
155
+ },
156
+ numberSpacingProps: ({ numberSpacing }: NumberSpacing) => {
157
+ let css = ''
158
+ css += numberSpacing ? `ns_${numberSpacing} ` : ''
159
+ return css
160
+ },
161
+ maxWidthProps: ({ maxWidth }: MaxWidth) => {
162
+ let css = ''
163
+ css += maxWidth ? `max_width_${maxWidth } ` : ''
164
+ return css
165
+ },
166
+ zIndexProps: ({ zIndex }: ZIndex) => {
167
+ let css = ''
168
+ css += zIndex ? `z_index_${zIndex } ` : ''
169
+ return css
170
+ },
171
+ shadowProps: ({ shadow }: Shadow) => {
172
+ let css = ''
173
+ css += shadow ? `shadow_${shadow} ` : ''
174
+ return css
175
+ },
176
+ lineHeightProps: ({ lineHeight }: LineHeight) => {
177
+ let css = ''
178
+ css += lineHeight ? `line_height_${lineHeight} ` : ''
179
+ return css
180
+ },
181
+ displayProps: ({ display }: Display) => {
182
+ let css = ''
183
+ css += display ? `display_${display} ` : ''
184
+ return css
185
+ },
186
+ cursorProps: ({ cursor }: Cursor) => {
187
+ let css = ''
188
+ css += cursor ? `cursor_${cursor} ` : ''
189
+ return css
190
+ },
191
+ flexDirectionProps: ({ flexDirection }: FlexDirection) => {
192
+ let css = ''
193
+ css += flexDirection == 'columnReverse' ? 'flex_direction_column_reverse' :
194
+ flexDirection == 'rowReverse' ? 'flex_direction_row_reverse' :
195
+ flexDirection ? `flex_direction_${flexDirection} ` : ''
196
+ return css
197
+ },
198
+ flexWrapProps: ({ flexWrap }: FlexWrap) => {
199
+ let css = ''
200
+ css += flexWrap == 'wrapReverse' ? 'flex_wrap_reverse' :
201
+ flexWrap == 'nowrap' ? 'flex_nowrap' :
202
+ flexWrap ? `flex_wrap_${flexWrap} ` : ''
203
+ return css
204
+ },
205
+ justifyContentProps: ({ justifyContent }: JustifyContent) => {
206
+ let css = ''
207
+ css += justifyContent == 'spaceBetween' ? 'justify_content_space_between' :
208
+ justifyContent == 'spaceEvenly' ? 'justify_content_space_evenly' :
209
+ justifyContent == 'spaceAround' ? 'justify_content_space_around' :
210
+ justifyContent ? `justify_content_${justifyContent}` : ''
211
+ return css
212
+ },
213
+ justifySelfProps: ({ justifySelf }: JustifySelf) => {
214
+ let css = ''
215
+ css += justifySelf ? `justify_self_${justifySelf}` : ''
216
+ return css
217
+ },
218
+ alignItemsProps: ({ alignItems }: AlignItems) => {
219
+ let css = ''
220
+ css += alignItems == 'flexStart' ? 'align_items_flex_start' :
221
+ alignItems == 'flexEnd' ? 'align_items_flex_end' :
222
+ alignItems ? `align_items_${alignItems}` : ''
223
+ return css
224
+ },
225
+ alignContentProps: ({ alignContent }: AlignContent) => {
226
+ let css = ''
227
+ css += alignContent == 'spaceBetween' ? 'align_content_space_between' :
228
+ alignContent == 'spaceEvenly' ? 'align_content_space_evenly' :
229
+ alignContent == 'spaceAround' ? 'align_content_space_around' :
230
+ alignContent ? `align_content_${alignContent}` : ''
231
+ return css
232
+ },
233
+ alignSelfProps: ({ alignSelf }: AlignSelf) => {
234
+ let css = ''
235
+ css += alignSelf ? `align_self_${alignSelf}` : ''
236
+ return css
237
+ },
238
+ flexProps: ({ flex }: Flex) => {
239
+ let css = ''
240
+ css += flex ? `flex_${flex}` : ''
241
+ return css
242
+ },
243
+ flexGrowProps: ({ flexGrow }: FlexGrow) => {
244
+ let css = ''
245
+ css += flexGrow ? `flex_grow_${flexGrow}` : ''
246
+ return css
247
+ },
248
+ flexShrinkProps: ({ flexShrink }: FlexShrink) => {
249
+ let css = ''
250
+ css += flexShrink ? `flex_shrink_${flexShrink}` : ''
251
+ return css
252
+ },
253
+ orderProps: ({ order }: Order) => {
254
+ let css = ''
255
+ css += order ? `order_${order}` : ''
256
+ return css
257
+ }
258
+ }
259
+
260
+ export const globalProps = (props: GlobalProps, defaultProps: {[key: string]: string} | {} = {}): string => {
261
+ const allProps = { ...props, ...defaultProps }
262
+ return Object.keys(PROP_CATEGORIES).map((key) => {
263
+ return PROP_CATEGORIES[key](allProps)
264
+ }).filter((value) => value?.length > 0).join(" ")
265
+ }
266
+
267
+ export const deprecatedProps = (kit: string, props: string[] = []): void => {
268
+ if (process.env.NODE_ENV === 'development') {
269
+ /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
270
+ props.forEach((prop) => {
271
+ console.warn(`${kit} Kit: The prop '${prop}' is deprecated and will be removed in a future release!`)
272
+ })
273
+ }
274
+ }
@@ -10,10 +10,11 @@ import classnames from 'classnames'
10
10
  * @param {Object} data the object containing the data to derive the props from.
11
11
  * @returns {Object} an object whose keys have the prefix added to them.
12
12
  */
13
- const buildPrefixedProps = (prefix, data) => Object.keys(data).reduce((props, key) => {
14
- props[`${prefix}-${key}`] = data[key]
15
- return props
16
- }, {})
13
+ const buildPrefixedProps = (prefix: string, data: {[key: string]: any}) =>
14
+ Object.keys(data).reduce((props: {[key: string]: any}, key: string) => {
15
+ props[`${prefix}-${key}`] = data[key]
16
+ return props
17
+ }, {})
17
18
 
18
19
  /**
19
20
  * Represent a "No-Operation" function that can be used as a sensible
@@ -29,7 +30,8 @@ export const noop = () => {}
29
30
  * @param {Object} aria the object containing the aria prop values.
30
31
  * @returns {Object} an object holding the HTML valid aria props and their values.
31
32
  */
32
- export const buildAriaProps = (aria) => buildPrefixedProps('aria', aria)
33
+ export const buildAriaProps = (aria: {[key: string]: string}): {[key: string]: string} =>
34
+ buildPrefixedProps('aria', aria)
33
35
 
34
36
  /**
35
37
  * Maps a given data object into HTML valid data attribtues and their values.
@@ -37,7 +39,7 @@ export const buildAriaProps = (aria) => buildPrefixedProps('aria', aria)
37
39
  * @param {Object} data the object containing the data prop values.
38
40
  * @returns {Object} an object holding the HTML valid data props and their values.
39
41
  */
40
- export const buildDataProps = (data) => buildPrefixedProps('data', data)
42
+ export const buildDataProps = (data: {[key: string]: any}) => buildPrefixedProps('data', data)
41
43
 
42
44
  /**
43
45
  * Builds a Playbook valid root className off of the incoming css rules.
@@ -45,5 +47,5 @@ export const buildDataProps = (data) => buildPrefixedProps('data', data)
45
47
  * @param {Object} rules a 'classnames' compliant rules object, used to derive the root className.
46
48
  * @returns {String} the derived root className value.
47
49
  */
48
- export const buildCss = (...rules) => classnames(rules).replace(/\s/g, '_')
50
+ export const buildCss = (...rules: string[]) => classnames(rules).replace(/\s/g, '_')
49
51
 
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module AlignContent
5
+ def self.included(base)
6
+ base.prop :align_content
7
+ end
8
+
9
+ def align_content_props
10
+ selected_props = align_content_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ align_content_value = send(k)
15
+ "align_content_#{align_content_value}" if align_content_values.include? align_content_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def align_content_options
20
+ {
21
+ align_content: "align_content",
22
+ }
23
+ end
24
+
25
+ def align_content_values
26
+ %w[start end center space_between space_around space_evenly]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module AlignItems
5
+ def self.included(base)
6
+ base.prop :align_items
7
+ end
8
+
9
+ def align_items_props
10
+ selected_props = align_items_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ align_items_value = send(k)
15
+ "align_items_#{align_items_value}" if align_items_values.include? align_items_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def align_items_options
20
+ {
21
+ align_items: "align_items",
22
+ }
23
+ end
24
+
25
+ def align_items_values
26
+ %w[flex_start flex_end start end center baseline stretch]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module AlignSelf
5
+ def self.included(base)
6
+ base.prop :align_self
7
+ end
8
+
9
+ def align_self_props
10
+ selected_props = align_self_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ align_self_value = send(k)
15
+ "align_self_#{align_self_value}" if align_self_values.include? align_self_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def align_self_options
20
+ {
21
+ align_self: "align_self",
22
+ }
23
+ end
24
+
25
+ def align_self_values
26
+ %w[auto start end center stretch baseline]
27
+ end
28
+ end
29
+ end
@@ -20,6 +20,17 @@ module Playbook
20
20
  line_height_props,
21
21
  display_props,
22
22
  cursor_props,
23
+ flex_direction_props,
24
+ flex_wrap_props,
25
+ justify_content_props,
26
+ justify_self_props,
27
+ align_items_props,
28
+ align_content_props,
29
+ align_self_props,
30
+ flex_props,
31
+ flex_grow_props,
32
+ flex_shrink_props,
33
+ order_props,
23
34
  ].compact.join(" ")
24
35
  end
25
36
 
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module Flex
5
+ def self.included(base)
6
+ base.prop :flex
7
+ end
8
+
9
+ def flex_props
10
+ selected_props = flex_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ flex_value = send(k)
15
+ "flex_#{flex_value}" if flex_values.include? flex_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def flex_options
20
+ {
21
+ flex: "flex",
22
+ }
23
+ end
24
+
25
+ def flex_values
26
+ %w[auto initial 0 1 2 3 4 5 6 7 8 9 10 11 12 none]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module FlexDirection
5
+ def self.included(base)
6
+ base.prop :flex_direction
7
+ end
8
+
9
+ def flex_direction_props
10
+ selected_props = flex_direction_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ flex_direction_value = send(k)
15
+ "flex_direction_#{flex_direction_value}" if flex_direction_values.include? flex_direction_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def flex_direction_options
20
+ {
21
+ flex_direction: "flex_direction",
22
+ }
23
+ end
24
+
25
+ def flex_direction_values
26
+ %w[row column row_reverse column_reverse]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module FlexGrow
5
+ def self.included(base)
6
+ base.prop :flex_grow
7
+ end
8
+
9
+ def flex_grow_props
10
+ selected_props = flex_grow_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ flex_grow_value = send(k)
15
+ "flex_grow_#{flex_grow_value}" if flex_grow_values.include? flex_grow_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def flex_grow_options
20
+ {
21
+ flex_grow: "flex_grow",
22
+ }
23
+ end
24
+
25
+ def flex_grow_values
26
+ %w[1 0]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module FlexShrink
5
+ def self.included(base)
6
+ base.prop :flex_shrink
7
+ end
8
+
9
+ def flex_shrink_props
10
+ selected_props = flex_shrink_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ flex_shrink_value = send(k)
15
+ "flex_shrink_#{flex_shrink_value}" if flex_shrink_values.include? flex_shrink_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def flex_shrink_options
20
+ {
21
+ flex_shrink: "flex_shrink",
22
+ }
23
+ end
24
+
25
+ def flex_shrink_values
26
+ %w[1 0]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module FlexWrap
5
+ def self.included(base)
6
+ base.prop :flex_wrap
7
+ end
8
+
9
+ def flex_wrap_props
10
+ selected_props = flex_wrap_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ flex_wrap_value = send(k)
15
+ "flex_wrap_#{flex_wrap_value}" if flex_wrap_values.include? flex_wrap_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def flex_wrap_options
20
+ {
21
+ flex_wrap: "flex_wrap",
22
+ }
23
+ end
24
+
25
+ def flex_wrap_values
26
+ %w[wrap nowrap wrap_reverse]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module JustifyContent
5
+ def self.included(base)
6
+ base.prop :justify_content
7
+ end
8
+
9
+ def justify_content_props
10
+ selected_props = justify_content_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ justify_content_value = send(k)
15
+ "justify_content_#{justify_content_value}" if justify_content_values.include? justify_content_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def justify_content_options
20
+ {
21
+ justify_content: "justify_content",
22
+ }
23
+ end
24
+
25
+ def justify_content_values
26
+ %w[start end center space_between space_around space_evenly]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module JustifySelf
5
+ def self.included(base)
6
+ base.prop :justify_self
7
+ end
8
+
9
+ def justify_self_props
10
+ selected_props = justify_self_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ justify_self_value = send(k)
15
+ "justify_self_#{justify_self_value}" if justify_self_values.include? justify_self_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def justify_self_options
20
+ {
21
+ justify_self: "justify_self",
22
+ }
23
+ end
24
+
25
+ def justify_self_values
26
+ %w[auto start end center stretch]
27
+ end
28
+ end
29
+ end
@@ -8,6 +8,17 @@ require "playbook/shadow"
8
8
  require "playbook/line_height"
9
9
  require "playbook/display"
10
10
  require "playbook/cursor"
11
+ require "playbook/flex_direction"
12
+ require "playbook/flex_wrap"
13
+ require "playbook/justify_content"
14
+ require "playbook/justify_self"
15
+ require "playbook/align_items"
16
+ require "playbook/align_content"
17
+ require "playbook/align_self"
18
+ require "playbook/flex"
19
+ require "playbook/flex_grow"
20
+ require "playbook/flex_shrink"
21
+ require "playbook/order"
11
22
 
12
23
  module Playbook
13
24
  class KitBase < ViewComponent::Base
@@ -21,6 +32,17 @@ module Playbook
21
32
  include Playbook::LineHeight
22
33
  include Playbook::Display
23
34
  include Playbook::Cursor
35
+ include Playbook::FlexDirection
36
+ include Playbook::FlexWrap
37
+ include Playbook::JustifyContent
38
+ include Playbook::JustifySelf
39
+ include Playbook::AlignItems
40
+ include Playbook::AlignContent
41
+ include Playbook::AlignSelf
42
+ include Playbook::Flex
43
+ include Playbook::FlexGrow
44
+ include Playbook::FlexShrink
45
+ include Playbook::Order
24
46
 
25
47
  prop :id
26
48
  prop :data, type: Playbook::Props::Hash, default: {}
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module Order
5
+ def self.included(base)
6
+ base.prop :order
7
+ end
8
+
9
+ def order_props
10
+ selected_props = order_options.keys.select { |sk| try(sk) }
11
+ return nil unless selected_props.present?
12
+
13
+ selected_props.map do |k|
14
+ order_value = send(k)
15
+ "order_#{order_value}" if order_values.include? order_value
16
+ end.compact.join(" ")
17
+ end
18
+
19
+ def order_options
20
+ {
21
+ order: "order",
22
+ }
23
+ end
24
+
25
+ def order_values
26
+ %w[1 2 3 4 5 6 7 8 9 10 11 12 first none]
27
+ end
28
+ end
29
+ end