-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
component.tsx
46 lines (41 loc) · 1.19 KB
/
component.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* WordPress dependencies
*/
import { link, linkOff } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import Button from '../../button';
import Tooltip from '../../tooltip';
import { View } from '../../view';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import { useBorderBoxControlLinkedButton } from './hook';
import type { LinkedButtonProps } from '../types';
const BorderBoxControlLinkedButton = (
props: WordPressComponentProps< LinkedButtonProps, 'div' >,
forwardedRef: React.ForwardedRef< any >
) => {
const { className, isLinked, ...buttonProps } =
useBorderBoxControlLinkedButton( props );
const label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );
return (
<Tooltip text={ label }>
<View className={ className }>
<Button
{ ...buttonProps }
isSmall
icon={ isLinked ? link : linkOff }
iconSize={ 24 }
aria-label={ label }
ref={ forwardedRef }
/>
</View>
</Tooltip>
);
};
const ConnectedBorderBoxControlLinkedButton = contextConnect(
BorderBoxControlLinkedButton,
'BorderBoxControlLinkedButton'
);
export default ConnectedBorderBoxControlLinkedButton;