@automattic/jetpack-components 0.41.2 → 0.42.1
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 +17 -0
- package/components/boost-score-graph/background.tsx +183 -0
- package/components/boost-score-graph/index.tsx +24 -16
- package/components/boost-score-graph/style.scss +17 -0
- package/components/boost-score-graph/types/declarations.d.ts +4 -0
- package/components/boost-score-graph/uplot-line-chart.tsx +11 -5
- package/components/boost-score-graph/use-boost-score-transform.ts +21 -18
- package/components/gridicon/index.tsx +13 -0
- package/components/{pricing-slider → number-slider}/index.tsx +12 -12
- package/components/{pricing-slider → number-slider}/style.scss +8 -8
- package/components/{pricing-slider → number-slider}/types.ts +2 -2
- package/components/popover/index.tsx +19 -0
- package/components/popover/style.scss +25 -0
- package/index.ts +2 -1
- package/package.json +12 -12
- package/.gitattributes +0 -8
- package/components/action-button/stories/index.stories.jsx +0 -38
- package/components/action-button/test/component.jsx +0 -16
- package/components/action-popover/stories/index.stories.jsx +0 -115
- package/components/action-popover/stories/styles.module.scss +0 -7
- package/components/admin-page/stories/index.stories.tsx +0 -35
- package/components/admin-page/stories/style.module.scss +0 -13
- package/components/admin-section/stories/index.stories.tsx +0 -60
- package/components/alert/stories/index.stories.jsx +0 -24
- package/components/automattic-byline-logo/stories/index.stories.tsx +0 -20
- package/components/automattic-byline-logo/test/component.tsx +0 -28
- package/components/boost-score-bar/stories/index.stories.tsx +0 -39
- package/components/boost-score-bar/test/component.tsx +0 -102
- package/components/boost-score-graph/stories/index.stories.tsx +0 -187
- package/components/boost-score-graph/stories/tooltip.stories.tsx +0 -41
- package/components/button/stories/index.mdx +0 -90
- package/components/button/stories/index.stories.tsx +0 -400
- package/components/button/stories/style.module.scss +0 -20
- package/components/contextual-upgrade-trigger/stories/index.stories.tsx +0 -25
- package/components/decorative-card/stories/index.stories.tsx +0 -18
- package/components/dialog/stories/boost.png +0 -0
- package/components/dialog/stories/declaration.d.ts +0 -1
- package/components/dialog/stories/index.stories.tsx +0 -118
- package/components/dialog/stories/js-components.components.dialog.mdx +0 -62
- package/components/dialog/stories/js-components.components.dialog.stories.js +0 -37
- package/components/dialog/stories/style.module.scss +0 -21
- package/components/donut-meter/stories/index.stories.tsx +0 -51
- package/components/donut-meter/test/component.tsx +0 -24
- package/components/gridicon/stories/index.stories.tsx +0 -18
- package/components/icon-tooltip/stories/index.stories.tsx +0 -108
- package/components/icon-tooltip/stories/style.scss +0 -36
- package/components/icon-tooltip/test/component.tsx +0 -15
- package/components/icons/stories/index.stories.tsx +0 -65
- package/components/icons/stories/style.module.scss +0 -33
- package/components/indeterminate-progress-bar/stories/index.stories.tsx +0 -14
- package/components/jetpack-footer/stories/index.stories.tsx +0 -39
- package/components/jetpack-footer/test/__snapshots__/component.tsx.snap +0 -186
- package/components/jetpack-footer/test/component.tsx +0 -159
- package/components/jetpack-logo/stories/index.stories.tsx +0 -20
- package/components/jetpack-logo/test/component.tsx +0 -16
- package/components/jetpack-search-logo/stories/index.stories.tsx +0 -21
- package/components/jetpack-search-logo/test/component.tsx +0 -16
- package/components/jetpack-vaultpress-backup-logo/stories/index.stories.tsx +0 -20
- package/components/jetpack-vaultpress-backup-logo/test/component.tsx +0 -18
- package/components/jetpack-videopress-logo/stories/index.stories.tsx +0 -20
- package/components/jetpack-videopress-logo/test/component.tsx +0 -16
- package/components/layout/stories/index.stories.tsx +0 -145
- package/components/layout/stories/styles.module.scss +0 -22
- package/components/loading-placeholder/stories/index.stories.tsx +0 -78
- package/components/notice/stories/index.stories.jsx +0 -90
- package/components/pricing-card/stories/index.stories.tsx +0 -55
- package/components/pricing-card/test/component.tsx +0 -89
- package/components/pricing-slider/stories/index.stories.tsx +0 -44
- package/components/pricing-slider/test/component.tsx +0 -14
- package/components/pricing-table/stories/index.stories.tsx +0 -74
- package/components/pricing-table/test/component.tsx +0 -41
- package/components/product-offer/stories/index.stories.tsx +0 -104
- package/components/product-price/stories/index.stories.tsx +0 -33
- package/components/product-price/test/component.tsx +0 -26
- package/components/qr-code/stories/index.stories.tsx +0 -32
- package/components/record-meter-bar/stories/index.stories.tsx +0 -39
- package/components/record-meter-bar/test/component.tsx +0 -52
- package/components/spinner/stories/index.stories.jsx +0 -20
- package/components/spinner/test/component.jsx +0 -17
- package/components/split-button/stories/index.stories.tsx +0 -35
- package/components/stat-card/stories/index.mdx +0 -35
- package/components/stat-card/stories/index.stories.tsx +0 -41
- package/components/stat-card/test/component.tsx +0 -24
- package/components/status/stories/index.stories.tsx +0 -44
- package/components/terms-of-service/test/index.test.jsx +0 -52
- package/components/testimonials/test/component.tsx +0 -103
- package/components/text/stories/headings.index.stories.tsx +0 -80
- package/components/text/stories/index.mdx +0 -195
- package/components/text/stories/index.stories.tsx +0 -69
- package/components/text/stories/style.module.scss +0 -64
- package/components/text/stories/title.index.stories.tsx +0 -34
- package/components/theme-provider/stories/index.stories.tsx +0 -164
- package/components/theme-provider/stories/style.module.scss +0 -79
- package/components/toggle-control/stories/index.stories.tsx +0 -83
- package/components/zendesk-chat/stories/index.stories.tsx +0 -15
- package/components/zendesk-chat/test/component.tsx +0 -16
- package/lib/locale/test/index.ts +0 -21
- package/tools/jp-redirect/test/index.tsx +0 -89
- package/tools/pricing-utils/test/index.ts +0 -39
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './style.scss';
|
|
2
|
+
|
|
3
|
+
type PopoverProps = {
|
|
4
|
+
action: React.ReactNode;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Popover: React.FC< PopoverProps > = ( { icon, children, action } ) => {
|
|
10
|
+
return (
|
|
11
|
+
<div className="jp-popover">
|
|
12
|
+
<div className="jp-popover__icon">{ icon }</div>
|
|
13
|
+
<div className="jp-popover__body">{ children }</div>
|
|
14
|
+
<div className="jp-popover__action">{ action }</div>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Popover;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.jp-popover {
|
|
2
|
+
width: 600px;
|
|
3
|
+
max-width: calc( 100% - 32px );
|
|
4
|
+
padding: 16px;
|
|
5
|
+
background-color: #fff;
|
|
6
|
+
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.06), 0px 4px 8px 0px rgba(0, 0, 0, 0.03);
|
|
7
|
+
border: 1px solid rgba(220, 220, 222, 1);
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
text-align: center;
|
|
10
|
+
position: absolute;
|
|
11
|
+
top: 50%;
|
|
12
|
+
left: 50%;
|
|
13
|
+
transform: translate(-50%, -50%);
|
|
14
|
+
|
|
15
|
+
> * {
|
|
16
|
+
margin: 16px;
|
|
17
|
+
clear: both;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__body p {
|
|
21
|
+
font-weight: 400;
|
|
22
|
+
line-height: 1.6em;
|
|
23
|
+
font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif;
|
|
24
|
+
}
|
|
25
|
+
}
|
package/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { default as Gridicon } from './components/gridicon';
|
|
|
28
28
|
export { default as IconTooltip } from './components/icon-tooltip';
|
|
29
29
|
export { default as ActionButton } from './components/action-button';
|
|
30
30
|
export { default as PricingCard } from './components/pricing-card';
|
|
31
|
-
export { default as
|
|
31
|
+
export { default as NumberSlider } from './components/number-slider';
|
|
32
32
|
export { default as AdminSection } from './components/admin-section/basic';
|
|
33
33
|
export { default as AdminSectionHero } from './components/admin-section/hero';
|
|
34
34
|
export { default as AdminPage } from './components/admin-page';
|
|
@@ -63,6 +63,7 @@ export { default as RecordMeterBar } from './components/record-meter-bar';
|
|
|
63
63
|
export { default as ContextualUpgradeTrigger } from './components/contextual-upgrade-trigger';
|
|
64
64
|
export { default as Alert } from './components/alert';
|
|
65
65
|
export { default as Notice } from './components/notice';
|
|
66
|
+
export { default as Popover } from './components/popover';
|
|
66
67
|
export { default as Status } from './components/status';
|
|
67
68
|
export { default as IndeterminateProgressBar } from './components/indeterminate-progress-bar';
|
|
68
69
|
export { default as ActionPopover } from './components/action-popover';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "Jetpack Components Package",
|
|
5
5
|
"author": "Automattic",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@automattic/format-currency": "1.0.1",
|
|
18
|
-
"@automattic/jetpack-boost-score-api": "^0.1.
|
|
18
|
+
"@automattic/jetpack-boost-score-api": "^0.1.9",
|
|
19
19
|
"@babel/runtime": "^7",
|
|
20
|
-
"@wordpress/browserslist-config": "5.
|
|
21
|
-
"@wordpress/components": "25.
|
|
22
|
-
"@wordpress/compose": "6.
|
|
23
|
-
"@wordpress/data": "9.
|
|
24
|
-
"@wordpress/date": "4.
|
|
25
|
-
"@wordpress/element": "5.
|
|
26
|
-
"@wordpress/i18n": "4.
|
|
27
|
-
"@wordpress/icons": "9.
|
|
20
|
+
"@wordpress/browserslist-config": "5.24.0",
|
|
21
|
+
"@wordpress/components": "25.7.0",
|
|
22
|
+
"@wordpress/compose": "6.18.0",
|
|
23
|
+
"@wordpress/data": "9.11.0",
|
|
24
|
+
"@wordpress/date": "4.41.0",
|
|
25
|
+
"@wordpress/element": "5.18.0",
|
|
26
|
+
"@wordpress/i18n": "4.41.0",
|
|
27
|
+
"@wordpress/icons": "9.32.0",
|
|
28
28
|
"classnames": "2.3.2",
|
|
29
29
|
"prop-types": "^15.7.2",
|
|
30
30
|
"qrcode.react": "3.1.0",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"uplot-react": "1.1.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
37
|
-
"@babel/core": "7.22.
|
|
36
|
+
"@automattic/jetpack-base-styles": "^0.6.8",
|
|
37
|
+
"@babel/core": "7.22.11",
|
|
38
38
|
"@babel/preset-react": "7.22.5",
|
|
39
39
|
"@jest/globals": "29.4.3",
|
|
40
40
|
"@storybook/addon-actions": "7.1.0",
|
package/.gitattributes
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { action } from '@storybook/addon-actions';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import ActionButton from '../index.jsx';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'JS Packages/Components/Action Button',
|
|
7
|
-
component: ActionButton,
|
|
8
|
-
// TODO: Storybook Actions are not working. See https://github.com/storybookjs/storybook/issues/7215
|
|
9
|
-
argTypes: {
|
|
10
|
-
onButtonClick: { action: 'clicked' },
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Export additional stories using pre-defined values
|
|
15
|
-
const Template = args => <ActionButton { ...args } />;
|
|
16
|
-
|
|
17
|
-
const DefaultArgs = {
|
|
18
|
-
onButtonClick: action( 'onButtonClick' ),
|
|
19
|
-
displayError: false,
|
|
20
|
-
isLoading: false,
|
|
21
|
-
label: 'Action!',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Export Default story
|
|
25
|
-
export const _default = Template.bind( {} );
|
|
26
|
-
_default.args = DefaultArgs;
|
|
27
|
-
|
|
28
|
-
export const Loading = Template.bind( {} );
|
|
29
|
-
Loading.args = {
|
|
30
|
-
...DefaultArgs,
|
|
31
|
-
isLoading: true,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const Errored = Template.bind( {} );
|
|
35
|
-
Errored.args = {
|
|
36
|
-
...DefaultArgs,
|
|
37
|
-
displayError: true,
|
|
38
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import ActionButton from '../index';
|
|
3
|
-
|
|
4
|
-
describe( 'ActionButton', () => {
|
|
5
|
-
const testProps = {
|
|
6
|
-
label: 'Action!',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe( 'Render the ActionButton component', () => {
|
|
10
|
-
render( <ActionButton { ...testProps } /> );
|
|
11
|
-
|
|
12
|
-
it( 'renders the register button', () => {
|
|
13
|
-
expect( screen.getByRole( 'button' ) ).toHaveTextContent( 'Action!' );
|
|
14
|
-
} );
|
|
15
|
-
} );
|
|
16
|
-
} );
|
|
@@ -1,115 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
);
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
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;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import AutomatticBylineLogo from '../index';
|
|
3
|
-
|
|
4
|
-
describe( 'AutomatticBylineLogo', () => {
|
|
5
|
-
const testProps = {
|
|
6
|
-
className: 'sample-classname',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe( 'Render the AutomatticBylineLogo component', () => {
|
|
10
|
-
it( 'validate the class name', () => {
|
|
11
|
-
const { container } = render( <AutomatticBylineLogo { ...testProps } /> );
|
|
12
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
13
|
-
expect( container.firstChild ).toHaveClass( 'sample-classname' );
|
|
14
|
-
} );
|
|
15
|
-
|
|
16
|
-
it( 'renders the default title', () => {
|
|
17
|
-
render( <AutomatticBylineLogo /> );
|
|
18
|
-
|
|
19
|
-
expect( screen.getByText( 'An Automattic Airline' ) ).toBeInTheDocument();
|
|
20
|
-
} );
|
|
21
|
-
|
|
22
|
-
it( 'renders the given title', () => {
|
|
23
|
-
render( <AutomatticBylineLogo title="An A8C Airline" /> );
|
|
24
|
-
|
|
25
|
-
expect( screen.getByText( 'An A8C Airline' ) ).toBeInTheDocument();
|
|
26
|
-
} );
|
|
27
|
-
} );
|
|
28
|
-
} );
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import BoostScoreBar from '../index';
|
|
2
|
-
import type { Meta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
const meta: Meta< typeof BoostScoreBar > = {
|
|
5
|
-
title: 'JS Packages/Components/Boost Score Bar',
|
|
6
|
-
component: BoostScoreBar,
|
|
7
|
-
argTypes: {
|
|
8
|
-
score: { control: 'range', min: 0, max: 100, defaultValue: 80 },
|
|
9
|
-
prevScore: { control: 'range', min: 0, max: 100 },
|
|
10
|
-
isLoading: { control: 'boolean' },
|
|
11
|
-
showPrevScores: { control: 'boolean' },
|
|
12
|
-
active: { control: 'boolean' },
|
|
13
|
-
scoreBarType: { control: 'radio', options: [ 'desktop', 'mobile' ] },
|
|
14
|
-
noBoostScoreTooltip: { control: 'text' },
|
|
15
|
-
},
|
|
16
|
-
decorators: [
|
|
17
|
-
Story => (
|
|
18
|
-
<div style={ { width: '80%', maxWidth: '1320px', margin: '200px auto', fontSize: '16px' } }>
|
|
19
|
-
<Story />
|
|
20
|
-
</div>
|
|
21
|
-
),
|
|
22
|
-
],
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const defaultValues = {
|
|
26
|
-
score: 80,
|
|
27
|
-
prevScore: 70,
|
|
28
|
-
isLoading: false,
|
|
29
|
-
showPrevScores: true,
|
|
30
|
-
active: true,
|
|
31
|
-
scoreBarType: 'desktop',
|
|
32
|
-
noBoostScoreTooltip: 'No boost score',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default meta;
|
|
36
|
-
|
|
37
|
-
const Template = args => <BoostScoreBar { ...args } />;
|
|
38
|
-
export const _default = Template.bind( {} );
|
|
39
|
-
_default.args = defaultValues;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/* eslint-disable testing-library/no-container */
|
|
2
|
-
/* eslint-disable testing-library/no-node-access */
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import BoostScoreBar from '..';
|
|
5
|
-
import type { BoostScoreBarProps } from '../types';
|
|
6
|
-
|
|
7
|
-
describe( 'BoostScrollBar', () => {
|
|
8
|
-
const defaultProps: BoostScoreBarProps = {
|
|
9
|
-
score: 80,
|
|
10
|
-
prevScore: 60,
|
|
11
|
-
scoreBarType: 'desktop',
|
|
12
|
-
active: true,
|
|
13
|
-
showPrevScores: true,
|
|
14
|
-
isLoading: false,
|
|
15
|
-
noBoostScoreTooltip: 'Test tooltip text',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
it( 'renders the boost scroll bar when active is true', () => {
|
|
19
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } /> );
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
22
|
-
expect( container.firstChild ).toHaveAttribute( 'class', 'jb-score-bar jb-score-bar--desktop' );
|
|
23
|
-
} );
|
|
24
|
-
|
|
25
|
-
it( 'does not render the boost scroll bar when active is false', () => {
|
|
26
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } active={ false } /> );
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
29
|
-
expect( container ).toBeEmptyDOMElement();
|
|
30
|
-
} );
|
|
31
|
-
|
|
32
|
-
it( 'does not render the tooltip when noBoostScoreTooltip is not provided', () => {
|
|
33
|
-
render( <BoostScoreBar { ...defaultProps } noBoostScoreTooltip={ undefined } /> );
|
|
34
|
-
|
|
35
|
-
expect( screen.queryByRole( 'tooltip' ) ).not.toBeInTheDocument();
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
it( 'renders the tooltip with the correct text when noBoostScoreTooltip is provided', () => {
|
|
39
|
-
render( <BoostScoreBar { ...defaultProps } /> );
|
|
40
|
-
|
|
41
|
-
expect( screen.getByRole( 'tooltip' ) ).toHaveTextContent( 'Test tooltip text' );
|
|
42
|
-
} );
|
|
43
|
-
|
|
44
|
-
it( 'displays loading spinner when isLoading is true', () => {
|
|
45
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } isLoading={ true } /> );
|
|
46
|
-
|
|
47
|
-
expect( container.querySelector( '.jb-score-bar__loading' ) ).toBeInTheDocument();
|
|
48
|
-
} );
|
|
49
|
-
|
|
50
|
-
it( 'does not display loading spinner when isLoading is false', () => {
|
|
51
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } /> );
|
|
52
|
-
|
|
53
|
-
expect( container.querySelector( '.jb-score-bar__loading' ) ).not.toBeInTheDocument();
|
|
54
|
-
} );
|
|
55
|
-
|
|
56
|
-
it( 'renders mobile icon and text when scoreBarType is mobile', () => {
|
|
57
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } scoreBarType="mobile" /> );
|
|
58
|
-
|
|
59
|
-
expect( screen.getByText( 'Mobile score' ) ).toBeInTheDocument();
|
|
60
|
-
expect( container.querySelector( '.gridicons-phone' ) ).toBeInTheDocument();
|
|
61
|
-
} );
|
|
62
|
-
|
|
63
|
-
it( 'renders desktop icon and text when scoreBarType is desktop', () => {
|
|
64
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } /> );
|
|
65
|
-
|
|
66
|
-
expect( screen.getByText( 'Desktop score' ) ).toBeInTheDocument();
|
|
67
|
-
expect( container.querySelector( '.gridicons-computer' ) ).toBeInTheDocument();
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
|
-
it( 'renders previous scores when showPrevScores is true', () => {
|
|
71
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } /> );
|
|
72
|
-
|
|
73
|
-
const previousScoreContainer = container.querySelector( '.jb-score-bar__no_boost_score' );
|
|
74
|
-
|
|
75
|
-
expect( previousScoreContainer ).toBeInTheDocument();
|
|
76
|
-
expect( previousScoreContainer ).toHaveTextContent( '60' );
|
|
77
|
-
} );
|
|
78
|
-
|
|
79
|
-
it( 'does not render previous scores when showPrevScores is false', () => {
|
|
80
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } showPrevScores={ false } /> );
|
|
81
|
-
|
|
82
|
-
expect( container.querySelector( '.jb-score-bar__no_boost_score' ) ).not.toBeInTheDocument();
|
|
83
|
-
} );
|
|
84
|
-
|
|
85
|
-
it( 'renders the correct score bar class when score is < 50', () => {
|
|
86
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } score={ 40 } /> );
|
|
87
|
-
|
|
88
|
-
expect( container.querySelector( '.fill-bad' ) ).toBeInTheDocument();
|
|
89
|
-
} );
|
|
90
|
-
|
|
91
|
-
it( 'renders the correct score bar class when score is >= 50 and < 71', () => {
|
|
92
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } score={ 60 } /> );
|
|
93
|
-
|
|
94
|
-
expect( container.querySelector( '.fill-mediocre' ) ).toBeInTheDocument();
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
it( 'renders the correct score bar class when score is > 70', () => {
|
|
98
|
-
const { container } = render( <BoostScoreBar { ...defaultProps } /> );
|
|
99
|
-
|
|
100
|
-
expect( container.querySelector( '.fill-good' ) ).toBeInTheDocument();
|
|
101
|
-
} );
|
|
102
|
-
} );
|