@automattic/jetpack-components 2.3.0 → 3.0.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/build/components/admin-page/style.module.scss +3 -3
- package/build/index.d.ts +0 -12
- package/build/index.js +0 -12
- package/components/admin-page/style.module.scss +3 -3
- package/index.ts +0 -12
- package/package.json +16 -16
- package/build/components/alert/index.d.ts +0 -23
- package/build/components/alert/index.js +0 -33
- package/build/components/alert/style.module.scss +0 -47
- package/build/components/chip/index.d.ts +0 -17
- package/build/components/chip/index.js +0 -18
- package/build/components/chip/style.module.scss +0 -14
- package/build/components/contextual-upgrade-trigger/index.d.ts +0 -19
- package/build/components/contextual-upgrade-trigger/index.js +0 -27
- package/build/components/contextual-upgrade-trigger/style.module.scss +0 -77
- package/build/components/contextual-upgrade-trigger/types.d.ts +0 -9
- package/build/components/contextual-upgrade-trigger/types.js +0 -1
- package/build/components/dialog/index.d.ts +0 -20
- package/build/components/dialog/index.js +0 -32
- package/build/components/dialog/style.module.scss +0 -31
- package/build/components/jetpack-protect-logo/index.d.ts +0 -4
- package/build/components/jetpack-protect-logo/index.js +0 -10
- package/build/components/jetpack-protect-logo/types.d.ts +0 -7
- package/build/components/jetpack-protect-logo/types.js +0 -1
- package/build/components/jetpack-search-logo/index.d.ts +0 -4
- package/build/components/jetpack-search-logo/index.js +0 -7
- package/build/components/jetpack-search-logo/types.d.ts +0 -7
- package/build/components/jetpack-search-logo/types.js +0 -1
- package/build/components/jetpack-videopress-logo/index.d.ts +0 -4
- package/build/components/jetpack-videopress-logo/index.js +0 -8
- package/build/components/jetpack-videopress-logo/types.d.ts +0 -6
- package/build/components/jetpack-videopress-logo/types.js +0 -1
- package/build/components/product-offer/icons-card.d.ts +0 -10
- package/build/components/product-offer/icons-card.js +0 -23
- package/build/components/product-offer/index.d.ts +0 -11
- package/build/components/product-offer/index.js +0 -31
- package/build/components/product-offer/product-offer-header.d.ts +0 -9
- package/build/components/product-offer/product-offer-header.js +0 -14
- package/build/components/product-offer/style.module.scss +0 -93
- package/build/components/product-offer/types.d.ts +0 -102
- package/build/components/product-offer/types.js +0 -1
- package/build/components/radio-control/index.d.ts +0 -24
- package/build/components/radio-control/index.js +0 -7
- package/build/components/split-button/index.d.ts +0 -4
- package/build/components/split-button/index.js +0 -14
- package/build/components/split-button/style.module.scss +0 -26
- package/build/components/split-button/types.d.ts +0 -5
- package/build/components/split-button/types.js +0 -1
- package/build/components/status/index.d.ts +0 -19
- package/build/components/status/index.js +0 -29
- package/build/components/status/style.module.scss +0 -82
- package/build/components/toggle-control/index.d.ts +0 -23
- package/build/components/toggle-control/index.js +0 -21
- package/build/components/toggle-control/styles.module.scss +0 -24
- package/components/alert/index.tsx +0 -60
- package/components/alert/style.module.scss +0 -47
- package/components/chip/README.md +0 -21
- package/components/chip/index.tsx +0 -25
- package/components/chip/style.module.scss +0 -14
- package/components/contextual-upgrade-trigger/README.md +0 -81
- package/components/contextual-upgrade-trigger/index.tsx +0 -59
- package/components/contextual-upgrade-trigger/style.module.scss +0 -77
- package/components/contextual-upgrade-trigger/types.ts +0 -9
- package/components/dialog/index.tsx +0 -70
- package/components/dialog/style.module.scss +0 -31
- package/components/jetpack-protect-logo/README.md +0 -20
- package/components/jetpack-protect-logo/index.tsx +0 -60
- package/components/jetpack-protect-logo/types.ts +0 -7
- package/components/jetpack-search-logo/README.md +0 -20
- package/components/jetpack-search-logo/index.tsx +0 -93
- package/components/jetpack-search-logo/types.ts +0 -7
- package/components/jetpack-videopress-logo/README.md +0 -19
- package/components/jetpack-videopress-logo/index.tsx +0 -95
- package/components/jetpack-videopress-logo/types.tsx +0 -6
- package/components/product-offer/icons-card.tsx +0 -48
- package/components/product-offer/index.tsx +0 -115
- package/components/product-offer/product-offer-header.tsx +0 -23
- package/components/product-offer/style.module.scss +0 -93
- package/components/product-offer/types.ts +0 -126
- package/components/radio-control/README.md +0 -5
- package/components/radio-control/index.tsx +0 -55
- package/components/split-button/index.tsx +0 -48
- package/components/split-button/style.module.scss +0 -26
- package/components/split-button/types.ts +0 -12
- package/components/status/README.md +0 -42
- package/components/status/index.tsx +0 -52
- package/components/status/style.module.scss +0 -82
- package/components/toggle-control/README.md +0 -5
- package/components/toggle-control/index.tsx +0 -80
- package/components/toggle-control/styles.module.scss +0 -24
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
.wrapper {
|
|
2
|
-
padding: calc(var(--spacing-base) * 8);
|
|
3
|
-
position: relative;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.is-card {
|
|
7
|
-
background-color: var(--jp-white);
|
|
8
|
-
border: 1px solid var(--jp-gray);
|
|
9
|
-
border-radius: var(--jp-border-radius);
|
|
10
|
-
box-shadow: 0 2px 6px var(--product-card-shadow), 0 1px 2px var(--product-card-shadow);
|
|
11
|
-
|
|
12
|
-
.card-header {
|
|
13
|
-
border-radius: var(--jp-border-radius) var(--jp-border-radius) 0 0;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.card-header {
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: center;
|
|
20
|
-
background: var(--jp-black);
|
|
21
|
-
color: var(--jp-white);
|
|
22
|
-
padding: calc(var(--spacing-base) / 2) var(--spacing-base);
|
|
23
|
-
line-height: calc(var(--spacing-base) * 3);
|
|
24
|
-
position: absolute;
|
|
25
|
-
top: 0;
|
|
26
|
-
left: 0;
|
|
27
|
-
width: 100%;
|
|
28
|
-
box-sizing: border-box;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.card-container {
|
|
32
|
-
height: 100%;
|
|
33
|
-
display: flex;
|
|
34
|
-
flex-direction: column;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.product-bundle-icon {
|
|
38
|
-
fill: var(--jp-white);
|
|
39
|
-
margin-right: var(--spacing-base);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.product-bundle-icons,
|
|
43
|
-
.product-icon {
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
margin-bottom: calc(var(--spacing-base) * 4);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.plus-icon {
|
|
50
|
-
fill: rgb(140, 143, 148);
|
|
51
|
-
height: 24px;
|
|
52
|
-
line-height: 24px;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.features {
|
|
56
|
-
margin: 0;
|
|
57
|
-
padding: 0;
|
|
58
|
-
flex-grow: 1;
|
|
59
|
-
margin-bottom: calc(var(--spacing-base) * 2);
|
|
60
|
-
|
|
61
|
-
li {
|
|
62
|
-
list-style: none;
|
|
63
|
-
display: flex;
|
|
64
|
-
align-items: flex-start;
|
|
65
|
-
margin-bottom: var(--spacing-base);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.check {
|
|
69
|
-
fill: var(--jp-green-primary);
|
|
70
|
-
margin-right: var(--spacing-base);
|
|
71
|
-
flex-shrink: 0;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.product-has-required-plan {
|
|
76
|
-
display: flex;
|
|
77
|
-
justify-content: center;
|
|
78
|
-
align-items: center;
|
|
79
|
-
|
|
80
|
-
svg {
|
|
81
|
-
margin-right: var(--spacing-base);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.add-button {
|
|
86
|
-
width: 100%;
|
|
87
|
-
justify-content: center;
|
|
88
|
-
|
|
89
|
-
&:global(.is-primary):disabled {
|
|
90
|
-
opacity: 1;
|
|
91
|
-
background-color: var(--jp-black);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { ProductPriceProps } from '../product-price/types.ts';
|
|
2
|
-
import type { JetpackIconSlug } from '../icons/index.tsx';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
export type ProductOfferProps = {
|
|
6
|
-
/**
|
|
7
|
-
* Product slug.
|
|
8
|
-
*/
|
|
9
|
-
slug?: JetpackIconSlug;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Product name.
|
|
13
|
-
*/
|
|
14
|
-
name?: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Custom Icon slug.
|
|
18
|
-
*/
|
|
19
|
-
icon?: JetpackIconSlug;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Product title.
|
|
23
|
-
*/
|
|
24
|
-
title?: string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Product sub-title.
|
|
28
|
-
*/
|
|
29
|
-
subTitle?: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Product description.
|
|
33
|
-
*/
|
|
34
|
-
description?: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Features list of the product.
|
|
38
|
-
*/
|
|
39
|
-
features?: Array< string >;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Add the styles to look like a card.
|
|
43
|
-
*/
|
|
44
|
-
isCard?: boolean;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Whether or not the product is a bundle.
|
|
48
|
-
*/
|
|
49
|
-
isBundle?: boolean;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* List of supported products (for bundles).
|
|
53
|
-
*/
|
|
54
|
-
supportedProducts?: Array< JetpackIconSlug >;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Product Pricing object.
|
|
58
|
-
*/
|
|
59
|
-
pricing?: Pricing;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Whether or not the product has the required plan.
|
|
63
|
-
*/
|
|
64
|
-
hasRequiredPlan?: boolean;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Applies the isLoading style to the component.
|
|
68
|
-
*/
|
|
69
|
-
isLoading?: boolean;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* A className to be concat with default ones.
|
|
73
|
-
*/
|
|
74
|
-
className?: string;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Callback function to be executed on click on Add button.
|
|
78
|
-
*/
|
|
79
|
-
onAdd?: VoidFunction;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The checkout URL to add/buy the product.
|
|
83
|
-
*/
|
|
84
|
-
addProductUrl?: string;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The text to be displayed on the Add button.
|
|
88
|
-
*/
|
|
89
|
-
buttonText?: string;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Content displayed below the Add button.
|
|
93
|
-
*/
|
|
94
|
-
buttonDisclaimer?: ReactNode;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Error message.
|
|
98
|
-
*/
|
|
99
|
-
error?: string;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export type Pricing = Pick< ProductPriceProps, 'currency' | 'offPrice' | 'price' > & {
|
|
103
|
-
/**
|
|
104
|
-
* Whether it is a free product
|
|
105
|
-
*/
|
|
106
|
-
isFree?: boolean;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export type IconsCardProps = {
|
|
110
|
-
/**
|
|
111
|
-
* Custom icon slug.
|
|
112
|
-
*/
|
|
113
|
-
icon: JetpackIconSlug;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* List of supported products.
|
|
117
|
-
*/
|
|
118
|
-
products: Array< JetpackIconSlug >;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Icon size.
|
|
122
|
-
*/
|
|
123
|
-
size: number;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export type ProductOfferHeaderProps = Pick< ProductOfferProps, 'title' >;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# RadioControl
|
|
2
|
-
|
|
3
|
-
A wrapper component for applying Jetpack Emerald styles to the [RadioControl](https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/radio-control) component from `@wordpress/components`.
|
|
4
|
-
|
|
5
|
-
The documentation for the base `RadioControl` component can be found via the [Gutenberg Handbook](https://developer.wordpress.org/block-editor/reference-guides/components/radio-control/).
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { RadioControl as WPRadioControl } from '@wordpress/components';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import type { FC, ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
export interface RadioControlProps {
|
|
6
|
-
/** The current value. */
|
|
7
|
-
selected: string;
|
|
8
|
-
|
|
9
|
-
/** Custom class name to append to the component. */
|
|
10
|
-
className?: string;
|
|
11
|
-
|
|
12
|
-
/** Whether or not the radio control is currently disabled. */
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
|
|
15
|
-
/** Additional information to display below the radio control. */
|
|
16
|
-
help?: ReactNode;
|
|
17
|
-
|
|
18
|
-
/** The label for the radio control. */
|
|
19
|
-
label?: ReactNode;
|
|
20
|
-
|
|
21
|
-
/** If true, the label will only be visible to screen readers. */
|
|
22
|
-
hideLabelFromVision?: boolean;
|
|
23
|
-
|
|
24
|
-
/** A list of options to show. */
|
|
25
|
-
options: { label: string; value: string }[];
|
|
26
|
-
|
|
27
|
-
/** A callback function invoked when the value is changed. */
|
|
28
|
-
onChange: ( value: string ) => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const RadioControl: FC< RadioControlProps > = ( {
|
|
32
|
-
selected,
|
|
33
|
-
className,
|
|
34
|
-
disabled,
|
|
35
|
-
help,
|
|
36
|
-
label,
|
|
37
|
-
hideLabelFromVision,
|
|
38
|
-
options,
|
|
39
|
-
onChange,
|
|
40
|
-
} ) => {
|
|
41
|
-
return (
|
|
42
|
-
<WPRadioControl
|
|
43
|
-
selected={ selected }
|
|
44
|
-
className={ clsx( 'radio', className ) }
|
|
45
|
-
disabled={ disabled }
|
|
46
|
-
help={ help }
|
|
47
|
-
label={ label }
|
|
48
|
-
hideLabelFromVision={ hideLabelFromVision }
|
|
49
|
-
options={ options }
|
|
50
|
-
onChange={ onChange }
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default RadioControl;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Button, Flex, DropdownMenu } from '@wordpress/components';
|
|
2
|
-
import styles from './style.module.scss';
|
|
3
|
-
import { SplitButtonProps } from './types.ts';
|
|
4
|
-
import type { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
const DownIcon = () => (
|
|
7
|
-
<svg width="15" height="9" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="10 9 4 7">
|
|
8
|
-
<path
|
|
9
|
-
fillRule="evenodd"
|
|
10
|
-
clipRule="evenodd"
|
|
11
|
-
d="m18.004 10.555-6.005 5.459-6.004-5.459 1.009-1.11 4.995 4.542 4.996-4.542 1.009 1.11Z"
|
|
12
|
-
/>
|
|
13
|
-
</svg>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const SplitButton: FC< SplitButtonProps > = ( {
|
|
17
|
-
variant,
|
|
18
|
-
controls,
|
|
19
|
-
popoverProps,
|
|
20
|
-
toggleProps,
|
|
21
|
-
label,
|
|
22
|
-
...buttonProps
|
|
23
|
-
} ) => {
|
|
24
|
-
// Cast to work around WPButton's strict union type
|
|
25
|
-
const wpButtonProps = {
|
|
26
|
-
variant,
|
|
27
|
-
className: styles.button,
|
|
28
|
-
...buttonProps,
|
|
29
|
-
} as React.ComponentProps< typeof Button >;
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Flex className={ styles[ 'split-button' ] }>
|
|
33
|
-
<div role="group" className="components-button-group">
|
|
34
|
-
<Button { ...wpButtonProps } />
|
|
35
|
-
<DropdownMenu
|
|
36
|
-
toggleProps={ { variant, className: styles.button, ...toggleProps } }
|
|
37
|
-
popoverProps={ { noArrow: false, ...popoverProps } }
|
|
38
|
-
icon={ <DownIcon /> }
|
|
39
|
-
disableOpenOnArrowDown={ true }
|
|
40
|
-
controls={ controls }
|
|
41
|
-
label={ label }
|
|
42
|
-
/>
|
|
43
|
-
</div>
|
|
44
|
-
</Flex>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default SplitButton;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
.split-button {
|
|
2
|
-
--actions-size: 28px;
|
|
3
|
-
display: flex;
|
|
4
|
-
height: var(--actions-size);
|
|
5
|
-
border-radius: var(--jp-border-radius);
|
|
6
|
-
|
|
7
|
-
:global(.components-button-group) {
|
|
8
|
-
display: flex;
|
|
9
|
-
height: 100%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
> .button:first-child {
|
|
13
|
-
border-radius: var(--jp-border-radius) 0 0 var(--jp-border-radius);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
> :global(.components-dropdown) > .button {
|
|
17
|
-
border-radius: 0 var(--jp-border-radius) var(--jp-border-radius) 0;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.button {
|
|
22
|
-
font-size: var(--font-body-extra-small);
|
|
23
|
-
border-radius: var(--jp-border-radius);
|
|
24
|
-
height: var(--actions-size);
|
|
25
|
-
line-height: var(--actions-size);
|
|
26
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Button, DropdownMenu } from '@wordpress/components';
|
|
2
|
-
import type { ComponentProps } from 'react';
|
|
3
|
-
|
|
4
|
-
type AllowedDropdownMenuProps = Pick<
|
|
5
|
-
ComponentProps< typeof DropdownMenu >,
|
|
6
|
-
'controls' | 'popoverProps' | 'toggleProps' | 'label'
|
|
7
|
-
>;
|
|
8
|
-
|
|
9
|
-
export type SplitButtonProps = Omit< ComponentProps< typeof Button >, 'controls' > &
|
|
10
|
-
AllowedDropdownMenuProps &
|
|
11
|
-
// make `controls` prop required
|
|
12
|
-
Required< Pick< AllowedDropdownMenuProps, 'controls' > >;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
= Status
|
|
2
|
-
|
|
3
|
-
A simple component to display a status indicator.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```jsx
|
|
8
|
-
import { Status } from '@automattic/jetpack-components';
|
|
9
|
-
|
|
10
|
-
function MyComponent() {
|
|
11
|
-
return (
|
|
12
|
-
<>
|
|
13
|
-
{ /* Default status is "inactive". */}
|
|
14
|
-
<Status />
|
|
15
|
-
|
|
16
|
-
{ /* You can also pass a status prop to display a different status. */}
|
|
17
|
-
<Status status="active" />
|
|
18
|
-
|
|
19
|
-
{ /* You can also pass a label prop to display a label beside the status indicator. */}
|
|
20
|
-
<Status status="error" label="Connection Error" />
|
|
21
|
-
</>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Props
|
|
27
|
-
|
|
28
|
-
### status
|
|
29
|
-
|
|
30
|
-
Optional. The status to display. It can be one of the following:
|
|
31
|
-
|
|
32
|
-
- `active`
|
|
33
|
-
- `inactive`
|
|
34
|
-
- `error`
|
|
35
|
-
|
|
36
|
-
Defaults to `inactive`.
|
|
37
|
-
|
|
38
|
-
### label
|
|
39
|
-
|
|
40
|
-
Optional. The label to display beside the status indicator.
|
|
41
|
-
|
|
42
|
-
If none is provided, the name of the status will be used by default (i.e. "Active"). Pass an empty string to hide the label.
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import Text from '../text/index.tsx';
|
|
4
|
-
import styles from './style.module.scss';
|
|
5
|
-
import type { JSX } from 'react';
|
|
6
|
-
|
|
7
|
-
export interface StatusProps {
|
|
8
|
-
status?: 'active' | 'error' | 'inactive' | 'action' | 'initializing';
|
|
9
|
-
label?: string;
|
|
10
|
-
className?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Status component.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated Inline the equivalent JSX using `Text` from `@wordpress/ui` and a small color-coded indicator span. The wrapper renders a flex container at `body-sm` size with `font-weight: 600` and a `0.666em` round indicator coloured by status using WPDS design tokens (`var(--wpds-color-foreground-content-success-weak)` for `active`, `--wpds-color-foreground-content-error-weak` for `error`, `--wpds-color-foreground-content-neutral-weak` for `inactive`, `--wpds-color-foreground-content-warning-weak` for `action`, `--wpds-color-foreground-content-info-weak` for `initializing`). Include a fallback hex for surfaces that don't load `@wordpress/theme/design-tokens.css` (e.g. the legacy Jetpack settings dashboard).
|
|
17
|
-
*
|
|
18
|
-
* @param {StatusProps} props - The component properties.
|
|
19
|
-
* @param {string} props.className - Optional className forwarded to the outer element.
|
|
20
|
-
* @param {string} props.label - Status label. Defaults to a status-derived string.
|
|
21
|
-
* @param {string} props.status - Status key: `active | error | inactive | action | initializing`.
|
|
22
|
-
* @return {JSX.Element} The `Status` component.
|
|
23
|
-
*/
|
|
24
|
-
const Status = ( { className, label, status = 'inactive' }: StatusProps ): JSX.Element => {
|
|
25
|
-
const defaultLabels: Record< string, string > = {
|
|
26
|
-
active: __( 'Active', 'jetpack-components' ),
|
|
27
|
-
error: __( 'Error', 'jetpack-components' ),
|
|
28
|
-
action: __( 'Action needed', 'jetpack-components' ),
|
|
29
|
-
inactive: __( 'Inactive', 'jetpack-components' ),
|
|
30
|
-
initializing: __( 'Setting up', 'jetpack-components' ),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Text
|
|
35
|
-
variant="body-extra-small"
|
|
36
|
-
className={ clsx(
|
|
37
|
-
styles.status,
|
|
38
|
-
{
|
|
39
|
-
[ styles[ `is-${ status }` ] ]: status,
|
|
40
|
-
},
|
|
41
|
-
className
|
|
42
|
-
) }
|
|
43
|
-
>
|
|
44
|
-
<span className={ styles.status__indicator } />
|
|
45
|
-
<span className={ styles.status__label }>
|
|
46
|
-
{ label || label === '' ? label : defaultLabels[ status ] }
|
|
47
|
-
</span>
|
|
48
|
-
</Text>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default Status;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
.status {
|
|
2
|
-
--spacing-base: 8px;
|
|
3
|
-
--wp-admin-border-width-focus: 1.5px;
|
|
4
|
-
|
|
5
|
-
align-items: center;
|
|
6
|
-
display: flex;
|
|
7
|
-
white-space: nowrap;
|
|
8
|
-
|
|
9
|
-
&__indicator {
|
|
10
|
-
background-color: var(--jp-gray-50);
|
|
11
|
-
border-radius: 50%;
|
|
12
|
-
flex-shrink: 0;
|
|
13
|
-
height: 0.666em;
|
|
14
|
-
width: 0.666em;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&__label {
|
|
18
|
-
font-weight: 600;
|
|
19
|
-
line-height: 1.666;
|
|
20
|
-
margin-left: calc(var(--spacing-base) / 2); // 4px
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&.is-active {
|
|
24
|
-
|
|
25
|
-
span,
|
|
26
|
-
a {
|
|
27
|
-
color: var(--jp-green-50);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.status__indicator {
|
|
31
|
-
background-color: var(--jp-green-50);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&.is-inactive {
|
|
36
|
-
|
|
37
|
-
span,
|
|
38
|
-
a {
|
|
39
|
-
color: var(--jp-gray-50);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.status__indicator {
|
|
43
|
-
background-color: var(--jp-gray-50);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
&.is-error {
|
|
48
|
-
|
|
49
|
-
span,
|
|
50
|
-
a {
|
|
51
|
-
color: var(--jp-red-50);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.status__indicator {
|
|
55
|
-
background-color: var(--jp-red-50);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&.is-action {
|
|
60
|
-
|
|
61
|
-
span,
|
|
62
|
-
a {
|
|
63
|
-
color: var(--jp-yellow-30);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.status__indicator {
|
|
67
|
-
background-color: var(--jp-yellow-30);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
&.is-initializing {
|
|
72
|
-
|
|
73
|
-
span,
|
|
74
|
-
a {
|
|
75
|
-
color: var(--jp-blue-40);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.status__indicator {
|
|
79
|
-
background-color: var(--jp-blue-40);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Toggle Control
|
|
2
|
-
|
|
3
|
-
A wrapper component for applying Jetpack Emerald styles to the [ToggleControl](https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/form-toggle) component from `@wordpress/components`.
|
|
4
|
-
|
|
5
|
-
The documentation for the base `ToggleControl` component can be found via the [Gutenberg Handbook](https://developer.wordpress.org/block-editor/components/toggle-control/).
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { ToggleControl as WPToggleControl } from '@wordpress/components';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
import styles from './styles.module.scss';
|
|
5
|
-
import type { FC, ReactNode } from 'react';
|
|
6
|
-
|
|
7
|
-
export interface ToggleControlProps {
|
|
8
|
-
/** Whether or not the toggle is currently enabled. */
|
|
9
|
-
checked?: boolean;
|
|
10
|
-
|
|
11
|
-
/** Custom class name to append to the component. */
|
|
12
|
-
className?: string;
|
|
13
|
-
|
|
14
|
-
/** Whether or not the toggle is currently disabled. */
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
|
|
17
|
-
/** Additional information to display below the toggle. */
|
|
18
|
-
help?: ReactNode;
|
|
19
|
-
|
|
20
|
-
/** Whether or not the toggling is currently toggling. */
|
|
21
|
-
toggling?: boolean;
|
|
22
|
-
|
|
23
|
-
/** The label for the toggle. */
|
|
24
|
-
label?: ReactNode;
|
|
25
|
-
|
|
26
|
-
/** Accessible name for the underlying checkbox. Use when no visible `label` is rendered. */
|
|
27
|
-
'aria-label'?: string;
|
|
28
|
-
|
|
29
|
-
/** The size of the toggle. */
|
|
30
|
-
size?: 'small' | 'normal';
|
|
31
|
-
|
|
32
|
-
/** A callback function invoked when the toggle is clicked. */
|
|
33
|
-
onChange: ( value: boolean ) => void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const ToggleControl: FC< ToggleControlProps > = ( {
|
|
37
|
-
checked,
|
|
38
|
-
className,
|
|
39
|
-
disabled,
|
|
40
|
-
help,
|
|
41
|
-
toggling,
|
|
42
|
-
label,
|
|
43
|
-
'aria-label': ariaLabel,
|
|
44
|
-
size = 'normal',
|
|
45
|
-
onChange,
|
|
46
|
-
} ) => {
|
|
47
|
-
const showChecked =
|
|
48
|
-
toggling !== undefined ? ( checked && ! toggling ) || ( ! checked && toggling ) : checked;
|
|
49
|
-
|
|
50
|
-
const handleOnChange = useCallback(
|
|
51
|
-
( value: boolean ) => {
|
|
52
|
-
// Don't toggle if the toggle is already toggling.
|
|
53
|
-
if ( toggling ) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
onChange( value );
|
|
58
|
-
},
|
|
59
|
-
[ toggling, onChange ]
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<WPToggleControl
|
|
64
|
-
__nextHasNoMarginBottom={ true }
|
|
65
|
-
checked={ showChecked }
|
|
66
|
-
className={ clsx( styles.toggle, className, {
|
|
67
|
-
[ styles[ 'is-toggling' ] ]: toggling,
|
|
68
|
-
[ styles[ 'is-small' ] ]: size === 'small',
|
|
69
|
-
[ styles[ 'no-label' ] ]: ! label,
|
|
70
|
-
} ) }
|
|
71
|
-
disabled={ disabled }
|
|
72
|
-
help={ help }
|
|
73
|
-
label={ label }
|
|
74
|
-
aria-label={ ariaLabel }
|
|
75
|
-
onChange={ handleOnChange }
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default ToggleControl;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// Toggle Control
|
|
2
|
-
///
|
|
3
|
-
/// Overrides the @wordpress/components ToggleControl component.
|
|
4
|
-
/// @link https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/form-toggle
|
|
5
|
-
.toggle {
|
|
6
|
-
|
|
7
|
-
&.is-small {
|
|
8
|
-
--base-width: 6px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&.no-label :global(.components-toggle-control__label) {
|
|
12
|
-
display: none;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.toggle.is-toggling {
|
|
17
|
-
|
|
18
|
-
:global {
|
|
19
|
-
|
|
20
|
-
.components-form-toggle {
|
|
21
|
-
opacity: 0.6;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|