-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #992 from maykinmedia/feature/2036-implement-login…
…-tab-design [#2036] Add tab-design for login page
- Loading branch information
Showing
17 changed files
with
567 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
248 changes: 157 additions & 91 deletions
248
src/open_inwoner/accounts/templates/registration/login.html
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
export class LoginFormFocus { | ||
static selector = '#login-form' | ||
|
||
constructor(node) { | ||
this.node = node | ||
this.usernameInput = node.querySelector('input[name="username"]') | ||
this.loginFormColumn = document.getElementById('column__login-form') | ||
this.emailToggleParent = document.getElementById('column__email-toggle') | ||
|
||
this.removeAutofocusAndFocus() | ||
this.hideLoginFormOnLoad() | ||
this.addEmailToggleListener() | ||
this.activateTabFromHash() | ||
} | ||
|
||
removeAutofocusAndFocus() { | ||
if (this.usernameInput) { | ||
this.usernameInput.removeAttribute('autofocus') | ||
this.usernameInput.blur() | ||
} | ||
} | ||
|
||
hideLoginFormOnLoad() { | ||
if (this.loginFormColumn) { | ||
this.emailToggleParent.setAttribute('aria-expanded', 'false') | ||
this.loginFormColumn.classList.add('hide') | ||
} | ||
} | ||
|
||
addEmailToggleListener() { | ||
if (this.emailToggleParent) { | ||
const emailToggleParents = | ||
this.emailToggleParent.querySelectorAll('.link') | ||
emailToggleParents.forEach((link) => { | ||
link.addEventListener('click', (event) => { | ||
event.preventDefault() | ||
this.emailToggleParent.classList.add('hide') | ||
this.toggleLoginFormVisibility() | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
toggleLoginFormVisibility() { | ||
if (this.loginFormColumn) { | ||
this.loginFormColumn.classList.toggle('hide') | ||
this.usernameInput.focus() | ||
} | ||
} | ||
|
||
activateTabFromHash() { | ||
const hash = window.location.hash | ||
const particulierLink = document.querySelector( | ||
'.tab__header[href="/accounts/login/#particulier"]' | ||
) | ||
const zakelijkLink = document.querySelector( | ||
'.tab__header[href="/accounts/login/#zakelijk"]' | ||
) | ||
const particulierTab = document.getElementById('particulier') | ||
const zakelijkTab = document.getElementById('zakelijk') | ||
|
||
if (hash.includes('zakelijk')) { | ||
particulierLink.classList.remove('active') | ||
particulierTab.classList.remove('active') | ||
particulierTab.classList.add('hide') | ||
|
||
zakelijkTab.classList.remove('hide') | ||
zakelijkTab.classList.add('active') | ||
zakelijkLink.classList.add('active') | ||
} else { | ||
particulierTab.classList.remove('hide') | ||
particulierLink.classList.add('active') | ||
particulierTab.classList.remove('active') | ||
|
||
zakelijkTab.classList.add('hide') | ||
zakelijkTab.classList.remove('active') | ||
zakelijkLink.classList.remove('active') | ||
} | ||
} | ||
} | ||
|
||
const loginformFocuses = document.querySelectorAll(LoginFormFocus.selector) | ||
;[...loginformFocuses].forEach((element) => new LoginFormFocus(element)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
export class TabPanel { | ||
static selector = '.login-tab--container' | ||
|
||
constructor(node) { | ||
this.node = node | ||
this.tabHeadersRow = node.querySelector('.tabs__headers') | ||
this.tabHeaders = node.querySelectorAll('.tab__header') | ||
this.tabContent = node.querySelectorAll('.tab__content') | ||
|
||
this.tabHeadersRow.addEventListener('click', (e) => { | ||
e.preventDefault() // Prevent 'other' tab__panel from disappearing immediately | ||
|
||
const target = e.target.closest('.tab__header') | ||
if (target) { | ||
const index = [...this.tabHeaders].indexOf(target) | ||
if (index !== -1) { | ||
this.hideContent() | ||
this.showContent(index) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
hideContent() { | ||
this.tabContent.forEach((item) => { | ||
item.classList.add('hide') | ||
item.classList.remove('active') | ||
}) | ||
this.tabHeaders.forEach((item) => { | ||
item.classList.remove('active') | ||
}) | ||
} | ||
|
||
showContent(index = 0) { | ||
this.tabContent.forEach((item, idx) => { | ||
if (idx === index) { | ||
item.classList.remove('hide') | ||
item.classList.add('active') | ||
} else { | ||
item.classList.add('hide') | ||
item.classList.remove('active') | ||
} | ||
}) | ||
this.tabHeaders.forEach((item, idx) => { | ||
if (idx === index) { | ||
item.classList.add('active') | ||
} else { | ||
item.classList.remove('active') | ||
} | ||
}) | ||
} | ||
} | ||
|
||
const tabpanels = document.querySelectorAll(TabPanel.selector) | ||
;[...tabpanels].forEach((tabpanel) => new TabPanel(tabpanel)) | ||
|
||
// Activate tab from hash on page load | ||
// Relies on instantiated TabPanel instances | ||
window.addEventListener('load', () => { | ||
const hash = window.location.hash | ||
if (hash) { | ||
const tabHeader = document.querySelector(`.tab__header[href="${hash}"]`) | ||
if (tabHeader) { | ||
const index = [...tabHeader.parentNode.children].indexOf(tabHeader) | ||
const tabPanel = tabHeader.closest('.tab--container') | ||
const tabPanelInstance = tabPanel && tabPanel.TabPanel | ||
if (tabPanelInstance) { | ||
tabPanelInstance.showContent(index) | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#login-form { | ||
//display: none; | ||
|
||
&.active { | ||
display: grid; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.digid-logo { | ||
&__image { | ||
height: 40px; | ||
height: 50px; | ||
} | ||
} |
Oops, something went wrong.