playbook_ui 12.38.0.pre.alpha.PLAY932removemomentqp1088 → 12.38.0.pre.alpha.PLAY966collapsiblenav41082

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +6 -0
  3. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +3 -3
  4. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +10 -9
  5. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_color.jsx +2 -2
  6. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +2 -2
  7. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +4 -8
  8. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.md +1 -1
  9. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_size.jsx +5 -5
  10. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +75 -0
  11. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.md +3 -0
  12. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +7 -6
  13. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +2 -1
  14. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +8 -18
  15. data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +39 -45
  16. data/app/pb_kits/playbook/pb_kit/dateTime.ts +1 -204
  17. data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +280 -17
  18. data/app/pb_kits/playbook/pb_nav/_horizontal_nav.scss +6 -0
  19. data/app/pb_kits/playbook/pb_nav/_item.tsx +75 -24
  20. data/app/pb_kits/playbook/pb_nav/_mixins.scss +5 -0
  21. data/app/pb_kits/playbook/pb_nav/_nav.tsx +18 -1
  22. data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +6 -7
  23. data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
  24. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +85 -58
  25. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +1 -0
  26. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.jsx +58 -0
  27. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.md +1 -0
  28. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.html.erb +23 -0
  29. data/app/pb_kits/playbook/pb_nav/docs/{_collapsible_nav_custom_icons.jsx → _collapsible_nav_emphasize.jsx} +14 -5
  30. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.md +1 -0
  31. data/app/pb_kits/playbook/pb_nav/docs/example.yml +5 -3
  32. data/app/pb_kits/playbook/pb_nav/docs/index.js +2 -1
  33. data/app/pb_kits/playbook/pb_nav/item.html.erb +5 -4
  34. data/app/pb_kits/playbook/pb_nav/item.rb +29 -3
  35. data/dist/playbook-rails.js +279 -7
  36. data/lib/playbook/version.rb +1 -1
  37. metadata +11 -3
@@ -116,6 +116,7 @@ export const toIso = (newDate: Date | string): string => {
116
116
  }
117
117
 
118
118
  export const fromNow = (newDate: Date | string): string => {
119
+
119
120
  const startDate = formatDate(newDate).getTime()
120
121
  const endDate = new Date().getTime()
121
122
  const elapsedTime = endDate - startDate
@@ -153,193 +154,6 @@ export const toCustomFormat = (newDate: Date | string, format = 'month_day'): st
153
154
  }
154
155
  }
155
156
 
156
- // For quickPick.tsx
157
- // Yesterday
158
- export const getYesterdayDate = (newDate: Date | string): Date => {
159
- const today = formatDate(newDate)
160
- const yesterday = new Date()
161
- yesterday.setDate(today.getDate() - 1)
162
-
163
- return yesterday
164
- }
165
-
166
- // Weeks
167
- export const getFirstDayOfWeek = (newDate: Date | string): Date => {
168
- const today = formatDate(newDate)
169
- const dayOfWeek = today.getDay()
170
- // Replicate Moment.js: Start of week (Monday) has a time of 00:00:00
171
- const firstDayOfWeek = new Date(today.setHours(0, 0, 0))
172
- const isSunday = dayOfWeek === 0
173
-
174
- const daysToSubtract = isSunday ? 6 : (dayOfWeek - 1)
175
- firstDayOfWeek.setDate(today.getDate() - daysToSubtract)
176
-
177
- return firstDayOfWeek
178
- }
179
-
180
- export const getLastDayOfWeek = (newDate: Date | string): Date => {
181
- const today = formatDate(newDate)
182
- const dayOfWeek = today.getDay()
183
- // Replicate Moment.js: End of week (Sunday) has a time of 23:59:59
184
- const lastDayOfWeek = new Date(today.setHours(23, 59, 59, 0))
185
- const isSunday = dayOfWeek === 0
186
-
187
- const daysToAdd = isSunday ? 0 : (7 - dayOfWeek)
188
- lastDayOfWeek.setDate(today.getDate() + daysToAdd)
189
-
190
- return lastDayOfWeek
191
- }
192
-
193
- export const getPreviousWeekStartDate = (newDate: Date | string): Date => {
194
- const firstDayOfWeek = getFirstDayOfWeek(newDate)
195
- const firstDayOfPreviousWeek = new Date(
196
- firstDayOfWeek.getFullYear(),
197
- firstDayOfWeek.getMonth(),
198
- firstDayOfWeek.getDate() - 7
199
- )
200
-
201
- return firstDayOfPreviousWeek
202
- }
203
-
204
- export const getPreviousWeekEndDate = (newDate: Date | string): Date => {
205
- const lastDayOfWeek = getLastDayOfWeek(newDate)
206
- const lastDayOfPreviousWeek = new Date(
207
- lastDayOfWeek.getFullYear(),
208
- lastDayOfWeek.getMonth(),
209
- lastDayOfWeek.getDate() - 7,
210
- lastDayOfWeek.getHours(),
211
- lastDayOfWeek.getMinutes(),
212
- lastDayOfWeek.getSeconds()
213
- )
214
-
215
- return lastDayOfPreviousWeek
216
- }
217
-
218
- // Months
219
- export const getMonthStartDate = (newDate: Date | string): Date => {
220
- const date = formatDate(newDate)
221
- const firstDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1)
222
-
223
- return firstDayOfMonth
224
- }
225
-
226
- export const getMonthEndDate = (newDate: Date | string): Date => {
227
- const date = formatDate(newDate)
228
- // Replicate Moment.js: End of month has a time of 23:59:59
229
- const lastDayOfMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0, 23, 59, 59)
230
-
231
- return lastDayOfMonth
232
- }
233
-
234
- export const getPreviousMonthStartDate = (newDate: Date | string): Date => {
235
- const firstDayOfMonth = getMonthStartDate(newDate)
236
- const firstDayOfPreviousMonth = new Date(
237
- firstDayOfMonth.getFullYear(),
238
- firstDayOfMonth.getMonth() - 1,
239
- firstDayOfMonth.getDate()
240
- )
241
-
242
- return firstDayOfPreviousMonth
243
- }
244
-
245
- export const getPreviousMonthEndDate = (newDate: Date | string): Date => {
246
- const lastDayOfMonth = getMonthEndDate(newDate)
247
- const lastDayOfPreviousMonth = new Date(
248
- lastDayOfMonth.getFullYear(),
249
- lastDayOfMonth.getMonth() - 1,
250
- lastDayOfMonth.getDate(),
251
- lastDayOfMonth.getHours(),
252
- lastDayOfMonth.getMinutes(),
253
- lastDayOfMonth.getSeconds()
254
- )
255
-
256
- return lastDayOfPreviousMonth
257
- }
258
-
259
- // Quarters
260
- export const getQuarterStartDate = (newDate: Date | string): Date => {
261
- const date = formatDate(newDate)
262
- const quarter = Math.floor(date.getMonth() / 3)
263
- const startOfQuarter = new Date(date.getFullYear(), quarter * 3, 1)
264
-
265
- return startOfQuarter
266
- }
267
-
268
- export const getQuarterEndDate = (newDate: Date | string): Date => {
269
- const date = formatDate(newDate)
270
- const quarter = Math.floor(date.getMonth() / 3)
271
- const startOfNextQuarter = new Date(date.getFullYear(), (quarter + 1) * 3, 1)
272
- // Replicate Moment.js: End of quarter has a time of 23:59:59
273
- const endOfQuarter = new Date(startOfNextQuarter.getTime() - 1)
274
-
275
- return endOfQuarter
276
- }
277
-
278
- export const getPreviousQuarterStartDate = (newDate: Date | string): Date => {
279
- const startOfQuarter = getQuarterStartDate(newDate)
280
- const firstDayOfPreviousQuarter = new Date(
281
- startOfQuarter.getFullYear(),
282
- startOfQuarter.getMonth() - 3,
283
- startOfQuarter.getDate()
284
- )
285
-
286
- return firstDayOfPreviousQuarter
287
- }
288
-
289
- export const getPreviousQuarterEndDate = (newDate: Date | string): Date => {
290
- const endOfQuarter = getQuarterEndDate(newDate)
291
- const lastDayOfPreviousQuarter = new Date(
292
- endOfQuarter.getFullYear(),
293
- endOfQuarter.getMonth() - 3,
294
- endOfQuarter.getDate(),
295
- endOfQuarter.getHours(),
296
- endOfQuarter.getMinutes(),
297
- endOfQuarter.getSeconds()
298
- )
299
-
300
- return lastDayOfPreviousQuarter
301
- }
302
-
303
- // Years
304
- export const getYearStartDate = (newDate: Date | string): Date => {
305
- const date = formatDate(newDate)
306
- const startOfYear = new Date(date.getFullYear(), 0, 1)
307
-
308
- return startOfYear
309
- }
310
-
311
- export const getYearEndDate = (newDate: Date | string): Date => {
312
- const date = formatDate(newDate)
313
- const endOfYear = new Date(date.getFullYear(), 11, 31, 23, 59, 59)
314
-
315
- return endOfYear
316
- }
317
-
318
- export const getPreviousYearStartDate = (newDate: Date | string): Date => {
319
- const startOfYear = getYearStartDate(newDate)
320
- const firstDayOfPreviousYear = new Date(
321
- startOfYear.getFullYear() - 1,
322
- startOfYear.getMonth(),
323
- startOfYear.getDate()
324
- )
325
-
326
- return firstDayOfPreviousYear
327
- }
328
-
329
- export const getPreviousYearEndDate = (newDate: Date | string): Date => {
330
- const endOfYear = getYearEndDate(newDate)
331
- const lastDayOfPreviousYear = new Date(
332
- endOfYear.getFullYear() - 1,
333
- endOfYear.getMonth(),
334
- endOfYear.getDate(),
335
- endOfYear.getHours(),
336
- endOfYear.getMinutes(),
337
- endOfYear.getSeconds()
338
- )
339
-
340
- return lastDayOfPreviousYear
341
- }
342
-
343
157
  export default {
344
158
  toMinute,
345
159
  toHour,
@@ -356,21 +170,4 @@ export default {
356
170
  toIso,
357
171
  fromNow,
358
172
  toCustomFormat,
359
- getYesterdayDate,
360
- getFirstDayOfWeek,
361
- getLastDayOfWeek,
362
- getPreviousWeekStartDate,
363
- getPreviousWeekEndDate,
364
- getMonthStartDate,
365
- getMonthEndDate,
366
- getPreviousMonthStartDate,
367
- getPreviousMonthEndDate,
368
- getQuarterStartDate,
369
- getQuarterEndDate,
370
- getPreviousQuarterStartDate,
371
- getPreviousQuarterEndDate,
372
- getYearStartDate,
373
- getYearEndDate,
374
- getPreviousYearStartDate,
375
- getPreviousYearEndDate
376
173
  }
@@ -1,27 +1,290 @@
1
1
  @import "../tokens/spacing";
2
2
  @import "../tokens/colors";
3
3
  @import "../tokens/border_radius";
4
+ @import "../tokens/titles";
5
+ @import "../tokens/typography";
6
+ @import "./mixins";
4
7
 
5
8
  [class^="pb_nav_list"] {
6
- .pb_collapsible_nav_item {
7
- .pb_collapsible_main_kit,
8
- .pb_collapsible_content_kit,
9
- .pb_collapsible_kit {
10
- padding: 0 !important;
11
- }
12
-
13
- .icon_wrapper {
14
- border-radius: $border_radius_rounded;
15
- width: 19px;
16
- height: 19px;
17
- display:flex;
18
- align-items: center;
19
- justify-content: center;
20
- margin-right: $space_xs;
9
+ .font_size_small {
10
+ .pb_nav_list_item_text,
11
+ .pb_nav_list_item_text_collapsible {
12
+ font-size: $font_small !important;
13
+ }
14
+ }
15
+
16
+ .font_bolder {
17
+ .pb_nav_list_item_text {
18
+ @include pb_title_4;
19
+ }
20
+ .pb_collapsible_main_kit {
21
+ .pb_nav_list_item_text_collapsible {
22
+ @include pb_title_4;
23
+ font-weight: $bolder !important;
24
+ }
25
+ }
26
+ }
27
+
28
+ .font_bold {
29
+ .pb_nav_list_item_text {
30
+ font-weight: $bold;
31
+ }
32
+ .pb_collapsible_main_kit {
33
+ .pb_nav_list_item_text_collapsible {
34
+ font-weight: $bold !important;
35
+ }
36
+ }
37
+ }
38
+
39
+ .font_regular {
40
+ .pb_nav_list_item_text {
41
+ font-weight: $regular;
42
+ }
43
+ .pb_collapsible_main_kit {
44
+ .pb_nav_list_item_text_collapsible {
45
+ font-weight: $regular !important;
46
+ }
47
+ }
48
+ }
49
+
50
+ //styling for default variant with collapsible
51
+ &[class*="_normal"] {
52
+ [class*="pb_collapsible_nav_item"] {
53
+ .pb_collapsible_content_kit {
54
+ margin-left: $space_lg + 3;
55
+ }
56
+ .pb_collapsible_main_kit {
57
+ border-radius: unset;
58
+ }
59
+ &[class*="_active"] {
60
+ .pb_collapsible_main_kit {
61
+ background-color: $active_light;
62
+ }
63
+ .pb_nav_list_item_link {
64
+ border-color: transparent !important;
65
+ .pb_nav_list_item_text {
66
+ color: unset !important;
67
+ font-weight: $regular !important;
68
+ }
69
+ }
70
+ }
71
+
72
+ &.dark {
73
+ border-color: $border_dark;
74
+ .pb_collapsible_main_kit:hover {
75
+ .pb_nav_list_item_text_collapsible {
76
+ color: $white !important;
77
+ }
78
+ }
79
+ &[class*="_active"] {
80
+ .pb_collapsible_main_kit {
81
+ background-color: mix($white, $card_dark, 20%);
82
+ .pb_nav_list_item_text_collapsible,
83
+ svg {
84
+ color: $white !important;
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ //styling bold variant to work with collapsible
93
+ &[class*="_bold"] {
94
+ [class*="pb_collapsible_nav_item"] {
95
+ &[class*="_active"] {
96
+ .pb_collapsible_main_kit {
97
+ background-color: $primary !important;
98
+ border-radius: $border_rad_heavier;
99
+ .pb_nav_list_item_text_collapsible,
100
+ .pb_nav_list_item_icon_collapsible,
101
+ .icon_wrapper,
102
+ .pb_icon_kit {
103
+ color: $white !important;
104
+ }
105
+ }
106
+ .pb_nav_list_item_link {
107
+ background-color: unset !important;
108
+ box-shadow: unset !important;
109
+ &:hover {
110
+ background-color: rgba($primary, 0.03) !important;
111
+ .pb_nav_list_item_text {
112
+ color: $primary !important;
113
+ }
114
+ }
115
+ .pb_nav_list_item_text {
116
+ font-weight: $regular !important;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ //styling for subtle variant with collapsible
124
+ &[class*="_subtle"] {
125
+ [class*="pb_collapsible_nav_item"] {
126
+ &[class*="_active"] {
127
+ .pb_collapsible_main_kit {
128
+ background-color: $primary !important;
129
+ border-radius: $border_rad_heavier;
130
+ .pb_nav_list_item_text_collapsible,
131
+ .pb_nav_list_item_icon_collapsible,
132
+ .icon_wrapper,
133
+ .pb_icon_kit {
134
+ color: $white !important;
135
+ }
136
+ }
137
+
138
+ &:hover {
139
+ background-color: unset;
140
+ }
141
+ .pb_collapsible_main_kit:hover {
142
+ .pb_nav_list_item_text_collapsible {
143
+ color: $white !important;
144
+ }
145
+ }
146
+
147
+ .icon_wrapper {
148
+ &:hover {
149
+ background-color: mix($primary, $card_light, 40%);
150
+ .pb_icon_kit {
151
+ color: $primary !important;
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ [class*="pb_collapsible_nav_item"] {
160
+ .pb_nav_list_kit_item {
161
+ margin-right: 0px !important;
162
+ }
163
+
164
+ &[class*="_active"] {
165
+ background-color: unset !important;
166
+ .pb_nav_list_item_link {
167
+ color: unset !important;
168
+ }
169
+ }
170
+
171
+ .pb_nav_list_item_link_collapsible {
172
+ &:focus-visible {
173
+ outline: none;
174
+ }
175
+ }
176
+
177
+ .pb_collapsible_main_kit {
178
+ &:focus-visible {
179
+ box-shadow: 0px 0px 0px 2px $primary_action;
180
+ border-radius: $border_rad_heavier;
181
+ }
182
+ }
183
+
184
+ //Make sure link is entire width of navitem when in collapsible
185
+ .pb_collapsible_main_kit {
186
+ .pb_flex_item_kit:first-child {
187
+ width: 100%;
188
+ }
189
+ }
190
+
21
191
  &:hover {
22
- background-color: rgba($primary_action, $opacity_3);
192
+ .pb_nav_list_item_link_collapsible {
193
+ background-color: unset !important;
194
+ }
195
+ }
196
+
197
+ // vertical line on left of collapsible content
198
+ .pb_collapsible_content_kit {
199
+ margin-left: $space_sm + 2;
200
+ border-left: 1px solid transparent;
201
+ }
202
+
203
+ .pb_collapsible_main_kit {
204
+ transition-property: color, border-color, background-color;
205
+ transition-duration: 0.15s;
206
+ transition-timing-function: $bezier;
207
+ border-radius: $border_rad_heavier;
208
+ &:hover {
209
+ background-color: mix($primary, $card_light, 10%);
210
+ .pb_nav_list_item_text_collapsible,
211
+ svg {
212
+ color: $primary !important;
213
+ }
214
+ }
215
+ }
216
+
217
+ .pb_collapsible_main_kit,
218
+ .pb_collapsible_content_kit,
219
+ .pb_collapsible_kit {
220
+ padding: 0 !important;
221
+ }
222
+
223
+ &[class*="_collapsible_trail"] {
224
+ @include collapsible_trail_class;
225
+ }
23
226
 
227
+ .icon_wrapper {
228
+ border-radius: $border_radius_rounded;
229
+ width: $space_sm + 3;
230
+ height: $space_sm + 3;
231
+ display: flex;
232
+ align-items: center;
233
+ justify-content: center;
234
+ margin-right: $space_xs;
235
+ &:hover {
236
+ background-color: mix($primary, $card_light, 40%);
237
+ }
238
+ }
239
+
240
+ &.dark {
241
+ .pb_nav_list_kit_item {
242
+ border-color: $border_dark;
243
+ .pb_nav_list_item_text {
244
+ color: $text_dk_light !important;
245
+ }
246
+ }
247
+ &[class*="pb_nav_list_kit_item"] [class*="_link"]:hover {
248
+ .pb_nav_list_item_text {
249
+ color: $white !important;
250
+ }
251
+ }
252
+
253
+ .pb_nav_list_item_text_collapsible {
254
+ color: $white !important;
255
+ }
256
+ .pb_nav_list_item_text {
257
+ color: $text_dk_light;
258
+ }
259
+ .pb_nav_list_kit_item:hover {
260
+ background-color: #ffffff33;
261
+ color: $white;
262
+ }
263
+ .pb_icon_kit {
264
+ color: $text_dk_light;
265
+ }
266
+
267
+ .pb_collapsible_main_kit:hover {
268
+ background-color: mix($white, $card_dark, 20%);
269
+ .pb_nav_list_item_text_collapsible,
270
+ svg {
271
+ color: $white !important;
272
+ }
273
+ }
274
+ .icon_wrapper:hover {
275
+ background-color: mix($white, $card_dark, 40%);
276
+ }
277
+ &[class*="_active"] {
278
+ .icon_wrapper:hover {
279
+ background-color: mix($primary, $card_light, 40%);
280
+ }
281
+ }
282
+
283
+ &[class*="pb_collapsible_nav_item"][class*="_collapsible_trail"] {
284
+ .pb_collapsible_content_kit {
285
+ border-color: $border_dark;
286
+ }
287
+ }
24
288
  }
25
289
  }
26
290
  }
27
- }
@@ -81,6 +81,9 @@ $selector: ".pb_nav_list";
81
81
  // Horizontal Overrides
82
82
  [class*=pb_nav_list_kit_item] {
83
83
  margin: 0;
84
+ [class*=_item_text]{
85
+ font-weight: $regular;
86
+ }
84
87
  }
85
88
  [class*=_active] {
86
89
  background-color: $active_light;
@@ -101,6 +104,9 @@ $selector: ".pb_nav_list";
101
104
  // Horizontal Overrides
102
105
  [class*=pb_nav_list_kit_item] {
103
106
  margin: 0;
107
+ [class*=_item_text]{
108
+ font-weight: $regular;
109
+ }
104
110
  }
105
111
  [class*=_active] {
106
112
  [class*=_text] {