Skip to content

Commit e7c616b

Browse files
authored
Merge pull request #198 from youda97/inline-select
Add inline select component
2 parents 9c5210f + f1d1480 commit e7c616b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/select/select.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
2828
selector: "ibm-select",
2929
template: `
3030
<div class="bx--form-item">
31-
<div class="bx--select">
31+
<div
32+
[ngClass]="{'bx--select--inline': display === 'inline'}"
33+
class="bx--select">
3234
<label [attr.for]="id" class="bx--label">{{label}}</label>
3335
<select
3436
#select
@@ -57,6 +59,11 @@ export class Select implements ControlValueAccessor {
5759
* Tracks the total number of selects instantiated. Used to generate unique IDs
5860
*/
5961
static selectCount = 0;
62+
63+
/**
64+
* `inline` or `default` select displays
65+
*/
66+
@Input() display: "inline" | "default" = "default";
6067
/**
6168
* Label for the select. Appears above the input.
6269
*/

src/select/select.stories.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ storiesOf("Select", module).addDecorator(
2626
</ibm-select>
2727
`
2828
}))
29+
.add("Inline", () => ({
30+
template: `
31+
<ibm-select display="inline">
32+
<option value="" disabled selected hidden>Choose an option</option>
33+
<option value="solong">A much longer option that is worth having around to check how text flows</option>
34+
<optgroup label="Category 1">
35+
<option value="option1">Option 1</option>
36+
<option value="option2">Option 2</option>
37+
</optgroup>
38+
<optgroup label="Category 2">
39+
<option value="option1">Option 1</option>
40+
<option value="option2">Option 2</option>
41+
</optgroup>
42+
</ibm-select>
43+
`
44+
}))
2945
.add("With ngModel", () => ({
3046
template: `
3147
<ibm-select [(ngModel)]="model">

0 commit comments

Comments
 (0)