playbook_ui 12.24.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown756 → 12.24.0.pre.alpha.alphatestforselfhostfak720
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/pb_date/_date.tsx +42 -96
- data/app/pb_kits/playbook/pb_date/date.html.erb +2 -22
- data/app/pb_kits/playbook/pb_date/date.rb +0 -2
- data/app/pb_kits/playbook/pb_date/docs/example.yml +4 -4
- data/app/pb_kits/playbook/pb_date/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +0 -26
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +95 -99
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +1 -44
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +2 -34
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +2 -3
- data/app/pb_kits/playbook/pb_docs/kit_api.html.erb +311 -0
- data/app/pb_kits/playbook/pb_docs/kit_api.rb +149 -0
- data/app/pb_kits/playbook/pb_docs/kit_example.rb +2 -0
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +1 -1
- data/app/pb_kits/playbook/pb_nav/_item.tsx +1 -1
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +1 -1
- data/app/pb_kits/playbook/pb_time/_time.tsx +35 -71
- data/app/pb_kits/playbook/pb_time/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_time/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_time/time.html.erb +7 -26
- data/app/pb_kits/playbook/pb_time/time.rb +0 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +1 -2
- data/app/pb_kits/playbook/pb_title/_title.tsx +2 -3
- data/app/pb_kits/playbook/pb_title/title.rb +3 -10
- data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
- data/lib/playbook/markdown/helper.rb +132 -0
- data/lib/playbook/markdown.rb +3 -0
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook.rb +2 -1
- metadata +36 -17
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.html.erb +0 -30
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +0 -47
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.md +0 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.html.erb +0 -8
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.jsx +0 -18
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +0 -164
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +0 -75
- data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.html.erb +0 -37
- data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.jsx +0 -58
- data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.md +0 -1
- data/dist/playbook-rails.js +0 -323
@@ -3,7 +3,6 @@ import { BaseOptions } from 'flatpickr/dist/types/options'
|
|
3
3
|
import monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect'
|
4
4
|
import weekSelect from "flatpickr/dist/plugins/weekSelect/weekSelect"
|
5
5
|
import timeSelectPlugin from './plugins/timeSelect'
|
6
|
-
import quickPickPlugin from './plugins/quickPick'
|
7
6
|
|
8
7
|
const getPositionElement = (element: string | Element) => {
|
9
8
|
return (typeof element === 'string') ? document.querySelectorAll(element)[0] : element
|
@@ -20,8 +19,8 @@ type DatePickerConfig = {
|
|
20
19
|
hideIcon?: boolean;
|
21
20
|
inLine?: boolean,
|
22
21
|
onChange: (dateStr: string, selectedDates: Date[]) => void,
|
23
|
-
selectionType?: "month" | "week" | "quickpick" | "",
|
24
22
|
onClose: (dateStr: Date[] | string, selectedDates: Date[] | string) => void,
|
23
|
+
selectionType?: "month" | "week" | "",
|
25
24
|
showTimezone?: boolean,
|
26
25
|
staticPosition: boolean,
|
27
26
|
timeCaption?: string,
|
@@ -91,23 +90,18 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
91
90
|
}
|
92
91
|
|
93
92
|
const setPlugins = () => {
|
94
|
-
|
93
|
+
let pluginList = []
|
95
94
|
|
96
95
|
// month and week selection
|
97
96
|
if (selectionType === "month" || plugins.length > 0) {
|
98
97
|
pluginList.push(monthSelectPlugin({ shorthand: true, dateFormat: 'F Y', altFormat: 'F Y' }))
|
99
98
|
} else if ( selectionType === "week") {
|
100
99
|
pluginList.push(weekSelect())
|
101
|
-
|
102
|
-
} else if (selectionType === "quickpick") {
|
103
|
-
//------- QUICKPICK VARIANT PLUGIN -------------//
|
104
|
-
pluginList.push(quickPickPlugin())
|
105
100
|
}
|
106
101
|
|
107
102
|
// time selection
|
108
103
|
if (enableTime) pluginList.push(timeSelectPlugin({ caption: timeCaption, showTimezone: showTimezone}))
|
109
104
|
|
110
|
-
|
111
105
|
return pluginList
|
112
106
|
}
|
113
107
|
|
@@ -150,9 +144,6 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
150
144
|
},
|
151
145
|
] : disabledParser(),
|
152
146
|
enableTime,
|
153
|
-
locale: {
|
154
|
-
rangeSeparator: ' → '
|
155
|
-
},
|
156
147
|
maxDate,
|
157
148
|
minDate,
|
158
149
|
mode,
|
@@ -180,33 +171,10 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
180
171
|
static: staticPosition,
|
181
172
|
})
|
182
173
|
|
183
|
-
|
184
174
|
// ===========================================================
|
185
175
|
// Additional JS Functionality |
|
186
176
|
// ===========================================================
|
187
177
|
|
188
|
-
// opens flatpickr instance when calander icon is clicked so we can have a hover state on icon
|
189
|
-
// window.addEventListener("DOMContentLoaded", (event) => {
|
190
|
-
// event.preventDefault();
|
191
|
-
// function attachIconClickHandler() {
|
192
|
-
// const variantArr = document.querySelectorAll(`#cal-icon-${pickerId}`)
|
193
|
-
// if (!variantArr) {
|
194
|
-
// setTimeout(attachIconClickHandler, 100);
|
195
|
-
// return;
|
196
|
-
// }
|
197
|
-
|
198
|
-
// const instance = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
|
199
|
-
// variantArr.forEach((icon) => {
|
200
|
-
// icon.addEventListener("click", function(event) {
|
201
|
-
// event.preventDefault();
|
202
|
-
// instance.open()
|
203
|
-
// });
|
204
|
-
// })
|
205
|
-
// }
|
206
|
-
|
207
|
-
// attachIconClickHandler();
|
208
|
-
// });
|
209
|
-
|
210
178
|
// Assign dynamically sourced flatpickr instance to variable
|
211
179
|
const picker = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
|
212
180
|
picker.innerContainer.parentElement.id = `cal-${pickerId}`
|
@@ -8,7 +8,6 @@ examples:
|
|
8
8
|
- date_picker_input: Input Field
|
9
9
|
- date_picker_label: Label
|
10
10
|
- date_picker_range: Range
|
11
|
-
- date_picker_quick_pick: Range (Quick Pick)
|
12
11
|
- date_picker_format: Format
|
13
12
|
- date_picker_disabled: Disabled Dates
|
14
13
|
- date_picker_min_max: Min Max
|
@@ -34,7 +33,6 @@ examples:
|
|
34
33
|
- date_picker_on_change: onChange
|
35
34
|
- date_picker_on_close: onClose
|
36
35
|
- date_picker_range: Range
|
37
|
-
- date_picker_quick_pick: Range (Quick Pick)
|
38
36
|
- date_picker_format: Format
|
39
37
|
- date_picker_disabled: Disabled Dates
|
40
38
|
- date_picker_min_max: Min Max
|
@@ -19,5 +19,4 @@ export { default as DatePickerWeek } from './_date_picker_week.jsx'
|
|
19
19
|
export { default as DatePickerPositions } from './_date_picker_positions.jsx'
|
20
20
|
export { default as DatePickerPositionsElement } from './_date_picker_positions_element.jsx'
|
21
21
|
export { default as DatePickerAllowInput } from './_date_picker_allow_input'
|
22
|
-
export { default as
|
23
|
-
export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
|
22
|
+
export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
|
@@ -1,4 +1,3 @@
|
|
1
|
-
@import "../../tokens/colors";
|
2
1
|
// Calendar Icon Styles
|
3
2
|
.cal_icon_wrapper {
|
4
3
|
pointer-events: none;
|
@@ -14,8 +13,8 @@
|
|
14
13
|
padding-left: $space_sm - 1;
|
15
14
|
color: $text_lt_light;
|
16
15
|
@media (hover: hover) {
|
17
|
-
&:hover{
|
18
|
-
|
16
|
+
&:hover {
|
17
|
+
cursor: pointer;
|
19
18
|
}
|
20
19
|
}
|
21
20
|
&.dark {
|
@@ -0,0 +1,311 @@
|
|
1
|
+
<% if !local_prop_data.present? %>
|
2
|
+
<div data-action="toggle" data-togglable="prop_example" class="pb--propsTable">
|
3
|
+
<%= pb_rails("title", props: { text: "Available Props", size: 3, margin_bottom: "sm" }) %>
|
4
|
+
<%= pb_rails("card", props: { padding: "none" }) do %>
|
5
|
+
<%= pb_rails("card/card_body", props: { padding: "sm" }) do %>
|
6
|
+
<%= pb_rails("nav", props: { orientation: "horizontal", variant: "subtle" }) do %>
|
7
|
+
<%= pb_rails("nav/item", props: { text: "Global Props", link: "#", active: true }) %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
<%= pb_rails("section_separator") %>
|
11
|
+
<%= pb_rails("card/card_body", props: {}) do %>
|
12
|
+
<%= pb_rails("table", props: {container: false, disable_hover: true }) do %>
|
13
|
+
<thead>
|
14
|
+
<tr>
|
15
|
+
<th>Props</th>
|
16
|
+
<th>Type</th>
|
17
|
+
<th>Values</th>
|
18
|
+
</tr>
|
19
|
+
</thead>
|
20
|
+
<tbody>
|
21
|
+
<% global_prop_data.each do |key, value|%>
|
22
|
+
<tr>
|
23
|
+
<td>
|
24
|
+
<%= pb_rails("title", props: { text: key, tag: "h4", size: 4 }) %>
|
25
|
+
</td>
|
26
|
+
<td>
|
27
|
+
<%= pb_rails("card", props: {
|
28
|
+
classname: "card",
|
29
|
+
padding: "xxs",
|
30
|
+
background: "light",
|
31
|
+
border_none: true,
|
32
|
+
border_radius: "sm"
|
33
|
+
}) do %>
|
34
|
+
<%= pb_rails("body", props: {
|
35
|
+
classname: "kearning"
|
36
|
+
}) do %>
|
37
|
+
<% if key =~ /^padding|^margin/ %>
|
38
|
+
<%= "array" %>
|
39
|
+
<% else %>
|
40
|
+
<%= value[:type].to_s.downcase %>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
<% end %>
|
44
|
+
</td>
|
45
|
+
<td>
|
46
|
+
<% if key =~ /^padding|^margin/ %>
|
47
|
+
<% padding_margin_values.each do |item| %>
|
48
|
+
<%= pb_rails("card", props: {
|
49
|
+
flex_direction: "row",
|
50
|
+
classname: "card",
|
51
|
+
padding: "xxs",
|
52
|
+
background: "light",
|
53
|
+
border_none: true,
|
54
|
+
border_radius: "sm",
|
55
|
+
margin: "xxs"
|
56
|
+
}) do %>
|
57
|
+
<%= pb_rails("body", props: {
|
58
|
+
classname: "kearning"
|
59
|
+
}) do %>
|
60
|
+
<%= item %>
|
61
|
+
<% end %>
|
62
|
+
<% end %>
|
63
|
+
<% end %>
|
64
|
+
<% else %>
|
65
|
+
<% if value[:values].present? %>
|
66
|
+
<% value[:values].each do |item| %>
|
67
|
+
<% if item != nil %>
|
68
|
+
<%= pb_rails("card", props: {
|
69
|
+
flex_direction: "row",
|
70
|
+
classname: "card",
|
71
|
+
padding: "xxs",
|
72
|
+
background: "light",
|
73
|
+
border_none: true,
|
74
|
+
border_radius: "sm",
|
75
|
+
margin: "xxs"
|
76
|
+
}) do %>
|
77
|
+
<%= pb_rails("body", props: {
|
78
|
+
classname: "kearning"
|
79
|
+
}) do %>
|
80
|
+
<%= item %>
|
81
|
+
<% end %>
|
82
|
+
<% end %>
|
83
|
+
<% end %>
|
84
|
+
<% end %>
|
85
|
+
<% end %>
|
86
|
+
<% end %>
|
87
|
+
</td>
|
88
|
+
</tr>
|
89
|
+
<% end %>
|
90
|
+
</tbody>
|
91
|
+
<% end %>
|
92
|
+
<% end %>
|
93
|
+
<% end %>
|
94
|
+
</div>
|
95
|
+
<% else %>
|
96
|
+
<div data-action="toggle" data-togglable="prop_example" class="pb--propsTable">
|
97
|
+
<%= pb_rails("title", props: { text: "Available Props", size: 3, margin_bottom: "sm" }) %>
|
98
|
+
<%= pb_rails("card", props: { padding: "none" }) do %>
|
99
|
+
<%= pb_rails("card/card_body", props: { padding: "sm" }) do %>
|
100
|
+
<%= pb_rails("nav", props: { orientation: "horizontal", variant: "subtle" }) do %>
|
101
|
+
<% if local_prop_data.present? %>
|
102
|
+
<%= pb_rails("nav/item", props: { text: "Kit Props", link: "#", active: true, id: "local-button-active", classname: "local-active" }) %>
|
103
|
+
<% end %>
|
104
|
+
<% if local_prop_data.present? %>
|
105
|
+
<%= pb_rails("nav/item", props: { text: "Kit Props", link: "#", id: "local-button", classname: "global-active" }) %>
|
106
|
+
<% end %>
|
107
|
+
<%= pb_rails("nav/item", props: { text: "Global Props", link: "#", active: true, id: "global-button-active", classname: "global-active" }) %>
|
108
|
+
<%= pb_rails("nav/item", props: { text: "Global Props", link: "#", id: "global-button", classname: "local-active" }) %>
|
109
|
+
<% end %>
|
110
|
+
<% end %>
|
111
|
+
<%= pb_rails("section_separator") %>
|
112
|
+
<%= pb_rails("card/card_body", props: {}) do %>
|
113
|
+
<%= pb_rails("table", props: {container: false, disable_hover: true, id: "global-prop-table", classname: "global-active"}) do %>
|
114
|
+
<thead>
|
115
|
+
<tr>
|
116
|
+
<th>Props</th>
|
117
|
+
<th>Type</th>
|
118
|
+
<th>Values</th>
|
119
|
+
</tr>
|
120
|
+
</thead>
|
121
|
+
<tbody>
|
122
|
+
<% global_prop_data.each do |key, value|%>
|
123
|
+
<tr>
|
124
|
+
<td>
|
125
|
+
<%= pb_rails("title", props: { text: key, tag: "h4", size: 4 }) %>
|
126
|
+
</td>
|
127
|
+
<td>
|
128
|
+
<%= pb_rails("card", props: {
|
129
|
+
classname: "card",
|
130
|
+
padding: "xxs",
|
131
|
+
background: "light",
|
132
|
+
border_none: true,
|
133
|
+
border_radius: "sm"
|
134
|
+
}) do %>
|
135
|
+
<%= pb_rails("body", props: {
|
136
|
+
classname: "kearning"
|
137
|
+
}) do %>
|
138
|
+
<% if key =~ /^padding|^margin/ %>
|
139
|
+
<%= "array" %>
|
140
|
+
<% else %>
|
141
|
+
<%= value[:type].to_s.downcase %>
|
142
|
+
<% end %>
|
143
|
+
<% end %>
|
144
|
+
<% end %>
|
145
|
+
</td>
|
146
|
+
<td>
|
147
|
+
<% if key =~ /^padding|^margin/ %>
|
148
|
+
<% padding_margin_values.each do |item| %>
|
149
|
+
<%= pb_rails("card", props: {
|
150
|
+
flex_direction: "row",
|
151
|
+
classname: "card",
|
152
|
+
padding: "xxs",
|
153
|
+
background: "light",
|
154
|
+
border_none: true,
|
155
|
+
border_radius: "sm",
|
156
|
+
margin: "xxs"
|
157
|
+
}) do %>
|
158
|
+
<%= pb_rails("body", props: {
|
159
|
+
classname: "kearning"
|
160
|
+
}) do %>
|
161
|
+
<%= item %>
|
162
|
+
<% end %>
|
163
|
+
<% end %>
|
164
|
+
<% end %>
|
165
|
+
<% else %>
|
166
|
+
<% if value[:values].present? %>
|
167
|
+
<% value[:values].each do |item| %>
|
168
|
+
<% if item != nil %>
|
169
|
+
<%= pb_rails("card", props: {
|
170
|
+
flex_direction: "row",
|
171
|
+
classname: "card",
|
172
|
+
padding: "xxs",
|
173
|
+
background: "light",
|
174
|
+
border_none: true,
|
175
|
+
border_radius: "sm",
|
176
|
+
margin: "xxs"
|
177
|
+
}) do %>
|
178
|
+
<%= pb_rails("body", props: {
|
179
|
+
classname: "kearning"
|
180
|
+
}) do %>
|
181
|
+
<%= item %>
|
182
|
+
<% end %>
|
183
|
+
<% end %>
|
184
|
+
<% end %>
|
185
|
+
<% end %>
|
186
|
+
<% end %>
|
187
|
+
<% end %>
|
188
|
+
</td>
|
189
|
+
</tr>
|
190
|
+
<% end %>
|
191
|
+
</tbody>
|
192
|
+
<% end %>
|
193
|
+
<%= pb_rails("table", props: {container: false, disable_hover: true, id: "local-prop-table", classname: "local-active"}) do %>
|
194
|
+
<thead>
|
195
|
+
<tr>
|
196
|
+
<th>Props</th>
|
197
|
+
<th>Type</th>
|
198
|
+
<th>Values</th>
|
199
|
+
<th>Default</th>
|
200
|
+
</tr>
|
201
|
+
</thead>
|
202
|
+
<tbody>
|
203
|
+
<% local_prop_data.each do |key, value|%>
|
204
|
+
<tr>
|
205
|
+
<td>
|
206
|
+
<%= pb_rails("title", props: { text: key, tag: "h4", size: 4 }) %>
|
207
|
+
</td>
|
208
|
+
<td>
|
209
|
+
<%= pb_rails("card", props: {
|
210
|
+
classname: "card",
|
211
|
+
padding: "xxs",
|
212
|
+
background: "light",
|
213
|
+
border_none: true,
|
214
|
+
border_radius: "sm"
|
215
|
+
}) do %>
|
216
|
+
<%= pb_rails("body", props: {
|
217
|
+
classname: "kearning"
|
218
|
+
}) do %>
|
219
|
+
<%= value[:type].downcase %>
|
220
|
+
<% end %>
|
221
|
+
<% end %>
|
222
|
+
</td>
|
223
|
+
<td>
|
224
|
+
<% if value[:values].present? %>
|
225
|
+
<% value[:values].each do |item| %>
|
226
|
+
<% if item != nil %>
|
227
|
+
<%= pb_rails("card", props: {
|
228
|
+
flex_direction: "row",
|
229
|
+
classname: "card",
|
230
|
+
padding: "xxs",
|
231
|
+
background: "light",
|
232
|
+
border_none: true,
|
233
|
+
border_radius: "sm",
|
234
|
+
margin: "xxs"
|
235
|
+
}) do %>
|
236
|
+
<%= pb_rails("body", props: {
|
237
|
+
classname: "kearning"
|
238
|
+
}) do %>
|
239
|
+
<%= item %>
|
240
|
+
<% end %>
|
241
|
+
<% end %>
|
242
|
+
<% end %>
|
243
|
+
<% end %>
|
244
|
+
<% end %>
|
245
|
+
</td>
|
246
|
+
<td>
|
247
|
+
<% if value[:default].present? || value[:default].is_a?(TrueClass) || value[:default].is_a?(FalseClass) %>
|
248
|
+
<%= pb_rails("card", props: {
|
249
|
+
classname: "card",
|
250
|
+
padding: "xxs",
|
251
|
+
background: "light",
|
252
|
+
border_none: true,
|
253
|
+
border_radius: "sm"
|
254
|
+
}) do %>
|
255
|
+
<%= pb_rails("body", props: {
|
256
|
+
classname: "kearning"
|
257
|
+
}) do %>
|
258
|
+
<%= value[:default] %>
|
259
|
+
<% end %>
|
260
|
+
<% end %>
|
261
|
+
<% end %>
|
262
|
+
</td>
|
263
|
+
</tr>
|
264
|
+
<% end %>
|
265
|
+
</tbody>
|
266
|
+
<% end %>
|
267
|
+
<% end %>
|
268
|
+
<% end %>
|
269
|
+
</div>
|
270
|
+
<% end %>
|
271
|
+
|
272
|
+
<script>
|
273
|
+
|
274
|
+
const globalNavAndTable = document.querySelectorAll('.global-active');
|
275
|
+
const localNavAndTable = document.querySelectorAll('.local-active');
|
276
|
+
|
277
|
+
globalNavAndTable.forEach(element => {
|
278
|
+
element.style.display = 'none';
|
279
|
+
});
|
280
|
+
|
281
|
+
const globalButton = document.getElementById("global-button");
|
282
|
+
if (globalButton) {
|
283
|
+
globalButton.addEventListener("click", showGlobal);
|
284
|
+
}
|
285
|
+
|
286
|
+
const localButton = document.getElementById("local-button");
|
287
|
+
if (localButton) {
|
288
|
+
localButton.addEventListener("click", showLocal);
|
289
|
+
}
|
290
|
+
|
291
|
+
function showGlobal() {
|
292
|
+
localNavAndTable.forEach(element => {
|
293
|
+
element.style.display = 'none';
|
294
|
+
});
|
295
|
+
|
296
|
+
globalNavAndTable.forEach(element => {
|
297
|
+
element.style.display = 'table';
|
298
|
+
});
|
299
|
+
}
|
300
|
+
|
301
|
+
function showLocal() {
|
302
|
+
localNavAndTable.forEach(element => {
|
303
|
+
element.style.display = 'table';
|
304
|
+
});
|
305
|
+
|
306
|
+
globalNavAndTable.forEach(element => {
|
307
|
+
element.style.display = 'none';
|
308
|
+
});
|
309
|
+
}
|
310
|
+
|
311
|
+
</script>
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbDocs
|
5
|
+
class KitApi < Playbook::KitBase
|
6
|
+
prop :kit, type: Playbook::Props::String, required: true
|
7
|
+
|
8
|
+
def kit_local_props
|
9
|
+
local = []
|
10
|
+
kit_props.each do |key, value|
|
11
|
+
value.kit != Playbook::KitBase && local.push({ key: key, value: value })
|
12
|
+
end
|
13
|
+
local
|
14
|
+
end
|
15
|
+
|
16
|
+
def padding_margin_values
|
17
|
+
%w[none xxs xs sm md lg xl]
|
18
|
+
end
|
19
|
+
|
20
|
+
def local_prop_data
|
21
|
+
local_props = {}
|
22
|
+
|
23
|
+
kit_local_props.each do |key, _value|
|
24
|
+
name = key[:value].instance_variable_get(:@name)
|
25
|
+
type = key[:value].class.to_s.split("::").last
|
26
|
+
default = key[:value].instance_variable_get(:@default)
|
27
|
+
values = key[:value].instance_variable_get(:@values)
|
28
|
+
local_props[name.to_sym] = { "type": type, "default": default, "values": values }
|
29
|
+
end
|
30
|
+
local_props
|
31
|
+
end
|
32
|
+
|
33
|
+
def kit_global_props
|
34
|
+
global_props = {}
|
35
|
+
global_prop_names = []
|
36
|
+
global_prop_values = {}
|
37
|
+
global_props_with_values = {}
|
38
|
+
global_props_without_values = []
|
39
|
+
parent_child_object = {}
|
40
|
+
updated_global_props_with_values = {}
|
41
|
+
|
42
|
+
# extracts the modules from kit_base.rb, which is where we import all the global props that we inject into every rails kit
|
43
|
+
pb_module = Playbook::KitBase.included_modules.select { |mod| mod.to_s.include?("Playbook::") }
|
44
|
+
|
45
|
+
# loops through the kits and extracts each prop with its values and pushes that to the global_props hash
|
46
|
+
kit_props.each do |key, value|
|
47
|
+
value.kit == Playbook::KitBase && global_props[key.to_sym] = value
|
48
|
+
end
|
49
|
+
|
50
|
+
# loops through the global_props and extracts the name of each prop and pushes that to global_prop_names array
|
51
|
+
global_props.each do |name, _values|
|
52
|
+
global_prop_names.push(name)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Loops through each module in pb_module and searches for methods that end in _values, as these methods hold the values for each prop
|
56
|
+
# we then save the values and type and push that to the values hash as a key value pair
|
57
|
+
pb_module.each do |mod|
|
58
|
+
mod.instance_methods.each do |method_name|
|
59
|
+
next unless method_name.to_s.end_with?("_values")
|
60
|
+
|
61
|
+
value = send(method_name)
|
62
|
+
type = value.class
|
63
|
+
global_prop_values[method_name.to_s.chomp("_values").to_sym] = { "type": type, "values": value }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# loops through the global_prop_names array
|
68
|
+
# then loops through the global_prop_values hash and extracts the values that have the same name found in global_prop_names
|
69
|
+
# this loop helps ensure only global props values are actually extracted, as there could be other methods that end in _values in the modules we are iterating over
|
70
|
+
# these verified global props with values are then pushed to the global_props_with_values hash
|
71
|
+
global_prop_names.each do |name, _prop|
|
72
|
+
global_prop_values.each do |key, value|
|
73
|
+
global_props_with_values[key] = value if key == name
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# now we grab all the global_prop_names that do not have a matching key in global_prop_values.
|
78
|
+
# This gives us any global prop that did not have any predefined value. like classname and dark
|
79
|
+
global_props_without_values = global_prop_names - global_prop_values.keys
|
80
|
+
|
81
|
+
# Loops through each module in pb_module and searches for methods that end in _options, as these methods hold all the props in the module
|
82
|
+
# save the prop names prop values and and parent module name to parent_child_object hash
|
83
|
+
# this is a comprehensive list of all parent module and children props for edge cases like spacing.rb, that is not named after the props it represents
|
84
|
+
pb_module.each do |mod|
|
85
|
+
mod.instance_methods.each do |method_name|
|
86
|
+
next unless method_name.to_s.end_with?("_options")
|
87
|
+
|
88
|
+
props = send(method_name)
|
89
|
+
parent = mod.to_s.split("::").last
|
90
|
+
values = send("#{parent.underscore}_values")
|
91
|
+
parent_child_object[parent] = { "props": props, "values": values }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# loops through each object in parent_child_object and extracts its children (props and values)
|
96
|
+
# loops through each child and extracts the individual props
|
97
|
+
# Checks if the props match any of the props in global_props_without_values
|
98
|
+
# if it does, then we push that prop to global_props_with_values hash
|
99
|
+
# This extracts the props in the spacing.rb file and any file that is not named after the props it represents
|
100
|
+
parent_child_object.each do |_parent, children|
|
101
|
+
children.each do |_child, props|
|
102
|
+
props.each do |prop, _value|
|
103
|
+
type = children[:values].class
|
104
|
+
values = children[:values]
|
105
|
+
global_props_with_values[prop] = { "type": type, "values": values } if global_props_without_values.include?(prop)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# loop through the global_props hash and the global_props_with_values hash.
|
111
|
+
# extract the props from global_props that are not found in global_props_with_values into updated_global_props_with_values
|
112
|
+
# This is the last piece that grabs the global props that did not have values at all, like classname and dark, and adds it to our hash
|
113
|
+
global_props.each do |prop, value|
|
114
|
+
unless global_props_with_values.include?(prop)
|
115
|
+
type = value.class.to_s.split("::").last
|
116
|
+
updated_global_props_with_values[prop] = { "type": type }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Merge updated_global_props_with_values into global_props_with_values
|
121
|
+
# global_props_with_values will now hold all the global props thier values and type
|
122
|
+
global_props_with_values.merge!(updated_global_props_with_values)
|
123
|
+
|
124
|
+
global_props_with_values
|
125
|
+
end
|
126
|
+
|
127
|
+
def global_prop_data
|
128
|
+
global_props = {}
|
129
|
+
|
130
|
+
kit_global_props.each do |key, value|
|
131
|
+
type = value[:type]
|
132
|
+
values = value[:values]
|
133
|
+
global_props[key] = { "type": type, "values": values }
|
134
|
+
end
|
135
|
+
global_props
|
136
|
+
end
|
137
|
+
|
138
|
+
def kit_props
|
139
|
+
kit_class.props
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
def kit_class
|
145
|
+
@kit_class ||= Playbook::KitResolver.resolve(kit.to_s)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -5,6 +5,8 @@
|
|
5
5
|
module Playbook
|
6
6
|
module PbDocs
|
7
7
|
class KitExample < Playbook::KitBase
|
8
|
+
include Playbook::Markdown::Helper
|
9
|
+
|
8
10
|
prop :kit, type: Playbook::Props::String, required: true
|
9
11
|
prop :example_title, type: Playbook::Props::String, required: true
|
10
12
|
prop :example_key, type: Playbook::Props::String, required: true
|
@@ -33,7 +33,7 @@ module Playbook
|
|
33
33
|
values: ["lg", "xs", "sm", "1x", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "9x", "10x", nil],
|
34
34
|
default: nil
|
35
35
|
prop :font_style, type: Playbook::Props::Enum,
|
36
|
-
values: %w[far fas fab],
|
36
|
+
values: %w[far fas fab fak],
|
37
37
|
default: "far"
|
38
38
|
prop :spin, type: Playbook::Props::Boolean,
|
39
39
|
default: false
|