Skip to content

Commit

Permalink
Adds super select to font picker (elastic#23855)
Browse files Browse the repository at this point in the history
* Adds super select to font picker. Removes fauxSelect component

* Removed import for font_picker.scss
  • Loading branch information
cqliu1 committed Oct 10, 2018
1 parent fcaa287 commit 89e700f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 102 deletions.
31 changes: 0 additions & 31 deletions x-pack/plugins/canvas/public/components/faux_select/faux_select.js

This file was deleted.

10 changes: 0 additions & 10 deletions x-pack/plugins/canvas/public/components/faux_select/index.js

This file was deleted.

52 changes: 12 additions & 40 deletions x-pack/plugins/canvas/public/components/font_picker/font_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,22 @@

import React from 'react';
import PropTypes from 'prop-types';
import { EuiLink } from '@elastic/eui';
import { EuiSuperSelect } from '@elastic/eui';
import { fonts } from '../../../common/lib/fonts';
import { Popover } from '../popover';
import { FauxSelect } from '../faux_select';

export const FontPicker = ({ onSelect, value, anchorPosition }) => {
const selected = fonts.find(font => font.value === value) || { label: value, value };

// TODO: replace faux select with better EUI custom select or dropdown when it becomes available
const popoverButton = handleClick => (
<FauxSelect handleClick={handleClick}>
<div style={{ fontFamily: selected.value }}>{selected.label}</div>
</FauxSelect>
);

return (
<Popover
id="font-picker-popover"
className="canvasFontPicker__wrapper"
button={popoverButton}
panelClassName="canvasFontPicker__popover"
anchorPosition={anchorPosition}
panelPaddingSize="none"
>
{() => (
<div className="canvasFontPicker">
{fonts.map(font => (
<EuiLink
key={font.label}
className="canvasFontPicker__font"
style={{ fontFamily: font.value }}
onClick={() => onSelect(font.value)}
>
{font.label}
</EuiLink>
))}
</div>
)}
</Popover>
);
};
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)}
/>
);

FontPicker.propTypes = {
value: PropTypes.string,
onSelect: PropTypes.func,
anchorPosition: PropTypes.string,
};

This file was deleted.

1 change: 0 additions & 1 deletion x-pack/plugins/canvas/public/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@import '../components/element_content/element_content';
@import '../components/element_types/element_types';
@import '../components/expression_input/suggestion';
@import '../components/font_picker/font_picker';
@import '../components/fullscreen/fullscreen';
@import '../components/function_form/function_form';
@import '../components/hover_annotation/hover_annotation';
Expand Down

0 comments on commit 89e700f

Please sign in to comment.