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

278 inputgroup flexbox #279

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
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
50 changes: 49 additions & 1 deletion examples/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,59 @@ class App extends PureComponent<{}, AppState> {
</Row>

<Row>
<Column>
<Column xs={12} sm={6}>
<h3>Using DIVs as Buttons</h3>
<InputGroup>
<input type="number" />
<Button component="div" tabIndex={0}>
Done
</Button>
</InputGroup>

<InputGroup block>
<InputGroupAddon>$</InputGroupAddon>
<input type="number" />
<Button component="div" tabIndex={0}>
Done
</Button>
</InputGroup>

<InputGroup>
<Button component="div" tabIndex={0}>
1
</Button>
<Button component="div" tabIndex={0}>
2
</Button>
<Button component="div" tabIndex={0}>
3
</Button>
<Button component="div" tabIndex={0}>
4
</Button>
</InputGroup>
</Column>
<Column xs={12} sm={6}>
<h3>Using Buttons</h3>
<InputGroup>
<InputGroupAddon>£</InputGroupAddon>
<input type="number" />
</InputGroup>
<InputGroup block>
<InputGroupAddon>£</InputGroupAddon>
<input type="number" />
<Button>I'm a button!</Button>
</InputGroup>
<InputGroup>
<input type="number" />
<Button>Send Button</Button>
</InputGroup>
<InputGroup block>
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
<Button>Button 4</Button>
</InputGroup>
</Column>
</Row>

Expand Down
83 changes: 39 additions & 44 deletions src/less/inputs.less
Original file line number Diff line number Diff line change
Expand Up @@ -131,66 +131,61 @@ textarea {
}

.input-group {
display: inline-table !important; // lesshint importantRule: false
display: inline-flex;
width: auto;
margin-top: @margin-large;
margin-bottom: @margin-large;
margin: @margin-large auto;
border-collapse: separate;
border-spacing: 0;

&.block {
display: table;
width: 100%;
input,
button,
.button,
.input-group-addon {
border: @input-border;
border-left-width: 0;
min-height: @input-height;
}

& > * { // lesshint universalSelector: false
width: 1px;
/* IE10 layout fix */
div.button {
overflow: inherit;
}

& > label,
& > input,
& > select,
& > button,
& > .input-group-addon,
& > .input,
& > .select,
& > .label,
& > .button {
display: table-cell;
margin-top: 0;
margin-bottom: 0;
border: @input-border;
border-right: @border-none;

&:first-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
& > *:first-child { // lesshint universalSelector: false
border-left: @input-border;
border-top-left-radius: @border-radius-base;
border-bottom-left-radius: @border-radius-base;
}

&:last-child {
border: @input-border;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
& > *:last-child { // lesshint universalSelector: false
border-top-right-radius: @border-radius-base;
border-bottom-right-radius: @border-radius-base;
}

&:not(:last-child):not(:first-child) {
border-radius: 0;
}
& > * { // lesshint universalSelector: false
display: inline-block;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think swapping this for inline-flex might fix it in IE9-10.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no because this is a selector for the children, not the parent. inline-block is fine, and is overridden by the flex declaration on the parent. Have now fixed all IE alignment issues FTW 👍

border-left-width: none;
border-radius: 0;
}

& > input,
& > select,
& > .input,
& > .select {
&.block {
display: flex;
width: 100%;
}

& > .input-group-addon {
vertical-align: middle;
.input-group-addon {
display: inline-flex;
height: @input-height;
padding: @padding-base / 2 @padding-base;
border-radius: @border-radius-base;
background-color: @input-group-addon-background;
line-height: 1em;
align-items: center;
}

& > input,
& > .input,
& > select,
& > .select {
flex-grow: 1;
justify-self: stretch;
height: auto;
}
}