1 import Option from '@proton/components/components/option/Option';
2 import SelectTwo from '@proton/components/components/selectTwo/SelectTwo';
4 import { DEFAULT_FONT_FACE, FONT_FACES } from '../../components/editor/constants';
9 onChange: (value: string) => void;
13 const options = Object.values(FONT_FACES).map(({ label: text, value }) => ({ text, value: value.toLowerCase() }));
15 const FontFaceSelect = ({ id, fontFace, onChange, loading, ...rest }: Props) => {
16 const isValid = fontFace && options.some((option) => option.value === fontFace.toLowerCase());
17 // FontFace default API value is null and it doesn't trigger default parameter value
18 const fontFaceValue = isValid ? fontFace.toLowerCase() : DEFAULT_FONT_FACE.toLowerCase();
25 onChange={({ value: selectedValue }) => {
26 const option = Object.values(FONT_FACES).find(({ value }) => value.toLowerCase() === selectedValue);
29 onChange(option.value);
34 {options.map(({ text, value }) => (
35 <Option key={value} title={text} value={value} />
41 export default FontFaceSelect;