@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
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { BoostScoreGraph } from '..';
|
|
2
|
-
import type { Meta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
const exampleRawResponse = {
|
|
5
|
-
data: {
|
|
6
|
-
_meta: {
|
|
7
|
-
start: 1689772803000,
|
|
8
|
-
end: 1690647000000,
|
|
9
|
-
},
|
|
10
|
-
periods: [
|
|
11
|
-
{
|
|
12
|
-
timestamp: 1690636803000,
|
|
13
|
-
dimensions: {
|
|
14
|
-
desktop_overall_score: 86,
|
|
15
|
-
mobile_overall_score: 52,
|
|
16
|
-
desktop_cls: 0.088,
|
|
17
|
-
desktop_lcp: 3.2,
|
|
18
|
-
desktop_tbt: 0,
|
|
19
|
-
mobile_cls: 0.088,
|
|
20
|
-
mobile_lcp: 3.2,
|
|
21
|
-
mobile_tbt: 0,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
timestamp: 1689772803000,
|
|
26
|
-
dimensions: {
|
|
27
|
-
desktop_overall_score: 75,
|
|
28
|
-
mobile_overall_score: 52,
|
|
29
|
-
desktop_cls: 0.088,
|
|
30
|
-
desktop_lcp: 3.2,
|
|
31
|
-
desktop_tbt: 0,
|
|
32
|
-
mobile_cls: 0.088,
|
|
33
|
-
mobile_lcp: 3.2,
|
|
34
|
-
mobile_tbt: 0,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
timestamp: 1689859203000,
|
|
39
|
-
dimensions: {
|
|
40
|
-
desktop_overall_score: 72,
|
|
41
|
-
mobile_overall_score: 49,
|
|
42
|
-
desktop_cls: 0.088,
|
|
43
|
-
desktop_lcp: 3.2,
|
|
44
|
-
desktop_tbt: 0,
|
|
45
|
-
mobile_cls: 0.088,
|
|
46
|
-
mobile_lcp: 3.2,
|
|
47
|
-
mobile_tbt: 0,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
timestamp: 1689945603000,
|
|
52
|
-
dimensions: {
|
|
53
|
-
desktop_overall_score: 20,
|
|
54
|
-
mobile_overall_score: 30,
|
|
55
|
-
desktop_cls: 0.088,
|
|
56
|
-
desktop_lcp: 3.2,
|
|
57
|
-
desktop_tbt: 0,
|
|
58
|
-
mobile_cls: 0.088,
|
|
59
|
-
mobile_lcp: 3.2,
|
|
60
|
-
mobile_tbt: 0,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
timestamp: 1690032003000,
|
|
65
|
-
dimensions: {
|
|
66
|
-
desktop_overall_score: 72,
|
|
67
|
-
mobile_overall_score: 40,
|
|
68
|
-
desktop_cls: 0.088,
|
|
69
|
-
desktop_lcp: 3.2,
|
|
70
|
-
desktop_tbt: 0,
|
|
71
|
-
mobile_cls: 0.088,
|
|
72
|
-
mobile_lcp: 3.2,
|
|
73
|
-
mobile_tbt: 0,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
timestamp: 1690118403000,
|
|
78
|
-
dimensions: {
|
|
79
|
-
desktop_overall_score: 55,
|
|
80
|
-
mobile_overall_score: 45,
|
|
81
|
-
desktop_cls: 0.088,
|
|
82
|
-
desktop_lcp: 3.2,
|
|
83
|
-
desktop_tbt: 0,
|
|
84
|
-
mobile_cls: 0.088,
|
|
85
|
-
mobile_lcp: 3.2,
|
|
86
|
-
mobile_tbt: 0,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
timestamp: 1690204803000,
|
|
91
|
-
dimensions: {
|
|
92
|
-
desktop_overall_score: 75,
|
|
93
|
-
mobile_overall_score: 52,
|
|
94
|
-
desktop_cls: 0.088,
|
|
95
|
-
desktop_lcp: 3.2,
|
|
96
|
-
desktop_tbt: 0,
|
|
97
|
-
mobile_cls: 0.088,
|
|
98
|
-
mobile_lcp: 3.2,
|
|
99
|
-
mobile_tbt: 0,
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
timestamp: 1690291203000,
|
|
104
|
-
dimensions: {
|
|
105
|
-
desktop_overall_score: 70,
|
|
106
|
-
mobile_overall_score: 50,
|
|
107
|
-
desktop_cls: 0.088,
|
|
108
|
-
desktop_lcp: 3.2,
|
|
109
|
-
desktop_tbt: 0,
|
|
110
|
-
mobile_cls: 0.088,
|
|
111
|
-
mobile_lcp: 3.2,
|
|
112
|
-
mobile_tbt: 0,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
timestamp: 1690377603000,
|
|
117
|
-
dimensions: {
|
|
118
|
-
desktop_overall_score: 75,
|
|
119
|
-
mobile_overall_score: 90,
|
|
120
|
-
desktop_cls: 0.088,
|
|
121
|
-
desktop_lcp: 3.2,
|
|
122
|
-
desktop_tbt: 0,
|
|
123
|
-
mobile_cls: 0.088,
|
|
124
|
-
mobile_lcp: 3.2,
|
|
125
|
-
mobile_tbt: 0,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
timestamp: 1690464003000,
|
|
130
|
-
dimensions: {
|
|
131
|
-
desktop_overall_score: 80,
|
|
132
|
-
mobile_overall_score: 60,
|
|
133
|
-
desktop_cls: 0.088,
|
|
134
|
-
desktop_lcp: 3.2,
|
|
135
|
-
desktop_tbt: 0,
|
|
136
|
-
mobile_cls: 0.088,
|
|
137
|
-
mobile_lcp: 3.2,
|
|
138
|
-
mobile_tbt: 0,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
timestamp: 1690550403000,
|
|
143
|
-
dimensions: {
|
|
144
|
-
desktop_overall_score: 85,
|
|
145
|
-
mobile_overall_score: 60,
|
|
146
|
-
desktop_cls: 0.088,
|
|
147
|
-
desktop_lcp: 3.2,
|
|
148
|
-
desktop_tbt: 0,
|
|
149
|
-
mobile_cls: 0.088,
|
|
150
|
-
mobile_lcp: 3.2,
|
|
151
|
-
mobile_tbt: 0,
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const meta: Meta< typeof BoostScoreGraph > = {
|
|
159
|
-
title: 'JS Packages/Components/Boost Score Graph',
|
|
160
|
-
component: BoostScoreGraph,
|
|
161
|
-
argTypes: {
|
|
162
|
-
startDate: { control: 'date' },
|
|
163
|
-
endDate: { control: 'date' },
|
|
164
|
-
title: { control: 'string', defaultValue: 'Title' },
|
|
165
|
-
isLoading: { control: 'boolean', defaultValue: false },
|
|
166
|
-
},
|
|
167
|
-
decorators: [
|
|
168
|
-
Story => (
|
|
169
|
-
<div style={ { width: '80%', maxWidth: '1320px', margin: '200px auto', fontSize: '16px' } }>
|
|
170
|
-
<Story />
|
|
171
|
-
</div>
|
|
172
|
-
),
|
|
173
|
-
],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const defaultValues = {
|
|
177
|
-
startDate: exampleRawResponse.data._meta.start,
|
|
178
|
-
endDate: exampleRawResponse.data._meta.end,
|
|
179
|
-
periods: exampleRawResponse.data.periods,
|
|
180
|
-
isLoading: false,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
export default meta;
|
|
184
|
-
|
|
185
|
-
const Template = args => <BoostScoreGraph { ...args } />;
|
|
186
|
-
export const _default = Template.bind( {} );
|
|
187
|
-
_default.args = defaultValues;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Tooltip } from '../tooltip';
|
|
2
|
-
import type { Meta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
const meta: Meta< typeof Tooltip > = {
|
|
5
|
-
title: 'JS Packages/Components/Boost Score Tooltip',
|
|
6
|
-
component: Tooltip,
|
|
7
|
-
argTypes: {
|
|
8
|
-
period: {
|
|
9
|
-
control: 'object',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
decorators: [
|
|
13
|
-
Story => (
|
|
14
|
-
<div style={ { width: '300px', margin: '200px auto', fontSize: '16px' } }>
|
|
15
|
-
<Story />
|
|
16
|
-
</div>
|
|
17
|
-
),
|
|
18
|
-
],
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default meta;
|
|
22
|
-
|
|
23
|
-
const Template = args => {
|
|
24
|
-
return <Tooltip { ...args } />;
|
|
25
|
-
};
|
|
26
|
-
export const _default = Template.bind( {} );
|
|
27
|
-
_default.args = {
|
|
28
|
-
period: {
|
|
29
|
-
timestamp: 1689772803000,
|
|
30
|
-
dimensions: {
|
|
31
|
-
desktop_overall_score: 75,
|
|
32
|
-
mobile_overall_score: 52,
|
|
33
|
-
desktop_cls: 0.088,
|
|
34
|
-
desktop_lcp: 3.2,
|
|
35
|
-
desktop_tbt: 0,
|
|
36
|
-
mobile_cls: 0.088,
|
|
37
|
-
mobile_lcp: 3.2,
|
|
38
|
-
mobile_tbt: 0,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, Canvas } from '@storybook/blocks';
|
|
2
|
-
import Button from '../index';
|
|
3
|
-
import * as ButtonStories from './index.stories';
|
|
4
|
-
|
|
5
|
-
<Meta of={ButtonStories} />
|
|
6
|
-
|
|
7
|
-
# Button
|
|
8
|
-
This is a component to create buttons and links across Jetpack.
|
|
9
|
-
|
|
10
|
-
## Props
|
|
11
|
-
|
|
12
|
-
Below is the current available props for `Button`.
|
|
13
|
-
|
|
14
|
-
### variant
|
|
15
|
-
|
|
16
|
-
It accepts 4 variant types: `primary`, `secondary`, `link`, `external-link`.
|
|
17
|
-
|
|
18
|
-
<Canvas withSource="open">
|
|
19
|
-
<Story id="js-packages-components-button--button-primary" />
|
|
20
|
-
<Story id="js-packages-components-button--button-secondary" />
|
|
21
|
-
<Story id="js-packages-components-button--button-link" />
|
|
22
|
-
<Story id="js-packages-components-button--button-external-link" />
|
|
23
|
-
</Canvas>
|
|
24
|
-
|
|
25
|
-
### size
|
|
26
|
-
|
|
27
|
-
It accepts 2 size types: `normal` and `small`.
|
|
28
|
-
|
|
29
|
-
<Canvas>
|
|
30
|
-
<Story id="js-packages-components-button--button-primary" />
|
|
31
|
-
<Button size="small">Jetpack Button</Button>
|
|
32
|
-
</Canvas>
|
|
33
|
-
|
|
34
|
-
### weight
|
|
35
|
-
|
|
36
|
-
It accepts 2 weight types: `bold` and `regular`. `bold` as default.
|
|
37
|
-
|
|
38
|
-
### icon
|
|
39
|
-
|
|
40
|
-
It accepts an SVG, Component or string.
|
|
41
|
-
|
|
42
|
-
You could use the ones from [@wordpress/icons](https://github.com/WordPress/gutenberg/blob/trunk/packages/icons/src/index.js).
|
|
43
|
-
|
|
44
|
-
<Canvas withSource="open">
|
|
45
|
-
<Story id="js-packages-components-button--icon" />
|
|
46
|
-
</Canvas>
|
|
47
|
-
|
|
48
|
-
### iconSize
|
|
49
|
-
|
|
50
|
-
It defines the size of the icon, it needs to be a number.
|
|
51
|
-
|
|
52
|
-
### disabled
|
|
53
|
-
|
|
54
|
-
Disables the button removing cursor-pointer effect.
|
|
55
|
-
|
|
56
|
-
<Canvas withSource="open">
|
|
57
|
-
<Story id="js-packages-components-button--disabled" />
|
|
58
|
-
</Canvas>
|
|
59
|
-
|
|
60
|
-
### isDestructive
|
|
61
|
-
|
|
62
|
-
Set button on destructive state, which changes the color to red.
|
|
63
|
-
|
|
64
|
-
<Canvas withSource="open">
|
|
65
|
-
<Story id="js-packages-components-button--destructive" />
|
|
66
|
-
</Canvas>
|
|
67
|
-
|
|
68
|
-
### isLoading
|
|
69
|
-
|
|
70
|
-
Set button on loading state, which applies a centered spinner.
|
|
71
|
-
|
|
72
|
-
<Canvas withSource="open">
|
|
73
|
-
<Story id="js-packages-components-button--loading" />
|
|
74
|
-
</Canvas>
|
|
75
|
-
|
|
76
|
-
### text
|
|
77
|
-
|
|
78
|
-
It applies a text before children, it could be used together or on its own.
|
|
79
|
-
|
|
80
|
-
<Canvas>
|
|
81
|
-
<Button text="My Text">My Children</Button>
|
|
82
|
-
</Canvas>
|
|
83
|
-
|
|
84
|
-
### fullWidth
|
|
85
|
-
|
|
86
|
-
Stretches the button to take up the full width of the container.
|
|
87
|
-
|
|
88
|
-
<Canvas withSource="open">
|
|
89
|
-
<Story id="js-packages-components-button--full-width" />
|
|
90
|
-
</Canvas>
|
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
import * as allIcons from '@wordpress/icons';
|
|
2
|
-
import Col from '../../layout/col';
|
|
3
|
-
import Container from '../../layout/container';
|
|
4
|
-
import Text, { H3 } from '../../text';
|
|
5
|
-
import Button from '../index';
|
|
6
|
-
import styles from './style.module.scss';
|
|
7
|
-
|
|
8
|
-
const { Icon: WPIcon, ...icons } = allIcons;
|
|
9
|
-
const { check, cloud } = icons;
|
|
10
|
-
|
|
11
|
-
const disableVariant = {
|
|
12
|
-
variant: {
|
|
13
|
-
table: {
|
|
14
|
-
disable: true,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const disableDisabled = {
|
|
20
|
-
disabled: {
|
|
21
|
-
table: {
|
|
22
|
-
disable: true,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const disableIsDestructive = {
|
|
28
|
-
isDestructive: {
|
|
29
|
-
table: {
|
|
30
|
-
disable: true,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const disableIsLoading = {
|
|
36
|
-
isLoading: {
|
|
37
|
-
table: {
|
|
38
|
-
disable: true,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const disableIcon = {
|
|
44
|
-
icon: {
|
|
45
|
-
table: {
|
|
46
|
-
disable: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const disableClassName = {
|
|
52
|
-
className: {
|
|
53
|
-
table: {
|
|
54
|
-
disable: true,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const disableFullWidth = {
|
|
60
|
-
fullWidth: {
|
|
61
|
-
table: {
|
|
62
|
-
disable: true,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default {
|
|
68
|
-
title: 'JS Packages/Components/Button',
|
|
69
|
-
component: Button,
|
|
70
|
-
argTypes: {
|
|
71
|
-
variant: {
|
|
72
|
-
control: {
|
|
73
|
-
type: 'select',
|
|
74
|
-
},
|
|
75
|
-
options: [ 'primary', 'secondary', 'link', 'tertiary' ],
|
|
76
|
-
},
|
|
77
|
-
size: {
|
|
78
|
-
control: {
|
|
79
|
-
type: 'select',
|
|
80
|
-
},
|
|
81
|
-
options: [ 'normal', 'small' ],
|
|
82
|
-
},
|
|
83
|
-
weight: {
|
|
84
|
-
control: {
|
|
85
|
-
type: 'select',
|
|
86
|
-
},
|
|
87
|
-
options: [ 'bold', 'regular' ],
|
|
88
|
-
},
|
|
89
|
-
icon: {
|
|
90
|
-
control: {
|
|
91
|
-
type: 'select',
|
|
92
|
-
},
|
|
93
|
-
options: [ 'none', ...Object.keys( icons ) ],
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
parameters: {
|
|
97
|
-
backgrounds: {
|
|
98
|
-
default: 'Jetpack Dashboard',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const DefaultTemplate = args => {
|
|
104
|
-
const icon = args?.icon && args?.icon !== 'none' ? <WPIcon icon={ icons[ args.icon ] } /> : null;
|
|
105
|
-
return <Button { ...args } icon={ icon } />;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const _default = DefaultTemplate.bind( {} );
|
|
109
|
-
_default.args = {
|
|
110
|
-
variant: 'primary',
|
|
111
|
-
size: 'normal',
|
|
112
|
-
weight: 'bold',
|
|
113
|
-
icon: 'cloud',
|
|
114
|
-
isExternalLink: false,
|
|
115
|
-
isLoading: false,
|
|
116
|
-
disabled: false,
|
|
117
|
-
isDestructive: false,
|
|
118
|
-
fullWidth: false,
|
|
119
|
-
children: 'Once upon a time… a button story',
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const Template = args => <Button { ...args } />;
|
|
123
|
-
|
|
124
|
-
export const ButtonPrimary = Template.bind( {} );
|
|
125
|
-
ButtonPrimary.argTypes = {
|
|
126
|
-
...disableVariant,
|
|
127
|
-
...disableDisabled,
|
|
128
|
-
...disableIcon,
|
|
129
|
-
...disableIsLoading,
|
|
130
|
-
...disableIsDestructive,
|
|
131
|
-
...disableFullWidth,
|
|
132
|
-
};
|
|
133
|
-
ButtonPrimary.args = {
|
|
134
|
-
size: 'normal',
|
|
135
|
-
children: 'Jetpack Button',
|
|
136
|
-
variant: 'primary',
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export const ButtonSecondary = Template.bind( {} );
|
|
140
|
-
ButtonSecondary.argTypes = {
|
|
141
|
-
...disableVariant,
|
|
142
|
-
...disableDisabled,
|
|
143
|
-
...disableIcon,
|
|
144
|
-
...disableIsLoading,
|
|
145
|
-
...disableIsDestructive,
|
|
146
|
-
...disableClassName,
|
|
147
|
-
...disableFullWidth,
|
|
148
|
-
};
|
|
149
|
-
ButtonSecondary.args = {
|
|
150
|
-
size: 'normal',
|
|
151
|
-
children: 'Jetpack Button',
|
|
152
|
-
variant: 'secondary',
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const ButtonLink = Template.bind( {} );
|
|
156
|
-
ButtonLink.argTypes = {
|
|
157
|
-
...disableVariant,
|
|
158
|
-
...disableDisabled,
|
|
159
|
-
...disableIcon,
|
|
160
|
-
...disableIsLoading,
|
|
161
|
-
...disableIsDestructive,
|
|
162
|
-
...disableClassName,
|
|
163
|
-
...disableFullWidth,
|
|
164
|
-
};
|
|
165
|
-
ButtonLink.args = {
|
|
166
|
-
size: 'normal',
|
|
167
|
-
children: 'Jetpack Button',
|
|
168
|
-
variant: 'link',
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
export const ButtonExternalLink = Template.bind( {} );
|
|
172
|
-
ButtonExternalLink.argTypes = {
|
|
173
|
-
...disableVariant,
|
|
174
|
-
...disableDisabled,
|
|
175
|
-
...disableIcon,
|
|
176
|
-
...disableIsLoading,
|
|
177
|
-
...disableIsDestructive,
|
|
178
|
-
...disableClassName,
|
|
179
|
-
...disableFullWidth,
|
|
180
|
-
};
|
|
181
|
-
ButtonExternalLink.args = {
|
|
182
|
-
size: 'normal',
|
|
183
|
-
children: 'Jetpack Button',
|
|
184
|
-
variant: 'external-link',
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export const Icon = Template.bind( {} );
|
|
188
|
-
Icon.argTypes = {
|
|
189
|
-
...disableIcon,
|
|
190
|
-
...disableDisabled,
|
|
191
|
-
...disableIsLoading,
|
|
192
|
-
...disableIsDestructive,
|
|
193
|
-
...disableClassName,
|
|
194
|
-
...disableFullWidth,
|
|
195
|
-
};
|
|
196
|
-
Icon.args = {
|
|
197
|
-
size: 'normal',
|
|
198
|
-
children: 'Jetpack Button',
|
|
199
|
-
icon: <WPIcon icon={ check } />,
|
|
200
|
-
variant: 'primary',
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export const Disabled = Template.bind( {} );
|
|
204
|
-
Disabled.argTypes = {
|
|
205
|
-
...disableDisabled,
|
|
206
|
-
...disableIsDestructive,
|
|
207
|
-
...disableIsLoading,
|
|
208
|
-
...disableClassName,
|
|
209
|
-
...disableFullWidth,
|
|
210
|
-
...disableIcon,
|
|
211
|
-
};
|
|
212
|
-
Disabled.args = {
|
|
213
|
-
size: 'normal',
|
|
214
|
-
children: 'Jetpack Button',
|
|
215
|
-
variant: 'primary',
|
|
216
|
-
disabled: true,
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
export const Destructive = Template.bind( {} );
|
|
220
|
-
Destructive.argTypes = {
|
|
221
|
-
...disableIsDestructive,
|
|
222
|
-
...disableIsLoading,
|
|
223
|
-
...disableDisabled,
|
|
224
|
-
...disableClassName,
|
|
225
|
-
...disableFullWidth,
|
|
226
|
-
...disableIcon,
|
|
227
|
-
};
|
|
228
|
-
Destructive.args = {
|
|
229
|
-
size: 'normal',
|
|
230
|
-
children: 'Jetpack Button',
|
|
231
|
-
variant: 'primary',
|
|
232
|
-
isDestructive: true,
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
export const Loading = Template.bind( {} );
|
|
236
|
-
Loading.argTypes = {
|
|
237
|
-
...disableIsDestructive,
|
|
238
|
-
...disableIsLoading,
|
|
239
|
-
...disableDisabled,
|
|
240
|
-
...disableClassName,
|
|
241
|
-
...disableFullWidth,
|
|
242
|
-
...disableIcon,
|
|
243
|
-
};
|
|
244
|
-
Loading.args = {
|
|
245
|
-
size: 'normal',
|
|
246
|
-
children: 'Jetpack Button',
|
|
247
|
-
variant: 'primary',
|
|
248
|
-
isLoading: true,
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
export const FullWidth = Template.bind( {} );
|
|
252
|
-
FullWidth.argTypes = {
|
|
253
|
-
...disableIsDestructive,
|
|
254
|
-
...disableIsLoading,
|
|
255
|
-
...disableDisabled,
|
|
256
|
-
...disableClassName,
|
|
257
|
-
...disableIcon,
|
|
258
|
-
};
|
|
259
|
-
FullWidth.args = {
|
|
260
|
-
size: 'normal',
|
|
261
|
-
children: 'Jetpack Button',
|
|
262
|
-
variant: 'primary',
|
|
263
|
-
fullWidth: true,
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export const VariantsAndProps = () => {
|
|
267
|
-
const variants = [ 'primary', 'secondary', 'link' ];
|
|
268
|
-
return (
|
|
269
|
-
<>
|
|
270
|
-
<Container>
|
|
271
|
-
<Col>
|
|
272
|
-
<H3>Variants & Props</H3>
|
|
273
|
-
</Col>
|
|
274
|
-
<Col>
|
|
275
|
-
<Text mb={ 3 }>
|
|
276
|
-
The following shows how the properties modify the appearance and/or behavior of the
|
|
277
|
-
button, in the different variants. Keep in mind that you cannot combine the variants but
|
|
278
|
-
you can combine the props. Use the { '' }
|
|
279
|
-
<a href="./?path=/story/js-packages-components-button--default">default story</a> to
|
|
280
|
-
play with the combinations.
|
|
281
|
-
</Text>
|
|
282
|
-
</Col>
|
|
283
|
-
</Container>
|
|
284
|
-
<Container className={ styles.container } horizontalGap={ 0 }>
|
|
285
|
-
<Col
|
|
286
|
-
className={ `${ styles[ 'row-instance' ] } ${ styles.header }` }
|
|
287
|
-
sm={ 4 }
|
|
288
|
-
md={ 2 }
|
|
289
|
-
lg={ 3 }
|
|
290
|
-
>
|
|
291
|
-
<Text size="body-extra-small">props / variants</Text>
|
|
292
|
-
</Col>
|
|
293
|
-
|
|
294
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
295
|
-
<Text size="body-extra-small" className={ styles.header }>
|
|
296
|
-
Primary
|
|
297
|
-
</Text>
|
|
298
|
-
</Col>
|
|
299
|
-
|
|
300
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
301
|
-
<Text size="body-extra-small" className={ styles.header }>
|
|
302
|
-
Secondary
|
|
303
|
-
</Text>
|
|
304
|
-
</Col>
|
|
305
|
-
|
|
306
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
307
|
-
<Text size="body-extra-small" className={ styles.header }>
|
|
308
|
-
Link
|
|
309
|
-
</Text>
|
|
310
|
-
</Col>
|
|
311
|
-
|
|
312
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
313
|
-
<Text size="body-extra-small">no props</Text>
|
|
314
|
-
</Col>
|
|
315
|
-
{ variants.map( variant => (
|
|
316
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
317
|
-
<Button { ...ButtonPrimary.args } variant={ variant } />
|
|
318
|
-
</Col>
|
|
319
|
-
) ) }
|
|
320
|
-
|
|
321
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
322
|
-
<Text size="body-extra-small">size: small</Text>
|
|
323
|
-
</Col>
|
|
324
|
-
{ variants.map( variant => (
|
|
325
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
326
|
-
<Button { ...ButtonPrimary.args } variant={ variant } size="small" />
|
|
327
|
-
</Col>
|
|
328
|
-
) ) }
|
|
329
|
-
|
|
330
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
331
|
-
<Text size="body-extra-small">weight: regular</Text>
|
|
332
|
-
</Col>
|
|
333
|
-
{ variants.map( variant => (
|
|
334
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
335
|
-
<Button { ...ButtonPrimary.args } variant={ variant } weight="regular" />
|
|
336
|
-
</Col>
|
|
337
|
-
) ) }
|
|
338
|
-
|
|
339
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
340
|
-
<Text size="body-extra-small">icon (cloud)</Text>
|
|
341
|
-
</Col>
|
|
342
|
-
{ variants.map( variant => (
|
|
343
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
344
|
-
<Button
|
|
345
|
-
{ ...ButtonPrimary.args }
|
|
346
|
-
variant={ variant }
|
|
347
|
-
icon={ <WPIcon icon={ cloud } /> }
|
|
348
|
-
/>
|
|
349
|
-
</Col>
|
|
350
|
-
) ) }
|
|
351
|
-
|
|
352
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
353
|
-
<Text size="body-extra-small">disabled</Text>
|
|
354
|
-
</Col>
|
|
355
|
-
{ variants.map( variant => (
|
|
356
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
357
|
-
<Button { ...ButtonPrimary.args } variant={ variant } disabled />
|
|
358
|
-
</Col>
|
|
359
|
-
) ) }
|
|
360
|
-
|
|
361
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
362
|
-
<Text size="body-extra-small">isDestructive</Text>
|
|
363
|
-
</Col>
|
|
364
|
-
{ variants.map( variant => (
|
|
365
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
366
|
-
<Button { ...ButtonPrimary.args } variant={ variant } isDestructive />
|
|
367
|
-
</Col>
|
|
368
|
-
) ) }
|
|
369
|
-
|
|
370
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
371
|
-
<Text size="body-extra-small">isExternalLink</Text>
|
|
372
|
-
</Col>
|
|
373
|
-
{ variants.map( variant => (
|
|
374
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
375
|
-
<Button { ...ButtonPrimary.args } variant={ variant } isExternalLink />
|
|
376
|
-
</Col>
|
|
377
|
-
) ) }
|
|
378
|
-
|
|
379
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
380
|
-
<Text size="body-extra-small">isLoading</Text>
|
|
381
|
-
</Col>
|
|
382
|
-
{ variants.map( variant => (
|
|
383
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
384
|
-
<Button { ...ButtonPrimary.args } variant={ variant } isLoading />
|
|
385
|
-
</Col>
|
|
386
|
-
) ) }
|
|
387
|
-
|
|
388
|
-
<Col className={ styles[ 'row-instance' ] } sm={ 4 } md={ 2 } lg={ 3 }>
|
|
389
|
-
<Text size="body-extra-small">fullWidth</Text>
|
|
390
|
-
</Col>
|
|
391
|
-
{ variants.map( variant => (
|
|
392
|
-
<Col sm={ 4 } md={ 2 } lg={ 3 }>
|
|
393
|
-
<Button { ...ButtonPrimary.args } variant={ variant } fullWidth />
|
|
394
|
-
</Col>
|
|
395
|
-
) ) }
|
|
396
|
-
</Container>
|
|
397
|
-
</>
|
|
398
|
-
);
|
|
399
|
-
};
|
|
400
|
-
VariantsAndProps.storyName = 'Variants & Props';
|