newspack-components 4.10.0 → 4.11.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/CHANGELOG.md +7 -0
- package/DEVELOPMENT.md +1 -0
- package/dist/cjs/card-sortable-list/index.js +6 -3
- package/dist/cjs/card-sortable-list/index.test.js +21 -0
- package/dist/cjs/card-sortable-list/style.scss +8 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/reorder-modal/index.js +521 -0
- package/dist/cjs/reorder-modal/index.test.js +1223 -0
- package/dist/cjs/reorder-modal/style.scss +114 -0
- package/dist/esm/card-sortable-list/index.js +5 -2
- package/dist/esm/card-sortable-list/index.test.js +21 -0
- package/dist/esm/card-sortable-list/style.scss +8 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/reorder-modal/index.js +514 -0
- package/dist/esm/reorder-modal/index.test.js +1224 -0
- package/dist/esm/reorder-modal/style.scss +114 -0
- package/package.json +1 -1
- package/src/card-sortable-list/index.test.js +13 -0
- package/src/card-sortable-list/index.tsx +4 -1
- package/src/card-sortable-list/style.scss +8 -0
- package/src/index.js +1 -0
- package/src/reorder-modal/index.js +484 -0
- package/src/reorder-modal/index.test.js +566 -0
- package/src/reorder-modal/style.scss +114 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
2
|
+
@use "~@wordpress/base-styles/mixins" as wp-mixins;
|
|
3
|
+
@use "~@wordpress/base-styles/variables" as wp-vars;
|
|
4
|
+
|
|
5
|
+
.newspack-reorder-modal {
|
|
6
|
+
&__body {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
min-height: calc(#{wp-vars.$grid-unit} * 23);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&__loading {
|
|
13
|
+
align-items: center;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex: 1;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&__notice {
|
|
20
|
+
margin: 0 0 wp-vars.$grid-unit-10;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__list {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: wp-vars.$grid-unit-10;
|
|
27
|
+
list-style: none;
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&__item {
|
|
33
|
+
--newspack-reorder-modal-divider: #{wp-colors.$gray-100};
|
|
34
|
+
--wp-ui-card-padding: #{wp-vars.$grid-unit-15};
|
|
35
|
+
|
|
36
|
+
align-items: stretch;
|
|
37
|
+
cursor: grab;
|
|
38
|
+
flex-direction: row;
|
|
39
|
+
margin: 0;
|
|
40
|
+
|
|
41
|
+
&:focus-within,
|
|
42
|
+
&:hover {
|
|
43
|
+
--newspack-reorder-modal-divider: #{wp-colors.$gray-300};
|
|
44
|
+
|
|
45
|
+
border-color: wp-colors.$gray-300;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.is-dragging {
|
|
49
|
+
cursor: grabbing;
|
|
50
|
+
opacity: 0.5;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__grip {
|
|
55
|
+
align-items: center;
|
|
56
|
+
color: wp-colors.$gray-700;
|
|
57
|
+
display: flex;
|
|
58
|
+
padding-left: wp-vars.$grid-unit-05;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__move {
|
|
62
|
+
align-items: center;
|
|
63
|
+
border-right: 1px solid var(--newspack-reorder-modal-divider);
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
padding: wp-vars.$grid-unit-05;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&__content {
|
|
70
|
+
align-items: center;
|
|
71
|
+
align-self: center;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex: 1;
|
|
74
|
+
gap: wp-vars.$grid-unit-10;
|
|
75
|
+
min-width: 0;
|
|
76
|
+
padding-block-end: var(--wp-ui-card-padding);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&__title {
|
|
80
|
+
@include wp-mixins.heading-large();
|
|
81
|
+
|
|
82
|
+
min-width: 0;
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
text-overflow: ellipsis;
|
|
85
|
+
white-space: nowrap;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&__badge {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-shrink: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&__toggle {
|
|
94
|
+
align-items: center;
|
|
95
|
+
display: flex;
|
|
96
|
+
padding-inline-end: wp-vars.$grid-unit-15;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&__description {
|
|
100
|
+
margin: 0 0 wp-vars.$grid-unit-20;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&__item.is-off &__title {
|
|
104
|
+
color: wp-colors.$gray-700;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&__footer {
|
|
108
|
+
display: flex;
|
|
109
|
+
gap: wp-vars.$grid-unit-10;
|
|
110
|
+
justify-content: flex-end;
|
|
111
|
+
margin-top: auto;
|
|
112
|
+
padding-top: wp-vars.$grid-unit-30;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -17,7 +17,7 @@ import { Badge } from '@wordpress/ui';
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
20
|
-
import
|
|
20
|
+
import Card from '../card';
|
|
21
21
|
import './style.scss';
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -412,7 +412,10 @@ var CardSortableList = function CardSortableList(_ref) {
|
|
|
412
412
|
}, item.onToggleChange !== undefined && {
|
|
413
413
|
actionType: 'toggle',
|
|
414
414
|
isActive: item.toggleChecked,
|
|
415
|
-
onToggle: item.onToggleChange
|
|
415
|
+
onToggle: item.onToggleChange,
|
|
416
|
+
// Names the toggle for assistive tech. The card hides this
|
|
417
|
+
// label, since the header already shows the title.
|
|
418
|
+
title: item.title
|
|
416
419
|
}), item.actions !== undefined && {
|
|
417
420
|
actions: item.actions
|
|
418
421
|
})
|
|
@@ -43,4 +43,25 @@ describe('CardSortableList', function () {
|
|
|
43
43
|
// An unguarded Badge would still emit an empty span, so assert on element children.
|
|
44
44
|
expect(container.querySelector('h3').children).toHaveLength(0);
|
|
45
45
|
});
|
|
46
|
+
it('names each toggle after its item', function () {
|
|
47
|
+
render(/*#__PURE__*/_jsx(CardSortableList, {
|
|
48
|
+
items: [{
|
|
49
|
+
id: 1,
|
|
50
|
+
title: 'Homepage',
|
|
51
|
+
toggleChecked: true,
|
|
52
|
+
onToggleChange: function onToggleChange() {}
|
|
53
|
+
}, {
|
|
54
|
+
id: 2,
|
|
55
|
+
title: 'About',
|
|
56
|
+
toggleChecked: false,
|
|
57
|
+
onToggleChange: function onToggleChange() {}
|
|
58
|
+
}]
|
|
59
|
+
}));
|
|
60
|
+
expect(screen.getByRole('checkbox', {
|
|
61
|
+
name: 'Homepage'
|
|
62
|
+
})).toBeChecked();
|
|
63
|
+
expect(screen.getByRole('checkbox', {
|
|
64
|
+
name: 'About'
|
|
65
|
+
})).not.toBeChecked();
|
|
66
|
+
});
|
|
46
67
|
});
|
|
@@ -6,6 +6,14 @@ $drop-duration: 400ms; /* must match DROP_ANIMATION_DURATION in index.tsx */
|
|
|
6
6
|
&__item {
|
|
7
7
|
cursor: grab;
|
|
8
8
|
|
|
9
|
+
/*
|
|
10
|
+
* Keep a card's title in the case it was written in. The block editor
|
|
11
|
+
* sidebar uppercases every h3 (`.interface-complementary-area h3`).
|
|
12
|
+
*/
|
|
13
|
+
.newspack-card--core__header-content h3 {
|
|
14
|
+
text-transform: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
/*
|
|
10
18
|
* Animate items sliding to fill/make space around the dragged item.
|
|
11
19
|
*/
|
package/dist/esm/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export { default as PluginToggle } from './plugin-toggle';
|
|
|
39
39
|
export { default as Popover } from './popover';
|
|
40
40
|
export { default as ProgressBar } from './progress-bar';
|
|
41
41
|
export { default as RadioControl } from './radio-control';
|
|
42
|
+
export { default as ReorderModal } from './reorder-modal';
|
|
42
43
|
export { default as SectionHeader } from './section-header';
|
|
43
44
|
export { default as SelectControl } from './select-control';
|
|
44
45
|
export { default as Settings } from './settings';
|