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,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies.
|
|
7
|
+
*/
|
|
8
|
+
import { forwardRef } from '@wordpress/element';
|
|
9
|
+
import { __experimentalConfirmDialog as BaseComponent } from '@wordpress/components'; // eslint-disable-line @wordpress/no-unsafe-wp-apis
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* External dependencies.
|
|
13
|
+
*/
|
|
14
|
+
import classnames from 'classnames';
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* See both https://wordpress.github.io/gutenberg/?path=/docs/components-confirmdialog--docs and
|
|
18
|
+
* https://wordpress.github.io/gutenberg/?path=/docs/components-modal--docs for all supported props.
|
|
19
|
+
*/
|
|
20
|
+
type ConfirmDialogProps = {
|
|
21
|
+
className?: string;
|
|
22
|
+
size?: 'small' | 'medium' | 'large' | 'x-large' | 'full';
|
|
23
|
+
hideTitle?: boolean;
|
|
24
|
+
title?: string;
|
|
25
|
+
isDestructive?: boolean;
|
|
26
|
+
cancelButtonText?: string;
|
|
27
|
+
confirmButtonText?: string;
|
|
28
|
+
onConfirm: () => void;
|
|
29
|
+
onCancel: () => void;
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const sizeClassMap = {
|
|
34
|
+
small: 'newspack-modal--size-small',
|
|
35
|
+
medium: 'newspack-modal--size-medium',
|
|
36
|
+
large: 'newspack-modal--size-large',
|
|
37
|
+
'x-large': 'newspack-modal--size-x-large',
|
|
38
|
+
full: 'newspack-modal--size-full',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function ConfirmDialog(
|
|
42
|
+
{ className, size = 'small', hideTitle, isDestructive, onConfirm, onCancel, ...otherProps }: ConfirmDialogProps,
|
|
43
|
+
ref: React.Ref< HTMLDivElement >
|
|
44
|
+
) {
|
|
45
|
+
const classes = classnames(
|
|
46
|
+
'newspack-modal',
|
|
47
|
+
sizeClassMap[ size ],
|
|
48
|
+
hideTitle && 'newspack-modal--hide-title', // Note: also hides the X close button.
|
|
49
|
+
isDestructive && 'newspack-modal--destructive',
|
|
50
|
+
className
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<BaseComponent
|
|
55
|
+
className={ classes }
|
|
56
|
+
{ ...otherProps }
|
|
57
|
+
ref={ ref }
|
|
58
|
+
onConfirm={ onConfirm }
|
|
59
|
+
onCancel={ onCancel }
|
|
60
|
+
__experimentalHideHeader={ false }
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
export default forwardRef( ConfirmDialog );
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Divider
|
|
2
|
+
|
|
3
|
+
Horizontal rule component with alignment, variant, and margin options.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
|------|------|---------|-------------|
|
|
9
|
+
| `alignment` | `'full-width'` \| `'none'` | `'none'` | `full-width` breaks out of the container to span the viewport; `none` stays within the container. |
|
|
10
|
+
| `className` | `string` | — | Additional CSS class. |
|
|
11
|
+
| `marginBottom` | `number` \| `string` | `64` | Bottom margin (e.g. `64` or `"2rem"`). Capped at 32px on viewports < 783px. |
|
|
12
|
+
| `marginTop` | `number` \| `string` | `64` | Top margin (e.g. `64` or `"2rem"`). Capped at 32px on viewports < 783px. |
|
|
13
|
+
| `variant` | `'default'` \| `'primary'` \| `'secondary'` \| `'tertiary'` | `'default'` | Line color: `default` uses `$gray-300`; `primary` uses the admin theme color (`--wp-admin-theme-color`); `secondary` uses `$gray-900`; `tertiary` uses `$gray-100`. |
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { Divider } from 'newspack-components';
|
|
19
|
+
|
|
20
|
+
<Divider />
|
|
21
|
+
|
|
22
|
+
<Divider alignment="full-width" variant="primary" />
|
|
23
|
+
|
|
24
|
+
<Divider marginBottom={ 48 } marginTop={ 32 } variant="secondary" />
|
|
25
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divider
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import './style.scss';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* External dependencies
|
|
12
|
+
*/
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
|
|
15
|
+
const Divider = ( { alignment = 'none', className = undefined, marginBottom = 64, marginTop = 64, variant = 'default', ...otherProps } ) => {
|
|
16
|
+
const classes = classNames(
|
|
17
|
+
'newspack-divider',
|
|
18
|
+
className,
|
|
19
|
+
alignment && `newspack-divider--alignment-${ alignment }`,
|
|
20
|
+
variant && `newspack-divider--variant-${ variant }`
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const style = {
|
|
24
|
+
'--divider-margin-bottom': typeof marginBottom === 'number' ? `${ marginBottom }px` : marginBottom,
|
|
25
|
+
'--divider-margin-top': typeof marginTop === 'number' ? `${ marginTop }px` : marginTop,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return <hr className={ classes } style={ style } { ...otherProps } />;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default Divider;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divider
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
|
|
7
|
+
.newspack-divider {
|
|
8
|
+
background: transparent;
|
|
9
|
+
border: 0;
|
|
10
|
+
display: block;
|
|
11
|
+
height: 1px;
|
|
12
|
+
margin-bottom: min(32px, var(--divider-margin-bottom, 64px));
|
|
13
|
+
margin-left: 0;
|
|
14
|
+
margin-right: 0;
|
|
15
|
+
margin-top: min(32px, var(--divider-margin-top, 64px));
|
|
16
|
+
padding: 0;
|
|
17
|
+
|
|
18
|
+
@media screen and (min-width: 783px) {
|
|
19
|
+
margin-bottom: var(--divider-margin-bottom, 64px);
|
|
20
|
+
margin-top: var(--divider-margin-top, 64px);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Alignment
|
|
24
|
+
|
|
25
|
+
&--alignment-full-width {
|
|
26
|
+
margin-left: calc(-50vw + 50%);
|
|
27
|
+
width: 100vw;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&--alignment-none {
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Variant
|
|
35
|
+
|
|
36
|
+
&--variant-default {
|
|
37
|
+
background-color: wp-colors.$gray-300;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&--variant-primary {
|
|
41
|
+
background-color: var(--wp-admin-theme-color);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&--variant-secondary {
|
|
45
|
+
background-color: wp-colors.$gray-900;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&--variant-tertiary {
|
|
49
|
+
background-color: wp-colors.$gray-100;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/grid/index.tsx
CHANGED
|
@@ -12,9 +12,10 @@ import './style.scss';
|
|
|
12
12
|
*/
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
|
|
15
|
-
const Grid = ( { className = '', columns = 2, gutter = 32, noMargin = false, rowGap = 0, ...otherProps } ) => {
|
|
15
|
+
const Grid = ( { className = '', borders = false, columns = 2, gutter = 32, noMargin = false, rowGap = 0, ...otherProps } ) => {
|
|
16
16
|
const classes = classnames(
|
|
17
17
|
'newspack-grid',
|
|
18
|
+
borders && 'newspack-grid__borders',
|
|
18
19
|
noMargin && 'newspack-grid--no-margin',
|
|
19
20
|
columns && 'newspack-grid__columns-' + columns,
|
|
20
21
|
gutter && 'newspack-grid__gutter-' + gutter,
|
package/src/grid/style.scss
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
// No Margin
|
|
15
15
|
&--no-margin {
|
|
16
|
-
margin: 0;
|
|
16
|
+
margin: 0 !important;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Gutter 0
|
|
@@ -41,6 +41,11 @@
|
|
|
41
41
|
grid-gap: 32px;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Gutter 64
|
|
45
|
+
&__gutter-64 {
|
|
46
|
+
grid-gap: 64px;
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
// Row Gap 0
|
|
45
50
|
&__row-gap-0 {
|
|
46
51
|
grid-row-gap: 0;
|
|
@@ -61,11 +66,6 @@
|
|
|
61
66
|
grid-row-gap: 32px;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
// Gutter 64
|
|
65
|
-
&__gutter-64 {
|
|
66
|
-
grid-gap: 64px;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
69
|
// Columns 6
|
|
70
70
|
&__columns-6 {
|
|
71
71
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -77,6 +77,14 @@
|
|
|
77
77
|
&__columns-3,
|
|
78
78
|
&__columns-4 {
|
|
79
79
|
grid-template-columns: repeat(2, 1fr);
|
|
80
|
+
|
|
81
|
+
> [start] {
|
|
82
|
+
grid-column-start: 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
> [end] {
|
|
86
|
+
grid-column-end: -1;
|
|
87
|
+
}
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
&__columns-6 {
|
|
@@ -84,8 +92,8 @@
|
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
94
|
|
|
87
|
-
// Media Queries -
|
|
88
|
-
@media screen and ( min-width:
|
|
95
|
+
// Media Queries - 1054px
|
|
96
|
+
@media screen and ( min-width: 1054px ) {
|
|
89
97
|
// Columns 3
|
|
90
98
|
&__columns-3 {
|
|
91
99
|
grid-template-columns: repeat(3, 1fr);
|
|
@@ -94,6 +102,14 @@
|
|
|
94
102
|
// Columns 4
|
|
95
103
|
&__columns-4 {
|
|
96
104
|
grid-template-columns: repeat(4, 1fr);
|
|
105
|
+
|
|
106
|
+
> [start="2"] {
|
|
107
|
+
grid-column-start: 2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
> [end="4"] {
|
|
111
|
+
grid-column-end: 4;
|
|
112
|
+
}
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
// Columns 6
|
|
@@ -116,6 +132,44 @@
|
|
|
116
132
|
> * {
|
|
117
133
|
margin-bottom: 0 !important;
|
|
118
134
|
margin-top: 0 !important;
|
|
135
|
+
> h1:first-child,
|
|
136
|
+
> h2:first-child,
|
|
137
|
+
> h3:first-child,
|
|
138
|
+
> h4:first-child,
|
|
139
|
+
> h5:first-child,
|
|
140
|
+
> h6:first-child {
|
|
141
|
+
margin-top: 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Borders
|
|
146
|
+
&__borders {
|
|
147
|
+
grid-gap: 0 !important;
|
|
148
|
+
> * {
|
|
149
|
+
border-bottom: 1px solid wp-colors.$gray-300;
|
|
150
|
+
&:last-child {
|
|
151
|
+
border-bottom: none;
|
|
152
|
+
}
|
|
153
|
+
@media screen and ( min-width: 744px ) {
|
|
154
|
+
border-bottom: none;
|
|
155
|
+
border-right: 1px solid wp-colors.$gray-300;
|
|
156
|
+
&:last-child {
|
|
157
|
+
border-right: none;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
&.newspack-grid__gutter-8 > * {
|
|
162
|
+
padding: 8px;
|
|
163
|
+
}
|
|
164
|
+
&.newspack-grid__gutter-16 > * {
|
|
165
|
+
padding: 16px;
|
|
166
|
+
}
|
|
167
|
+
&.newspack-grid__gutter-32 > * {
|
|
168
|
+
padding: 32px;
|
|
169
|
+
}
|
|
170
|
+
&.newspack-grid__gutter-64 > * {
|
|
171
|
+
padding: 64px;
|
|
172
|
+
}
|
|
119
173
|
}
|
|
120
174
|
|
|
121
175
|
.components-base-control {
|
|
@@ -163,4 +217,4 @@
|
|
|
163
217
|
&__tbody + &__tbody {
|
|
164
218
|
margin-top: -32px;
|
|
165
219
|
}
|
|
166
|
-
}
|
|
220
|
+
}
|
package/src/index.js
CHANGED
|
@@ -2,13 +2,19 @@ export { default as Accordion } from './accordion';
|
|
|
2
2
|
export { default as ActionCard } from './action-card';
|
|
3
3
|
export { default as AutocompleteTokenField } from './autocomplete-tokenfield';
|
|
4
4
|
export { default as AutocompleteWithSuggestions } from './autocomplete-with-suggestions';
|
|
5
|
+
export { default as AutocompleteWithLatestPosts } from './autocomplete-with-latest-posts';
|
|
6
|
+
export { default as Badge } from './badge';
|
|
5
7
|
export { default as Button } from './button';
|
|
6
8
|
export { default as ButtonCard } from './button-card';
|
|
7
9
|
export { default as BoxContrast } from './box-contrast';
|
|
8
10
|
export { default as Card } from './card';
|
|
11
|
+
export { default as CardSettingsGroup } from './card-settings-group';
|
|
12
|
+
export { default as CardSortableList } from './card-sortable-list';
|
|
9
13
|
export { default as CategoryAutocomplete } from './category-autocomplete';
|
|
10
14
|
export { default as ColorPicker } from './color-picker';
|
|
15
|
+
export { default as ConfirmDialog } from './confirm-dialog';
|
|
11
16
|
export { default as CustomSelectControl } from './custom-select-control';
|
|
17
|
+
export { default as Divider } from './divider';
|
|
12
18
|
export { default as FormTokenField } from './form-token-field';
|
|
13
19
|
export { default as Footer } from './footer';
|
|
14
20
|
export { default as Handoff } from './handoff';
|
package/src/modal/index.js
CHANGED
|
@@ -18,12 +18,21 @@ import './style.scss';
|
|
|
18
18
|
*/
|
|
19
19
|
import classnames from 'classnames';
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const sizeClassMap = {
|
|
22
|
+
small: 'newspack-modal--size-small',
|
|
23
|
+
medium: 'newspack-modal--size-medium',
|
|
24
|
+
large: 'newspack-modal--size-large',
|
|
25
|
+
'x-large': 'newspack-modal--size-x-large',
|
|
26
|
+
full: 'newspack-modal--size-full',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getSizeClassName = size => sizeClassMap[ size ] || sizeClassMap.medium;
|
|
30
|
+
|
|
31
|
+
function Modal( { className, size = 'medium', hideTitle, ...otherProps }, ref ) {
|
|
22
32
|
const classes = classnames(
|
|
23
33
|
'newspack-modal',
|
|
24
|
-
isWide && 'newspack-modal--wide',
|
|
25
|
-
isNarrow && 'newspack-modal--narrow',
|
|
26
34
|
hideTitle && 'newspack-modal--hide-title', // Note: also hides the X close button.
|
|
35
|
+
getSizeClassName( size ),
|
|
27
36
|
className
|
|
28
37
|
);
|
|
29
38
|
|
package/src/modal/style.scss
CHANGED
|
@@ -12,20 +12,37 @@
|
|
|
12
12
|
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-700--rgb};
|
|
13
13
|
--wp-admin-theme-color-darker-20: #{colors.$primary-800};
|
|
14
14
|
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-800--rgb};
|
|
15
|
+
--wp-admin-theme-color-lighter-10: #{colors.$primary-000};
|
|
16
|
+
--wp-admin-theme-color-lighter-10--rgb: #{colors.$primary-000--rgb};
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
border-radius: 8px;
|
|
19
|
+
margin: auto;
|
|
20
|
+
max-height: calc(100% - 64px);
|
|
21
|
+
max-width: 512px;
|
|
22
|
+
width: calc(100% - 64px);
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
&--size-small {
|
|
25
|
+
max-width: 384px;
|
|
26
|
+
|
|
27
|
+
&.newspack-modal--hide-title {
|
|
28
|
+
max-width: 350px;
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
&--
|
|
27
|
-
max-width:
|
|
28
|
-
|
|
32
|
+
&--size-medium {
|
|
33
|
+
max-width: 512px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&--size-large {
|
|
37
|
+
max-width: 840px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&--size-x-large {
|
|
41
|
+
max-width: calc(var(--newspack-wizard-section-width) + 64px)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&--size-full {
|
|
45
|
+
max-width: 100%;
|
|
29
46
|
}
|
|
30
47
|
|
|
31
48
|
&--hide-title {
|
|
@@ -39,8 +56,15 @@
|
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
58
|
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
&--destructive {
|
|
60
|
+
.components-button.is-primary {
|
|
61
|
+
background-color: colors.$error-500;
|
|
62
|
+
color: colors.$neutral-000;
|
|
63
|
+
&:hover,
|
|
64
|
+
&:focus {
|
|
65
|
+
background-color: colors.$error-600;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
44
68
|
}
|
|
45
69
|
|
|
46
70
|
// Links
|
|
@@ -60,8 +84,14 @@
|
|
|
60
84
|
}
|
|
61
85
|
|
|
62
86
|
.components-modal__content {
|
|
63
|
-
>
|
|
64
|
-
|
|
87
|
+
> * {
|
|
88
|
+
&:first-child {
|
|
89
|
+
margin-top: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&:last-child {
|
|
93
|
+
margin-bottom: 0;
|
|
94
|
+
}
|
|
65
95
|
}
|
|
66
96
|
}
|
|
67
97
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
@use '../../../colors/colors.module.scss' as colors;
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Newspack Icon
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
.newspack-icon {
|
|
6
|
-
background:
|
|
8
|
+
background: colors.$primary-600;
|
|
7
9
|
fill: white;
|
|
8
10
|
padding: 12px;
|
|
9
11
|
|
|
10
12
|
&--white {
|
|
11
13
|
background: white;
|
|
12
|
-
fill:
|
|
14
|
+
fill: colors.$primary-600;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
&--simple {
|
|
16
18
|
background: none;
|
|
17
|
-
fill:
|
|
19
|
+
fill: colors.$primary-600;
|
|
18
20
|
padding: 0;
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
8
9
|
import { useEffect, useRef } from '@wordpress/element';
|
|
10
|
+
import { Tooltip } from '@wordpress/components'; // eslint-disable-line @wordpress/no-unsafe-wp-apis
|
|
11
|
+
import { Icon, chevronLeft } from '@wordpress/icons';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Internal dependencies
|
|
12
15
|
*/
|
|
13
|
-
import { Grid } from '..';
|
|
16
|
+
import { Badge, Button, Grid } from '..';
|
|
14
17
|
import './style.scss';
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -22,14 +25,20 @@ import classnames from 'classnames';
|
|
|
22
25
|
* Represents a section header component.
|
|
23
26
|
*
|
|
24
27
|
* @typedef {Object} SectionHeaderProps
|
|
25
|
-
* @property {
|
|
26
|
-
* @property {
|
|
27
|
-
* @property {string
|
|
28
|
-
* @property {
|
|
29
|
-
* @property {
|
|
30
|
-
* @property {
|
|
31
|
-
* @property {
|
|
32
|
-
* @property {
|
|
28
|
+
* @property {string} [backNav=''] - URL to navigate back to.
|
|
29
|
+
* @property {string|string[]} [badge] - Badge to display in the header.
|
|
30
|
+
* @property {string} [badgeLevel] - Badge level, e.g., 'success', 'info', 'warning', 'error'.
|
|
31
|
+
* @property {boolean} [centered=false] - Indicates if the header is centered.
|
|
32
|
+
* @property {?string} [className=null] - Additional CSS class name.
|
|
33
|
+
* @property {string|Function|*} [description] - Description of the section.
|
|
34
|
+
* @property {number} [heading=2] - HTML heading level, e.g., 1 for h1, 2 for h2, etc.
|
|
35
|
+
* @property {string|Function|*} [icon] - Icon to display in the header.
|
|
36
|
+
* @property {boolean} [isWhite=false] - Indicates if the header should use a white theme.
|
|
37
|
+
* @property {boolean} [noMargin=false] - Indicates if the header should have no margin.
|
|
38
|
+
* @property {boolean} [pageHeader=false] - Indicates if the header is used as a page header.
|
|
39
|
+
* @property {string} title - The title of the section.
|
|
40
|
+
* @property {?string} [id=null] - Optional ID for the header element.
|
|
41
|
+
* @property {?string|Function|*} [children=null] - Optional children to display in the header.
|
|
33
42
|
*/
|
|
34
43
|
|
|
35
44
|
/**
|
|
@@ -38,14 +47,21 @@ import classnames from 'classnames';
|
|
|
38
47
|
* @param {SectionHeaderProps} props - The properties for the section header.
|
|
39
48
|
*/
|
|
40
49
|
const SectionHeader = ( {
|
|
50
|
+
backNav = '',
|
|
51
|
+
badges,
|
|
41
52
|
centered = false,
|
|
42
53
|
className = null,
|
|
43
54
|
description = '',
|
|
44
55
|
heading = 2,
|
|
56
|
+
icon = null,
|
|
45
57
|
isWhite = false,
|
|
46
58
|
noMargin = false,
|
|
59
|
+
pageHeader = false,
|
|
47
60
|
title,
|
|
48
61
|
id = null,
|
|
62
|
+
primaryAction,
|
|
63
|
+
secondaryAction,
|
|
64
|
+
children = null,
|
|
49
65
|
} ) => {
|
|
50
66
|
// If id is in the URL as a scrollTo param, scroll to it on render.
|
|
51
67
|
const ref = useRef();
|
|
@@ -65,20 +81,63 @@ const SectionHeader = ( {
|
|
|
65
81
|
centered && 'newspack-section-header--is-centered',
|
|
66
82
|
isWhite && 'newspack-section-header--is-white',
|
|
67
83
|
noMargin && 'newspack-section-header--no-margin',
|
|
68
|
-
|
|
84
|
+
pageHeader && 'newspack-section-header--page-header'
|
|
69
85
|
);
|
|
70
86
|
|
|
71
|
-
const HeadingTag = `h${ heading }`;
|
|
87
|
+
const HeadingTag = pageHeader ? 'h1' : `h${ heading }`;
|
|
72
88
|
|
|
73
89
|
return (
|
|
74
|
-
<div
|
|
90
|
+
<div
|
|
91
|
+
id={ id }
|
|
92
|
+
className={ classnames(
|
|
93
|
+
'newspack-section-header__container',
|
|
94
|
+
backNav && 'newspack-section-header--has-back-nav',
|
|
95
|
+
primaryAction && 'newspack-section-header--has-primary-action',
|
|
96
|
+
className
|
|
97
|
+
) }
|
|
98
|
+
ref={ ref }
|
|
99
|
+
>
|
|
75
100
|
<Grid columns={ 1 } gutter={ 8 } className={ classes }>
|
|
76
|
-
{
|
|
101
|
+
{ icon && (
|
|
102
|
+
<div className="newspack-section-header__icon">
|
|
103
|
+
<Icon icon={ icon } size={ 48 } />
|
|
104
|
+
</div>
|
|
105
|
+
) }
|
|
106
|
+
{ backNav && (
|
|
107
|
+
<div className="newspack-section-header__back-nav">
|
|
108
|
+
<Tooltip text={ __( 'Go back', 'newspack-plugin' ) }>
|
|
109
|
+
<Button href={ backNav } icon={ chevronLeft } variant="tertiary" />
|
|
110
|
+
</Tooltip>
|
|
111
|
+
</div>
|
|
112
|
+
) }
|
|
113
|
+
{ typeof title === 'string' && (
|
|
114
|
+
<div className="newspack-section-header__title-container">
|
|
115
|
+
<HeadingTag>{ title }</HeadingTag>
|
|
116
|
+
{ badges?.length
|
|
117
|
+
? badges.map( ( badge, i ) => <Badge key={ i } text={ badge.label } level={ badge.level || 'default' } /> )
|
|
118
|
+
: null }
|
|
119
|
+
{ secondaryAction && (
|
|
120
|
+
<div className="newspack-section-header__secondary-action">
|
|
121
|
+
<Button variant="link" href={ secondaryAction.href } onClick={ secondaryAction.action }>
|
|
122
|
+
{ secondaryAction.label }
|
|
123
|
+
</Button>
|
|
124
|
+
</div>
|
|
125
|
+
) }
|
|
126
|
+
</div>
|
|
127
|
+
) }
|
|
77
128
|
{ typeof title === 'function' && <HeadingTag>{ title() }</HeadingTag> }
|
|
78
129
|
{ description && typeof description === 'string' && <p>{ description }</p> }
|
|
79
130
|
{ typeof description === 'function' && <p>{ description() }</p> }
|
|
80
131
|
{ description && typeof description !== 'string' && typeof description !== 'function' && <p>{ description }</p> }
|
|
132
|
+
{ children && <div className="newspack-section-header__children">{ children }</div> }
|
|
81
133
|
</Grid>
|
|
134
|
+
{ primaryAction && (
|
|
135
|
+
<div className="newspack-section-header__primary-action">
|
|
136
|
+
<Button href={ primaryAction.href } variant="primary" onClick={ primaryAction.action }>
|
|
137
|
+
{ primaryAction.label }
|
|
138
|
+
</Button>
|
|
139
|
+
</div>
|
|
140
|
+
) }
|
|
82
141
|
</div>
|
|
83
142
|
);
|
|
84
143
|
};
|