Commit de489a35 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '345745_04-better-main-import' into 'master'

Global Search - Dynamic Import Header Search

See merge request gitlab-org/gitlab!76594
parents 3ac2648a e464a8e6
......@@ -140,6 +140,7 @@ export default {
class="header-search gl-relative"
>
<gl-search-box-by-type
id="search"
v-model="searchText"
role="searchbox"
class="gl-z-index-1"
......
......@@ -14,7 +14,6 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { initRails } from '~/lib/utils/rails_ujs';
import * as popovers from '~/popovers';
import * as tooltips from '~/tooltips';
import { initHeaderSearchApp } from '~/header_search';
import initAlertHandler from './alert_handler';
import { addDismissFlashClickListener } from './flash';
import initTodoToggle from './header';
......@@ -100,25 +99,30 @@ function deferredInitialisation() {
initFeatureHighlight();
initCopyCodeButton();
if (gon.features?.newHeaderSearch) {
initHeaderSearchApp();
} else {
const search = document.querySelector('#search');
if (search) {
search.addEventListener(
'focus',
() => {
if (gon.features?.newHeaderSearch) {
import(/* webpackChunkName: 'globalSearch' */ '~/header_search')
.then(async ({ initHeaderSearchApp }) => {
await initHeaderSearchApp();
document.querySelector('#search').focus();
})
.catch(() => {});
} else {
import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete')
.then(({ default: initSearchAutocomplete }) => {
const searchDropdown = initSearchAutocomplete();
searchDropdown.onSearchInputFocus();
})
.catch(() => {});
}
},
{ once: true },
);
}
}
addSelectOnFocusBehaviour('.js-select-on-focus');
......
......@@ -407,6 +407,21 @@ h1 {
.gl-form-input.form-control::placeholder {
color: #868686;
}
.gl-icon {
fill: currentColor;
}
.gl-icon.s12 {
width: 12px;
height: 12px;
}
.gl-icon.s16 {
width: 16px;
height: 16px;
}
.gl-icon.s32 {
width: 32px;
height: 32px;
}
.gl-button {
display: inline-flex;
}
......@@ -439,6 +454,29 @@ h1 {
outline: none;
background-color: #404040;
}
.gl-button.gl-button.btn-default:active .gl-icon,
.gl-button.gl-button.btn-default.active .gl-icon {
color: #fafafa;
}
.gl-button.gl-button.btn-default .gl-icon {
color: #999;
}
.gl-search-box-by-type-search-icon {
margin: 0.5rem;
color: #999;
width: 1rem;
position: absolute;
}
.gl-search-box-by-type {
display: flex;
position: relative;
}
.gl-search-box-by-type-input,
.gl-search-box-by-type-input.gl-form-input {
height: 2rem;
padding-right: 2rem;
padding-left: 1.75rem;
}
body,
.form-control,
.search form {
......
......@@ -388,6 +388,21 @@ h1 {
.gl-form-input.form-control::placeholder {
color: #868686;
}
.gl-icon {
fill: currentColor;
}
.gl-icon.s12 {
width: 12px;
height: 12px;
}
.gl-icon.s16 {
width: 16px;
height: 16px;
}
.gl-icon.s32 {
width: 32px;
height: 32px;
}
.gl-button {
display: inline-flex;
}
......@@ -420,6 +435,29 @@ h1 {
outline: none;
background-color: #dbdbdb;
}
.gl-button.gl-button.btn-default:active .gl-icon,
.gl-button.gl-button.btn-default.active .gl-icon {
color: #303030;
}
.gl-button.gl-button.btn-default .gl-icon {
color: #666;
}
.gl-search-box-by-type-search-icon {
margin: 0.5rem;
color: #666;
width: 1rem;
position: absolute;
}
.gl-search-box-by-type {
display: flex;
position: relative;
}
.gl-search-box-by-type-input,
.gl-search-box-by-type-input.gl-form-input {
height: 2rem;
padding-right: 2rem;
padding-left: 1.75rem;
}
body,
.form-control,
.search form {
......
......@@ -36,7 +36,9 @@
'issues-path' => issues_dashboard_path,
'mr-path' => merge_requests_dashboard_path,
'autocomplete-path' => search_autocomplete_path } }
%input{ type: "text", placeholder: _('Search or jump to...'), class: 'form-control gl-form-input' }
.gl-search-box-by-type
= sprite_icon('search', css_class: 'gl-search-box-by-type-search-icon gl-icon')
%input{ type: "text", placeholder: _('Search or jump to...'), class: 'form-control gl-form-input gl-search-box-by-type-input', id: 'search', autocomplete: 'off' }
- else
= render 'layouts/search'
%li.nav-item{ class: 'd-none d-sm-inline-block d-lg-none' }
......
......@@ -407,6 +407,21 @@ h1 {
.gl-form-input.form-control::placeholder {
color: #868686;
}
.gl-icon {
fill: currentColor;
}
.gl-icon.s12 {
width: 12px;
height: 12px;
}
.gl-icon.s16 {
width: 16px;
height: 16px;
}
.gl-icon.s32 {
width: 32px;
height: 32px;
}
.gl-button {
display: inline-flex;
}
......@@ -439,6 +454,29 @@ h1 {
outline: none;
background-color: #404040;
}
.gl-button.gl-button.btn-default:active .gl-icon,
.gl-button.gl-button.btn-default.active .gl-icon {
color: #fafafa;
}
.gl-button.gl-button.btn-default .gl-icon {
color: #999;
}
.gl-search-box-by-type-search-icon {
margin: 0.5rem;
color: #999;
width: 1rem;
position: absolute;
}
.gl-search-box-by-type {
display: flex;
position: relative;
}
.gl-search-box-by-type-input,
.gl-search-box-by-type-input.gl-form-input {
height: 2rem;
padding-right: 2rem;
padding-left: 1.75rem;
}
body,
.form-control,
.search form {
......
......@@ -388,6 +388,21 @@ h1 {
.gl-form-input.form-control::placeholder {
color: #868686;
}
.gl-icon {
fill: currentColor;
}
.gl-icon.s12 {
width: 12px;
height: 12px;
}
.gl-icon.s16 {
width: 16px;
height: 16px;
}
.gl-icon.s32 {
width: 32px;
height: 32px;
}
.gl-button {
display: inline-flex;
}
......@@ -420,6 +435,29 @@ h1 {
outline: none;
background-color: #dbdbdb;
}
.gl-button.gl-button.btn-default:active .gl-icon,
.gl-button.gl-button.btn-default.active .gl-icon {
color: #303030;
}
.gl-button.gl-button.btn-default .gl-icon {
color: #666;
}
.gl-search-box-by-type-search-icon {
margin: 0.5rem;
color: #666;
width: 1rem;
position: absolute;
}
.gl-search-box-by-type {
display: flex;
position: relative;
}
.gl-search-box-by-type-input,
.gl-search-box-by-type-input.gl-form-input {
height: 2rem;
padding-right: 2rem;
padding-left: 1.75rem;
}
body,
.form-control,
.search form {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment