Add types for custom font-family select options
[MAILPOET-4323]
This commit is contained in:
@@ -15,6 +15,14 @@ const standardFonts = [
|
|||||||
'Verdana',
|
'Verdana',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
type Option = {
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
selectable: boolean;
|
||||||
|
value?: string;
|
||||||
|
style?: CSSProperties;
|
||||||
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onChange: (value: string | undefined) => void;
|
onChange: (value: string | undefined) => void;
|
||||||
value?: string;
|
value?: string;
|
||||||
@@ -42,7 +50,7 @@ export function FontFamilySettings({
|
|||||||
cursor: 'default',
|
cursor: 'default',
|
||||||
marginLeft: 16,
|
marginLeft: 16,
|
||||||
});
|
});
|
||||||
const options = [
|
const options: Option[] = [
|
||||||
{
|
{
|
||||||
key: MailPoet.I18n.t('formFontsDefaultTheme'),
|
key: MailPoet.I18n.t('formFontsDefaultTheme'),
|
||||||
name: MailPoet.I18n.t('formFontsDefaultTheme'),
|
name: MailPoet.I18n.t('formFontsDefaultTheme'),
|
||||||
@@ -90,8 +98,9 @@ export function FontFamilySettings({
|
|||||||
<CustomSelectControl
|
<CustomSelectControl
|
||||||
options={options}
|
options={options}
|
||||||
onChange={(selected): void => {
|
onChange={(selected): void => {
|
||||||
if (selected.selectedItem.selectable) {
|
const selectedItem = selected.selectedItem as Option;
|
||||||
onChange(selected.selectedItem.value as string);
|
if (selectedItem.selectable) {
|
||||||
|
onChange(selectedItem.value);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
value={selectedValue}
|
value={selectedValue}
|
||||||
|
Reference in New Issue
Block a user