Files
nomad/website/components/search/style.css
2020-08-07 12:36:38 -04:00

370 lines
6.7 KiB
CSS

:root {
--search-bar-height: 40px;
--search-bar-focus-outline: rgba(220, 221, 224, 0.45);
--legend-height: 40px;
--mobile-margin: 24px;
--mobile-margin-negative: -24px;
--nav-height: 64px;
}
.g-search {
/* Allow focus ring to be fully visible on Safari */
padding-top: 3px;
max-width: 600px;
@media (min-width: 768px) and (max-width: 939px) {
margin: 0 0.5rem;
}
/* Remove non-standard clear `X` buttons */
& input::-webkit-search-cancel-button {
display: none;
}
/* Ensure iOS does not round corners */
& input,
& [type='search'],
& input[type='search'] {
border-radius: 2px !important;
-webkit-appearance: none !important;
}
}
/* SearchBox */
.g-search .c-search-box {
display: flex;
& form {
position: relative;
width: 100%;
display: flex;
align-items: center;
}
& input {
width: 100%;
color: var(--gray-4);
border: 1px solid var(--gray-7);
background: var(--gray-7);
padding: 0 8px 0 40px;
height: var(--search-bar-height);
transition: width 0.2s ease-in-out;
cursor: text;
&:placeholder-shown,
&::placeholder {
opacity: 1;
}
&:focus,
&:active,
&:focus-visible {
color: var(--black);
border-color: var(--black);
outline: 3px solid var(--search-bar-focus-outline);
box-shadow: 0 0 3pt 2pt var(--search-bar-focus-outline);
}
}
/* Input styles when search query present */
& input[value]:not([value='']) {
color: var(--black);
border-color: var(--black);
outline: 3px solid var(--search-bar-focus-outline);
box-shadow: 0 0 3pt 2pt var(--search-bar-focus-outline);
}
& .btn-submit {
position: absolute;
left: 0;
background: transparent;
border: 0;
height: 100%;
width: 40px;
padding: 0;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
& > svg {
width: 18px;
/* Nudge */
position: relative;
top: 1px;
}
&:focus,
&:focus-visible {
outline: 1px dotted var(--black);
}
}
/* Submit button styles when search query present */
& input[value]:not([value='']) ~ .btn-submit > svg path {
stroke: var(--black);
}
& .btn-reset {
position: absolute;
right: 0;
height: 100%;
width: 40px;
padding: 0;
background: transparent;
border: none;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
opacity: 0;
pointer-events: none;
& > svg {
width: 10px;
}
&:focus,
&:focus-visible {
outline: 1px dotted var(--black);
}
}
/* Reset button styles when search query present */
& input[value]:not([value='']) ~ .btn-reset {
opacity: 1;
pointer-events: auto;
}
& .icon-loading {
position: absolute;
right: 40px;
display: flex;
justify-content: center;
}
/* Remove unwanted loading flash when no query is present */
& input[value=''] ~ .icon-loading {
display: none;
}
& .icon-slash {
position: absolute;
right: 8px;
top: 8px;
height: 60%;
pointer-events: none;
display: none;
margin: 0; /* reset for generic styles applied to all img */
@media (--medium-up) {
width: 24px;
height: 24px;
display: block;
}
}
/* Reset button styles when search query present */
& input[value]:not([value='']) ~ .icon-slash {
opacity: 0;
}
}
/* Hits */
.g-search .c-hits {
position: relative;
z-index: 890;
& .no-hits {
position: absolute;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
color: #323339;
background: var(--white);
margin: 0;
padding: 0.5rem 1rem;
box-shadow: 0 4px 5px rgba(37, 38, 45, 0.12);
& .title,
& .message {
width: 100%;
}
& .title {
font-size: 15px;
font-weight: var(--font-weight-bold);
}
& .message {
color: var(--gray-3);
font-size: 0.75rem;
}
}
& .hits {
position: absolute;
width: 100%;
box-shadow: 0 4px 5px rgba(37, 38, 45, 0.12);
}
& .hits-list {
list-style: none;
overflow-y: scroll;
background: var(--white);
margin: 0;
padding: 0;
max-height: 45vh;
& .hit-link-wrapper {
width: 100%;
height: 100%;
scroll-behavior: smooth;
&.active > .hit,
&:focus > .hit,
& > .hit:hover {
background: var(--gray-7);
& .icon-return {
opacity: 1;
}
}
}
}
& .hit-item {
margin: 0;
}
& .hit {
pointer-events: inherit;
display: flex;
flex-wrap: nowrap;
padding: 8px 16px;
@media (--small) {
padding-left: var(--mobile-margin);
}
}
& .icon-return {
max-width: 30px;
display: flex;
align-items: center;
opacity: 0;
}
& .hit-content {
pointer-events: inherit;
display: flex;
justify-content: flex-start;
align-items: flex-start;
color: #323339;
flex-wrap: wrap;
width: 100%;
&:first-of-type {
margin-top: 0;
}
&:last-of-type {
margin-bottom: 0;
}
& .name {
font-size: 15px;
font-weight: var(--font-weight-bold);
padding-right: 0.5rem;
}
& .category {
display: flex;
justify-content: flex-start;
}
& .description {
color: var(--gray-3);
font-size: 0.75rem;
margin-bottom: 0.5rem;
width: 100%;
}
& .badge-group {
display: flex;
padding: 0;
margin: 5px 0;
justify-content: flex-start;
}
& .badge {
font-size: 0.65rem;
display: block;
padding: 0 0.5rem;
border-radius: 2px;
margin-right: 0.25rem;
border: 1px solid var(--gray-6);
color: var(--gray-4);
}
& .product-name {
margin-right: 0.5rem;
position: relative;
color: var(--gray-3);
}
}
& .ais-Highlight-highlighted {
background-color: #c1f1e0;
}
}
/* Legend */
.g-search .c-search-legend {
display: none;
width: 100%;
height: var(--legend-height);
margin: 0;
padding: 0 1rem;
background: var(--white);
border-bottom: 1px solid var(--gray-6);
flex-direction: row;
align-items: center;
justify-content: space-between;
@media (--medium-up) {
display: flex;
}
& .legend-item {
display: flex;
align-items: center;
margin: 0;
height: var(--legend-height);
& > div {
height: 24px;
}
}
& .g-type-tag-label {
font-size: 13px;
color: var(--gray-4);
padding-left: 8px;
}
& .visually-hidden {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
}
}