@automattic/jetpack-components 0.42.4 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/components/button/types.ts +1 -1
- package/components/copy-to-clipboard/index.tsx +67 -0
- package/components/copy-to-clipboard/types.ts +7 -0
- package/components/icons/README.md +3 -0
- package/components/icons/index.tsx +37 -0
- package/components/icons/style.module.scss +3 -0
- package/index.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Components package releases.
|
|
4
4
|
|
|
5
|
+
## [0.43.0] - 2023-10-03
|
|
6
|
+
### Added
|
|
7
|
+
- Added new sharing icon [#33244]
|
|
8
|
+
|
|
9
|
+
## [0.42.5] - 2023-09-25
|
|
10
|
+
### Added
|
|
11
|
+
- Added WhatsApp social icon. [#33074]
|
|
12
|
+
- Added CopyToClipboard component. [#33265]
|
|
13
|
+
|
|
5
14
|
## [0.42.4] - 2023-09-19
|
|
15
|
+
|
|
6
16
|
- Minor internal updates.
|
|
7
17
|
|
|
8
18
|
## [0.42.3] - 2023-09-13
|
|
@@ -820,6 +830,8 @@
|
|
|
820
830
|
### Changed
|
|
821
831
|
- Update node version requirement to 14.16.1
|
|
822
832
|
|
|
833
|
+
[0.43.0]: https://github.com/Automattic/jetpack-components/compare/0.42.5...0.43.0
|
|
834
|
+
[0.42.5]: https://github.com/Automattic/jetpack-components/compare/0.42.4...0.42.5
|
|
823
835
|
[0.42.4]: https://github.com/Automattic/jetpack-components/compare/0.42.3...0.42.4
|
|
824
836
|
[0.42.3]: https://github.com/Automattic/jetpack-components/compare/0.42.2...0.42.3
|
|
825
837
|
[0.42.2]: https://github.com/Automattic/jetpack-components/compare/0.42.1...0.42.2
|
|
@@ -13,7 +13,7 @@ type JetpackButtonBaseProps = {
|
|
|
13
13
|
variant?: 'primary' | 'secondary' | 'link' | 'tertiary';
|
|
14
14
|
weight?: 'bold' | 'regular';
|
|
15
15
|
fullWidth?: boolean;
|
|
16
|
-
ref
|
|
16
|
+
ref?: React.ForwardedRef< unknown >;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
type WPButtonProps = Omit< React.ComponentProps< typeof Button >, 'size' | 'variant' >;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
2
|
+
import { useState, useRef, useEffect } from '@wordpress/element';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import Button from '../button';
|
|
5
|
+
import { ClipboardIcon, CheckmarkIcon } from '../icons';
|
|
6
|
+
import { CopyToClipboardProps } from './types';
|
|
7
|
+
import type React from 'react';
|
|
8
|
+
|
|
9
|
+
export const CopyToClipboard: React.FC< CopyToClipboardProps > = ( {
|
|
10
|
+
buttonStyle = 'icon',
|
|
11
|
+
textToCopy,
|
|
12
|
+
onCopy,
|
|
13
|
+
...buttonProps
|
|
14
|
+
} ) => {
|
|
15
|
+
const [ hasCopied, setHasCopied ] = useState( false );
|
|
16
|
+
|
|
17
|
+
const copyTimer = useRef< ReturnType< typeof setTimeout > | undefined >();
|
|
18
|
+
|
|
19
|
+
const copyRef = useCopyToClipboard( textToCopy, () => {
|
|
20
|
+
if ( copyTimer.current ) {
|
|
21
|
+
clearTimeout( copyTimer.current );
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setHasCopied( true );
|
|
25
|
+
|
|
26
|
+
onCopy?.();
|
|
27
|
+
|
|
28
|
+
copyTimer.current = setTimeout( () => {
|
|
29
|
+
setHasCopied( false );
|
|
30
|
+
copyTimer.current = undefined;
|
|
31
|
+
}, 3000 );
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
useEffect( () => {
|
|
35
|
+
// Clear copyTimer on component unmount.
|
|
36
|
+
return () => {
|
|
37
|
+
if ( copyTimer.current ) {
|
|
38
|
+
clearTimeout( copyTimer.current );
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}, [] );
|
|
42
|
+
|
|
43
|
+
let icon: React.ReactNode = null;
|
|
44
|
+
let label: React.ReactNode = null;
|
|
45
|
+
|
|
46
|
+
if ( 'text' !== buttonStyle ) {
|
|
47
|
+
icon = hasCopied ? <CheckmarkIcon /> : <ClipboardIcon />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const defaultLabel = __( 'Copy to clipboard', 'jetpack' );
|
|
51
|
+
|
|
52
|
+
if ( 'icon' !== buttonStyle ) {
|
|
53
|
+
label = hasCopied ? __( 'Copied!', 'jetpack' ) : defaultLabel;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Button
|
|
58
|
+
aria-label={ defaultLabel }
|
|
59
|
+
icon={ icon }
|
|
60
|
+
children={ label }
|
|
61
|
+
ref={ copyRef }
|
|
62
|
+
{ ...buttonProps }
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default CopyToClipboard;
|
|
@@ -48,6 +48,7 @@ return (
|
|
|
48
48
|
* StarIcon
|
|
49
49
|
* VideopressIcon
|
|
50
50
|
* JetpackIcon
|
|
51
|
+
* ShareIcon
|
|
51
52
|
* FacebookIcon
|
|
52
53
|
* TwitterIcon
|
|
53
54
|
* LinkedinIcon
|
|
@@ -67,6 +68,7 @@ import {
|
|
|
67
68
|
StarIcon,
|
|
68
69
|
VideoPressIcon,
|
|
69
70
|
JetpackIcon,
|
|
71
|
+
ShareIcon,
|
|
70
72
|
FacebookIcon,
|
|
71
73
|
TwitterIcon,
|
|
72
74
|
LinkedinIcon,
|
|
@@ -87,6 +89,7 @@ return (
|
|
|
87
89
|
<StarIcon />
|
|
88
90
|
<VideoPressIcon />
|
|
89
91
|
<JetpackIcon />
|
|
92
|
+
<ShareIcon />
|
|
90
93
|
<FacebookIcon />
|
|
91
94
|
<TwitterIcon />
|
|
92
95
|
<LinkedinIcon />
|
|
@@ -171,6 +171,16 @@ export const CheckmarkIcon: React.FC< BaseIconProps > = ( {
|
|
|
171
171
|
</IconWrapper>
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
+
export const ClipboardIcon: React.FC< BaseIconProps > = ( {
|
|
175
|
+
size,
|
|
176
|
+
className = styles[ 'clipboard-icon' ],
|
|
177
|
+
color,
|
|
178
|
+
} ) => (
|
|
179
|
+
<IconWrapper className={ className } size={ size } color={ color }>
|
|
180
|
+
<Path d="M5.625 5.5H15.375C15.444 5.5 15.5 5.55596 15.5 5.625V15.375C15.5 15.444 15.444 15.5 15.375 15.5H5.625C5.55596 15.5 5.5 15.444 5.5 15.375V5.625C5.5 5.55596 5.55596 5.5 5.625 5.5ZM4 5.625C4 4.72754 4.72754 4 5.625 4H15.375C16.2725 4 17 4.72754 17 5.625V10V15.375C17 16.2725 16.2725 17 15.375 17C15.375 17 6.52246 17 5.625 17C4.72754 17 4 16.2725 4 15.375V5.625ZM18.5 17.2812V8.28125H20V17.2812C20 18.7995 18.7704 20 17.2511 20H6.25V18.5H17.2511C17.9409 18.5 18.5 17.9721 18.5 17.2812Z" />
|
|
181
|
+
</IconWrapper>
|
|
182
|
+
);
|
|
183
|
+
|
|
174
184
|
export const JetpackIcon: React.FC< BaseIconProps > = ( {
|
|
175
185
|
size,
|
|
176
186
|
className = styles.jetpack,
|
|
@@ -188,6 +198,19 @@ export const JetpackIcon: React.FC< BaseIconProps > = ( {
|
|
|
188
198
|
);
|
|
189
199
|
};
|
|
190
200
|
|
|
201
|
+
export const ShareIcon: React.FC< BaseIconProps > = ( { size = 16, className, color } ) => {
|
|
202
|
+
return (
|
|
203
|
+
<IconWrapper className={ className } size={ size } color={ color } viewBox="0 0 16 16">
|
|
204
|
+
<Path
|
|
205
|
+
fill="#161722"
|
|
206
|
+
fillRule="evenodd"
|
|
207
|
+
d="M8.3 4.66C3.85 5.308.727 9.75.034 13.69l-.02.117c-.137.842.809 1.232 1.446.68 2.013-1.745 3.648-2.475 5.318-2.719a10.482 10.482 0 011.524-.103v2.792c0 .694.82 1.041 1.3.55l6.176-6.307a.79.79 0 00.012-1.088L9.614 1.004C9.14.496 8.301.84 8.301 1.542v3.117zm1.525-1.175v1.85a.773.773 0 01-.654.77l-.655.096c-2.133.311-3.987 1.732-5.295 3.672-.472.7-.854 1.44-1.143 2.18a12.32 12.32 0 011.675-.972c1.58-.75 3.048-.972 4.548-.972h.762a.77.77 0 01.762.779v1.69l4.347-4.44-4.347-4.653z"
|
|
208
|
+
clipRule="evenodd"
|
|
209
|
+
></Path>
|
|
210
|
+
</IconWrapper>
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
|
|
191
214
|
/**
|
|
192
215
|
* Wrapper of the Social Icons. Adds a default CSS class.
|
|
193
216
|
*
|
|
@@ -307,6 +330,18 @@ export const MastodonIcon: React.FC< SocialIconWrapperProps > = ( { fill, size,
|
|
|
307
330
|
);
|
|
308
331
|
};
|
|
309
332
|
|
|
333
|
+
export const WhatsAppIcon: React.FC< SocialIconWrapperProps > = ( { fill, size, className } ) => {
|
|
334
|
+
return (
|
|
335
|
+
<SocialIconWrapper
|
|
336
|
+
fill={ fill }
|
|
337
|
+
size={ size }
|
|
338
|
+
className={ classNames( styles.whatsapp, className ) }
|
|
339
|
+
>
|
|
340
|
+
<Path d="M 12.011719 2 C 6.5057187 2 2.0234844 6.478375 2.0214844 11.984375 C 2.0204844 13.744375 2.4814687 15.462563 3.3554688 16.976562 L 2 22 L 7.2324219 20.763672 C 8.6914219 21.559672 10.333859 21.977516 12.005859 21.978516 L 12.009766 21.978516 C 17.514766 21.978516 21.995047 17.499141 21.998047 11.994141 C 22.000047 9.3251406 20.962172 6.8157344 19.076172 4.9277344 C 17.190172 3.0407344 14.683719 2.001 12.011719 2 z M 12.009766 4 C 14.145766 4.001 16.153109 4.8337969 17.662109 6.3417969 C 19.171109 7.8517969 20.000047 9.8581875 19.998047 11.992188 C 19.996047 16.396187 16.413812 19.978516 12.007812 19.978516 C 10.674812 19.977516 9.3544062 19.642812 8.1914062 19.007812 L 7.5175781 18.640625 L 6.7734375 18.816406 L 4.8046875 19.28125 L 5.2851562 17.496094 L 5.5019531 16.695312 L 5.0878906 15.976562 C 4.3898906 14.768562 4.0204844 13.387375 4.0214844 11.984375 C 4.0234844 7.582375 7.6067656 4 12.009766 4 z M 8.4765625 7.375 C 8.3095625 7.375 8.0395469 7.4375 7.8105469 7.6875 C 7.5815469 7.9365 6.9355469 8.5395781 6.9355469 9.7675781 C 6.9355469 10.995578 7.8300781 12.182609 7.9550781 12.349609 C 8.0790781 12.515609 9.68175 15.115234 12.21875 16.115234 C 14.32675 16.946234 14.754891 16.782234 15.212891 16.740234 C 15.670891 16.699234 16.690438 16.137687 16.898438 15.554688 C 17.106437 14.971687 17.106922 14.470187 17.044922 14.367188 C 16.982922 14.263188 16.816406 14.201172 16.566406 14.076172 C 16.317406 13.951172 15.090328 13.348625 14.861328 13.265625 C 14.632328 13.182625 14.464828 13.140625 14.298828 13.390625 C 14.132828 13.640625 13.655766 14.201187 13.509766 14.367188 C 13.363766 14.534188 13.21875 14.556641 12.96875 14.431641 C 12.71875 14.305641 11.914938 14.041406 10.960938 13.191406 C 10.218937 12.530406 9.7182656 11.714844 9.5722656 11.464844 C 9.4272656 11.215844 9.5585938 11.079078 9.6835938 10.955078 C 9.7955938 10.843078 9.9316406 10.663578 10.056641 10.517578 C 10.180641 10.371578 10.223641 10.267562 10.306641 10.101562 C 10.389641 9.9355625 10.347156 9.7890625 10.285156 9.6640625 C 10.223156 9.5390625 9.737625 8.3065 9.515625 7.8125 C 9.328625 7.3975 9.131125 7.3878594 8.953125 7.3808594 C 8.808125 7.3748594 8.6425625 7.375 8.4765625 7.375 z" />
|
|
341
|
+
</SocialIconWrapper>
|
|
342
|
+
);
|
|
343
|
+
};
|
|
344
|
+
|
|
310
345
|
const jetpackIcons = {
|
|
311
346
|
'anti-spam': AntiSpamIcon,
|
|
312
347
|
backup: BackupIcon,
|
|
@@ -320,6 +355,7 @@ const jetpackIcons = {
|
|
|
320
355
|
star: StarIcon,
|
|
321
356
|
videopress: VideopressIcon,
|
|
322
357
|
jetpack: JetpackIcon,
|
|
358
|
+
share: ShareIcon,
|
|
323
359
|
};
|
|
324
360
|
|
|
325
361
|
const socialIcons = {
|
|
@@ -330,6 +366,7 @@ const socialIcons = {
|
|
|
330
366
|
tumblr: TumblrIcon,
|
|
331
367
|
google: GoogleIcon,
|
|
332
368
|
mastodon: MastodonIcon,
|
|
369
|
+
whatsapp: WhatsAppIcon,
|
|
333
370
|
};
|
|
334
371
|
|
|
335
372
|
const iconsMap = {
|
package/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { default as Col } from './components/layout/col';
|
|
|
37
37
|
export { default as Testimonials } from './components/testimonials';
|
|
38
38
|
export { default as Container } from './components/layout/container';
|
|
39
39
|
export { default as useBreakpointMatch } from './components/layout/use-breakpoint-match';
|
|
40
|
+
export { default as CopyToClipboard } from './components/copy-to-clipboard';
|
|
40
41
|
export * from './components/icons';
|
|
41
42
|
export { default as SplitButton } from './components/split-button';
|
|
42
43
|
export { default as ThemeProvider } from './components/theme-provider';
|