Replace search icon png with fontawesome icon

This commit is contained in:
Johannes Rauh 2025-04-24 14:08:59 +02:00 committed by Johannes Meyer
parent 0eea5cae51
commit aa7a60c893
5 changed files with 37 additions and 29 deletions

View File

@ -8,6 +8,7 @@ $searchDashboard->setUser($this->Auth()->getUser());
if ($searchDashboard->search('dummy')->getPane('search')->hasDashlets()): ?> if ($searchDashboard->search('dummy')->getPane('search')->hasDashlets()): ?>
<form action="<?= $this->href('search') ?>" method="get" role="search" class="search-control"> <form action="<?= $this->href('search') ?>" method="get" role="search" class="search-control">
<i class="icon fa-search fa search-icon"></i>
<input type="text" name="q" id="search" class="search search-input" required <input type="text" name="q" id="search" class="search search-input" required
placeholder="<?= $this->translate('Search') ?> &hellip;" placeholder="<?= $this->translate('Search') ?> &hellip;"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"> autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">

View File

@ -3,17 +3,17 @@
namespace Icinga\Web\Widget; namespace Icinga\Web\Widget;
use Exception;
use Icinga\Application\Icinga;
use Icinga\Data\Filter\Filter;
use Icinga\Data\Filter\FilterChain;
use Icinga\Data\Filter\FilterExpression;
use Icinga\Data\Filter\FilterOr;
use Icinga\Data\Filterable; use Icinga\Data\Filterable;
use Icinga\Data\FilterColumns; use Icinga\Data\FilterColumns;
use Icinga\Data\Filter\Filter;
use Icinga\Data\Filter\FilterExpression;
use Icinga\Data\Filter\FilterChain;
use Icinga\Data\Filter\FilterOr;
use Icinga\Web\Url;
use Icinga\Application\Icinga;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Exception; use Icinga\Web\Url;
/** /**
* Filter * Filter
@ -737,10 +737,11 @@ class FilterEditor extends AbstractWidget
$preservedUrl = $this->preservedUrl(); $preservedUrl = $this->preservedUrl();
$html = ' <form method="post" class="search inline" action="' $html = ' <form method="post" class="search inline" action="'
. $preservedUrl . $preservedUrl
. '"><input type="text" name="q" class="search search-input" value="" placeholder="' . '"><i class="icon fa-search fa search-icon"></i>'
. t('Search...') . '<input type="text" name="q" class="search search-input" value="" placeholder="'
. '" /></form>'; . t('Search...')
. '" /></form>';
if ($this->filter->isEmpty()) { if ($this->filter->isEmpty()) {
$title = t('Filter this list'); $title = t('Filter this list');

View File

@ -10,6 +10,7 @@ use ipl\Html\FormElement\InputElement;
use ipl\Html\HtmlElement; use ipl\Html\HtmlElement;
use ipl\Web\Control\SearchBar\Suggestions; use ipl\Web\Control\SearchBar\Suggestions;
use ipl\Web\Url; use ipl\Web\Url;
use ipl\Web\Widget\Icon;
class SingleValueSearchControl extends Form class SingleValueSearchControl extends Form
{ {
@ -106,6 +107,8 @@ class SingleValueSearchControl extends Form
{ {
$suggestionsId = Icinga::app()->getRequest()->protectId('single-value-suggestions'); $suggestionsId = Icinga::app()->getRequest()->protectId('single-value-suggestions');
$this->addHtml(new Icon('search', Attributes::create(['class' => 'search-icon'])));
$this->addElement( $this->addElement(
'text', 'text',
$this->searchParameter, $this->searchParameter,

View File

@ -21,35 +21,35 @@
} }
} }
form > .search-icon {
position: absolute;
left: 0.25em;
top: ~"calc(50% - 0.5em)";
pointer-events: none;
color: @menu-color;
opacity: 0.8;
}
form:has(> .search-icon) {
position: relative;
}
.controls input.search, .controls input.search,
input.search { input.search {
.transition(border 0.3s ease); .transition(border 0.3s ease);
.transition(background-image 0.2s ease);
background-image: url(../img/icons/search_white.png);
background-repeat: no-repeat;
background-size: 1em 1em;
background-position: .25em center;
outline: none; outline: none;
padding-left: 1.5em; padding-left: 1.5em;
width: 20em; width: 20em;
&:focus {
background-image: url(../img/icons/search_icinga_blue.png);
}
&:focus:not([readonly]) { &:focus:not([readonly]) {
border-color: @icinga-blue; border-color: @icinga-blue;
} }
} }
@light-mode: { form:has(input.search:focus) > .search-icon {
#menu input.search, color: @icinga-blue;
.controls input.search, }
input.search {
background-image: url(../img/icons/search.png);
}
};
.backend-selection, .backend-selection,
.pagination-control, .pagination-control,

View File

@ -210,9 +210,12 @@
opacity: .6; opacity: .6;
} }
#menu .search-icon {
left: 1em;
}
#menu input.search { #menu input.search {
background: transparent url('../img/icons/search_white.png') no-repeat 1em center; background-color: @menu-bg-color;
background-size: 1em auto;
border: none; border: none;
color: @menu-color; color: @menu-color;
line-height: 2.167em; line-height: 2.167em;