Fixes font picker when using custom fonts (#24937)

* Adds custom font as option in font picker

* Adjusted font sizes in ecommerce sample worpad

* Adjusted font sizes in sample flight workpad

* Adjusted font sizes in smaple web logs workpad
This commit is contained in:
Catherine Liu 2018-11-01 14:16:26 -07:00 committed by GitHub
parent 8efd352912
commit ffe24a8318
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 1775 additions and 1775 deletions

View file

@ -9,17 +9,25 @@ import PropTypes from 'prop-types';
import { EuiSuperSelect } from '@elastic/eui';
import { fonts } from '../../../common/lib/fonts';
export const FontPicker = ({ onSelect, value }) => (
<EuiSuperSelect
compressed
options={fonts.map(({ value, label }) => ({
value,
inputDisplay: <div style={{ fontFamily: value }}>{label}</div>,
}))}
valueOfSelected={value}
onChange={value => onSelect(value)}
/>
);
export const FontPicker = ({ onSelect, value }) => {
if (value && !fonts.find(font => font.value === value)) {
const label = (value.indexOf(',') >= 0 ? value.split(',')[0] : value).replace(/['"]/g, '');
fonts.push({ value, label });
fonts.sort((a, b) => a.label.localeCompare(b.label));
}
return (
<EuiSuperSelect
compressed
options={fonts.map(({ value, label }) => ({
value,
inputDisplay: <div style={{ fontFamily: value }}>{label}</div>,
}))}
valueOfSelected={value}
onChange={value => onSelect(value)}
/>
);
};
FontPicker.propTypes = {
value: PropTypes.string,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long