Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
design-system-lib
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
julkiset-sivut
design-system-lib
Commits
ea0ee071
Commit
ea0ee071
authored
4 years ago
by
katja
Browse files
Options
Downloads
Patches
Plain Diff
search panel coordinates
parent
520d5aeb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/site-header/site-search/site-search.tsx
+69
-6
69 additions, 6 deletions
src/components/site-header/site-search/site-search.tsx
with
69 additions
and
6 deletions
src/components/site-header/site-search/site-search.tsx
+
69
−
6
View file @
ea0ee071
...
...
@@ -128,6 +128,8 @@ export class SiteSearch {
// Close desktop menu panel and lang menu panel if they are open.
this
.
searchPanelToggled
.
emit
();
this
.
adjustPosition
(
this
.
el
);
/*
let hyHeader = this.el.closest('.hy-site-header') as HTMLElement;
const headerHeight = hyHeader.classList.contains('hy-site-header--sticky-active')
? `${hyHeader.offsetHeight}px`
...
...
@@ -135,12 +137,6 @@ export class SiteSearch {
const searchPanel = this.el.shadowRoot.querySelectorAll(`.site-search__panel`)[0] as HTMLElement;
searchPanel.style.top = headerHeight;
// Remove hidden class from cludo suggestions
let
cludoSayt
=
document
.
querySelectorAll
(
'
stencil-cludo-sayt
'
)[
0
]
as
HTMLElement
;
if
(
cludoSayt
)
{
cludoSayt
.
classList
.
remove
(
'
hidden
'
);
}
// Add shadow backdrop
let rect = searchPanel.getBoundingClientRect();
...
...
@@ -148,6 +144,13 @@ export class SiteSearch {
? hyHeader.offsetHeight + rect.height
: hyHeader.offsetTop + hyHeader.offsetHeight + rect.height;
this.showBackdropShadow('open', shadowTop);
*/
// Remove hidden class from cludo suggestions
let
cludoSayt
=
document
.
querySelectorAll
(
'
stencil-cludo-sayt
'
)[
0
]
as
HTMLElement
;
if
(
cludoSayt
)
{
cludoSayt
.
classList
.
remove
(
'
hidden
'
);
}
// Without setTimeout it will not focus the input because it hasn't rendered yet.
setTimeout
(()
=>
{
...
...
@@ -160,6 +163,66 @@ export class SiteSearch {
event
.
stopPropagation
();
}
adjustPosition
(
target
)
{
let
headerHeight
=
'
0
'
;
let
shadowTop
=
0
;
const
searchPanel
=
target
.
shadowRoot
.
querySelectorAll
(
`.site-search__panel`
)[
0
]
as
HTMLElement
;
let
rect
=
searchPanel
.
getBoundingClientRect
();
if
(
this
.
isGroup
)
{
let
hyHeader
=
target
.
closest
(
'
.hy-site-header__content-top
'
)
as
HTMLElement
;
if
(
hyHeader
)
{
let
rectHeader
=
hyHeader
.
getBoundingClientRect
();
headerHeight
=
`
${
rectHeader
.
height
}
px`
;
// Add shadow backdrop
//@todo For some reason rect (Search Panel) is {
// "x": 0,
// "y": 0,
// "width": 0,
// "height": 0,
// "top": 0,
// "right": 0,
// "bottom": 0,
// "left": 0
// }
shadowTop
=
hyHeader
.
offsetHeight
+
rect
.
height
;
}
}
else
{
let
hyHeader
=
target
.
closest
(
'
.hy-site-header
'
)
as
HTMLElement
;
headerHeight
=
hyHeader
.
classList
.
contains
(
'
hy-site-header--sticky-active
'
)
?
`
${
hyHeader
.
offsetHeight
}
px`
:
`
${
hyHeader
.
offsetTop
+
hyHeader
.
offsetHeight
}
px`
;
// Add shadow backdrop
shadowTop
=
hyHeader
.
classList
.
contains
(
'
hy-site-header--sticky-active
'
)
?
hyHeader
.
offsetHeight
+
rect
.
height
:
hyHeader
.
offsetTop
+
hyHeader
.
offsetHeight
+
rect
.
height
;
}
searchPanel
.
style
.
top
=
headerHeight
;
this
.
showBackdropShadow
(
'
open
'
,
shadowTop
);
/*
let hyTopHeader = this.el.closest('.hy-site-header__content-top') as HTMLElement;
if (hyTopHeader && hyTopHeader.hasAttribute('is-mobile')) {
console.log('do mobile stuff');
} else {
let mainMenuToggle = target.shadowRoot.querySelector('.menu--main-group__toggle') as HTMLElement;
let mainMenuDropdown = target.shadowRoot.querySelector('.menu--main-group__dropdown') as HTMLElement;
let mainMenuList = target.shadowRoot.querySelector('.list') as HTMLElement;
if (mainMenuDropdown && mainMenuList && mainMenuToggle) {
let rectHeader = hyTopHeader.getBoundingClientRect();
let rectMenuToggle = mainMenuToggle.getBoundingClientRect();
mainMenuDropdown.style.top = `${rectHeader.height}px`;
mainMenuList.style.left = `${rectMenuToggle.left}px`;
}
}
*/
}
showBackdropShadow
(
state
=
'
close
'
,
top
=
0
)
{
let
hyHeader
=
this
.
el
.
closest
(
'
.hy-site-header
'
)
as
HTMLElement
;
let
hyBackdropDiv
=
hyHeader
.
children
[
0
]
as
HTMLElement
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment