@automattic/jetpack-components 1.12.10 → 1.12.12

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 CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Components package releases.
4
4
 
5
+ ## [1.12.12] - 2026-06-25
6
+ ### Fixed
7
+ - Icon tooltip: Type `iconCode` as `ReactElement` so it matches the `@wordpress/icons` Icon and `@wordpress/ui` 0.15 type definitions. [#49795]
8
+
9
+ ## [1.12.11] - 2026-06-24
10
+ ### Removed
11
+ - Remove deprecated Spinner component. Use Spinner from @wordpress/components instead. [#49856]
12
+
5
13
  ## [1.12.10] - 2026-06-23
6
14
  ### Changed
7
15
  - Update package dependencies. [#49831]
@@ -1852,6 +1860,8 @@
1852
1860
  ### Changed
1853
1861
  - Update node version requirement to 14.16.1
1854
1862
 
1863
+ [1.12.12]: https://github.com/Automattic/jetpack-components/compare/1.12.11...1.12.12
1864
+ [1.12.11]: https://github.com/Automattic/jetpack-components/compare/1.12.10...1.12.11
1855
1865
  [1.12.10]: https://github.com/Automattic/jetpack-components/compare/1.12.9...1.12.10
1856
1866
  [1.12.9]: https://github.com/Automattic/jetpack-components/compare/1.12.8...1.12.9
1857
1867
  [1.12.8]: https://github.com/Automattic/jetpack-components/compare/1.12.7...1.12.8
@@ -3,10 +3,10 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
3
3
  * External dependencies
4
4
  */
5
5
  import { Popover } from '@wordpress/components';
6
+ import { useViewportMatch } from '@wordpress/compose';
6
7
  import { __, sprintf } from '@wordpress/i18n';
7
8
  import { close } from '@wordpress/icons';
8
9
  import Button from '../button/index.js';
9
- import useBreakpointMatch from '../layout/use-breakpoint-match/index.js';
10
10
  import Text from '../text/index.js';
11
11
  /**
12
12
  * Internal dependencies
@@ -14,7 +14,7 @@ import Text from '../text/index.js';
14
14
  import ThemeProvider from '../theme-provider/index.js';
15
15
  import styles from './styles.module.scss';
16
16
  const ActionPopover = ({ hideCloseButton = false, title, children, step = null, totalSteps = null, buttonContent = null, buttonDisabled = false, buttonHref = null, buttonExternalLink = false, offset = 32, onClose, onClick, ...otherPopoverProps }) => {
17
- const [isSm] = useBreakpointMatch('sm');
17
+ const isSm = useViewportMatch('small', '<');
18
18
  if (!title || !children || !buttonContent) {
19
19
  return null;
20
20
  }
@@ -1,8 +1,8 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useViewportMatch } from '@wordpress/compose';
2
3
  import clsx from 'clsx';
3
4
  import Col from '../layout/col/index.js';
4
5
  import Container from '../layout/container/index.js';
5
- import useBreakpointMatch from '../layout/use-breakpoint-match/index.js';
6
6
  import styles from './style.module.scss';
7
7
  /**
8
8
  * Dialog component.
@@ -15,7 +15,8 @@ import styles from './style.module.scss';
15
15
  * @return {ReactNode} Rendered dialog
16
16
  */
17
17
  const Dialog = ({ primary, secondary, isTwoSections = false, ...containerProps }) => {
18
- const [isSmall, isLowerThanLarge] = useBreakpointMatch(['sm', 'lg'], [null, '<']);
18
+ const isSmall = useViewportMatch('small', '<');
19
+ const isLowerThanLarge = useViewportMatch('large', '<');
19
20
  /*
20
21
  * By convention, secondary section is not shown when:
21
22
  * - layout is a two-sections setup
@@ -1,5 +1,5 @@
1
- import type { IconType } from '@wordpress/components';
2
- import type { ReactNode } from 'react';
1
+ import type { Icon } from '@wordpress/icons';
2
+ import type { ComponentProps, ReactNode } from 'react';
3
3
  export type Placement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
4
4
  export type Position = 'top left' | 'top center' | 'top right' | 'bottom left' | 'bottom center' | 'bottom right';
5
5
  export type IconTooltipProps = {
@@ -26,7 +26,7 @@ export type IconTooltipProps = {
26
26
  /**
27
27
  * The icon to display. Accepts icon components from `@wordpress/icons`.
28
28
  */
29
- iconCode?: IconType;
29
+ iconCode?: ComponentProps<typeof Icon>['icon'];
30
30
  /**
31
31
  * The title of Popover.
32
32
  */
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useViewportMatch } from '@wordpress/compose';
2
3
  import { __, sprintf } from '@wordpress/i18n';
3
4
  import { Icon, check, closeSmall } from '@wordpress/icons';
4
5
  import clsx from 'clsx';
5
6
  import { createContext, useContext, Children, cloneElement, } from 'react';
6
7
  import IconTooltip from '../icon-tooltip/index.js';
7
- import useBreakpointMatch from '../layout/use-breakpoint-match/index.js';
8
8
  import TermsOfService from '../terms-of-service/index.js';
9
9
  import Text from '../text/index.js';
10
10
  import styles from './styles.module.scss';
@@ -30,7 +30,7 @@ const getItemLabels = (isComingSoon, isIncluded, featureNameLabel) => {
30
30
  };
31
31
  };
32
32
  export const PricingTableItem = ({ isIncluded = false, isComingSoon = false, index = 0, label = null, tooltipInfo, tooltipTitle, tooltipClassName = '', }) => {
33
- const [isLg] = useBreakpointMatch('lg');
33
+ const isLg = useViewportMatch('large');
34
34
  const item = useContext(PricingTableContext)[index];
35
35
  const isExplicitlyEmpty = label === '';
36
36
  const showTick = isComingSoon || isIncluded;
@@ -61,7 +61,7 @@ export const PricingTableColumn = ({ primary = false, children, className, }) =>
61
61
  }) }));
62
62
  };
63
63
  const PricingTable = ({ title, headerLogo, items, children, showIntroOfferDisclaimer = false, }) => {
64
- const [isLg] = useBreakpointMatch('lg');
64
+ const isLg = useViewportMatch('large');
65
65
  return (_jsxs(PricingTableContext.Provider, { value: items, children: [
66
66
  _jsx("div", { className: clsx(styles.container, { [styles['is-viewport-large']]: isLg }), style: {
67
67
  '--rows': items.length + 1,
package/build/index.d.ts CHANGED
@@ -10,8 +10,6 @@ export { default as AutomatticBylineLogo } from './components/automattic-byline-
10
10
  export { default as AutomatticIconLogo } from './components/automattic-icon-logo/index.tsx';
11
11
  export { default as AutomatticForAgenciesLogo } from './components/automattic-for-agencies-logo/index.tsx';
12
12
  export { default as JetpackFooter } from './components/jetpack-footer/index.tsx';
13
- /** @deprecated Use `Spinner` from `@wordpress/components` instead. */
14
- export { default as Spinner } from './components/spinner/index.tsx';
15
13
  export { default as Gravatar } from './components/gravatar/index.tsx';
16
14
  export type { GravatarProps } from './components/gravatar/index.tsx';
17
15
  export { default as IconTooltip } from './components/icon-tooltip/index.tsx';
@@ -25,7 +23,6 @@ export { default as DecorativeCard } from './components/decorative-card/index.ts
25
23
  export { default as Col } from './components/layout/col/index.tsx';
26
24
  export { default as Testimonials } from './components/testimonials/index.tsx';
27
25
  export { default as Container } from './components/layout/container/index.tsx';
28
- export { default as useBreakpointMatch } from './components/layout/use-breakpoint-match/index.ts';
29
26
  export { default as CopyToClipboard } from './components/copy-to-clipboard/index.tsx';
30
27
  export * from './components/icons/index.tsx';
31
28
  export { default as SplitButton } from './components/split-button/index.tsx';
package/build/index.js CHANGED
@@ -24,8 +24,6 @@ export { default as AutomatticBylineLogo } from './components/automattic-byline-
24
24
  export { default as AutomatticIconLogo } from './components/automattic-icon-logo/index.js';
25
25
  export { default as AutomatticForAgenciesLogo } from './components/automattic-for-agencies-logo/index.js';
26
26
  export { default as JetpackFooter } from './components/jetpack-footer/index.js';
27
- /** @deprecated Use `Spinner` from `@wordpress/components` instead. */
28
- export { default as Spinner } from './components/spinner/index.js';
29
27
  export { default as Gravatar } from './components/gravatar/index.js';
30
28
  export { default as IconTooltip } from './components/icon-tooltip/index.js';
31
29
  export { default as ActionButton } from './components/action-button/index.js';
@@ -38,7 +36,6 @@ export { default as DecorativeCard } from './components/decorative-card/index.js
38
36
  export { default as Col } from './components/layout/col/index.js';
39
37
  export { default as Testimonials } from './components/testimonials/index.js';
40
38
  export { default as Container } from './components/layout/container/index.js';
41
- export { default as useBreakpointMatch } from './components/layout/use-breakpoint-match/index.js';
42
39
  export { default as CopyToClipboard } from './components/copy-to-clipboard/index.js';
43
40
  export * from './components/icons/index.js';
44
41
  export { default as SplitButton } from './components/split-button/index.js';
@@ -2,10 +2,10 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { Popover } from '@wordpress/components';
5
+ import { useViewportMatch } from '@wordpress/compose';
5
6
  import { __, sprintf } from '@wordpress/i18n';
6
7
  import { close } from '@wordpress/icons';
7
8
  import Button from '../button/index.tsx';
8
- import useBreakpointMatch from '../layout/use-breakpoint-match/index.ts';
9
9
  import Text from '../text/index.tsx';
10
10
  /**
11
11
  * Internal dependencies
@@ -32,7 +32,7 @@ const ActionPopover = ( {
32
32
  onClick,
33
33
  ...otherPopoverProps
34
34
  }: ActionPopoverProps ) => {
35
- const [ isSm ] = useBreakpointMatch( 'sm' );
35
+ const isSm = useViewportMatch( 'small', '<' );
36
36
 
37
37
  if ( ! title || ! children || ! buttonContent ) {
38
38
  return null;
@@ -1,7 +1,7 @@
1
+ import { useViewportMatch } from '@wordpress/compose';
1
2
  import clsx from 'clsx';
2
3
  import Col from '../layout/col/index.tsx';
3
4
  import Container from '../layout/container/index.tsx';
4
- import useBreakpointMatch from '../layout/use-breakpoint-match/index.ts';
5
5
  import styles from './style.module.scss';
6
6
  import type { ReactNode, FC } from 'react';
7
7
 
@@ -29,7 +29,8 @@ const Dialog: FC< DialogProps > = ( {
29
29
  isTwoSections = false,
30
30
  ...containerProps
31
31
  } ) => {
32
- const [ isSmall, isLowerThanLarge ] = useBreakpointMatch( [ 'sm', 'lg' ], [ null, '<' ] );
32
+ const isSmall = useViewportMatch( 'small', '<' );
33
+ const isLowerThanLarge = useViewportMatch( 'large', '<' );
33
34
 
34
35
  /*
35
36
  * By convention, secondary section is not shown when:
@@ -1,5 +1,5 @@
1
- import type { IconType } from '@wordpress/components';
2
- import type { ReactNode } from 'react';
1
+ import type { Icon } from '@wordpress/icons';
2
+ import type { ComponentProps, ReactNode } from 'react';
3
3
 
4
4
  export type Placement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
5
5
 
@@ -40,7 +40,7 @@ export type IconTooltipProps = {
40
40
  /**
41
41
  * The icon to display. Accepts icon components from `@wordpress/icons`.
42
42
  */
43
- iconCode?: IconType;
43
+ iconCode?: ComponentProps< typeof Icon >[ 'icon' ];
44
44
 
45
45
  /**
46
46
  * The title of Popover.
@@ -1,3 +1,4 @@
1
+ import { useViewportMatch } from '@wordpress/compose';
1
2
  import { __, sprintf } from '@wordpress/i18n';
2
3
  import { Icon, check, closeSmall } from '@wordpress/icons';
3
4
  import clsx from 'clsx';
@@ -11,7 +12,6 @@ import {
11
12
  CSSProperties,
12
13
  } from 'react';
13
14
  import IconTooltip from '../icon-tooltip/index.tsx';
14
- import useBreakpointMatch from '../layout/use-breakpoint-match/index.ts';
15
15
  import TermsOfService from '../terms-of-service/index.tsx';
16
16
  import Text from '../text/index.tsx';
17
17
  import styles from './styles.module.scss';
@@ -59,7 +59,7 @@ export const PricingTableItem: FC< PricingTableItemProps > = ( {
59
59
  tooltipTitle,
60
60
  tooltipClassName = '',
61
61
  } ) => {
62
- const [ isLg ] = useBreakpointMatch( 'lg' );
62
+ const isLg = useViewportMatch( 'large' );
63
63
  const item = useContext( PricingTableContext )[ index ];
64
64
  const isExplicitlyEmpty = label === '';
65
65
  const showTick = isComingSoon || isIncluded;
@@ -158,7 +158,7 @@ const PricingTable: FC< PricingTableProps > = ( {
158
158
  children,
159
159
  showIntroOfferDisclaimer = false,
160
160
  } ) => {
161
- const [ isLg ] = useBreakpointMatch( 'lg' );
161
+ const isLg = useViewportMatch( 'large' );
162
162
 
163
163
  return (
164
164
  <PricingTableContext.Provider value={ items }>
package/index.ts CHANGED
@@ -25,8 +25,6 @@ export { default as AutomatticBylineLogo } from './components/automattic-byline-
25
25
  export { default as AutomatticIconLogo } from './components/automattic-icon-logo/index.tsx';
26
26
  export { default as AutomatticForAgenciesLogo } from './components/automattic-for-agencies-logo/index.tsx';
27
27
  export { default as JetpackFooter } from './components/jetpack-footer/index.tsx';
28
- /** @deprecated Use `Spinner` from `@wordpress/components` instead. */
29
- export { default as Spinner } from './components/spinner/index.tsx';
30
28
  export { default as Gravatar } from './components/gravatar/index.tsx';
31
29
  export type { GravatarProps } from './components/gravatar/index.tsx';
32
30
  export { default as IconTooltip } from './components/icon-tooltip/index.tsx';
@@ -40,7 +38,6 @@ export { default as DecorativeCard } from './components/decorative-card/index.ts
40
38
  export { default as Col } from './components/layout/col/index.tsx';
41
39
  export { default as Testimonials } from './components/testimonials/index.tsx';
42
40
  export { default as Container } from './components/layout/container/index.tsx';
43
- export { default as useBreakpointMatch } from './components/layout/use-breakpoint-match/index.ts';
44
41
  export { default as CopyToClipboard } from './components/copy-to-clipboard/index.tsx';
45
42
  export * from './components/icons/index.tsx';
46
43
  export { default as SplitButton } from './components/split-button/index.tsx';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-components",
3
- "version": "1.12.10",
3
+ "version": "1.12.12",
4
4
  "description": "Jetpack Components Package",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/components/#readme",
6
6
  "bugs": {
@@ -1,17 +0,0 @@
1
- type Operators = '<' | '<=' | '>' | '>=';
2
- /**
3
- * Hook to match if current viewport is equal, greater or less than expected breakpoint
4
- *
5
- * @param {(Breakpoints | Array< Breakpoints >)} breakpointToMatch - An single breakpoint or list of breakpoints to match.
6
- * @param {(Operators | Array< Operators >)} operatorToMatch - An single operator or list of them. It should follow the same sequence than breakpoints.
7
- * @return {Array<boolean>} - List of matches, following breakpoints sequence.
8
- * @example
9
- *
10
- * ```es6
11
- * useBreakpointMatch('sm')
12
- * useBreakpointMatch('lg', '<')
13
- * useBreakpointMatch([ 'lg', 'sm' ], [ '<', null ])
14
- * ```
15
- */
16
- declare const useBreakpointMatch: (breakpointToMatch: "lg" | "md" | "sm" | ("lg" | "md" | "sm")[], operatorToMatch?: Operators[] | Operators) => boolean[];
17
- export default useBreakpointMatch;
@@ -1,50 +0,0 @@
1
- import { useMediaQuery } from '@wordpress/compose';
2
- import breakpointsValues from '../breakpoints.module.scss';
3
- const BREAKPOINTS = ['sm', 'md', 'lg'];
4
- const getMediaByOperator = (breakpoint, operator, matches) => {
5
- const breakpointIndex = BREAKPOINTS.indexOf(breakpoint);
6
- const breakpointIndexPlusOne = breakpointIndex + 1;
7
- const isEqual = operator.includes('=');
8
- let allNeededBreakpoints = [];
9
- if (operator.startsWith('<')) {
10
- allNeededBreakpoints = BREAKPOINTS.slice(0, isEqual ? breakpointIndexPlusOne : breakpointIndex);
11
- }
12
- if (operator.startsWith('>')) {
13
- allNeededBreakpoints = BREAKPOINTS.slice(isEqual ? breakpointIndex : breakpointIndexPlusOne);
14
- }
15
- return allNeededBreakpoints?.length
16
- ? allNeededBreakpoints.some(brk => matches[brk])
17
- : matches[breakpoint];
18
- };
19
- /**
20
- * Hook to match if current viewport is equal, greater or less than expected breakpoint
21
- *
22
- * @param {(Breakpoints | Array< Breakpoints >)} breakpointToMatch - An single breakpoint or list of breakpoints to match.
23
- * @param {(Operators | Array< Operators >)} operatorToMatch - An single operator or list of them. It should follow the same sequence than breakpoints.
24
- * @return {Array<boolean>} - List of matches, following breakpoints sequence.
25
- * @example
26
- *
27
- * ```es6
28
- * useBreakpointMatch('sm')
29
- * useBreakpointMatch('lg', '<')
30
- * useBreakpointMatch([ 'lg', 'sm' ], [ '<', null ])
31
- * ```
32
- */
33
- const useBreakpointMatch = (breakpointToMatch, operatorToMatch) => {
34
- const breakpoints = Array.isArray(breakpointToMatch)
35
- ? breakpointToMatch
36
- : [breakpointToMatch];
37
- const operators = Array.isArray(operatorToMatch)
38
- ? operatorToMatch
39
- : [operatorToMatch];
40
- const [smKey, mdKey, lgKey] = BREAKPOINTS;
41
- const sm = useMediaQuery(breakpointsValues[smKey]);
42
- const md = useMediaQuery(breakpointsValues[mdKey]);
43
- const lg = useMediaQuery(breakpointsValues[lgKey]);
44
- const matches = { sm, md, lg };
45
- return breakpoints.map((breakpoint, idx) => {
46
- const operator = operators[idx];
47
- return operator ? getMediaByOperator(breakpoint, operator, matches) : matches[breakpoint];
48
- });
49
- };
50
- export default useBreakpointMatch;
@@ -1,17 +0,0 @@
1
- import './style.scss';
2
- declare function Spinner({ color, className, size }: {
3
- className?: string;
4
- color?: string;
5
- size?: number;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- declare namespace Spinner {
8
- var propTypes: {
9
- /** The spinner color. */
10
- color: any;
11
- /** CSS class names. */
12
- className: any;
13
- /** The spinner size. */
14
- size: any;
15
- };
16
- }
17
- export default Spinner;
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import PropTypes from 'prop-types';
3
- import './style.scss';
4
- const Spinner = ({ color = '#FFFFFF', className = '', size = 20 }) => {
5
- const theClassName = className + ' jp-components-spinner';
6
- const styleOuter = {
7
- width: size,
8
- height: size,
9
- fontSize: size, // allows border-width to be specified in em units
10
- borderTopColor: color,
11
- };
12
- const styleInner = {
13
- borderTopColor: color,
14
- borderRightColor: color,
15
- };
16
- return (_jsx("div", { className: theClassName, children: _jsx("div", { className: "jp-components-spinner__outer", style: styleOuter, children: _jsx("div", { className: "jp-components-spinner__inner", style: styleInner }) }) }));
17
- };
18
- Spinner.propTypes = {
19
- /** The spinner color. */
20
- color: PropTypes.string,
21
- /** CSS class names. */
22
- className: PropTypes.string,
23
- /** The spinner size. */
24
- size: PropTypes.number,
25
- };
26
- export default Spinner;
@@ -1,33 +0,0 @@
1
- @keyframes rotate-spinner {
2
-
3
- 100% {
4
- transform: rotate(360deg);
5
- }
6
- }
7
-
8
- .jp-components-spinner {
9
- display: flex;
10
- align-items: center;
11
- }
12
-
13
- .jp-components-spinner__outer,
14
- .jp-components-spinner__inner {
15
- margin: auto;
16
- box-sizing: border-box;
17
- border: 0.1em solid transparent;
18
- border-radius: 50%;
19
- animation: 3s linear infinite;
20
- animation-name: rotate-spinner;
21
- }
22
-
23
- .jp-components-spinner__outer {
24
- border-top-color: #fff;
25
- }
26
-
27
- .jp-components-spinner__inner {
28
- width: 100%;
29
- height: 100%;
30
- border-top-color: #fff;
31
- border-right-color: #fff;
32
- opacity: 0.4;
33
- }
@@ -1,43 +0,0 @@
1
- # useBreakpointMatch
2
-
3
- Utility to match against breakpoints.
4
-
5
- [ Storybook Reference ](https://automattic.github.io/jetpack-storybook/?path=/story/js-packages-components-layout--breakpoint-match)
6
-
7
- ## Usage
8
-
9
- ```jsx
10
- import { useBreakpointMatch } from '@automattic/jetpack-components';
11
- const [ isLg ] = useBreakpointMatch('lg')
12
- return isLg && <Component />
13
- ```
14
-
15
- ## Parameters
16
-
17
- ### breakpointToMatch
18
-
19
- Single or Array of breakpoints to match against.
20
-
21
- - Type: `String`|`Array<String>`
22
- - Required: `true`
23
-
24
- ```javascript
25
- useBreakpointMatch('lg');
26
- useBreakpointMatch([ 'lg', 'sm' ]);
27
- ```
28
-
29
- ### operator
30
-
31
- A Single or Array of operators to match less, equal, or greater than the breakpoint.
32
-
33
- In Array, it matches against the same index from breakpoint.
34
-
35
- - Type: `String`|`Array<String>`
36
- - Required: `false`
37
-
38
- #### Example
39
-
40
- ```javascript
41
- useBreakpointMatch('md', '<=');
42
- useBreakpointMatch([ 'lg', 'sm' ], ['<', '>']);
43
- ```
@@ -1,9 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: { [ key: string ]: string };
3
- export default classes;
4
- }
5
-
6
- declare module '*.module.scss' {
7
- const classes: { [ key: string ]: string };
8
- export default classes;
9
- }
@@ -1,79 +0,0 @@
1
- import { useMediaQuery } from '@wordpress/compose';
2
- import breakpointsValues from '../breakpoints.module.scss';
3
-
4
- const BREAKPOINTS = [ 'sm', 'md', 'lg' ] as const;
5
-
6
- type Breakpoints = ( typeof BREAKPOINTS )[ number ];
7
-
8
- type Operators = '<' | '<=' | '>' | '>=';
9
-
10
- type Matches = { sm: boolean; md: boolean; lg: boolean };
11
-
12
- const getMediaByOperator = (
13
- breakpoint: Breakpoints,
14
- operator: Operators,
15
- matches: Matches
16
- ): boolean => {
17
- const breakpointIndex = BREAKPOINTS.indexOf( breakpoint );
18
- const breakpointIndexPlusOne = breakpointIndex + 1;
19
- const isEqual = operator.includes( '=' );
20
-
21
- let allNeededBreakpoints = [];
22
-
23
- if ( operator.startsWith( '<' ) ) {
24
- allNeededBreakpoints = BREAKPOINTS.slice(
25
- 0,
26
- isEqual ? breakpointIndexPlusOne : breakpointIndex
27
- );
28
- }
29
-
30
- if ( operator.startsWith( '>' ) ) {
31
- allNeededBreakpoints = BREAKPOINTS.slice( isEqual ? breakpointIndex : breakpointIndexPlusOne );
32
- }
33
-
34
- return allNeededBreakpoints?.length
35
- ? allNeededBreakpoints.some( brk => matches[ brk ] )
36
- : matches[ breakpoint ];
37
- };
38
-
39
- /**
40
- * Hook to match if current viewport is equal, greater or less than expected breakpoint
41
- *
42
- * @param {(Breakpoints | Array< Breakpoints >)} breakpointToMatch - An single breakpoint or list of breakpoints to match.
43
- * @param {(Operators | Array< Operators >)} operatorToMatch - An single operator or list of them. It should follow the same sequence than breakpoints.
44
- * @return {Array<boolean>} - List of matches, following breakpoints sequence.
45
- * @example
46
- *
47
- * ```es6
48
- * useBreakpointMatch('sm')
49
- * useBreakpointMatch('lg', '<')
50
- * useBreakpointMatch([ 'lg', 'sm' ], [ '<', null ])
51
- * ```
52
- */
53
- const useBreakpointMatch = (
54
- breakpointToMatch: Breakpoints | Array< Breakpoints >,
55
- operatorToMatch?: Operators | Array< Operators >
56
- ) => {
57
- const breakpoints: Array< Breakpoints > = Array.isArray( breakpointToMatch )
58
- ? breakpointToMatch
59
- : [ breakpointToMatch ];
60
-
61
- const operators: Array< Operators > = Array.isArray( operatorToMatch )
62
- ? operatorToMatch
63
- : [ operatorToMatch ];
64
-
65
- const [ smKey, mdKey, lgKey ] = BREAKPOINTS;
66
-
67
- const sm = useMediaQuery( breakpointsValues[ smKey ] );
68
- const md = useMediaQuery( breakpointsValues[ mdKey ] );
69
- const lg = useMediaQuery( breakpointsValues[ lgKey ] );
70
-
71
- const matches: Matches = { sm, md, lg };
72
-
73
- return breakpoints.map( ( breakpoint, idx ) => {
74
- const operator = operators[ idx ];
75
- return operator ? getMediaByOperator( breakpoint, operator, matches ) : matches[ breakpoint ];
76
- } );
77
- };
78
-
79
- export default useBreakpointMatch;
@@ -1,28 +0,0 @@
1
- # Spinner (DEPRECATED)
2
-
3
- ## We encourage to use [core Spinner](https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/spinner#readme) component instead
4
- ---------
5
-
6
- Spinner is a React component for rendering a loading indicator.
7
-
8
- ## Usage
9
-
10
- ```jsx
11
- import { Component } from 'react';
12
- import Spinner from '@automattic/jetpack-components';
13
-
14
- export default class extends Component {
15
- render() {
16
- return <Spinner />;
17
- }
18
- }
19
- ```
20
-
21
- ## Props
22
-
23
- The following props can be passed to the Spinner component:
24
-
25
- | PROPERTY | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
26
- | --------- | -------- | -------- | --------- | ----------------------------------------------- |
27
- | **size** | _number_ | no | `20` | The width and height of the spinner, in pixels. |
28
- | **color** | _strong_ | no | `#000000` | The color of the spinner, in hex. |
@@ -1,38 +0,0 @@
1
- import PropTypes from 'prop-types';
2
-
3
- import './style.scss';
4
-
5
- const Spinner = ( { color = '#FFFFFF', className = '', size = 20 } ) => {
6
- const theClassName = className + ' jp-components-spinner';
7
-
8
- const styleOuter = {
9
- width: size,
10
- height: size,
11
- fontSize: size, // allows border-width to be specified in em units
12
- borderTopColor: color,
13
- };
14
-
15
- const styleInner = {
16
- borderTopColor: color,
17
- borderRightColor: color,
18
- };
19
-
20
- return (
21
- <div className={ theClassName }>
22
- <div className="jp-components-spinner__outer" style={ styleOuter }>
23
- <div className="jp-components-spinner__inner" style={ styleInner } />
24
- </div>
25
- </div>
26
- );
27
- };
28
-
29
- Spinner.propTypes = {
30
- /** The spinner color. */
31
- color: PropTypes.string,
32
- /** CSS class names. */
33
- className: PropTypes.string,
34
- /** The spinner size. */
35
- size: PropTypes.number,
36
- };
37
-
38
- export default Spinner;
@@ -1,33 +0,0 @@
1
- @keyframes rotate-spinner {
2
-
3
- 100% {
4
- transform: rotate(360deg);
5
- }
6
- }
7
-
8
- .jp-components-spinner {
9
- display: flex;
10
- align-items: center;
11
- }
12
-
13
- .jp-components-spinner__outer,
14
- .jp-components-spinner__inner {
15
- margin: auto;
16
- box-sizing: border-box;
17
- border: 0.1em solid transparent;
18
- border-radius: 50%;
19
- animation: 3s linear infinite;
20
- animation-name: rotate-spinner;
21
- }
22
-
23
- .jp-components-spinner__outer {
24
- border-top-color: #fff;
25
- }
26
-
27
- .jp-components-spinner__inner {
28
- width: 100%;
29
- height: 100%;
30
- border-top-color: #fff;
31
- border-right-color: #fff;
32
- opacity: 0.4;
33
- }