-
Notifications
You must be signed in to change notification settings - Fork 4k
/
collection-font-variant.js
58 lines (53 loc) · 1.23 KB
/
collection-font-variant.js
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
47
48
49
50
51
52
53
54
55
56
57
58
/**
* WordPress dependencies
*/
import {
CheckboxControl,
Flex,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
/**
* Internal dependencies
*/
import { getFontFaceVariantName } from './utils';
import FontDemo from './font-demo';
import { unlock } from '../../../lock-unlock';
function CollectionFontVariant( {
face,
font,
handleToggleVariant,
selected,
} ) {
const handleToggleActivation = () => {
if ( font?.fontFace ) {
handleToggleVariant( font, face );
return;
}
handleToggleVariant( font );
};
const displayName = font.name + ' ' + getFontFaceVariantName( face );
const { kebabCase } = unlock( componentsPrivateApis );
const checkboxId = kebabCase(
`${ font.slug }-${ getFontFaceVariantName( face ) }`
);
return (
<div className="font-library-modal__font-card">
<Flex justify="flex-start" align="center" gap="1rem">
<CheckboxControl
checked={ selected }
onChange={ handleToggleActivation }
__nextHasNoMarginBottom={ true }
id={ checkboxId }
/>
<label htmlFor={ checkboxId }>
<FontDemo
font={ face }
text={ displayName }
onClick={ handleToggleActivation }
/>
</label>
</Flex>
</div>
);
}
export default CollectionFontVariant;