Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds super select to font picker #23855

Merged
merged 2 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.