Skip to content

Commit

Permalink
Fixes font picker when using custom fonts (elastic#24937)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
cqliu1 committed Nov 1, 2018
1 parent e7a3bba commit 1b64020
Show file tree
Hide file tree
Showing 4 changed files with 1,783 additions and 1,783 deletions.
30 changes: 19 additions & 11 deletions x-pack/plugins/canvas/public/components/font_picker/font_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 1b64020

Please sign in to comment.