Skip to content

Commit

Permalink
feat(select): Styled select elements, both inline and as a list item
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Apr 3, 2014
1 parent 9725793 commit 8a12f2d
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 35 deletions.
16 changes: 1 addition & 15 deletions scss/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ textarea {
// -------------------------------

// Shared size and type resets
select,
textarea,
input[type="text"],
input[type="password"],
Expand Down Expand Up @@ -232,24 +231,11 @@ input[type="checkbox"] {
width: auto; // Override of generic input selector
}

// Make multiple select elements height not fixed
select[multiple],
select[size] {
height: auto;
}

// Set the height of select and file controls to match text inputs
select,
// Set the height of file to match text inputs
input[type="file"] {
line-height: $input-height-base;
}

// Make select elements obey height by applying a border
select {
border: $input-border-width solid $input-border;
background-color: $input-bg; // Chrome on Linux and Mobile Safari need background-color
}


// Placeholder
// -------------------------------
Expand Down
94 changes: 94 additions & 0 deletions scss/_select.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

/**
* Select
* --------------------------------------------------
*/


// shared styles for transparent select elements
.select-inline select,
.item-select select {
@include appearance(none);
border: none;
background: transparent;
color: #333;

// hack to hide default dropdown arrow in FF
text-indent: 1px;
text-overflow: '';

white-space: nowrap;
font-size: $font-size-base;
}

.select-inline {
position: relative;
display: inline-block;
overflow: hidden;
border: $input-border-width solid $input-border;
border-radius: 2px;
background-color: $input-bg;
color: $input-color;

vertical-align: middle;
font-size: $font-size-base;
line-height: $font-size-base + 2;

select {
padding: 6px 25px 7px 8px;
}
}

.select-inline + .select-inline {
margin-left: 6px;
}

.item-select {
position: static; // required for Android 2.3

select {
position: absolute;
top: 0;
right: 0;
padding: ($item-padding - 2) ($item-padding * 3) ($item-padding) 5px;
width: 100%;
direction: rtl; // right align the select text

&:focus {
min-width: 20%;
width: auto; // shrink width when opened
}
}
}


// shared styles for dropdown arrow
.select-inline:after,
.item-select:after {
position: absolute;
top: 50%;
margin-top: -3px;
width: 0;
height: 0;
border-top: 5px solid;
border-right: 5px solid rgba(0, 0, 0, 0);
border-left: 5px solid rgba(0, 0, 0, 0);
color: #999;
content: "";
pointer-events: none;
}

.select-inline:after {
right: 7px;
}

.item-select:after {
right: $item-padding;
}

select {
&[multiple],
&[size] {
height: auto;
}
}
1 change: 1 addition & 0 deletions scss/ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"toggle",
"radio",
"range",
"select",
"progress",

// Buttons
Expand Down
118 changes: 98 additions & 20 deletions test/html/input-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,124 @@
</head>
<body>

<section>
<header class="bar bar-header bar-dark">
<h1 class="title">Input: Select</h1>
</header>

<header class="bar bar-header bar-dark">
<h1 class="title">Input: Select</h1>
</header>
<main class="content has-header padding">

<main class="content has-header padding">

<p>
<select name="select">
<p>
<select>
<option>Unstyled select element</option>
<option>Unstyled select element</option>
<option>Unstyled select element</option>
</select>
</p>

<p>
<span class="select-inline">
<select>
<option>HTML</option>
<option>CSS</option>
<option>JavaScript</option>
</select>
</p>

<p>
<select name="select">
</span>
</p>

<p>
<span class="select-inline">
<select>
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<select name="select">
</span>
<span class="select-inline">
<select>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="select">
<option>2013</option>
</span>
<span class="select-inline">
<select>
<option>2014</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
<option>2019</option>
<option>2020</option>
</select>
</p>
</span>
</p>

<div class="margin">
<p><a class="button button-secondary" href="./">All CSS Tests</a></p>
<div class="list">

<div class="item item-input item-select">
<div class="input-label">
Select Month
</div>
<select>
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
</div>

</main>
</div>

<div class="margin">
<p><a class="button button-secondary" href="./">All CSS Tests</a></p>
</div>

</section>
</main>

</body>
</html>

0 comments on commit 8a12f2d

Please sign in to comment.