Commit e464a8e6 authored by Zack Cuddy's avatar Zack Cuddy Committed by Andrew Fontaine

Global Search - Dynamic Import Header Search

parent 0acbdfa9
...@@ -138,6 +138,7 @@ export default { ...@@ -138,6 +138,7 @@ export default {
class="header-search gl-relative" class="header-search gl-relative"
> >
<gl-search-box-by-type <gl-search-box-by-type
id="search"
v-model="searchText" v-model="searchText"
role="searchbox" role="searchbox"
class="gl-z-index-1" class="gl-z-index-1"
......
...@@ -14,7 +14,6 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; ...@@ -14,7 +14,6 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { initRails } from '~/lib/utils/rails_ujs'; import { initRails } from '~/lib/utils/rails_ujs';
import * as popovers from '~/popovers'; import * as popovers from '~/popovers';
import * as tooltips from '~/tooltips'; import * as tooltips from '~/tooltips';
import { initHeaderSearchApp } from '~/header_search';
import initAlertHandler from './alert_handler'; import initAlertHandler from './alert_handler';
import { addDismissFlashClickListener } from './flash'; import { addDismissFlashClickListener } from './flash';
import initTodoToggle from './header'; import initTodoToggle from './header';
...@@ -98,24 +97,29 @@ function deferredInitialisation() { ...@@ -98,24 +97,29 @@ function deferredInitialisation() {
initDefaultTrackers(); initDefaultTrackers();
initFeatureHighlight(); initFeatureHighlight();
if (gon.features?.newHeaderSearch) { const search = document.querySelector('#search');
initHeaderSearchApp(); if (search) {
} else { search.addEventListener(
const search = document.querySelector('#search'); 'focus',
if (search) { () => {
search.addEventListener( if (gon.features?.newHeaderSearch) {
'focus', import(/* webpackChunkName: 'globalSearch' */ '~/header_search')
() => { .then(async ({ initHeaderSearchApp }) => {
await initHeaderSearchApp();
document.querySelector('#search').focus();
})
.catch(() => {});
} else {
import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete') import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete')
.then(({ default: initSearchAutocomplete }) => { .then(({ default: initSearchAutocomplete }) => {
const searchDropdown = initSearchAutocomplete(); const searchDropdown = initSearchAutocomplete();
searchDropdown.onSearchInputFocus(); searchDropdown.onSearchInputFocus();
}) })
.catch(() => {}); .catch(() => {});
}, }
{ once: true }, },
); { once: true },
} );
} }
addSelectOnFocusBehaviour('.js-select-on-focus'); addSelectOnFocusBehaviour('.js-select-on-focus');
......
...@@ -407,6 +407,21 @@ h1 { ...@@ -407,6 +407,21 @@ h1 {
.gl-form-input.form-control::placeholder { .gl-form-input.form-control::placeholder {
color: #868686; 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 { .gl-button {
display: inline-flex; display: inline-flex;
} }
...@@ -439,6 +454,29 @@ h1 { ...@@ -439,6 +454,29 @@ h1 {
outline: none; outline: none;
background-color: #404040; 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, body,
.form-control, .form-control,
.search form { .search form {
......
...@@ -388,6 +388,21 @@ h1 { ...@@ -388,6 +388,21 @@ h1 {
.gl-form-input.form-control::placeholder { .gl-form-input.form-control::placeholder {
color: #868686; 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 { .gl-button {
display: inline-flex; display: inline-flex;
} }
...@@ -420,6 +435,29 @@ h1 { ...@@ -420,6 +435,29 @@ h1 {
outline: none; outline: none;
background-color: #dbdbdb; 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, body,
.form-control, .form-control,
.search form { .search form {
......
...@@ -36,7 +36,9 @@ ...@@ -36,7 +36,9 @@
'issues-path' => issues_dashboard_path, 'issues-path' => issues_dashboard_path,
'mr-path' => merge_requests_dashboard_path, 'mr-path' => merge_requests_dashboard_path,
'autocomplete-path' => search_autocomplete_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 - else
= render 'layouts/search' = render 'layouts/search'
%li.nav-item{ class: 'd-none d-sm-inline-block d-lg-none' } %li.nav-item{ class: 'd-none d-sm-inline-block d-lg-none' }
......
...@@ -407,6 +407,21 @@ h1 { ...@@ -407,6 +407,21 @@ h1 {
.gl-form-input.form-control::placeholder { .gl-form-input.form-control::placeholder {
color: #868686; 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 { .gl-button {
display: inline-flex; display: inline-flex;
} }
...@@ -439,6 +454,29 @@ h1 { ...@@ -439,6 +454,29 @@ h1 {
outline: none; outline: none;
background-color: #404040; 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, body,
.form-control, .form-control,
.search form { .search form {
......
...@@ -388,6 +388,21 @@ h1 { ...@@ -388,6 +388,21 @@ h1 {
.gl-form-input.form-control::placeholder { .gl-form-input.form-control::placeholder {
color: #868686; 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 { .gl-button {
display: inline-flex; display: inline-flex;
} }
...@@ -420,6 +435,29 @@ h1 { ...@@ -420,6 +435,29 @@ h1 {
outline: none; outline: none;
background-color: #dbdbdb; 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, body,
.form-control, .form-control,
.search form { .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