Skip to content

Commit

Permalink
Beeter demo, proper select size
Browse files Browse the repository at this point in the history
  • Loading branch information
kybarg committed Mar 8, 2017
1 parent cb094cf commit 0526359
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
32 changes: 17 additions & 15 deletions docs/site/src/demos/select-field/SimpleSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import MenuItem from 'material-ui/Menu/MenuItem';
import Icon from 'material-ui/Icon';

const styleSheet = createStyleSheet('SimpleSelectField', (theme) => ({
select: {
selectBox: {
display: 'inline-flex',
margin: 8,
}
}));
Expand All @@ -29,19 +30,20 @@ export default class SimpleSelectField extends Component {

return (
<div>
<SelectField
label="Sample"
value={this.state.value}
onChange={this.handleChange}
className={classes.select}
>
<MenuItem value=''>None</MenuItem>
<MenuItem value={1}>One</MenuItem>
<MenuItem value={2}>Two</MenuItem>
<MenuItem value={3}>Three</MenuItem>
</SelectField>

<SelectField
<div className={classes.selectBox}>
<SelectField
label="Sample"
value={this.state.value}
onChange={this.handleChange}
>
<MenuItem value=''>None</MenuItem>
<MenuItem value={1}>One</MenuItem>
<MenuItem value={2}>Two</MenuItem>
<MenuItem value={3}>Three</MenuItem>
</SelectField>
</div>
<div className={classes.selectBox}>
<SelectField
label="Sample"
hideLabel={true}
value={this.state.value}
Expand All @@ -53,7 +55,7 @@ export default class SimpleSelectField extends Component {
<MenuItem value={2}>Two</MenuItem>
<MenuItem value={3}>Three</MenuItem>
</SelectField>

</div>
</div>
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/SelectField/SelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import Menu from 'material-ui/Menu/Menu';

// import DropDownMenu from '../DropDownMenu';

export const styleSheet = createStyleSheet('MuiButton', (theme) => {
export const styleSheet = createStyleSheet('MuiSelectField', (theme) => {
return {
label: {
paddingLeft: 0,
},
menu: {
},
icon: {
right: 0,
},
Expand Down Expand Up @@ -142,11 +144,13 @@ class SelectField extends Component {
onMouseDown={this.handleMouseDown}
onClick={this.handleClick}
component={SelectFieldInput}
label={label}
options={children}
{...inputProps}
/>
<Menu
anchorEl={this.state.anchorEl}
className={classes.menu}
open={this.state.open}
onRequestClose={this.handleRequestClose}
{...menuProps}
Expand Down
7 changes: 6 additions & 1 deletion src/SelectField/SelectFieldInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const styleSheet = createStyleSheet('MuiSelectFieldInput', (theme) => {
position: 'relative',
zIndex: 2,
},
labelHolder: {
display: 'none',
},
icon: {
color: theme.palette.text.secondary,
position: 'absolute',
Expand All @@ -37,10 +40,12 @@ export default class SelectFieldInput extends Component {

render() {
const classes = this.context.styleManager.render(styleSheet)
const { options, ...inputprops } = this.props
const { label, options, ...inputprops } = this.props
return (
<div className={classes.root}>
<select {...inputprops} className={classNames(this.props.className, classes.select)}>
{/* Need this option for proper select sizing */}
<option className={classes.labelHolder}>{label}</option>
{React.Children.map(options, (option, index) =>
React.createElement('option', {
key: index,
Expand Down

0 comments on commit 0526359

Please sign in to comment.