CSS: Add clear button to the search field in the menu

refs #11835
This commit is contained in:
Eric Lippmann 2016-11-16 11:43:21 +01:00
parent 3c8e41d4f6
commit 6b06e05c04
2 changed files with 49 additions and 6 deletions

View File

@ -6,11 +6,11 @@ $searchDashboard = new SearchDashboard();
$searchDashboard->setUser($this->Auth()->getUser());
if ($searchDashboard->search('dummy')->getPane('search')->hasDashlets()): ?>
<form action="<?= $this->href('search') ?>" method="get" role="search">
<input
type="text" name="q" id="search" class="search" placeholder="<?= $this->translate('Search') ?> &hellip;"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
/>
<form action="<?= $this->href('search') ?>" method="get" role="search" class="search-control">
<input type="text" name="q" id="search" class="search search-input"
placeholder="<?= $this->translate('Search') ?> &hellip;"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" required="required">
<button class="search-reset icon-cancel" type="reset"></button>
</form>
<?php endif; ?>
<?= $menuRenderer->setCssClass('primary-nav')->setElementTag('nav')->setHeading(t('Navigation')); ?>

View File

@ -167,7 +167,6 @@
}
// Accessibility skip links
.skip-links {
position: relative;
ul {
@ -198,3 +197,47 @@
bottom: 0 !important;
height: auto !important;
}
.search-control {
position: relative;
}
.search-reset {
background: none;
border: 0;
cursor: pointer;
display: none;
height: 100%;
padding: 0;
position: absolute;
right: 0;
top: 0;
user-select: none;
}
.search-reset:focus {
outline: 0;
}
// Override forms.less
input[type=text].search-input {
padding-right: 1.4em;
text-overflow: ellipsis;
}
.search-input:valid ~ .search-reset {
animation-duration: .4s;
animation-name: search-reset-in;
display: block;
}
@keyframes search-reset-in {
0% {
opacity: 0;
transform: translate3d(-20%, 0, 0);
}
100% {
opacity: 1;
transform: none;
}
}