@automattic/jetpack-components 0.39.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/.gitattributes +8 -0
- package/CHANGELOG.md +747 -0
- package/LICENSE.txt +357 -0
- package/README.md +11 -0
- package/SECURITY.md +38 -0
- package/components/action-button/index.jsx +70 -0
- package/components/action-button/stories/index.stories.jsx +38 -0
- package/components/action-button/style.module.scss +11 -0
- package/components/action-button/test/component.jsx +16 -0
- package/components/action-popover/index.tsx +105 -0
- package/components/action-popover/stories/index.stories.jsx +115 -0
- package/components/action-popover/stories/styles.module.scss +7 -0
- package/components/action-popover/styles.module.scss +49 -0
- package/components/action-popover/types.ts +20 -0
- package/components/admin-page/index.tsx +58 -0
- package/components/admin-page/stories/index.stories.tsx +35 -0
- package/components/admin-page/stories/style.module.scss +13 -0
- package/components/admin-page/style.module.scss +11 -0
- package/components/admin-page/types.ts +41 -0
- package/components/admin-section/basic/index.tsx +15 -0
- package/components/admin-section/basic/style.module.scss +3 -0
- package/components/admin-section/hero/index.tsx +15 -0
- package/components/admin-section/hero/style.module.scss +3 -0
- package/components/admin-section/stories/index.stories.tsx +60 -0
- package/components/admin-section/types.ts +6 -0
- package/components/alert/index.tsx +61 -0
- package/components/alert/stories/index.stories.jsx +24 -0
- package/components/alert/style.module.scss +43 -0
- package/components/automattic-byline-logo/README.md +16 -0
- package/components/automattic-byline-logo/index.tsx +38 -0
- package/components/automattic-byline-logo/stories/index.stories.tsx +20 -0
- package/components/automattic-byline-logo/test/component.tsx +28 -0
- package/components/automattic-byline-logo/types.ts +18 -0
- package/components/boost-score-bar/index.tsx +103 -0
- package/components/boost-score-bar/stories/index.stories.tsx +39 -0
- package/components/boost-score-bar/style.scss +184 -0
- package/components/boost-score-bar/test/component.tsx +102 -0
- package/components/boost-score-bar/types.ts +9 -0
- package/components/button/index.tsx +84 -0
- package/components/button/stories/index.mdx +90 -0
- package/components/button/stories/index.stories.tsx +400 -0
- package/components/button/stories/style.module.scss +20 -0
- package/components/button/style.module.scss +212 -0
- package/components/button/types.ts +21 -0
- package/components/contextual-upgrade-trigger/README.md +81 -0
- package/components/contextual-upgrade-trigger/index.tsx +44 -0
- package/components/contextual-upgrade-trigger/stories/index.stories.tsx +25 -0
- package/components/contextual-upgrade-trigger/style.module.scss +75 -0
- package/components/contextual-upgrade-trigger/types.ts +9 -0
- package/components/decorative-card/index.tsx +44 -0
- package/components/decorative-card/stories/index.stories.tsx +18 -0
- package/components/decorative-card/style.scss +116 -0
- package/components/decorative-card/types.ts +16 -0
- package/components/dialog/index.tsx +69 -0
- package/components/dialog/stories/boost.png +0 -0
- package/components/dialog/stories/declaration.d.ts +1 -0
- package/components/dialog/stories/index.stories.tsx +118 -0
- package/components/dialog/stories/js-components.components.dialog.mdx +62 -0
- package/components/dialog/stories/js-components.components.dialog.stories.js +37 -0
- package/components/dialog/stories/style.module.scss +21 -0
- package/components/dialog/style.module.scss +30 -0
- package/components/donut-meter/index.tsx +147 -0
- package/components/donut-meter/stories/index.stories.tsx +51 -0
- package/components/donut-meter/style.scss +11 -0
- package/components/donut-meter/test/component.tsx +24 -0
- package/components/gridicon/index.tsx +298 -0
- package/components/gridicon/stories/index.stories.tsx +18 -0
- package/components/gridicon/style.scss +16 -0
- package/components/gridicon/types.ts +48 -0
- package/components/icon-tooltip/index.tsx +96 -0
- package/components/icon-tooltip/stories/index.stories.tsx +108 -0
- package/components/icon-tooltip/stories/style.scss +36 -0
- package/components/icon-tooltip/style.scss +121 -0
- package/components/icon-tooltip/test/component.tsx +15 -0
- package/components/icon-tooltip/types.ts +76 -0
- package/components/icons/README.md +98 -0
- package/components/icons/index.tsx +369 -0
- package/components/icons/stories/index.stories.tsx +65 -0
- package/components/icons/stories/style.module.scss +33 -0
- package/components/icons/style.module.scss +40 -0
- package/components/icons/types.ts +38 -0
- package/components/indeterminate-progress-bar/index.tsx +28 -0
- package/components/indeterminate-progress-bar/stories/index.stories.tsx +14 -0
- package/components/indeterminate-progress-bar/style.module.scss +34 -0
- package/components/indeterminate-progress-bar/types.ts +6 -0
- package/components/jetpack-footer/README.md +21 -0
- package/components/jetpack-footer/index.tsx +94 -0
- package/components/jetpack-footer/stories/index.stories.tsx +40 -0
- package/components/jetpack-footer/style.scss +116 -0
- package/components/jetpack-footer/test/component.tsx +45 -0
- package/components/jetpack-footer/types.ts +36 -0
- package/components/jetpack-logo/README.md +20 -0
- package/components/jetpack-logo/index.tsx +46 -0
- package/components/jetpack-logo/stories/index.stories.tsx +20 -0
- package/components/jetpack-logo/test/component.tsx +16 -0
- package/components/jetpack-logo/types.ts +7 -0
- package/components/jetpack-search-logo/README.md +20 -0
- package/components/jetpack-search-logo/index.tsx +93 -0
- package/components/jetpack-search-logo/stories/index.stories.tsx +21 -0
- package/components/jetpack-search-logo/test/component.tsx +16 -0
- package/components/jetpack-search-logo/types.ts +7 -0
- package/components/jetpack-vaultpress-backup-logo/README.md +19 -0
- package/components/jetpack-vaultpress-backup-logo/index.tsx +113 -0
- package/components/jetpack-vaultpress-backup-logo/stories/index.stories.tsx +20 -0
- package/components/jetpack-vaultpress-backup-logo/test/component.tsx +18 -0
- package/components/jetpack-vaultpress-backup-logo/types.ts +6 -0
- package/components/jetpack-videopress-logo/README.md +19 -0
- package/components/jetpack-videopress-logo/index.tsx +93 -0
- package/components/jetpack-videopress-logo/stories/index.stories.tsx +20 -0
- package/components/jetpack-videopress-logo/test/component.tsx +16 -0
- package/components/jetpack-videopress-logo/types.tsx +6 -0
- package/components/layout/README.md +9 -0
- package/components/layout/breakpoints.module.scss +20 -0
- package/components/layout/col/README.md +81 -0
- package/components/layout/col/index.tsx +49 -0
- package/components/layout/col/style.module.scss +28 -0
- package/components/layout/container/README.md +77 -0
- package/components/layout/container/index.tsx +42 -0
- package/components/layout/container/style.module.scss +35 -0
- package/components/layout/stories/index.stories.tsx +145 -0
- package/components/layout/stories/styles.module.scss +22 -0
- package/components/layout/types.ts +55 -0
- package/components/layout/use-breakpoint-match/README.md +43 -0
- package/components/layout/use-breakpoint-match/declaration.d.ts +9 -0
- package/components/layout/use-breakpoint-match/index.ts +79 -0
- package/components/loading-placeholder/README.md +22 -0
- package/components/loading-placeholder/index.tsx +23 -0
- package/components/loading-placeholder/stories/index.stories.tsx +78 -0
- package/components/loading-placeholder/style.module.scss +18 -0
- package/components/notice/index.tsx +98 -0
- package/components/notice/stories/index.stories.jsx +90 -0
- package/components/notice/style.module.scss +107 -0
- package/components/number-format/README.md +25 -0
- package/components/number-format/index.ts +16 -0
- package/components/pricing-card/index.tsx +127 -0
- package/components/pricing-card/stories/index.stories.tsx +55 -0
- package/components/pricing-card/style.scss +112 -0
- package/components/pricing-card/test/component.tsx +89 -0
- package/components/pricing-card/types.ts +52 -0
- package/components/pricing-slider/index.tsx +53 -0
- package/components/pricing-slider/stories/index.stories.tsx +44 -0
- package/components/pricing-slider/style.scss +55 -0
- package/components/pricing-slider/test/component.tsx +14 -0
- package/components/pricing-slider/types.ts +58 -0
- package/components/pricing-table/index.tsx +200 -0
- package/components/pricing-table/stories/index.stories.tsx +74 -0
- package/components/pricing-table/styles.module.scss +160 -0
- package/components/pricing-table/test/component.tsx +41 -0
- package/components/pricing-table/types.ts +84 -0
- package/components/product-offer/icons-card.tsx +47 -0
- package/components/product-offer/index.tsx +115 -0
- package/components/product-offer/product-offer-header.tsx +23 -0
- package/components/product-offer/stories/index.stories.tsx +104 -0
- package/components/product-offer/style.module.scss +93 -0
- package/components/product-offer/types.ts +125 -0
- package/components/product-price/index.tsx +90 -0
- package/components/product-price/price.tsx +35 -0
- package/components/product-price/stories/index.stories.tsx +33 -0
- package/components/product-price/style.module.scss +69 -0
- package/components/product-price/test/component.tsx +26 -0
- package/components/product-price/types.ts +73 -0
- package/components/qr-code/Readme.md +5 -0
- package/components/qr-code/index.tsx +78 -0
- package/components/qr-code/stories/index.stories.tsx +32 -0
- package/components/record-meter-bar/index.tsx +135 -0
- package/components/record-meter-bar/stories/index.stories.tsx +39 -0
- package/components/record-meter-bar/style.scss +38 -0
- package/components/record-meter-bar/test/component.tsx +52 -0
- package/components/spinner/README.md +28 -0
- package/components/spinner/index.jsx +45 -0
- package/components/spinner/stories/index.stories.jsx +20 -0
- package/components/spinner/style.scss +31 -0
- package/components/spinner/test/component.jsx +17 -0
- package/components/split-button/index.tsx +39 -0
- package/components/split-button/stories/index.stories.tsx +35 -0
- package/components/split-button/style.module.scss +21 -0
- package/components/split-button/types.ts +14 -0
- package/components/stat-card/index.tsx +49 -0
- package/components/stat-card/stories/index.mdx +35 -0
- package/components/stat-card/stories/index.stories.tsx +41 -0
- package/components/stat-card/style.module.scss +49 -0
- package/components/stat-card/test/component.tsx +24 -0
- package/components/stat-card/types.ts +28 -0
- package/components/status/README.md +42 -0
- package/components/status/index.tsx +40 -0
- package/components/status/stories/index.stories.tsx +44 -0
- package/components/status/style.module.scss +72 -0
- package/components/terms-of-service/index.tsx +63 -0
- package/components/terms-of-service/styles.scss +10 -0
- package/components/terms-of-service/test/index.test.jsx +52 -0
- package/components/terms-of-service/types.ts +30 -0
- package/components/testimonials/index.tsx +58 -0
- package/components/testimonials/style.scss +127 -0
- package/components/testimonials/test/component.tsx +103 -0
- package/components/testimonials/testimonial.tsx +47 -0
- package/components/testimonials/types.ts +17 -0
- package/components/text/constants.ts +30 -0
- package/components/text/index.tsx +91 -0
- package/components/text/stories/headings.index.stories.tsx +80 -0
- package/components/text/stories/index.mdx +195 -0
- package/components/text/stories/index.stories.tsx +69 -0
- package/components/text/stories/style.module.scss +64 -0
- package/components/text/stories/title.index.stories.tsx +34 -0
- package/components/text/style.module.scss +125 -0
- package/components/text/types.ts +53 -0
- package/components/theme-provider/Readme.md +49 -0
- package/components/theme-provider/globals.module.scss +6 -0
- package/components/theme-provider/index.tsx +151 -0
- package/components/theme-provider/stories/index.stories.tsx +164 -0
- package/components/theme-provider/stories/style.module.scss +79 -0
- package/components/theme-provider/types.ts +25 -0
- package/components/toggle-control/README.md +5 -0
- package/components/toggle-control/index.tsx +67 -0
- package/components/toggle-control/stories/index.stories.tsx +83 -0
- package/components/toggle-control/styles.module.scss +41 -0
- package/components/zendesk-chat/README.md +26 -0
- package/components/zendesk-chat/constants.ts +2 -0
- package/components/zendesk-chat/index.tsx +22 -0
- package/components/zendesk-chat/stories/index.stories.tsx +15 -0
- package/components/zendesk-chat/test/component.tsx +16 -0
- package/components/zendesk-chat/types.ts +3 -0
- package/index.ts +69 -0
- package/lib/locale/index.ts +48 -0
- package/lib/locale/test/index.ts +21 -0
- package/package.json +80 -0
- package/tools/get-product-checkout-url/Readme.md +32 -0
- package/tools/get-product-checkout-url/index.ts +31 -0
- package/tools/jp-redirect/README.md +61 -0
- package/tools/jp-redirect/index.ts +62 -0
- package/tools/jp-redirect/test/index.tsx +89 -0
- package/tools/jp-redirect/types.ts +49 -0
- package/tools/pricing-utils/README.md +16 -0
- package/tools/pricing-utils/index.ts +11 -0
- package/tools/pricing-utils/test/index.ts +39 -0
- package/tools/pricing-utils/types.ts +12 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { action } from '@storybook/addon-actions';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import ActionPopover from '../index';
|
|
10
|
+
import styles from './styles.module.scss';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'JS Packages/Components/Action Popover',
|
|
14
|
+
component: ActionPopover,
|
|
15
|
+
argTypes: {
|
|
16
|
+
hideCloseButton: {
|
|
17
|
+
control: { type: 'boolean' },
|
|
18
|
+
},
|
|
19
|
+
title: {
|
|
20
|
+
control: { type: 'text' },
|
|
21
|
+
},
|
|
22
|
+
children: {
|
|
23
|
+
control: { type: 'text' },
|
|
24
|
+
},
|
|
25
|
+
step: {
|
|
26
|
+
control: { type: 'number' },
|
|
27
|
+
},
|
|
28
|
+
totalSteps: {
|
|
29
|
+
control: { type: 'number' },
|
|
30
|
+
},
|
|
31
|
+
buttonContent: {
|
|
32
|
+
control: { type: 'text' },
|
|
33
|
+
},
|
|
34
|
+
buttonDisabled: {
|
|
35
|
+
control: { type: 'boolean' },
|
|
36
|
+
},
|
|
37
|
+
buttonHref: {
|
|
38
|
+
control: { type: 'text' },
|
|
39
|
+
},
|
|
40
|
+
buttonExternalLink: {
|
|
41
|
+
control: { type: 'boolean' },
|
|
42
|
+
},
|
|
43
|
+
offset: {
|
|
44
|
+
control: { type: 'number' },
|
|
45
|
+
},
|
|
46
|
+
position: {
|
|
47
|
+
control: {
|
|
48
|
+
type: 'select',
|
|
49
|
+
},
|
|
50
|
+
options: [
|
|
51
|
+
'top left',
|
|
52
|
+
'top right',
|
|
53
|
+
'top center',
|
|
54
|
+
'middle left',
|
|
55
|
+
'middle right',
|
|
56
|
+
'middle center',
|
|
57
|
+
'bottom left',
|
|
58
|
+
'bottom right',
|
|
59
|
+
'bottom center',
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
noArrow: {
|
|
63
|
+
control: { type: 'boolean' },
|
|
64
|
+
},
|
|
65
|
+
onClose: {
|
|
66
|
+
table: {
|
|
67
|
+
disable: true,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
onClick: {
|
|
71
|
+
table: {
|
|
72
|
+
disable: true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const Template = args => {
|
|
79
|
+
const [ anchor, setAnchor ] = useState( null );
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
<div className={ styles.wrapper }>
|
|
84
|
+
<div ref={ setAnchor }>⚓</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<ActionPopover { ...args } anchor={ anchor } />
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const defaultArgs = {
|
|
93
|
+
hideCloseButton: false,
|
|
94
|
+
title: 'Check this out',
|
|
95
|
+
children: 'Absque sudore et labore nullum opus perfectum est.',
|
|
96
|
+
step: null,
|
|
97
|
+
totalSteps: null,
|
|
98
|
+
buttonContent: 'Next',
|
|
99
|
+
buttonDisabled: false,
|
|
100
|
+
offset: 32,
|
|
101
|
+
position: 'top center',
|
|
102
|
+
noArrow: true,
|
|
103
|
+
onClose: () => action( 'close' )(),
|
|
104
|
+
onClick: () => action( 'click' )(),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const _default = Template.bind( {} );
|
|
108
|
+
_default.args = defaultArgs;
|
|
109
|
+
|
|
110
|
+
export const WithSteps = Template.bind( {} );
|
|
111
|
+
WithSteps.args = {
|
|
112
|
+
...defaultArgs,
|
|
113
|
+
step: 1,
|
|
114
|
+
totalSteps: 3,
|
|
115
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
width: 304px;
|
|
3
|
+
min-height: 230px;
|
|
4
|
+
padding: calc( var( --spacing-base ) * 3 ); // 24px;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
|
|
8
|
+
.header {
|
|
9
|
+
display: flex;
|
|
10
|
+
margin-bottom: calc( var( --spacing-base ) * 2 ); // 16px
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
|
|
13
|
+
.title {
|
|
14
|
+
max-width: 226px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.close-button {
|
|
18
|
+
height: calc( var( --spacing-base ) * 3 ); // 24px
|
|
19
|
+
width: calc( var( --spacing-base ) * 3 ); // 24px
|
|
20
|
+
min-width: unset;
|
|
21
|
+
color: var( --jp-gray-90 );
|
|
22
|
+
background-color: var( --jp-white );
|
|
23
|
+
flex-shrink: 0;
|
|
24
|
+
|
|
25
|
+
&:hover:not(:focus) {
|
|
26
|
+
box-shadow: none;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.footer {
|
|
32
|
+
height: calc( var( --spacing-base ) * 6 ); // 48px
|
|
33
|
+
margin-top: calc( var( --spacing-base ) * 2 ); // 16px
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: flex-end;
|
|
36
|
+
align-items: flex-end;
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
|
|
39
|
+
.steps {
|
|
40
|
+
color: var( --jp-gray-60 );
|
|
41
|
+
flex-grow: 1;
|
|
42
|
+
margin-bottom: var( --spacing-base );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.action-button {
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types
|
|
3
|
+
*/
|
|
4
|
+
import type { Popover } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
export type ActionPopoverProps = React.ComponentProps< typeof Popover > & {
|
|
7
|
+
anchor?: Element;
|
|
8
|
+
offset?: number;
|
|
9
|
+
} & {
|
|
10
|
+
hideCloseButton?: boolean;
|
|
11
|
+
title: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
step?: number;
|
|
14
|
+
totalSteps?: number;
|
|
15
|
+
buttonContent?: React.ReactNode;
|
|
16
|
+
buttonDisabled?: boolean;
|
|
17
|
+
buttonHref?: string;
|
|
18
|
+
buttonExternalLink?: boolean;
|
|
19
|
+
onClick?(): void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import JetpackFooter from '../jetpack-footer';
|
|
4
|
+
import JetpackLogo from '../jetpack-logo';
|
|
5
|
+
import Col from '../layout/col';
|
|
6
|
+
import Container from '../layout/container';
|
|
7
|
+
import styles from './style.module.scss';
|
|
8
|
+
import type { AdminPageProps } from './types';
|
|
9
|
+
import type React from 'react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This is the base structure for any admin page. It comes with Header and Footer.
|
|
13
|
+
*
|
|
14
|
+
* All content must be passed as children wrapped in as many <AdminSection> elements as needed.
|
|
15
|
+
*
|
|
16
|
+
* @param {AdminPageProps} props - Component properties.
|
|
17
|
+
* @returns {React.ReactNode} AdminPage component.
|
|
18
|
+
*/
|
|
19
|
+
const AdminPage: React.FC< AdminPageProps > = ( {
|
|
20
|
+
children,
|
|
21
|
+
moduleName = __( 'Jetpack', 'jetpack' ),
|
|
22
|
+
moduleNameHref,
|
|
23
|
+
a8cLogoHref,
|
|
24
|
+
showHeader = true,
|
|
25
|
+
showFooter = true,
|
|
26
|
+
showBackground = true,
|
|
27
|
+
header,
|
|
28
|
+
} ) => {
|
|
29
|
+
const rootClassName = classNames( styles[ 'admin-page' ], {
|
|
30
|
+
[ styles.background ]: showBackground,
|
|
31
|
+
} );
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className={ rootClassName }>
|
|
35
|
+
{ showHeader && (
|
|
36
|
+
<Container horizontalSpacing={ 5 }>
|
|
37
|
+
<Col>{ header ? header : <JetpackLogo /> }</Col>
|
|
38
|
+
</Container>
|
|
39
|
+
) }
|
|
40
|
+
<Container fluid horizontalSpacing={ 0 }>
|
|
41
|
+
<Col>{ children }</Col>
|
|
42
|
+
</Container>
|
|
43
|
+
{ showFooter && (
|
|
44
|
+
<Container horizontalSpacing={ 5 }>
|
|
45
|
+
<Col>
|
|
46
|
+
<JetpackFooter
|
|
47
|
+
moduleName={ moduleName }
|
|
48
|
+
a8cLogoHref={ a8cLogoHref }
|
|
49
|
+
moduleNameHref={ moduleNameHref }
|
|
50
|
+
/>
|
|
51
|
+
</Col>
|
|
52
|
+
</Container>
|
|
53
|
+
) }
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default AdminPage;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import JetpackLogo from '../../jetpack-logo/index';
|
|
3
|
+
import Text from '../../text/index';
|
|
4
|
+
import AdminPage from '../index';
|
|
5
|
+
import styles from './style.module.scss';
|
|
6
|
+
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'JS Packages/Components/Admin Page',
|
|
10
|
+
component: AdminPage,
|
|
11
|
+
argTypes: {
|
|
12
|
+
moduleName: { control: 'text', defaultValue: 'Jetpack' },
|
|
13
|
+
showHeader: { control: 'boolean', defaultValue: true },
|
|
14
|
+
showFooter: { control: 'boolean', defaultValue: true },
|
|
15
|
+
showBackground: { control: 'boolean', defaultValue: true },
|
|
16
|
+
},
|
|
17
|
+
} as ComponentMeta< typeof AdminPage >;
|
|
18
|
+
|
|
19
|
+
// Export additional stories using pre-defined values
|
|
20
|
+
const Template: ComponentStory< typeof AdminPage > = args => <AdminPage { ...args } />;
|
|
21
|
+
|
|
22
|
+
// Export Default story
|
|
23
|
+
export const _default = Template.bind( {} );
|
|
24
|
+
|
|
25
|
+
export const CustomHeader = Template.bind( {} );
|
|
26
|
+
CustomHeader.args = {
|
|
27
|
+
header: (
|
|
28
|
+
<div className={ styles[ 'custom-header' ] }>
|
|
29
|
+
<JetpackLogo height={ 40 } />
|
|
30
|
+
<Text className={ styles[ 'logo-title' ] } weight="regular">
|
|
31
|
+
Next Product is coming up
|
|
32
|
+
</Text>
|
|
33
|
+
</div>
|
|
34
|
+
),
|
|
35
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type AdminPageProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The page content
|
|
4
|
+
*/
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Link for 'An Automattic Airline' in the footer.
|
|
9
|
+
*/
|
|
10
|
+
a8cLogoHref?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Name of the module, e.g. 'Jetpack Search' that will be displayed in the footer.
|
|
14
|
+
*/
|
|
15
|
+
moduleName?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not to display the Header
|
|
19
|
+
*/
|
|
20
|
+
showHeader?: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Custom header. Optional
|
|
24
|
+
*/
|
|
25
|
+
header?: React.ReactNode;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether or not to display the Footer
|
|
29
|
+
*/
|
|
30
|
+
showFooter?: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Link that the Footer Module name will link to (optional).
|
|
34
|
+
*/
|
|
35
|
+
moduleNameHref?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Whether or not to display the Background Color
|
|
39
|
+
*/
|
|
40
|
+
showBackground?: boolean;
|
|
41
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './style.module.scss';
|
|
3
|
+
import type { AdminSectionBaseProps } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is the wrapper component to build sections within your admin page.
|
|
7
|
+
*
|
|
8
|
+
* @param {AdminSectionBaseProps} props - Component properties.
|
|
9
|
+
* @returns {React.ReactNode} AdminSection component.
|
|
10
|
+
*/
|
|
11
|
+
const AdminSection: React.FC< AdminSectionBaseProps > = ( { children } ) => {
|
|
12
|
+
return <div className={ styles.section }>{ children }</div>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default AdminSection;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './style.module.scss';
|
|
3
|
+
import type { AdminSectionBaseProps } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The wrapper component for a Hero Section to be used in admin pages.
|
|
7
|
+
*
|
|
8
|
+
* @param {AdminSectionBaseProps} props - Component properties.
|
|
9
|
+
* @returns {React.Component} AdminSectionHero component.
|
|
10
|
+
*/
|
|
11
|
+
const AdminSectionHero: React.FC< AdminSectionBaseProps > = ( { children } ) => {
|
|
12
|
+
return <div className={ styles[ 'section-hero' ] }>{ children }</div>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default AdminSectionHero;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import AdminPage from '../../admin-page';
|
|
2
|
+
import Col from '../../layout/col';
|
|
3
|
+
import Container from '../../layout/container';
|
|
4
|
+
import AdminSection from '../basic';
|
|
5
|
+
import AdminSectionHero from '../hero';
|
|
6
|
+
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'JS Packages/Components/Admin Sections',
|
|
10
|
+
} as ComponentMeta< typeof AdminSection >;
|
|
11
|
+
|
|
12
|
+
// Export additional stories using pre-defined values
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
const Template: ComponentStory< typeof AdminSection > = args => (
|
|
15
|
+
<AdminPage>
|
|
16
|
+
<AdminSectionHero>
|
|
17
|
+
<Container>
|
|
18
|
+
<Col lg={ 12 } md={ 8 } sm={ 4 }>
|
|
19
|
+
<h1>Sample Hero section</h1>
|
|
20
|
+
<p>This is a sample Hero section</p>
|
|
21
|
+
</Col>
|
|
22
|
+
</Container>
|
|
23
|
+
</AdminSectionHero>
|
|
24
|
+
<AdminSection>
|
|
25
|
+
<Container>
|
|
26
|
+
<Col lg={ 12 } md={ 8 } sm={ 4 }>
|
|
27
|
+
<h2>Sample Section</h2>
|
|
28
|
+
<p>This is a sample section</p>
|
|
29
|
+
</Col>
|
|
30
|
+
</Container>
|
|
31
|
+
</AdminSection>
|
|
32
|
+
</AdminPage>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Export Default story
|
|
36
|
+
export const _default = Template.bind( {} );
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
|
+
export const onlyBasic = args => (
|
|
40
|
+
<AdminSection>
|
|
41
|
+
<Container>
|
|
42
|
+
<Col lg={ 12 } md={ 8 } sm={ 4 }>
|
|
43
|
+
<h2>Sample Section</h2>
|
|
44
|
+
<p>This is a sample section</p>
|
|
45
|
+
</Col>
|
|
46
|
+
</Container>
|
|
47
|
+
</AdminSection>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
+
export const onlyHero = args => (
|
|
52
|
+
<AdminSectionHero>
|
|
53
|
+
<Container>
|
|
54
|
+
<Col lg={ 12 } md={ 8 } sm={ 4 }>
|
|
55
|
+
<h2>Sample Hero Section</h2>
|
|
56
|
+
<p>This is a sample Hero section</p>
|
|
57
|
+
</Col>
|
|
58
|
+
</Container>
|
|
59
|
+
</AdminSectionHero>
|
|
60
|
+
);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Icon, warning, info, check } from '@wordpress/icons';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styles from './style.module.scss';
|
|
5
|
+
|
|
6
|
+
type AlertProps = {
|
|
7
|
+
/** The severity of the alert. */
|
|
8
|
+
level: 'error' | 'warning' | 'info' | 'success';
|
|
9
|
+
|
|
10
|
+
/** Show/Hide icon */
|
|
11
|
+
showIcon?: boolean;
|
|
12
|
+
|
|
13
|
+
/** Children to be rendered inside the alert. */
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getIconByLevel = ( level: AlertProps[ 'level' ] ) => {
|
|
18
|
+
switch ( level ) {
|
|
19
|
+
case 'error':
|
|
20
|
+
return warning;
|
|
21
|
+
case 'warning':
|
|
22
|
+
return warning;
|
|
23
|
+
case 'info':
|
|
24
|
+
return info;
|
|
25
|
+
case 'success':
|
|
26
|
+
return check;
|
|
27
|
+
default:
|
|
28
|
+
return warning;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Alert component
|
|
34
|
+
*
|
|
35
|
+
* @param {object} props - The component properties.
|
|
36
|
+
* @param {string} props.level - The alert level: error, warning, info, success.
|
|
37
|
+
* @param {boolean} props.showIcon - Whether to show the alert icon.
|
|
38
|
+
* @param {React.Component} props.children - The alert content.
|
|
39
|
+
* @returns {React.ReactElement} The `Alert` component.
|
|
40
|
+
*/
|
|
41
|
+
const Alert: React.FC< AlertProps > = ( { level, children, showIcon } ) => {
|
|
42
|
+
const classes = classNames( styles.container, styles[ `is-${ level }` ] );
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div className={ classes }>
|
|
46
|
+
{ showIcon && (
|
|
47
|
+
<div className={ styles[ 'icon-wrapper' ] }>
|
|
48
|
+
<Icon icon={ getIconByLevel( level ) } className={ styles.icon } />
|
|
49
|
+
</div>
|
|
50
|
+
) }
|
|
51
|
+
<div>{ children }</div>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
Alert.defaultProps = {
|
|
57
|
+
level: 'warning',
|
|
58
|
+
showIcon: true,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default Alert;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Alert from '../index';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'JS Packages/Components/Alert',
|
|
6
|
+
component: Alert,
|
|
7
|
+
argTypes: {
|
|
8
|
+
level: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'select',
|
|
11
|
+
},
|
|
12
|
+
options: [ 'info', 'success', 'warning', 'error' ],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const Template = args => <Alert { ...args } />;
|
|
18
|
+
|
|
19
|
+
export const _default = Template.bind( {} );
|
|
20
|
+
_default.args = {
|
|
21
|
+
level: 'info',
|
|
22
|
+
children: "Don't forget to check your email for the latest news.",
|
|
23
|
+
showIcon: true,
|
|
24
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
font-size: var( --font-body );
|
|
4
|
+
line-height: calc( var( --spacing-base ) * 3 );
|
|
5
|
+
min-height: calc( var( --spacing-base ) * 3 );
|
|
6
|
+
align-items: center;
|
|
7
|
+
margin: calc( var( --spacing-base ) * 2 ) 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.icon-wrapper {
|
|
11
|
+
margin-right: calc( var( --spacing-base ) / 2 );
|
|
12
|
+
width: calc( var( --spacing-base ) * 3 );
|
|
13
|
+
height: calc( var( --spacing-base ) * 3 );
|
|
14
|
+
align-self: flex-start;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.is-error {
|
|
18
|
+
color: var( --jp-red );
|
|
19
|
+
.icon {
|
|
20
|
+
fill: var( --jp-red );
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.is-warning {
|
|
25
|
+
color: var( --jp-yellow-40 );
|
|
26
|
+
.icon {
|
|
27
|
+
fill: var( --jp-yellow-40 );
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.is-info {
|
|
32
|
+
color: var( --jp-blue-40 );
|
|
33
|
+
.icon {
|
|
34
|
+
fill: var( --jp-blue-40 );
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.is-success {
|
|
39
|
+
color: var( --jp-green );
|
|
40
|
+
.icon {
|
|
41
|
+
fill: var( --jp-green );
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Automattic Byline Logo
|
|
2
|
+
|
|
3
|
+
Component that renders the stylish `AN AUTOMATTIC AIRLINE`.
|
|
4
|
+
It takes width and height properties but defaults to 7 in height.
|
|
5
|
+
|
|
6
|
+
#### How to use:
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
<AutomatticBylineLogo height={ 7 } className="jp-automattic-byline-logo-jetpack" />
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
#### Props
|
|
13
|
+
|
|
14
|
+
- `className`: String - (default only: `jp-automattic-byline-logo`) the additional class name set on the SVG element.
|
|
15
|
+
- `height`: Number - (default: 8) set the height of the title.
|
|
16
|
+
- `title`: String - (default: `AN AUTOMATTIC AIRLINE`) title of the SVG.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { AutomatticBylineLogoProps } from './types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Automattic "By line" Logo component.
|
|
8
|
+
*
|
|
9
|
+
* @param {AutomatticBylineLogoProps} props - Component properties.
|
|
10
|
+
* @returns {React.ReactNode} AutomatticBylineLogo component.
|
|
11
|
+
*/
|
|
12
|
+
const AutomatticBylineLogo: React.FC< AutomatticBylineLogoProps > = ( {
|
|
13
|
+
title = __( 'An Automattic Airline', 'jetpack' ),
|
|
14
|
+
height = 7,
|
|
15
|
+
className,
|
|
16
|
+
...otherProps
|
|
17
|
+
} ) => {
|
|
18
|
+
return (
|
|
19
|
+
<svg
|
|
20
|
+
role="img"
|
|
21
|
+
x="0"
|
|
22
|
+
y="0"
|
|
23
|
+
viewBox="0 0 935 38.2"
|
|
24
|
+
enableBackground="new 0 0 935 38.2"
|
|
25
|
+
aria-labelledby="jp-automattic-byline-logo-title"
|
|
26
|
+
height={ height }
|
|
27
|
+
className={ classnames( 'jp-automattic-byline-logo', className ) }
|
|
28
|
+
{ ...otherProps }
|
|
29
|
+
>
|
|
30
|
+
<desc id="jp-automattic-byline-logo-title">{ title }</desc>
|
|
31
|
+
<path d="M317.1 38.2c-12.6 0-20.7-9.1-20.7-18.5v-1.2c0-9.6 8.2-18.5 20.7-18.5 12.6 0 20.8 8.9 20.8 18.5v1.2C337.9 29.1 329.7 38.2 317.1 38.2zM331.2 18.6c0-6.9-5-13-14.1-13s-14 6.1-14 13v0.9c0 6.9 5 13.1 14 13.1s14.1-6.2 14.1-13.1V18.6zM175 36.8l-4.7-8.8h-20.9l-4.5 8.8h-7L157 1.3h5.5L182 36.8H175zM159.7 8.2L152 23.1h15.7L159.7 8.2zM212.4 38.2c-12.7 0-18.7-6.9-18.7-16.2V1.3h6.6v20.9c0 6.6 4.3 10.5 12.5 10.5 8.4 0 11.9-3.9 11.9-10.5V1.3h6.7V22C231.4 30.8 225.8 38.2 212.4 38.2zM268.6 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H268.6zM397.3 36.8V8.7l-1.8 3.1 -14.9 25h-3.3l-14.7-25 -1.8-3.1v28.1h-6.5V1.3h9.2l14 24.4 1.7 3 1.7-3 13.9-24.4h9.1v35.5H397.3zM454.4 36.8l-4.7-8.8h-20.9l-4.5 8.8h-7l19.2-35.5h5.5l19.5 35.5H454.4zM439.1 8.2l-7.7 14.9h15.7L439.1 8.2zM488.4 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H488.4zM537.3 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H537.3zM569.3 36.8V4.6c2.7 0 3.7-1.4 3.7-3.4h2.8v35.5L569.3 36.8 569.3 36.8zM628 11.3c-3.2-2.9-7.9-5.7-14.2-5.7 -9.5 0-14.8 6.5-14.8 13.3v0.7c0 6.7 5.4 13 15.3 13 5.9 0 10.8-2.8 13.9-5.7l4 4.2c-3.9 3.8-10.5 7.1-18.3 7.1 -13.4 0-21.6-8.7-21.6-18.3v-1.2c0-9.6 8.9-18.7 21.9-18.7 7.5 0 14.3 3.1 18 7.1L628 11.3zM321.5 12.4c1.2 0.8 1.5 2.4 0.8 3.6l-6.1 9.4c-0.8 1.2-2.4 1.6-3.6 0.8l0 0c-1.2-0.8-1.5-2.4-0.8-3.6l6.1-9.4C318.7 11.9 320.3 11.6 321.5 12.4L321.5 12.4z" />
|
|
32
|
+
<path d="M37.5 36.7l-4.7-8.9H11.7l-4.6 8.9H0L19.4 0.8H25l19.7 35.9H37.5zM22 7.8l-7.8 15.1h15.9L22 7.8zM82.8 36.7l-23.3-24 -2.3-2.5v26.6h-6.7v-36H57l22.6 24 2.3 2.6V0.8h6.7v35.9H82.8z" />
|
|
33
|
+
<path d="M719.9 37l-4.8-8.9H694l-4.6 8.9h-7.1l19.5-36h5.6l19.8 36H719.9zM704.4 8l-7.8 15.1h15.9L704.4 8zM733 37V1h6.8v36H733zM781 37c-1.8 0-2.6-2.5-2.9-5.8l-0.2-3.7c-0.2-3.6-1.7-5.1-8.4-5.1h-12.8V37H750V1h19.6c10.8 0 15.7 4.3 15.7 9.9 0 3.9-2 7.7-9 9 7 0.5 8.5 3.7 8.6 7.9l0.1 3c0.1 2.5 0.5 4.3 2.2 6.1V37H781zM778.5 11.8c0-2.6-2.1-5.1-7.9-5.1h-13.8v10.8h14.4c5 0 7.3-2.4 7.3-5.2V11.8zM794.8 37V1h6.8v30.4h28.2V37H794.8zM836.7 37V1h6.8v36H836.7zM886.2 37l-23.4-24.1 -2.3-2.5V37h-6.8V1h6.5l22.7 24.1 2.3 2.6V1h6.8v36H886.2zM902.3 37V1H935v5.6h-26v9.2h20v5.5h-20v10.1h26V37H902.3z" />
|
|
34
|
+
</svg>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default AutomatticBylineLogo;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import AutomatticBylineLogo from '../index';
|
|
2
|
+
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'JS Packages/Components/Automattic Byline Logo',
|
|
6
|
+
component: AutomatticBylineLogo,
|
|
7
|
+
} as ComponentMeta< typeof AutomatticBylineLogo >;
|
|
8
|
+
|
|
9
|
+
const Template: ComponentStory< typeof AutomatticBylineLogo > = args => (
|
|
10
|
+
<AutomatticBylineLogo { ...args } />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const DefaultArgs = {
|
|
14
|
+
title: 'Title',
|
|
15
|
+
height: '50px',
|
|
16
|
+
className: 'sample-classname',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const _default = Template.bind( {} );
|
|
20
|
+
_default.args = DefaultArgs;
|