Added IconPicker listStyle prop

This commit is contained in:
David Douglas 2017-08-25 10:38:55 +01:00
Родитель b5a6c3e054
Коммит 850ff4c561
2 изменённых файлов: 8 добавлений и 10 удалений

Просмотреть файл

@ -4,15 +4,10 @@ import FontIcon from 'react-md/lib/FontIcons';
import icons from '../../constants/icons';
const styles = {
list: {
height: '136px',
} as React.CSSProperties
};
interface IIconPickerProps {
defaultLabel?: string;
defaultIcon?: string;
listStyle?: React.CSSProperties;
}
interface IIconPickerState {
@ -25,6 +20,7 @@ export default class IconPicker extends React.Component<IIconPickerProps, IIconP
static defaultProps = {
defaultLabel: 'Search icons',
defaultIcon: 'dashboard',
listStyle: {},
};
static listItems: any = [];
@ -53,12 +49,13 @@ export default class IconPicker extends React.Component<IIconPickerProps, IIconP
componentWillMount() {
if (IconPicker.listItems.length === 0) {
IconPicker.listItems = icons.map((icon, i) => ({ icon, leftIcon: <FontIcon key="icon">{icon}</FontIcon> }));
IconPicker.listItems = icons.map((icon) => ({ icon, leftIcon: <FontIcon key="icon">{icon}</FontIcon> }));
}
}
render() {
const { label, icon } = this.state;
const { listStyle } = this.props;
return (
<Autocomplete
id="icon"
@ -66,7 +63,7 @@ export default class IconPicker extends React.Component<IIconPickerProps, IIconP
className="md-cell--stretch"
data={IconPicker.listItems}
dataLabel={'icon'}
listStyle={styles.list}
listStyle={listStyle}
value={icon}
onChange={this.onChange}
onAutocomplete={this.onChange}

Просмотреть файл

@ -423,7 +423,8 @@ export default class Home extends React.Component<any, IHomeState> {
<IconPicker
ref={field => this._fieldIcon = field}
defaultLabel="Dashboard Icon"
defaultIcon={template && template.icon || 'dashboard'} />
defaultIcon={template && template.icon || 'dashboard'}
listStyle={{height: '136px'}} />
<TextField
id="id"
ref={field => this._fieldId = field}