File size: 886 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { ToggleControl } from '@wordpress/components';
import clsx from 'clsx';
import { useTranslate } from 'i18n-calypso';

type EmailMeNewPostsToggleProps = {
	className?: string;
	isDisabled?: boolean;
	hintText?: boolean;
	value: boolean;
	onChange: ( value: boolean ) => void;
};

const EmailMeNewPostsToggle = ( {
	className = '',
	isDisabled = false,
	hintText = false,
	value = false,
	onChange,
}: EmailMeNewPostsToggleProps ) => {
	const translate = useTranslate();

	return (
		<div className={ clsx( 'email-me-new-posts-toggle', className, { 'is-enabled': value } ) }>
			<ToggleControl
				label={ translate( 'Email me new posts' ) }
				onChange={ () => onChange( ! value ) }
				checked={ value }
				disabled={ isDisabled }
			/>
			{ hintText && <div className="email-new-posts-toggle__hint">{ hintText }</div> }
		</div>
	);
};

export default EmailMeNewPostsToggle;