newspack-components 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/colors/colors.module.scss +277 -0
- package/copy-styles.js +8 -1
- package/dist/cjs/action-card/action-card.d.js +5 -0
- package/dist/cjs/action-card/index.js +282 -186
- package/dist/cjs/action-card/style.scss +142 -44
- package/dist/cjs/autocomplete-tokenfield/index.js +6 -2
- package/dist/cjs/box-contrast/index.js +49 -0
- package/dist/cjs/button/index.js +1 -1
- package/dist/cjs/button-props/button-props.js +41 -0
- package/dist/cjs/button-props/index.js +13 -0
- package/dist/cjs/color-picker/index.js +11 -0
- package/dist/cjs/custom-select-control/style.scss +7 -12
- package/dist/cjs/footer/index.js +17 -24
- package/dist/cjs/footer/style.scss +0 -36
- package/dist/cjs/handoff-message/index.js +0 -3
- package/dist/cjs/hooks/useObjectState.js +9 -0
- package/dist/cjs/hooks/useObjectState.test.js +6 -6
- package/dist/cjs/image-upload/index.test.js +2 -2
- package/dist/cjs/index.js +7 -21
- package/dist/cjs/modal/index.js +16 -18
- package/dist/cjs/modal/style.scss +18 -7
- package/dist/cjs/newspack-icon/index.js +2 -2
- package/dist/cjs/newspack-icon/style.scss +3 -5
- package/dist/cjs/notice/index.js +1 -2
- package/dist/cjs/notice/style.scss +11 -9
- package/dist/cjs/plugin-installer/index.js +3 -3
- package/dist/cjs/plugin-settings/SettingsSection.js +2 -0
- package/dist/cjs/plugin-settings/index.js +4 -1
- package/dist/cjs/plugin-toggle/index.js +2 -0
- package/dist/cjs/popover/style.scss +5 -6
- package/dist/cjs/progress-bar/index.test.js +8 -9
- package/dist/cjs/progress-bar/style.scss +1 -2
- package/dist/cjs/proxied-imports/router.js +1 -2
- package/dist/cjs/radio-control/style.scss +8 -11
- package/dist/cjs/section-header/index.js +21 -1
- package/dist/cjs/select-control/ButtonGroupControl.js +2 -0
- package/dist/cjs/settings/SettingsCard.js +2 -6
- package/dist/cjs/sortable-newsletter-list-control/index.js +7 -5
- package/dist/cjs/sortable-newsletter-list-control/style.scss +11 -1
- package/dist/cjs/steps-list/style.scss +0 -3
- package/dist/cjs/steps-list-item/style.scss +1 -2
- package/dist/cjs/style-card/index.js +1 -0
- package/dist/cjs/style-card/style.scss +4 -5
- package/dist/cjs/style.scss +15 -0
- package/dist/cjs/tabbed-navigation/index.js +17 -7
- package/dist/cjs/tabbed-navigation/style.scss +2 -6
- package/dist/cjs/utils/color.js +35 -0
- package/dist/cjs/web-preview/index.js +1 -1
- package/dist/cjs/web-preview/style.scss +11 -11
- package/dist/cjs/with-wizard/index.js +80 -3
- package/dist/cjs/with-wizard/style.scss +34 -13
- package/dist/cjs/with-wizard-screen/index.js +3 -3
- package/dist/cjs/with-wizard-screen/style.scss +9 -9
- package/dist/cjs/wizard/index.js +38 -13
- package/dist/cjs/wizard/store/index.js +13 -5
- package/dist/cjs/wizard/store/utils.js +3 -1
- package/dist/esm/action-card/action-card.d.js +1 -0
- package/dist/esm/action-card/index.js +286 -188
- package/dist/esm/action-card/style.scss +142 -44
- package/dist/esm/autocomplete-tokenfield/index.js +6 -2
- package/dist/esm/box-contrast/index.js +44 -0
- package/dist/esm/button/index.js +1 -1
- package/dist/esm/button-props/button-props.js +34 -0
- package/dist/esm/button-props/index.js +1 -0
- package/dist/esm/color-picker/index.js +11 -0
- package/dist/esm/custom-select-control/style.scss +7 -12
- package/dist/esm/footer/index.js +18 -25
- package/dist/esm/footer/style.scss +0 -36
- package/dist/esm/handoff-message/index.js +0 -3
- package/dist/esm/hooks/useObjectState.js +12 -2
- package/dist/esm/hooks/useObjectState.test.js +7 -7
- package/dist/esm/hooks/usePrompt.js +2 -2
- package/dist/esm/image-upload/index.test.js +2 -2
- package/dist/esm/index.js +1 -3
- package/dist/esm/modal/index.js +17 -19
- package/dist/esm/modal/style.scss +18 -7
- package/dist/esm/newspack-icon/index.js +2 -2
- package/dist/esm/newspack-icon/style.scss +3 -5
- package/dist/esm/notice/index.js +1 -2
- package/dist/esm/notice/style.scss +11 -9
- package/dist/esm/plugin-installer/index.js +3 -3
- package/dist/esm/plugin-settings/SettingsSection.js +2 -0
- package/dist/esm/plugin-settings/index.js +4 -1
- package/dist/esm/plugin-toggle/index.js +2 -0
- package/dist/esm/popover/style.scss +5 -6
- package/dist/esm/progress-bar/index.test.js +7 -7
- package/dist/esm/progress-bar/style.scss +1 -2
- package/dist/esm/radio-control/style.scss +8 -11
- package/dist/esm/section-header/index.js +22 -0
- package/dist/esm/select-control/ButtonGroupControl.js +2 -0
- package/dist/esm/settings/SettingsCard.js +2 -6
- package/dist/esm/sortable-newsletter-list-control/index.js +8 -6
- package/dist/esm/sortable-newsletter-list-control/style.scss +11 -1
- package/dist/esm/steps-list/style.scss +0 -3
- package/dist/esm/steps-list-item/style.scss +1 -2
- package/dist/esm/style-card/index.js +1 -0
- package/dist/esm/style-card/style.scss +4 -5
- package/dist/esm/style.scss +15 -0
- package/dist/esm/tabbed-navigation/index.js +17 -7
- package/dist/esm/tabbed-navigation/style.scss +2 -6
- package/dist/esm/utils/color.js +29 -0
- package/dist/esm/web-preview/index.js +1 -1
- package/dist/esm/web-preview/style.scss +11 -11
- package/dist/esm/with-wizard/index.js +81 -4
- package/dist/esm/with-wizard/style.scss +34 -13
- package/dist/esm/with-wizard-screen/index.js +1 -1
- package/dist/esm/with-wizard-screen/style.scss +9 -9
- package/dist/esm/wizard/index.js +39 -13
- package/dist/esm/wizard/store/index.js +14 -6
- package/dist/esm/wizard/store/utils.js +3 -1
- package/package.json +2 -2
- package/src/accordion/index.js +1 -3
- package/src/action-card/action-card.d.ts +40 -0
- package/src/action-card/index.js +284 -201
- package/src/action-card/style.scss +142 -44
- package/src/autocomplete-tokenfield/index.js +3 -2
- package/src/autocomplete-with-suggestions/index.js +52 -63
- package/src/box-contrast/index.tsx +44 -0
- package/src/button/index.tsx +1 -1
- package/src/button-card/index.js +1 -12
- package/src/card/index.js +1 -11
- package/src/category-autocomplete/index.js +4 -19
- package/src/color-picker/index.js +11 -7
- package/src/custom-select-control/style.scss +7 -12
- package/src/footer/index.js +6 -18
- package/src/footer/style.scss +0 -36
- package/src/form-token-field/index.js +1 -2
- package/src/grid/index.tsx +1 -8
- package/src/handoff/index.js +4 -11
- package/src/handoff-message/index.js +0 -3
- package/src/hooks/useObjectState.js +10 -2
- package/src/hooks/useObjectState.test.js +14 -14
- package/src/image-upload/index.js +3 -23
- package/src/index.js +1 -3
- package/src/modal/index.js +11 -17
- package/src/modal/style.scss +18 -7
- package/src/newspack-icon/index.js +3 -14
- package/src/newspack-icon/style.scss +3 -5
- package/src/notice/index.js +0 -2
- package/src/notice/style.scss +11 -9
- package/src/plugin-installer/index.js +8 -17
- package/src/plugin-settings/SettingsSection.js +3 -7
- package/src/plugin-settings/index.js +7 -14
- package/src/plugin-toggle/README.md +3 -3
- package/src/plugin-toggle/index.js +10 -13
- package/src/popover/index.js +1 -5
- package/src/popover/style.scss +5 -6
- package/src/position-control/index.js +65 -75
- package/src/progress-bar/index.js +2 -9
- package/src/progress-bar/index.test.js +4 -13
- package/src/progress-bar/style.scss +1 -2
- package/src/radio-control/style.scss +8 -11
- package/src/section-header/index.js +20 -0
- package/src/select-control/ButtonGroupControl.js +2 -9
- package/src/select-control/GroupedSelectControl.js +1 -9
- package/src/select-control/index.js +1 -5
- package/src/settings/MinMaxSetting.js +2 -14
- package/src/settings/SettingsCard.js +2 -11
- package/src/sortable-newsletter-list-control/index.js +10 -26
- package/src/sortable-newsletter-list-control/style.scss +11 -1
- package/src/steps-list/style.scss +0 -3
- package/src/steps-list-item/index.js +1 -4
- package/src/steps-list-item/style.scss +1 -2
- package/src/style-card/index.js +6 -21
- package/src/style-card/style.scss +4 -5
- package/src/style.scss +15 -0
- package/src/tabbed-navigation/index.js +19 -7
- package/src/tabbed-navigation/style.scss +2 -6
- package/src/text-control/index.tsx +2 -12
- package/src/utils/color.ts +32 -0
- package/src/web-preview/style.scss +11 -11
- package/src/with-wizard/index.js +67 -16
- package/src/with-wizard/style.scss +34 -13
- package/src/with-wizard-screen/index.js +1 -1
- package/src/with-wizard-screen/style.scss +9 -9
- package/src/wizard/components/WizardError.js +2 -7
- package/src/wizard/index.js +64 -62
- package/src/wizard/store/index.js +8 -10
- package/src/wizard/store/utils.js +3 -4
- package/dist/cjs/date-range-picker/index.js +0 -39
- package/dist/cjs/date-range-picker/style.scss +0 -148
- package/dist/cjs/newspack-logo/index.js +0 -54
- package/dist/cjs/newspack-logo/style.scss +0 -30
- package/dist/cjs/patrons-logo/index.js +0 -77
- package/dist/esm/date-range-picker/index.js +0 -31
- package/dist/esm/date-range-picker/style.scss +0 -148
- package/dist/esm/newspack-logo/index.js +0 -46
- package/dist/esm/newspack-logo/style.scss +0 -30
- package/dist/esm/patrons-logo/index.js +0 -70
- package/shared/scss/_colors.scss +0 -27
- package/src/date-range-picker/index.js +0 -31
- package/src/date-range-picker/style.scss +0 -148
- package/src/newspack-logo/index.js +0 -45
- package/src/newspack-logo/style.scss +0 -30
- package/src/patrons-logo/index.js +0 -76
- /package/{shared/js → src/button-props}/button-props.js +0 -0
- /package/{shared/js → src/button-props}/index.js +0 -0
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
padding: 0;
|
|
10
10
|
border-color: wp-colors.$gray-300;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/* Clickable */
|
|
14
13
|
&.newspack-card--is-clickable {
|
|
15
14
|
transition: box-shadow 125ms ease-in-out;
|
|
16
15
|
|
|
@@ -19,8 +18,7 @@
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
/* Status */
|
|
24
22
|
&.newspack-card__is-disabled,
|
|
25
23
|
&.newspack-card__is-primary,
|
|
26
24
|
&.newspack-card__is-secondary,
|
|
@@ -49,7 +47,7 @@
|
|
|
49
47
|
box-shadow: inset 4px 0 0 wp-colors.$alert-red;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
/* Small */
|
|
53
51
|
&.is-small {
|
|
54
52
|
.newspack-action-card__region-top {
|
|
55
53
|
padding: 8px 16px;
|
|
@@ -116,8 +114,7 @@
|
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
/* Medium */
|
|
121
118
|
&.is-medium {
|
|
122
119
|
.newspack-action-card__region-top {
|
|
123
120
|
padding: 16px;
|
|
@@ -146,8 +143,7 @@
|
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
145
|
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
/* Nested children */
|
|
151
147
|
&.newspack-card--has-children {
|
|
152
148
|
.newspack-action-card {
|
|
153
149
|
&:first-child {
|
|
@@ -164,8 +160,7 @@
|
|
|
164
160
|
}
|
|
165
161
|
}
|
|
166
162
|
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
/* Has grey header */
|
|
169
164
|
&.newspack-card--has-grey-header {
|
|
170
165
|
overflow: hidden;
|
|
171
166
|
|
|
@@ -198,8 +193,7 @@
|
|
|
198
193
|
}
|
|
199
194
|
}
|
|
200
195
|
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
/* Indent */
|
|
203
197
|
&.newspack-card--indent {
|
|
204
198
|
margin-left: 56px;
|
|
205
199
|
position: relative;
|
|
@@ -216,8 +210,7 @@
|
|
|
216
210
|
}
|
|
217
211
|
}
|
|
218
212
|
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
/* Typography */
|
|
221
214
|
h2,
|
|
222
215
|
p:not([class*="components-base-control"]) {
|
|
223
216
|
margin: 0;
|
|
@@ -247,8 +240,7 @@
|
|
|
247
240
|
}
|
|
248
241
|
}
|
|
249
242
|
|
|
250
|
-
|
|
251
|
-
|
|
243
|
+
/* Regions */
|
|
252
244
|
.newspack-action-card__region {
|
|
253
245
|
align-items: center;
|
|
254
246
|
display: flex;
|
|
@@ -264,7 +256,7 @@
|
|
|
264
256
|
display: flex;
|
|
265
257
|
}
|
|
266
258
|
|
|
267
|
-
|
|
259
|
+
/* Toggle Control */
|
|
268
260
|
.components-toggle-control {
|
|
269
261
|
margin-bottom: 24px;
|
|
270
262
|
margin-top: 0;
|
|
@@ -359,14 +351,12 @@
|
|
|
359
351
|
}
|
|
360
352
|
}
|
|
361
353
|
|
|
362
|
-
|
|
363
|
-
|
|
354
|
+
/* Waiting */
|
|
364
355
|
.newspack-action-card__container {
|
|
365
356
|
display: flex;
|
|
366
357
|
}
|
|
367
358
|
|
|
368
|
-
|
|
369
|
-
|
|
359
|
+
/* Notifications */
|
|
370
360
|
.newspack-action-card__notification {
|
|
371
361
|
.newspack-notice {
|
|
372
362
|
margin: 0;
|
|
@@ -383,8 +373,7 @@
|
|
|
383
373
|
}
|
|
384
374
|
}
|
|
385
375
|
|
|
386
|
-
|
|
387
|
-
|
|
376
|
+
/* Image */
|
|
388
377
|
.newspack-action-card__image {
|
|
389
378
|
background-position: center;
|
|
390
379
|
background-repeat: no-repeat;
|
|
@@ -394,40 +383,52 @@
|
|
|
394
383
|
width: 48px;
|
|
395
384
|
}
|
|
396
385
|
|
|
397
|
-
|
|
398
|
-
|
|
386
|
+
/* Icon */
|
|
399
387
|
.newspack_plugin-installer__icon {
|
|
400
388
|
margin: 0;
|
|
401
389
|
}
|
|
402
390
|
|
|
403
|
-
|
|
404
|
-
|
|
391
|
+
/* Badge */
|
|
405
392
|
.newspack-action-card__badge {
|
|
406
393
|
background: wp-colors.$gray-100;
|
|
407
394
|
border-radius: 2px;
|
|
408
395
|
color: wp-colors.$gray-900;
|
|
409
396
|
display: block;
|
|
410
397
|
flex: 0 0 auto;
|
|
411
|
-
font-size:
|
|
412
|
-
font-weight:
|
|
413
|
-
line-height: 1.
|
|
398
|
+
font-size: 12px;
|
|
399
|
+
font-weight: 400;
|
|
400
|
+
line-height: 1.333;
|
|
414
401
|
margin: 0 8px 0 0;
|
|
415
|
-
padding: 2px
|
|
416
|
-
|
|
402
|
+
padding: 2px 4px;
|
|
403
|
+
|
|
404
|
+
&.newspack-action-card__badge-level-warning {
|
|
405
|
+
background-color: color-mix(in srgb, #fff 90%, wp-colors.$alert-yellow);
|
|
406
|
+
color: color-mix(in srgb, #000 50%, wp-colors.$alert-yellow);
|
|
407
|
+
}
|
|
408
|
+
&.newspack-action-card__badge-level-error {
|
|
409
|
+
background-color: color-mix(in srgb, #fff 90%, wp-colors.$alert-red);
|
|
410
|
+
color: color-mix(in srgb, #000 50%, wp-colors.$alert-red);
|
|
411
|
+
}
|
|
412
|
+
&.newspack-action-card__badge-level-success {
|
|
413
|
+
background-color: color-mix(in srgb, #fff 90%, wp-colors.$alert-green);
|
|
414
|
+
color: color-mix(in srgb, #000 50%, wp-colors.$alert-green);
|
|
415
|
+
}
|
|
416
|
+
&.newspack-action-card__badge-level-brand {
|
|
417
|
+
background-color: color-mix(in srgb, #fff 90%, var(--wp-admin-theme-color));
|
|
418
|
+
color: color-mix(in srgb, #000 50%, var(--wp-admin-theme-color));
|
|
419
|
+
}
|
|
417
420
|
|
|
418
421
|
+ .newspack-action-card__badge {
|
|
419
422
|
margin-left: -4px;
|
|
420
423
|
}
|
|
421
424
|
}
|
|
422
425
|
|
|
423
|
-
|
|
424
|
-
|
|
426
|
+
/* Description Card */
|
|
425
427
|
&.newspack-description-card {
|
|
426
428
|
font-style: italic;
|
|
427
429
|
}
|
|
428
430
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
+
/* Expandable card children */
|
|
431
432
|
&.is-expandable {
|
|
432
433
|
.newspack-action-card__title .components-button.is-link {
|
|
433
434
|
color: inherit;
|
|
@@ -439,6 +440,10 @@
|
|
|
439
440
|
.newspack-action-card__region-children {
|
|
440
441
|
border-top: 1px solid wp-colors.$gray-100;
|
|
441
442
|
padding-top: 24px;
|
|
443
|
+
|
|
444
|
+
+ .newspack-action-card__region-children {
|
|
445
|
+
border-top: none;
|
|
446
|
+
}
|
|
442
447
|
}
|
|
443
448
|
|
|
444
449
|
&.is-medium .newspack-action-card__region-children {
|
|
@@ -460,7 +465,7 @@
|
|
|
460
465
|
}
|
|
461
466
|
}
|
|
462
467
|
|
|
463
|
-
|
|
468
|
+
/* Action content with multiple buttons */
|
|
464
469
|
&.has-action-content .newspack-action-card__region-right {
|
|
465
470
|
flex-direction: row;
|
|
466
471
|
|
|
@@ -468,16 +473,109 @@
|
|
|
468
473
|
margin-left: 8px;
|
|
469
474
|
}
|
|
470
475
|
}
|
|
476
|
+
}
|
|
471
477
|
|
|
472
|
-
|
|
478
|
+
.newspack-card {
|
|
479
|
+
.newspack-card.newspack-action-card {
|
|
480
|
+
&:not(.newspack-card__no-border) {
|
|
481
|
+
border: 1px solid wp-colors.$gray-200;
|
|
482
|
+
}
|
|
483
|
+
&.newspack-card__no-border {
|
|
484
|
+
border: none;
|
|
485
|
+
.newspack-action-card__region-top,
|
|
486
|
+
.newspack-action-card__region-children {
|
|
487
|
+
padding: 0;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.newspack-action-card__draggable-wrapper {
|
|
494
|
+
margin: 16px 0;
|
|
473
495
|
|
|
474
|
-
|
|
475
|
-
|
|
496
|
+
&.is-dragging {
|
|
497
|
+
opacity: 0.5;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.newspack-card {
|
|
501
|
+
margin: 0;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.newspack-action-card {
|
|
505
|
+
display: flex;
|
|
506
|
+
flex-direction: row;
|
|
507
|
+
flex-wrap: wrap;
|
|
508
|
+
|
|
509
|
+
.newspack-action-card__draggable-controls {
|
|
510
|
+
flex: 0 0 50px;
|
|
511
|
+
align-items: center;
|
|
512
|
+
display: flex;
|
|
513
|
+
height: 100%;
|
|
514
|
+
min-height: 100%;
|
|
515
|
+
width: fit-content;
|
|
516
|
+
justify-content: center;
|
|
517
|
+
margin-left: 8px;
|
|
518
|
+
margin-right: 8px;
|
|
519
|
+
padding: 8px 12px 8px 0;
|
|
520
|
+
border-right: 1px solid wp-colors.$gray-300;
|
|
521
|
+
|
|
522
|
+
.drag-handle {
|
|
523
|
+
align-items: center;
|
|
524
|
+
cursor: grab;
|
|
525
|
+
display: flex;
|
|
526
|
+
height: 100%;
|
|
527
|
+
justify-content: flex-end;
|
|
528
|
+
margin-left: -8px;
|
|
529
|
+
width: 32px;
|
|
530
|
+
|
|
531
|
+
.is-dragging & {
|
|
532
|
+
cursor: grabbing;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
svg {
|
|
536
|
+
padding: 3px;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.movers {
|
|
541
|
+
display: flex;
|
|
542
|
+
flex-direction: column;
|
|
543
|
+
|
|
544
|
+
.components-button {
|
|
545
|
+
color: wp-colors.$gray-900;
|
|
546
|
+
display: block;
|
|
547
|
+
height: 24px;
|
|
548
|
+
line-height: 24px;
|
|
549
|
+
min-width: 24px;
|
|
550
|
+
padding: 0;
|
|
551
|
+
width: 24px;
|
|
552
|
+
+ .components-button {
|
|
553
|
+
margin-top: -4px;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.newspack-action-card__region-top {
|
|
560
|
+
flex: 1 1 auto;
|
|
561
|
+
padding: 8px 16px 8px 0 !important;
|
|
562
|
+
flex: 1;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.newspack-action-card__region-children {
|
|
566
|
+
flex: 0 0 100%;
|
|
567
|
+
padding: 0 0 0 16px;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
&.is-draggable {
|
|
571
|
+
display: flex;
|
|
572
|
+
align-items: center;
|
|
573
|
+
}
|
|
476
574
|
}
|
|
477
575
|
}
|
|
478
576
|
|
|
479
|
-
.
|
|
480
|
-
.newspack-card
|
|
481
|
-
|
|
577
|
+
.components-draggable__clone {
|
|
578
|
+
.newspack-card {
|
|
579
|
+
box-shadow: 0 0 8px 4px rgba(black, 0.08);
|
|
482
580
|
}
|
|
483
581
|
}
|
|
@@ -207,7 +207,7 @@ class AutocompleteTokenField extends Component {
|
|
|
207
207
|
* Render.
|
|
208
208
|
*/
|
|
209
209
|
render() {
|
|
210
|
-
const { help, label = '', placeholder = '', maxLength } = this.props;
|
|
210
|
+
const { help, label = '', placeholder = '', maxLength, style, __next40pxDefaultSize } = this.props;
|
|
211
211
|
const { suggestions, loading } = this.state;
|
|
212
212
|
|
|
213
213
|
const classNames = [ 'newspack-autocomplete-tokenfield__input-container' ];
|
|
@@ -217,7 +217,7 @@ class AutocompleteTokenField extends Component {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
return (
|
|
220
|
-
<div className="newspack-autocomplete-tokenfield">
|
|
220
|
+
<div className="newspack-autocomplete-tokenfield" style={ style }>
|
|
221
221
|
<div className={ classNames.join( ' ' ) }>
|
|
222
222
|
<FormTokenField
|
|
223
223
|
value={ this.getTokens() }
|
|
@@ -227,6 +227,7 @@ class AutocompleteTokenField extends Component {
|
|
|
227
227
|
label={ label }
|
|
228
228
|
maxLength={ maxLength }
|
|
229
229
|
placeholder={ placeholder }
|
|
230
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
230
231
|
/>
|
|
231
232
|
{ loading && <Spinner /> }
|
|
232
233
|
</div>
|
|
@@ -81,24 +81,24 @@ const AutocompleteWithSuggestions = ( {
|
|
|
81
81
|
const handleFetchSaved = fetchSavedPosts
|
|
82
82
|
? fetchSavedPosts
|
|
83
83
|
: async ( postIds = [], searchSlug = null ) => {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const postTypeSlug = searchSlug || postTypeToSearch;
|
|
85
|
+
const endpoint =
|
|
86
86
|
'post' === postTypeSlug || 'page' === postTypeSlug
|
|
87
87
|
? postTypeSlug + 's' // Default post type endpoints are plural.
|
|
88
88
|
: postTypeSlug; // Custom post type endpoints are singular.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
const posts = await apiFetch( {
|
|
90
|
+
path: addQueryArgs( '/wp/v2/' + endpoint, {
|
|
91
|
+
per_page: 100,
|
|
92
|
+
include: postIds.join( ',' ),
|
|
93
|
+
_fields: 'id,title',
|
|
94
|
+
} ),
|
|
95
|
+
} );
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
return posts.map( post => ( {
|
|
98
|
+
value: parseInt( post.id ),
|
|
99
|
+
label: decodeEntities( post.title ) || __( '(no title)', 'newspack-plugin' ),
|
|
100
|
+
} ) );
|
|
101
|
+
};
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* If passed a `fetchSuggestions` prop, use that, otherwise, build it based on the selected post type.
|
|
@@ -106,36 +106,36 @@ const AutocompleteWithSuggestions = ( {
|
|
|
106
106
|
const handleFetchSuggestions = fetchSuggestions
|
|
107
107
|
? fetchSuggestions
|
|
108
108
|
: async ( search = null, offset = 0, searchSlug = null ) => {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const postTypeSlug = searchSlug || postTypeToSearch;
|
|
110
|
+
const endpoint =
|
|
111
111
|
'post' === postTypeSlug || 'page' === postTypeSlug
|
|
112
112
|
? postTypeSlug + 's' // Default post type endpoints are plural.
|
|
113
113
|
: postTypeSlug; // Custom post type endpoints are singular.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
const response = await apiFetch( {
|
|
115
|
+
parse: false,
|
|
116
|
+
path: addQueryArgs( '/wp/v2/' + endpoint, {
|
|
117
|
+
search,
|
|
118
|
+
offset,
|
|
119
|
+
per_page: suggestionsToFetch,
|
|
120
|
+
_fields: 'id,title',
|
|
121
|
+
} ),
|
|
122
|
+
} );
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const total = parseInt( response.headers.get( 'x-wp-total' ) || 0 );
|
|
125
|
+
const posts = await response.json();
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
setMaxSuggestions( total );
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
// Format suggestions for FormTokenField display.
|
|
130
|
+
return posts.reduce( ( acc, post ) => {
|
|
131
|
+
acc.push( {
|
|
132
|
+
value: parseInt( post.id ),
|
|
133
|
+
label: decodeEntities( post?.title.rendered ) || __( '(no title)', 'newspack-plugin' ),
|
|
134
|
+
} );
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
return acc;
|
|
137
|
+
}, [] );
|
|
138
|
+
};
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* Intercept onChange callback so we can decide whether to allow multiple selections.
|
|
@@ -151,9 +151,7 @@ const AutocompleteWithSuggestions = ( {
|
|
|
151
151
|
|
|
152
152
|
// Loop through new selections to determine whether to add or remove them.
|
|
153
153
|
_selections.forEach( _selection => {
|
|
154
|
-
const existingSelection = selections.findIndex(
|
|
155
|
-
selection => parseInt( selection.value ) === parseInt( _selection.value )
|
|
156
|
-
);
|
|
154
|
+
const existingSelection = selections.findIndex( selection => parseInt( selection.value ) === parseInt( _selection.value ) );
|
|
157
155
|
|
|
158
156
|
if ( -1 < existingSelection ) {
|
|
159
157
|
// If the selection is already selected, remove it.
|
|
@@ -176,15 +174,16 @@ const AutocompleteWithSuggestions = ( {
|
|
|
176
174
|
const selections = selectedPost ? [ ...selectedItems, selectedPost ] : selectedItems;
|
|
177
175
|
const selectedMessage = multiSelect
|
|
178
176
|
? sprintf(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
177
|
+
// Translators: %1: the length of selections. %2: the selection leabel.
|
|
178
|
+
__( '%1$s %2$s selected', 'newspack-plugin' ),
|
|
179
|
+
selections.length,
|
|
180
|
+
selections.length > 1 ? postTypeLabelPlural : postTypeLabel
|
|
181
|
+
)
|
|
182
|
+
: sprintf(
|
|
183
|
+
// Translators: %s: The label for the selection.
|
|
184
|
+
__( 'Selected %s', 'newspack-plugin' ),
|
|
185
|
+
postTypeLabel
|
|
186
|
+
);
|
|
188
187
|
|
|
189
188
|
return (
|
|
190
189
|
<div className="newspack-autocomplete-with-suggestions__selected-items">
|
|
@@ -202,9 +201,7 @@ const AutocompleteWithSuggestions = ( {
|
|
|
202
201
|
key={ selection.value }
|
|
203
202
|
className="newspack-autocomplete-with-suggestions__selected-item-button"
|
|
204
203
|
isTertiary
|
|
205
|
-
onClick={ () =>
|
|
206
|
-
onChange( selections.filter( _selection => _selection.value !== selection.value ) )
|
|
207
|
-
}
|
|
204
|
+
onClick={ () => onChange( selections.filter( _selection => _selection.value !== selection.value ) ) }
|
|
208
205
|
>
|
|
209
206
|
{ selection.label }
|
|
210
207
|
</Button>
|
|
@@ -243,9 +240,7 @@ const AutocompleteWithSuggestions = ( {
|
|
|
243
240
|
if ( multiSelect ) {
|
|
244
241
|
const selections = selectedPost ? [ ...selectedItems, selectedPost ] : [ ...selectedItems ];
|
|
245
242
|
const isSelected = !! selections.find(
|
|
246
|
-
_selection =>
|
|
247
|
-
parseInt( _selection.value ) === parseInt( suggestion.value ) &&
|
|
248
|
-
_selection.label === suggestion.label
|
|
243
|
+
_selection => parseInt( _selection.value ) === parseInt( suggestion.value ) && _selection.label === suggestion.label
|
|
249
244
|
);
|
|
250
245
|
return (
|
|
251
246
|
<CheckboxControl
|
|
@@ -290,14 +285,8 @@ const AutocompleteWithSuggestions = ( {
|
|
|
290
285
|
<div className={ className }>
|
|
291
286
|
{ suggestions.map( renderSuggestion ) }
|
|
292
287
|
{ suggestions.length < ( maxItemsToSuggest || maxSuggestions ) && (
|
|
293
|
-
<Button
|
|
294
|
-
|
|
295
|
-
isSecondary
|
|
296
|
-
onClick={ () => setIsLoadingMore( true ) }
|
|
297
|
-
>
|
|
298
|
-
{ isLoadingMore
|
|
299
|
-
? __( 'Loading…', 'newspack-plugin' )
|
|
300
|
-
: __( 'Load more', 'newspack-plugin' ) }
|
|
288
|
+
<Button disabled={ isLoadingMore } isSecondary onClick={ () => setIsLoadingMore( true ) }>
|
|
289
|
+
{ isLoadingMore ? __( 'Loading…', 'newspack-plugin' ) : __( 'Load more', 'newspack-plugin' ) }
|
|
301
290
|
</Button>
|
|
302
291
|
) }
|
|
303
292
|
</div>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Box Contrast
|
|
3
|
+
*
|
|
4
|
+
* can be used to dynamically assign black or white color/background-color based on a hex color.
|
|
5
|
+
* Black/white can be assigned to either text or background-color.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { getContrast } from '../utils/color';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Box Contrast component
|
|
15
|
+
*
|
|
16
|
+
* @return JSX.Element
|
|
17
|
+
*/
|
|
18
|
+
const BoxContrast = ( {
|
|
19
|
+
hexColor,
|
|
20
|
+
isInverted = false,
|
|
21
|
+
children,
|
|
22
|
+
...props
|
|
23
|
+
}: {
|
|
24
|
+
children: string | JSX.Element;
|
|
25
|
+
hexColor: string;
|
|
26
|
+
isInverted?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
} ) => {
|
|
29
|
+
let contrastColor;
|
|
30
|
+
if ( hexColor === '#f0f0f0' ) {
|
|
31
|
+
contrastColor = '#1e1e1e';
|
|
32
|
+
} else {
|
|
33
|
+
contrastColor = getContrast( hexColor );
|
|
34
|
+
}
|
|
35
|
+
const style = isInverted ? { color: hexColor, backgoundColor: contrastColor } : { backgroundColor: hexColor, color: contrastColor };
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div { ...props } style={ style }>
|
|
39
|
+
{ children }
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default BoxContrast;
|
package/src/button/index.tsx
CHANGED
|
@@ -41,7 +41,7 @@ const Button = ( { href, onClick, ...otherProps }: Props ) => {
|
|
|
41
41
|
if ( isAwaitingOnClick ) {
|
|
42
42
|
otherProps.disabled = true;
|
|
43
43
|
}
|
|
44
|
-
// @ts-
|
|
44
|
+
// @ts-expect-error - @wordpress/components' Button can only have either href or onClick, not both.
|
|
45
45
|
return <BaseComponent { ...otherProps } />;
|
|
46
46
|
};
|
|
47
47
|
|
package/src/button-card/index.js
CHANGED
|
@@ -24,18 +24,7 @@ class ButtonCard extends Component {
|
|
|
24
24
|
* Render
|
|
25
25
|
*/
|
|
26
26
|
render() {
|
|
27
|
-
const {
|
|
28
|
-
chevron,
|
|
29
|
-
className,
|
|
30
|
-
desc,
|
|
31
|
-
grouped,
|
|
32
|
-
icon,
|
|
33
|
-
isDestructive,
|
|
34
|
-
isPressed,
|
|
35
|
-
isSmall,
|
|
36
|
-
title,
|
|
37
|
-
...otherProps
|
|
38
|
-
} = this.props;
|
|
27
|
+
const { chevron, className, desc, grouped, icon, isDestructive, isPressed, isSmall, title, ...otherProps } = this.props;
|
|
39
28
|
const classes = classnames(
|
|
40
29
|
'newspack-button-card',
|
|
41
30
|
className,
|
package/src/card/index.js
CHANGED
|
@@ -22,17 +22,7 @@ class Card extends Component {
|
|
|
22
22
|
* Render
|
|
23
23
|
*/
|
|
24
24
|
render() {
|
|
25
|
-
const {
|
|
26
|
-
buttonsCard,
|
|
27
|
-
className,
|
|
28
|
-
headerActions,
|
|
29
|
-
isNarrow,
|
|
30
|
-
isMedium,
|
|
31
|
-
isSmall,
|
|
32
|
-
isWhite,
|
|
33
|
-
noBorder,
|
|
34
|
-
...otherProps
|
|
35
|
-
} = this.props;
|
|
25
|
+
const { buttonsCard, className, headerActions, isNarrow, isMedium, isSmall, isWhite, noBorder, ...otherProps } = this.props;
|
|
36
26
|
const classes = classNames(
|
|
37
27
|
'newspack-card',
|
|
38
28
|
className,
|
|
@@ -79,10 +79,7 @@ class CategoryAutocomplete extends Component {
|
|
|
79
79
|
} )
|
|
80
80
|
.then( categories => {
|
|
81
81
|
this.setState( {
|
|
82
|
-
suggestions: categories.reduce(
|
|
83
|
-
( accumulator, category ) => ( { ...accumulator, [ category.name ]: category } ),
|
|
84
|
-
{}
|
|
85
|
-
),
|
|
82
|
+
suggestions: categories.reduce( ( accumulator, category ) => ( { ...accumulator, [ category.name ]: category } ), {} ),
|
|
86
83
|
} );
|
|
87
84
|
} )
|
|
88
85
|
.finally( () => this.setState( { isLoading: false } ) );
|
|
@@ -114,10 +111,7 @@ class CategoryAutocomplete extends Component {
|
|
|
114
111
|
}
|
|
115
112
|
return acc;
|
|
116
113
|
}, [] );
|
|
117
|
-
const availableSuggestions = filter(
|
|
118
|
-
suggestions,
|
|
119
|
-
( { id } ) => selectedIds.indexOf( id ) === -1
|
|
120
|
-
);
|
|
114
|
+
const availableSuggestions = filter( suggestions, ( { id } ) => selectedIds.indexOf( id ) === -1 );
|
|
121
115
|
return availableSuggestions.map( v => v.name );
|
|
122
116
|
};
|
|
123
117
|
|
|
@@ -125,15 +119,7 @@ class CategoryAutocomplete extends Component {
|
|
|
125
119
|
* Render the component.
|
|
126
120
|
*/
|
|
127
121
|
render() {
|
|
128
|
-
const {
|
|
129
|
-
className,
|
|
130
|
-
disabled,
|
|
131
|
-
description,
|
|
132
|
-
hideHelpFromVision,
|
|
133
|
-
hideLabelFromVision,
|
|
134
|
-
label,
|
|
135
|
-
value,
|
|
136
|
-
} = this.props;
|
|
122
|
+
const { className, disabled, description, hideHelpFromVision, hideLabelFromVision, label, value } = this.props;
|
|
137
123
|
const { allCategories, isLoading } = this.state;
|
|
138
124
|
const classes = classnames( 'newspack-category-autocomplete', className );
|
|
139
125
|
return (
|
|
@@ -141,8 +127,7 @@ class CategoryAutocomplete extends Component {
|
|
|
141
127
|
<FormTokenField
|
|
142
128
|
onInputChange={ input => this.debouncedUpdateSuggestions( input ) }
|
|
143
129
|
value={ value.reduce( ( acc, item ) => {
|
|
144
|
-
const categoryOrItem =
|
|
145
|
-
typeof item === 'number' ? find( allCategories, [ 'id', item ] ) : item;
|
|
130
|
+
const categoryOrItem = typeof item === 'number' ? find( allCategories, [ 'id', item ] ) : item;
|
|
146
131
|
if ( categoryOrItem ) {
|
|
147
132
|
acc.push( {
|
|
148
133
|
id: categoryOrItem.term_id || categoryOrItem.id,
|
|
@@ -21,6 +21,16 @@ import './style.scss';
|
|
|
21
21
|
extend( [ a11yPlugin ] );
|
|
22
22
|
const { InteractiveDiv } = utils;
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* ColorPicker component.
|
|
26
|
+
*
|
|
27
|
+
* @param {Object} props - Component props.
|
|
28
|
+
* @param {JSX.Element|string} props.label - Label for the color picker.
|
|
29
|
+
* @param {string} [props.color] - Default color.
|
|
30
|
+
* @param {Function} props.onChange - Function to call when the color changes.
|
|
31
|
+
* @param {string} [props.className] - Additional class name.
|
|
32
|
+
* @return {JSX.Element} ColorPicker component.
|
|
33
|
+
*/
|
|
24
34
|
const ColorPicker = ( { label, color = '#fff', onChange, className } ) => {
|
|
25
35
|
const [ isExpanded, setIsExpanded ] = useState( false );
|
|
26
36
|
const ref = useRef();
|
|
@@ -42,13 +52,7 @@ const ColorPicker = ( { label, color = '#fff', onChange, className } ) => {
|
|
|
42
52
|
</InteractiveDiv>
|
|
43
53
|
|
|
44
54
|
<div className="newspack-color-picker__main" ref={ ref }>
|
|
45
|
-
{ isExpanded && (
|
|
46
|
-
<ColorPickerComponent
|
|
47
|
-
color={ color }
|
|
48
|
-
onChange={ hex => onChange( hex ) }
|
|
49
|
-
enableAlpha={ false }
|
|
50
|
-
/>
|
|
51
|
-
) }
|
|
55
|
+
{ isExpanded && <ColorPickerComponent color={ color } onChange={ hex => onChange( hex ) } enableAlpha={ false } /> }
|
|
52
56
|
</div>
|
|
53
57
|
</div>
|
|
54
58
|
);
|