react-suggest
Version:
Pure react-based autosuggest with ajax suggestion list population
164 lines (150 loc) • 2.83 kB
CSS
/**
* Resets
*/
*, :before, :after {
margin: 0;
padding: 0;
position: relative;
box-sizing: border-box;
}
input, select, button, textarea {
-webkit-appearance: none;
-moz-appearance: none;
-moz-appearance: none;
font: inherit;
color: inherit;
}
/**
* Base
*/
html {
font: 112.5%/1.2 "Roboto", Arial, sans-serif;
color: #3d464d;
background-color: #fff;
font-weight: 300;
-webkit-font-smoothing: antialiased;
width: 100%;
height: 100%;
overflow: hidden-x;
text-align: center;
}
body {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 100%;
height: 100%;
}
.container {
-webkit-box-flex: 0;
-webkit-flex: 0 0 auto;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
max-width: 612px;
max-width: 34rem;
}
a {
color: #3d464d;
-webkit-transition: color 0.2s;
transition: color 0.2s;
}
a:hover, a:focus {
color: #267dc0;
}
h1 {
font-size: 72px;
font-size: 4rem;
font-weight: 100;
margin-bottom: .5em;
color: #267dc0;
}
.subheader {
font-weight: 300;
margin-bottom: 1.5em;
}
.hint {
color: #ccc;
margin: 2em 0;
}
.footer {
font-weight: 300;
padding-top: 2em;
margin-top: 2em;
border-top: 1px solid #ccc;
}
/**
* The autosuggest module
*/
.autosuggest {
font-size: 18px;
font-size: 1rem;
position: relative;
width: 80%;
margin: 1em auto;
text-align: left;
}
.autosuggest__input {
width: 100%;
border: 2px solid transparent;
box-shadow: 0 0 1px #3d464d;
padding: .5em 1em;
-webkit-transition: border 0.2s, box-shadow 0.2s;
transition: border 0.2s, box-shadow 0.2s;
}
.autosuggest__input:focus {
border-color: #267dc0;
box-shadow: 0 0 0 transparent;
}
.autosuggest__suggests {
position: absolute;
top: 100%;
left: 0;
right: 0;
max-height: 25em;
padding: 0;
margin-top: -1px;
background: #fff;
border: 2px solid #267dc0;
border-top-width: 0;
overflow-x: hidden;
overflow-y: auto;
list-style: none;
z-index: 5;
-webkit-transition: max-height 0.2s, border 0.2s;
transition: max-height 0.2s, border 0.2s;
}
.autosuggest__suggests--hidden {
max-height: 0;
overflow: hidden;
border-width: 0;
}
/**
* A autosuggest item
*/
.autosuggest-item {
font-size: 18px;
font-size: 1rem;
padding: .5em .65em;
cursor: pointer;
}
.autosuggest-item:hover,
.autosuggest-item:focus {
background: #f5f5f5;
}
.autosuggest-item--active {
background: #267dc0;
color: #fff;
}
.autosuggest-item--active:hover,
.autosuggest-item--active:focus {
background: #ccc;
}