newspack-components 4.2.0 → 4.3.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/dist/cjs/action-card/index.js +21 -12
- package/dist/cjs/action-card/style.scss +25 -2
- package/dist/cjs/autocomplete-tokenfield/index.js +2 -2
- package/dist/cjs/autocomplete-with-latest-posts/index.js +289 -0
- package/dist/cjs/autocomplete-with-latest-posts/style.scss +150 -0
- package/dist/cjs/badge/index.js +32 -0
- package/dist/cjs/badge/style.scss +36 -0
- package/dist/cjs/button/index.js +2 -0
- package/dist/cjs/card/core-card.js +141 -0
- package/dist/cjs/card/index.js +33 -0
- package/dist/cjs/card/style-core.scss +227 -0
- package/dist/cjs/card/style.scss +2 -2
- package/dist/cjs/card-settings-group/index.js +49 -0
- package/dist/cjs/card-settings-group/style.scss +33 -0
- package/dist/cjs/card-sortable-list/index.js +390 -0
- package/dist/cjs/card-sortable-list/style.scss +48 -0
- package/dist/cjs/confirm-dialog/index.js +59 -0
- package/dist/cjs/divider/index.js +42 -0
- package/dist/cjs/divider/style.scss +51 -0
- package/dist/cjs/form-token-field/style.scss +0 -5
- package/dist/cjs/grid/index.js +2 -1
- package/dist/cjs/grid/style.scss +63 -9
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/modal/index.js +11 -4
- package/dist/cjs/modal/style.scss +43 -13
- package/dist/cjs/newspack-icon/style.scss +5 -3
- package/dist/cjs/section-header/index.js +76 -17
- package/dist/cjs/section-header/style.scss +109 -4
- package/dist/cjs/style.scss +2 -0
- package/dist/cjs/waiting/index.js +3 -1
- package/dist/cjs/waiting/style.scss +4 -0
- package/dist/cjs/web-preview/index.js +98 -39
- package/dist/cjs/web-preview/style.scss +20 -53
- package/dist/cjs/with-wizard/index.js +1 -1
- package/dist/cjs/with-wizard/style.scss +24 -6
- package/dist/cjs/with-wizard-screen/style.scss +39 -10
- package/dist/cjs/wizard/components/WizardSnackbar.js +70 -0
- package/dist/cjs/wizard/components/style.scss +48 -0
- package/dist/cjs/wizard/index.js +97 -16
- package/dist/cjs/wizard/store/index.js +46 -0
- package/dist/esm/action-card/index.js +21 -12
- package/dist/esm/action-card/style.scss +25 -2
- package/dist/esm/autocomplete-tokenfield/index.js +2 -2
- package/dist/esm/autocomplete-with-latest-posts/index.js +281 -0
- package/dist/esm/autocomplete-with-latest-posts/style.scss +150 -0
- package/dist/esm/badge/index.js +24 -0
- package/dist/esm/badge/style.scss +36 -0
- package/dist/esm/button/index.js +2 -0
- package/dist/esm/card/core-card.js +133 -0
- package/dist/esm/card/index.js +33 -0
- package/dist/esm/card/style-core.scss +227 -0
- package/dist/esm/card/style.scss +2 -2
- package/dist/esm/card-settings-group/index.js +42 -0
- package/dist/esm/card-settings-group/style.scss +33 -0
- package/dist/esm/card-sortable-list/index.js +381 -0
- package/dist/esm/card-sortable-list/style.scss +48 -0
- package/dist/esm/confirm-dialog/index.js +49 -0
- package/dist/esm/divider/index.js +34 -0
- package/dist/esm/divider/style.scss +51 -0
- package/dist/esm/form-token-field/style.scss +0 -5
- package/dist/esm/grid/index.js +2 -1
- package/dist/esm/grid/style.scss +63 -9
- package/dist/esm/index.js +6 -0
- package/dist/esm/modal/index.js +11 -4
- package/dist/esm/modal/style.scss +43 -13
- package/dist/esm/newspack-icon/style.scss +5 -3
- package/dist/esm/section-header/index.js +75 -18
- package/dist/esm/section-header/style.scss +109 -4
- package/dist/esm/style.scss +2 -0
- package/dist/esm/waiting/index.js +3 -1
- package/dist/esm/waiting/style.scss +4 -0
- package/dist/esm/web-preview/index.js +101 -42
- package/dist/esm/web-preview/style.scss +20 -53
- package/dist/esm/with-wizard/index.js +1 -1
- package/dist/esm/with-wizard/style.scss +24 -6
- package/dist/esm/with-wizard-screen/style.scss +39 -10
- package/dist/esm/wizard/components/WizardSnackbar.js +64 -0
- package/dist/esm/wizard/components/style.scss +48 -0
- package/dist/esm/wizard/index.js +101 -20
- package/dist/esm/wizard/store/index.js +46 -0
- package/package.json +5 -6
- package/shared/author-context.js +26 -0
- package/shared/hooks/use-coauthors.js +220 -0
- package/shared/hooks/use-coauthors.test.js +624 -0
- package/shared/hooks/use-custom-byline.js +47 -0
- package/shared/hooks/use-custom-byline.test.js +133 -0
- package/shared/scss/_mixins.scss +46 -0
- package/src/action-card/action-card.d.ts +7 -3
- package/src/action-card/index.js +24 -11
- package/src/action-card/style.scss +25 -2
- package/src/autocomplete-tokenfield/index.js +2 -2
- package/src/autocomplete-with-latest-posts/index.js +290 -0
- package/src/autocomplete-with-latest-posts/style.scss +150 -0
- package/src/badge/index.tsx +24 -0
- package/src/badge/style.scss +36 -0
- package/src/button/index.tsx +3 -2
- package/src/card/core-card.js +147 -0
- package/src/card/index.js +39 -1
- package/src/card/style-core.scss +227 -0
- package/src/card/style.scss +2 -2
- package/src/card-settings-group/README.md +43 -0
- package/src/card-settings-group/index.tsx +53 -0
- package/src/card-settings-group/style.scss +33 -0
- package/src/card-sortable-list/README.md +51 -0
- package/src/card-sortable-list/index.tsx +412 -0
- package/src/card-sortable-list/style.scss +48 -0
- package/src/confirm-dialog/index.tsx +64 -0
- package/src/divider/README.md +25 -0
- package/src/divider/index.js +31 -0
- package/src/divider/style.scss +51 -0
- package/src/form-token-field/style.scss +0 -5
- package/src/grid/index.tsx +2 -1
- package/src/grid/style.scss +63 -9
- package/src/index.js +6 -0
- package/src/modal/index.js +12 -3
- package/src/modal/style.scss +43 -13
- package/src/newspack-icon/style.scss +5 -3
- package/src/section-header/index.js +72 -13
- package/src/section-header/style.scss +109 -4
- package/src/style.scss +2 -0
- package/src/waiting/index.js +2 -1
- package/src/waiting/style.scss +4 -0
- package/src/web-preview/index.js +90 -35
- package/src/web-preview/style.scss +20 -53
- package/src/with-wizard/index.js +1 -1
- package/src/with-wizard/style.scss +24 -6
- package/src/with-wizard-screen/style.scss +39 -10
- package/src/wizard/components/WizardSnackbar.js +58 -0
- package/src/wizard/components/style.scss +48 -0
- package/src/wizard/index.js +108 -14
- package/src/wizard/store/index.js +26 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for AutocompleteWithLatestPosts component.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
|
|
7
|
+
.newspack-autocomplete-with-latest-posts {
|
|
8
|
+
display: grid;
|
|
9
|
+
gap: 16px;
|
|
10
|
+
width: 100%;
|
|
11
|
+
|
|
12
|
+
.components-select-control__input {
|
|
13
|
+
max-width: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.components-input-control__backdrop {
|
|
17
|
+
border-color: wp-colors.$gray-700 !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.newspack-autocomplete-with-latest-posts__label,
|
|
21
|
+
.components-form-token-field__label,
|
|
22
|
+
.components-input-control__label,
|
|
23
|
+
.components-checkbox-control__label {
|
|
24
|
+
color: wp-colors.$gray-900 !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.newspack-autocomplete-tokenfield__help {
|
|
28
|
+
font-size: inherit;
|
|
29
|
+
margin-bottom: 8px !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.components-form-token-field {
|
|
33
|
+
&__input-container {
|
|
34
|
+
border-color: wp-colors.$gray-700;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&__suggestion {
|
|
38
|
+
padding: 8px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Hide the built-in "Separate with commas or the Enter key." help text when hideFormTokenHelp is true
|
|
43
|
+
&.hide-form-token-help .components-form-token-field__help {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
p.newspack-autocomplete-with-latest-posts__label {
|
|
48
|
+
font-size: inherit;
|
|
49
|
+
margin: 0 0 8px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__selected-items {
|
|
53
|
+
border-bottom: 1px solid wp-colors.$gray-700;
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
gap: 8px;
|
|
57
|
+
margin-bottom: 16px;
|
|
58
|
+
padding-bottom: 12px;
|
|
59
|
+
|
|
60
|
+
p.newspack-autocomplete-with-latest-posts__label {
|
|
61
|
+
flex: 0 0 100%;
|
|
62
|
+
margin: 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&__selected-item-button.components-button.is-tertiary {
|
|
67
|
+
background-color: wp-colors.$gray-300;
|
|
68
|
+
border-radius: 2px;
|
|
69
|
+
color: wp-colors.$gray-900;
|
|
70
|
+
font-size: 13px;
|
|
71
|
+
height: auto;
|
|
72
|
+
margin: 0;
|
|
73
|
+
padding-left: 8px;
|
|
74
|
+
padding-right: 8px;
|
|
75
|
+
|
|
76
|
+
&::after {
|
|
77
|
+
content: "✕";
|
|
78
|
+
margin-left: 8px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:hover {
|
|
82
|
+
box-shadow: none;
|
|
83
|
+
color: black;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&__search-suggestions,
|
|
88
|
+
&__search-suggestions-multiselect {
|
|
89
|
+
max-height: 220px;
|
|
90
|
+
overflow: visible auto;
|
|
91
|
+
margin: 0 -4px;
|
|
92
|
+
padding: 4px 4px 0;
|
|
93
|
+
|
|
94
|
+
.components-button {
|
|
95
|
+
display: block;
|
|
96
|
+
line-height: normal;
|
|
97
|
+
margin: auto;
|
|
98
|
+
|
|
99
|
+
&.is-link {
|
|
100
|
+
color: wp-colors.$gray-900;
|
|
101
|
+
padding: 8px;
|
|
102
|
+
text-decoration: none;
|
|
103
|
+
width: 100%;
|
|
104
|
+
|
|
105
|
+
&:active:not(:disabled),
|
|
106
|
+
&:hover:not(:disabled) {
|
|
107
|
+
background: wp-colors.$gray-900;
|
|
108
|
+
background: var(--wp-admin-theme-color);
|
|
109
|
+
color: white;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
&.is-secondary {
|
|
113
|
+
margin-bottom: 8px;
|
|
114
|
+
margin-top: 8px;
|
|
115
|
+
width: 100%;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&__search-suggestions {
|
|
121
|
+
border-radius: 2px;
|
|
122
|
+
border: 1px solid wp-colors.$gray-700;
|
|
123
|
+
padding: 0;
|
|
124
|
+
|
|
125
|
+
.components-button {
|
|
126
|
+
line-height: normal;
|
|
127
|
+
|
|
128
|
+
&:focus:not(:disabled) {
|
|
129
|
+
border-radius: 0;
|
|
130
|
+
box-shadow: inset 0 0 0 1.5px wp-colors.$gray-900;
|
|
131
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&.is-secondary {
|
|
135
|
+
width: calc(100% - 16px);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Temp: CSS work-around.
|
|
141
|
+
.newspack-autocomplete-with-suggestions__label {
|
|
142
|
+
font-size: 11px;
|
|
143
|
+
font-weight: 500;
|
|
144
|
+
line-height: 1.4;
|
|
145
|
+
text-transform: uppercase;
|
|
146
|
+
display: block;
|
|
147
|
+
margin: 0 0 8px;
|
|
148
|
+
padding: 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import './style.scss';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* External dependencies
|
|
8
|
+
*/
|
|
9
|
+
import classnames from 'classnames';
|
|
10
|
+
|
|
11
|
+
type BadgeProps = {
|
|
12
|
+
text: string;
|
|
13
|
+
level?: 'default' | 'info' | 'success' | 'warning' | 'error';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Badge component
|
|
18
|
+
*/
|
|
19
|
+
const Badge = ( { text, level = 'default' }: BadgeProps ) => {
|
|
20
|
+
const classes = classnames( 'newspack-badge', `is-${ level }` );
|
|
21
|
+
return <span className={ classes }>{ text }</span>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default Badge;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Badge
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
@use "../../../colors/colors.module" as colors;
|
|
7
|
+
|
|
8
|
+
$badge-colors: (
|
|
9
|
+
"info": colors.$primary-600,
|
|
10
|
+
"warning": wp-colors.$alert-yellow,
|
|
11
|
+
"error": wp-colors.$alert-red,
|
|
12
|
+
"success": wp-colors.$alert-green,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
.newspack-badge {
|
|
16
|
+
background-color: color-mix(in srgb, wp-colors.$white 90%, var(--base-color));
|
|
17
|
+
border-radius: 2px;
|
|
18
|
+
color: color-mix(in srgb, wp-colors.$black 50%, var(--base-color));
|
|
19
|
+
display: block;
|
|
20
|
+
flex: 0 0 auto;
|
|
21
|
+
font-size: 12px;
|
|
22
|
+
line-height: 1.5;
|
|
23
|
+
padding: 1px 4px;
|
|
24
|
+
|
|
25
|
+
&:where(.is-default) {
|
|
26
|
+
background-color: wp-colors.$gray-100;
|
|
27
|
+
color: wp-colors.$gray-800;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Generate color variants
|
|
31
|
+
@each $type, $color in $badge-colors {
|
|
32
|
+
&.is-#{$type} {
|
|
33
|
+
--base-color: #{$color};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/button/index.tsx
CHANGED
|
@@ -19,10 +19,11 @@ const { useHistory } = Router;
|
|
|
19
19
|
type OriginalButtonProps = typeof BaseComponent.defaultProps;
|
|
20
20
|
type Props = OriginalButtonProps & {
|
|
21
21
|
href?: string;
|
|
22
|
+
loading?: boolean;
|
|
22
23
|
onClick?: () => void;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const Button = ( { href, onClick, ...otherProps }: Props ) => {
|
|
26
|
+
const Button = ( { href, loading = undefined, onClick, ...otherProps }: Props ) => {
|
|
26
27
|
const history = useHistory();
|
|
27
28
|
const [ isAwaitingOnClick, setIsAwaitingOnClick ] = useState( false );
|
|
28
29
|
|
|
@@ -42,7 +43,7 @@ const Button = ( { href, onClick, ...otherProps }: Props ) => {
|
|
|
42
43
|
otherProps.disabled = true;
|
|
43
44
|
}
|
|
44
45
|
// @ts-expect-error - @wordpress/components' Button can only have either href or onClick, not both.
|
|
45
|
-
return <BaseComponent { ...otherProps } />;
|
|
46
|
+
return <BaseComponent loading={ loading ? true : undefined } { ...otherProps } />;
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
export default Button;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card using WP Core's Card component.
|
|
3
|
+
* https://wordpress.github.io/gutenberg/?path=/docs/components-card--docs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { Button, Card as CardWrapper, CardHeader, CardFooter, DropdownMenu, MenuItem, ToggleControl } from '@wordpress/components';
|
|
11
|
+
import { Icon, chevronDown, chevronRight, chevronUp, dragHandle, moreVertical } from '@wordpress/icons';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import './style-core.scss';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
21
|
+
import classNames from 'classnames';
|
|
22
|
+
|
|
23
|
+
const CoreCard = ( {
|
|
24
|
+
actions,
|
|
25
|
+
actionType,
|
|
26
|
+
as,
|
|
27
|
+
buttonsCard,
|
|
28
|
+
className,
|
|
29
|
+
footer,
|
|
30
|
+
header,
|
|
31
|
+
icon,
|
|
32
|
+
iconBackgroundColor,
|
|
33
|
+
isActive,
|
|
34
|
+
isDraggable,
|
|
35
|
+
isFirstTarget,
|
|
36
|
+
isLastTarget,
|
|
37
|
+
isNarrow,
|
|
38
|
+
isSmall,
|
|
39
|
+
dragIndex,
|
|
40
|
+
onDragCallback = () => {},
|
|
41
|
+
onHeaderClick,
|
|
42
|
+
noBorder,
|
|
43
|
+
noMargin,
|
|
44
|
+
children = null,
|
|
45
|
+
...otherProps
|
|
46
|
+
} ) => {
|
|
47
|
+
const classes = classNames(
|
|
48
|
+
'newspack-card--core',
|
|
49
|
+
className,
|
|
50
|
+
( buttonsCard || as === 'a' ) && 'newspack-card--core__buttons-card',
|
|
51
|
+
isDraggable && 'newspack-card--core__is-draggable',
|
|
52
|
+
isNarrow && 'newspack-card--core__is-narrow',
|
|
53
|
+
isSmall && 'newspack-card--core__is-small',
|
|
54
|
+
icon && 'newspack-card--core__has-icon',
|
|
55
|
+
iconBackgroundColor && 'newspack-card--core__has-icon-background-color',
|
|
56
|
+
isActive && 'newspack-card--core__is-active',
|
|
57
|
+
children && 'newspack-card--core__has-children',
|
|
58
|
+
noMargin && 'newspack-card--core__no-margin'
|
|
59
|
+
);
|
|
60
|
+
let sizeProps = isSmall ? 'small' : otherProps.size;
|
|
61
|
+
if ( buttonsCard || as === 'a' ) {
|
|
62
|
+
if ( ! isSmall ) {
|
|
63
|
+
sizeProps = 'large';
|
|
64
|
+
}
|
|
65
|
+
if ( as !== 'a' ) {
|
|
66
|
+
otherProps.as = 'a'; // Render as an anchor tag.
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if ( noBorder ) {
|
|
70
|
+
otherProps.isBorderless = true;
|
|
71
|
+
}
|
|
72
|
+
return (
|
|
73
|
+
<CardWrapper as={ as } className={ classes } { ...otherProps }>
|
|
74
|
+
{ ( header || icon ) && (
|
|
75
|
+
<CardHeader
|
|
76
|
+
as={ onHeaderClick ? 'button' : undefined }
|
|
77
|
+
className={ classNames( 'newspack-card--core__header', isDraggable && 'newspack-card--core__header--is-draggable' ) }
|
|
78
|
+
size={ sizeProps }
|
|
79
|
+
onClick={ onHeaderClick }
|
|
80
|
+
>
|
|
81
|
+
{ isDraggable && (
|
|
82
|
+
<div className="newspack-card--core__header__draggable-controls">
|
|
83
|
+
<div className="newspack-card--core__header__draggable-controls__drag-handle">
|
|
84
|
+
<Icon icon={ dragHandle } />
|
|
85
|
+
</div>
|
|
86
|
+
<div className="newspack-card--core__header__draggable-controls__move-buttons">
|
|
87
|
+
<Button
|
|
88
|
+
icon={ chevronUp }
|
|
89
|
+
onClick={ () => onDragCallback( dragIndex, dragIndex - 1 ) }
|
|
90
|
+
disabled={ isFirstTarget }
|
|
91
|
+
label={ __( 'Move one position up', 'newspack-plugin' ) }
|
|
92
|
+
size="small"
|
|
93
|
+
/>
|
|
94
|
+
<Button
|
|
95
|
+
icon={ chevronDown }
|
|
96
|
+
onClick={ () => onDragCallback( dragIndex, dragIndex + 1 ) }
|
|
97
|
+
disabled={ isLastTarget }
|
|
98
|
+
label={ __( 'Move one position down', 'newspack-plugin' ) }
|
|
99
|
+
size="small"
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
) }
|
|
104
|
+
{ icon && (
|
|
105
|
+
<div className="newspack-card--core__icon">
|
|
106
|
+
<Icon icon={ icon } height={ isSmall ? 24 : 48 } width={ isSmall ? 24 : 48 } />
|
|
107
|
+
</div>
|
|
108
|
+
) }
|
|
109
|
+
{ header && <div className="newspack-card--core__header-content">{ header }</div> }
|
|
110
|
+
{ ! actions?.length > 0 && actionType === 'chevron' && (
|
|
111
|
+
<Icon className="newspack-card--core__action" icon={ chevronRight } height={ 24 } width={ 24 } />
|
|
112
|
+
) }
|
|
113
|
+
{ ! actions?.length > 0 && actionType === 'toggle' && (
|
|
114
|
+
<ToggleControl
|
|
115
|
+
className="newspack-card--core__action"
|
|
116
|
+
label={ otherProps.title }
|
|
117
|
+
hideLabelFromVision
|
|
118
|
+
checked={ isActive }
|
|
119
|
+
onChange={ () => {} }
|
|
120
|
+
/>
|
|
121
|
+
) }
|
|
122
|
+
{ actions?.length > 0 && (
|
|
123
|
+
<DropdownMenu icon={ moreVertical } label={ __( 'More', 'newspack-plugin' ) }>
|
|
124
|
+
{ () =>
|
|
125
|
+
actions.map( ( action, index ) => (
|
|
126
|
+
<MenuItem
|
|
127
|
+
key={ index }
|
|
128
|
+
icon={ action.icon }
|
|
129
|
+
onClick={ action.action }
|
|
130
|
+
disabled={ action.disabled || false }
|
|
131
|
+
isDestructive={ action.destructive || false }
|
|
132
|
+
>
|
|
133
|
+
{ action.label }
|
|
134
|
+
</MenuItem>
|
|
135
|
+
) )
|
|
136
|
+
}
|
|
137
|
+
</DropdownMenu>
|
|
138
|
+
) }
|
|
139
|
+
</CardHeader>
|
|
140
|
+
) }
|
|
141
|
+
{ children && <div className="newspack-card--core__body">{ children }</div> }
|
|
142
|
+
{ footer && <CardFooter size={ sizeProps }>{ footer }</CardFooter> }
|
|
143
|
+
</CardWrapper>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default CoreCard;
|
package/src/card/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { Component } from '@wordpress/element';
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
+
import CoreCard from './core-card';
|
|
13
14
|
import './style.scss';
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -22,7 +23,44 @@ class Card extends Component {
|
|
|
22
23
|
* Render
|
|
23
24
|
*/
|
|
24
25
|
render() {
|
|
25
|
-
const {
|
|
26
|
+
const {
|
|
27
|
+
buttonsCard,
|
|
28
|
+
className,
|
|
29
|
+
headerActions,
|
|
30
|
+
isNarrow,
|
|
31
|
+
isMedium,
|
|
32
|
+
isSmall,
|
|
33
|
+
isWhite,
|
|
34
|
+
noBorder,
|
|
35
|
+
// Pass as `true` to render using WP Core's Card component: https://wordpress.github.io/gutenberg/?path=/docs/components-card--docs
|
|
36
|
+
__experimentalCoreCard,
|
|
37
|
+
// Pass props supported by WP Core's Card component in this single prop.
|
|
38
|
+
__experimentalCoreProps = {
|
|
39
|
+
actionType: null, // chevron | toggle | button | link | none
|
|
40
|
+
header: null, // Pass a React component to render in a CardHeader component.
|
|
41
|
+
icon: null,
|
|
42
|
+
footer: null, // Pass a React component to render in a CardFooter component.
|
|
43
|
+
noMargin: false,
|
|
44
|
+
isDraggable: false,
|
|
45
|
+
dragIndex: null,
|
|
46
|
+
onDragCallback: () => {},
|
|
47
|
+
},
|
|
48
|
+
...otherProps
|
|
49
|
+
} = this.props;
|
|
50
|
+
if ( __experimentalCoreCard ) {
|
|
51
|
+
const props = {
|
|
52
|
+
buttonsCard,
|
|
53
|
+
className,
|
|
54
|
+
isMedium,
|
|
55
|
+
isNarrow,
|
|
56
|
+
isSmall,
|
|
57
|
+
isWhite,
|
|
58
|
+
noBorder,
|
|
59
|
+
...otherProps,
|
|
60
|
+
...__experimentalCoreProps,
|
|
61
|
+
};
|
|
62
|
+
return <CoreCard { ...props } />;
|
|
63
|
+
}
|
|
26
64
|
const classes = classNames(
|
|
27
65
|
'newspack-card',
|
|
28
66
|
className,
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card using WP Core component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
@use "../../../colors/colors.module" as colors;
|
|
7
|
+
|
|
8
|
+
.newspack-card--core,
|
|
9
|
+
.newspack-wizard .newspack-card--core {
|
|
10
|
+
background: white;
|
|
11
|
+
position: relative;
|
|
12
|
+
transition: background-color 125ms ease-in-out, box-shadow 125ms ease-in-out, color 125ms ease-in-out;
|
|
13
|
+
svg {
|
|
14
|
+
transition: fill 125ms ease-in-out;
|
|
15
|
+
}
|
|
16
|
+
&__icon {
|
|
17
|
+
border-radius: 50%;
|
|
18
|
+
display: grid;
|
|
19
|
+
height: 48px;
|
|
20
|
+
place-items: center;
|
|
21
|
+
width: 48px;
|
|
22
|
+
svg {
|
|
23
|
+
fill: var(--wp-admin-theme-color);
|
|
24
|
+
height: 40px;
|
|
25
|
+
width: 40px;
|
|
26
|
+
}
|
|
27
|
+
.newspack-card--core__has-icon-background-color & {
|
|
28
|
+
background: var(--wp-admin-theme-color-lighter-10);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
&__is-small {
|
|
32
|
+
h1,
|
|
33
|
+
h2,
|
|
34
|
+
h3,
|
|
35
|
+
h4,
|
|
36
|
+
h5,
|
|
37
|
+
h6 {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
font-weight: 500;
|
|
40
|
+
}
|
|
41
|
+
.newspack-card--core__icon {
|
|
42
|
+
height: 40px;
|
|
43
|
+
width: 40px;
|
|
44
|
+
svg {
|
|
45
|
+
height: 24px;
|
|
46
|
+
width: 24px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
&__no-margin .components-card__body {
|
|
51
|
+
padding: 0 !important;
|
|
52
|
+
}
|
|
53
|
+
&__header {
|
|
54
|
+
color: wp-colors.$gray-700;
|
|
55
|
+
column-gap: 16px;
|
|
56
|
+
position: relative;
|
|
57
|
+
.newspack-card--core__action {
|
|
58
|
+
margin: 0;
|
|
59
|
+
label {
|
|
60
|
+
border: 0;
|
|
61
|
+
clip-path: inset(50%);
|
|
62
|
+
height: 1px;
|
|
63
|
+
margin: -1px;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
padding: 0;
|
|
66
|
+
position: absolute !important;
|
|
67
|
+
width: 1px;
|
|
68
|
+
word-wrap: normal !important;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
.components-dropdown-menu {
|
|
72
|
+
aspect-ratio: 1;
|
|
73
|
+
border-left: 1px solid wp-colors.$gray-200;
|
|
74
|
+
display: grid;
|
|
75
|
+
height: 100%;
|
|
76
|
+
padding: 4px;
|
|
77
|
+
place-items: center;
|
|
78
|
+
position: absolute;
|
|
79
|
+
right: 0;
|
|
80
|
+
top: 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
&__header--is-draggable {
|
|
84
|
+
.newspack-card--core__header-content {
|
|
85
|
+
padding-left: 65px;
|
|
86
|
+
}
|
|
87
|
+
.newspack-card--core__header__draggable-controls {
|
|
88
|
+
align-items: center;
|
|
89
|
+
border-right: 1px solid wp-colors.$gray-200;
|
|
90
|
+
display: flex;
|
|
91
|
+
height: 100%;
|
|
92
|
+
justify-content: space-between;
|
|
93
|
+
left: 0;
|
|
94
|
+
padding: 0 8px;
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 0;
|
|
97
|
+
}
|
|
98
|
+
.newspack-card--core__header__draggable-controls__drag-handle {
|
|
99
|
+
cursor: grab;
|
|
100
|
+
display: grid;
|
|
101
|
+
place-items: center;
|
|
102
|
+
}
|
|
103
|
+
.newspack-card--core__header__draggable-controls__move-buttons {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
.components-button.has-icon {
|
|
107
|
+
height: 16px;
|
|
108
|
+
padding: 0;
|
|
109
|
+
width: 100%;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
button.newspack-card--core__header {
|
|
114
|
+
appearance: none;
|
|
115
|
+
background-color: white;
|
|
116
|
+
border: none;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
text-align: left;
|
|
119
|
+
}
|
|
120
|
+
&__header-content {
|
|
121
|
+
display: grid;
|
|
122
|
+
flex: 1;
|
|
123
|
+
grid-gap: 8px;
|
|
124
|
+
h1,
|
|
125
|
+
h2,
|
|
126
|
+
h3,
|
|
127
|
+
h4,
|
|
128
|
+
h5,
|
|
129
|
+
h6,
|
|
130
|
+
p {
|
|
131
|
+
margin-bottom: 0;
|
|
132
|
+
margin-top: 0;
|
|
133
|
+
transition: color 125ms ease-in-out;
|
|
134
|
+
}
|
|
135
|
+
h1,
|
|
136
|
+
h2,
|
|
137
|
+
h3,
|
|
138
|
+
h4,
|
|
139
|
+
h5,
|
|
140
|
+
h6 {
|
|
141
|
+
align-items: center;
|
|
142
|
+
color: wp-colors.$gray-900;
|
|
143
|
+
font-weight: 500;
|
|
144
|
+
display: flex;
|
|
145
|
+
gap: 8px;
|
|
146
|
+
.newspack-badge {
|
|
147
|
+
font-weight: 400;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
&__is-active {
|
|
152
|
+
border-color: var(--wp-admin-theme-color);
|
|
153
|
+
box-shadow: var(--wp-admin-theme-color) 0 0 0 1px;
|
|
154
|
+
button.newspack-card--core__header {
|
|
155
|
+
background-color: rgba( var(--wp-admin-theme-color--rgb), 0.04 );
|
|
156
|
+
color: var(--wp-admin-theme-color);
|
|
157
|
+
h1,
|
|
158
|
+
h2,
|
|
159
|
+
h3,
|
|
160
|
+
h4,
|
|
161
|
+
h5,
|
|
162
|
+
h6 {
|
|
163
|
+
color: var(--wp-admin-theme-color);
|
|
164
|
+
}
|
|
165
|
+
svg {
|
|
166
|
+
fill: var(--wp-admin-theme-color);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&.newspack-card--core__has-children {
|
|
171
|
+
button.newspack-card--core__header {
|
|
172
|
+
border-bottom-left-radius: 0;
|
|
173
|
+
border-bottom-right-radius: 0;
|
|
174
|
+
}
|
|
175
|
+
.newspack-card--core__body {
|
|
176
|
+
border-top: 1px solid var(--wp-admin-theme-color);
|
|
177
|
+
}
|
|
178
|
+
.components-card__divider {
|
|
179
|
+
background: wp-colors.$gray-100;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
&__buttons-card {
|
|
184
|
+
display: block;
|
|
185
|
+
text-decoration: none;
|
|
186
|
+
&:active,
|
|
187
|
+
&:hover {
|
|
188
|
+
border-color: var(--wp-admin-theme-color);
|
|
189
|
+
box-shadow: var(--wp-admin-theme-color) 0 0 0 1px;
|
|
190
|
+
.newspack-card--core__header {
|
|
191
|
+
color: var(--wp-admin-theme-color);
|
|
192
|
+
h1,
|
|
193
|
+
h2,
|
|
194
|
+
h3,
|
|
195
|
+
h4,
|
|
196
|
+
h5,
|
|
197
|
+
h6 {
|
|
198
|
+
color: var(--wp-admin-theme-color);
|
|
199
|
+
}
|
|
200
|
+
svg {
|
|
201
|
+
fill: var(--wp-admin-theme-color);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
hr.components-card__divider {
|
|
207
|
+
margin: 0;
|
|
208
|
+
}
|
|
209
|
+
&__is-narrow {
|
|
210
|
+
margin-left: auto;
|
|
211
|
+
margin-right: auto;
|
|
212
|
+
@media screen and ( min-width: 608px ) {
|
|
213
|
+
max-width: 576px;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
&__body {
|
|
217
|
+
> div:not(.components-card__body):not(.components-card__media):not(.components-card__divider) {
|
|
218
|
+
padding: 16px 24px;
|
|
219
|
+
.newspack-card--core__is-small & {
|
|
220
|
+
padding: 16px;
|
|
221
|
+
}
|
|
222
|
+
.newspack-card--core__no-margin & {
|
|
223
|
+
padding: 0;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
package/src/card/style.scss
CHANGED
|
@@ -133,11 +133,11 @@
|
|
|
133
133
|
|
|
134
134
|
// Thematic Break
|
|
135
135
|
|
|
136
|
-
hr {
|
|
136
|
+
hr:not(.newspack-divider) {
|
|
137
137
|
background: wp-colors.$gray-300;
|
|
138
138
|
border: 0;
|
|
139
139
|
height: 1px;
|
|
140
|
-
margin:
|
|
140
|
+
margin: 32px 0;
|
|
141
141
|
|
|
142
142
|
@media screen and ( min-width: 744px ) {
|
|
143
143
|
margin: 64px 0;
|