Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
7f166649
Commit
7f166649
authored
5 years ago
by
Bekerle, Patrizio
Committed by
Reiter, Christoph
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add layout manager to set dropdown width and did more dropdown styling
parent
67f2fc17
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
packages/auth/src/vpu-auth.js
+57
-15
57 additions, 15 deletions
packages/auth/src/vpu-auth.js
with
57 additions
and
15 deletions
packages/auth/src/vpu-auth.js
+
57
−
15
View file @
7f166649
import
{
i18n
}
from
'
./i18n.js
'
;
import
{
i18n
}
from
'
./i18n.js
'
;
import
{
html
,
css
,
LitElement
}
from
'
lit-element
'
;
import
{
html
,
css
}
from
'
lit-element
'
;
import
{
unsafeHTML
}
from
'
lit-html/directives/unsafe-html.js
'
;
import
{
unsafeHTML
}
from
'
lit-html/directives/unsafe-html.js
'
;
import
JSONLD
from
'
vpu-common/jsonld
'
import
JSONLD
from
'
vpu-common/jsonld
'
import
*
as
commonUtils
from
'
vpu-common/utils
'
;
import
*
as
commonUtils
from
'
vpu-common/utils
'
;
import
*
as
commonStyles
from
'
vpu-common/styles
'
;
import
*
as
commonStyles
from
'
vpu-common/styles
'
;
import
'
vpu-common/vpu-icon.js
'
;
import
'
vpu-common/vpu-icon.js
'
;
import
VPULitElement
from
'
vpu-common/vpu-lit-element
'
;
/**
/**
* Keycloak auth web component
* Keycloak auth web component
...
@@ -18,7 +19,7 @@ import 'vpu-common/vpu-icon.js';
...
@@ -18,7 +19,7 @@ import 'vpu-common/vpu-icon.js';
* window.VPUPerson: Person json object of the user (optional, enable by setting the `load-person` attribute,
* window.VPUPerson: Person json object of the user (optional, enable by setting the `load-person` attribute,
* which will dispatch a `vpu-auth-person-init` event when loaded)
* which will dispatch a `vpu-auth-person-init` event when loaded)
*/
*/
class
VPUAuth
extends
LitElement
{
class
VPUAuth
extends
VPU
LitElement
{
constructor
()
{
constructor
()
{
super
();
super
();
this
.
lang
=
'
de
'
;
this
.
lang
=
'
de
'
;
...
@@ -77,12 +78,31 @@ class VPUAuth extends LitElement {
...
@@ -77,12 +78,31 @@ class VPUAuth extends LitElement {
this
.
loadKeycloak
();
this
.
loadKeycloak
();
}
}
const
that
=
this
;
this
.
updateComplete
.
then
(()
=>
{
this
.
updateComplete
.
then
(()
=>
{
window
.
onresize
=
()
=>
{
that
.
updateDropdownWidth
();
};
});
});
document
.
addEventListener
(
'
click
'
,
this
.
closeDropdown
);
document
.
addEventListener
(
'
click
'
,
this
.
closeDropdown
);
}
}
/**
* Set the dropdown width to almost the width of the web component
* We need to set the width manually because a percent width is in relation to the viewport
*/
updateDropdownWidth
()
{
const
dropdown
=
this
.
_
(
"
div.dropdown-menu
"
);
if
(
!
dropdown
)
{
return
;
}
dropdown
.
setAttribute
(
"
style
"
,
`width:
${
this
.
offsetWidth
-
5
}
px`
);
}
disconnectedCallback
()
{
disconnectedCallback
()
{
document
.
removeEventListener
(
'
click
'
,
this
.
closeDropdown
);
document
.
removeEventListener
(
'
click
'
,
this
.
closeDropdown
);
super
.
disconnectedCallback
();
super
.
disconnectedCallback
();
...
@@ -255,20 +275,39 @@ class VPUAuth extends LitElement {
...
@@ -255,20 +275,39 @@ class VPUAuth extends LitElement {
.dropdown-menu {
.dropdown-menu {
display: none;
display: none;
min-width:
12r
em;
min-width:
8
em;
padding-top: 4px;
padding-top: 4px;
position: absolute;
position: absolute;
z-index: 20;
z-index: 20;
border: solid 1px black;
border-radius: var(--vpu-border-radius);
overflow: hidden;
}
}
.dropdown-content {
.dropdown-content {
background-color: white;
background-color: white;
border-radius: var(--vpu-border-radius);
box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);
padding-bottom: 0.5rem;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
padding-top: 0.5rem;
}
}
.dropdown-content img {
max-width: 120px;
}
.menu a {
/*padding: 0.3em;*/
font-weight: 400;
color: #000;
display: block;
text-decoration: none;
}
.menu a:hover {
color: #E4154B;
}
.menu a.selected { color: white; background-color: black; }
.dropdown-item {
.dropdown-item {
color: #4a4a4a;
color: #4a4a4a;
display: block;
display: block;
...
@@ -343,6 +382,7 @@ class VPUAuth extends LitElement {
...
@@ -343,6 +382,7 @@ class VPUAuth extends LitElement {
if
(
chevron
!==
null
)
{
if
(
chevron
!==
null
)
{
chevron
.
name
=
event
.
currentTarget
.
classList
.
contains
(
'
is-active
'
)
?
'
chevron-up
'
:
'
chevron-down
'
;
chevron
.
name
=
event
.
currentTarget
.
classList
.
contains
(
'
is-active
'
)
?
'
chevron-up
'
:
'
chevron-down
'
;
}
}
this
.
updateDropdownWidth
();
}
}
closeDropdown
()
{
closeDropdown
()
{
...
@@ -357,17 +397,19 @@ class VPUAuth extends LitElement {
...
@@ -357,17 +397,19 @@ class VPUAuth extends LitElement {
return
html
`
return
html
`
<div class="dropdown" @click="
${
this
.
onDropdownClick
}
">
<div class="dropdown" @click="
${
this
.
onDropdownClick
}
">
<div class="dropdown-trigger">
<div class="dropdown-trigger">
<span>
${
this
.
name
}
</span>
<span>
${
this
.
name
}
</span>
<vpu-icon name="chevron-down" id="menu-chevron-icon"></vpu-icon>
<vpu-icon name="chevron-down" id="menu-chevron-icon"></vpu-icon>
</div>
</div>
<div class="dropdown-menu" id="dropdown-menu2" role="menu">
<div class="dropdown-menu" id="dropdown-menu2" role="menu">
<div class="dropdown-content">
<div class="dropdown-content">
${
imageURL
?
html
`<img alt="" src="
${
imageURL
}
" width="40%" height="40%" class="dropdown-item">`
:
''
}
${
imageURL
?
html
`<img alt="" src="
${
imageURL
}
" class="dropdown-item">`
:
''
}
<a href="#" @click="
${(
e
)
=>
{
e
.
preventDefault
();
this
.
dispatchProfileEvent
();}}
" class="dropdown-item">
${
i18n
.
t
(
'
profile
'
)}
</a>
<div class="menu">
<a href="#" @click="
${
this
.
logout
}
" class="dropdown-item">
${
i18n
.
t
(
'
logout
'
)}
</a>
<a href="#" @click="
${(
e
)
=>
{
e
.
preventDefault
();
this
.
dispatchProfileEvent
();}}
" class="dropdown-item">
${
i18n
.
t
(
'
profile
'
)}
</a>
<a href="#" @click="
${
this
.
logout
}
" class="dropdown-item">
${
i18n
.
t
(
'
logout
'
)}
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`
;
`
;
}
}
...
...
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