Add types for custom font-family select options

[MAILPOET-4323]
This commit is contained in:
Jan Jakes
2022-05-10 14:09:35 +02:00
committed by Veljko V
parent ec89251db2
commit 2b27f537f9

View File

@@ -15,6 +15,14 @@ const standardFonts = [
'Verdana',
];
type Option = {
key: string;
name: string;
selectable: boolean;
value?: string;
style?: CSSProperties;
};
type Props = {
onChange: (value: string | undefined) => void;
value?: string;
@@ -42,7 +50,7 @@ export function FontFamilySettings({
cursor: 'default',
marginLeft: 16,
});
const options = [
const options: Option[] = [
{
key: MailPoet.I18n.t('formFontsDefaultTheme'),
name: MailPoet.I18n.t('formFontsDefaultTheme'),
@@ -90,8 +98,9 @@ export function FontFamilySettings({
<CustomSelectControl
options={options}
onChange={(selected): void => {
if (selected.selectedItem.selectable) {
onChange(selected.selectedItem.value as string);
const selectedItem = selected.selectedItem as Option;
if (selectedItem.selectable) {
onChange(selectedItem.value);
}
}}
value={selectedValue}