UNPKG

@wordpress/block-editor

Version:
55 lines (49 loc) 1.13 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@wordpress/element"; /** * External dependencies */ import { isEmpty } from 'lodash'; /** * WordPress dependencies */ import { SelectControl } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import useEditorFeature from '../use-editor-feature'; export default function FontFamilyControl({ value = '', onChange, fontFamilies, ...props }) { const blockLevelFontFamilies = useEditorFeature('typography.fontFamilies'); if (!fontFamilies) { fontFamilies = blockLevelFontFamilies; } if (isEmpty(fontFamilies)) { return null; } const options = [{ value: '', label: __('Default') }, ...fontFamilies.map(({ fontFamily, name }) => { return { value: fontFamily, label: name || fontFamily }; })]; return createElement(SelectControl, _extends({ label: __('Font family'), options: options, value: value, onChange: onChange, labelPosition: "top" }, props)); } //# sourceMappingURL=index.js.map