Skip to content

Commit

Permalink
👌 [#4347] PR feedback
Browse files Browse the repository at this point in the history
* use `onLoaded` instead to add admin form toggle functionality
* use BEM syntax for admin login options
* fix admin-login-divider styling and use CSS var instead of hardcoded colors
  • Loading branch information
stevenbal committed Jun 10, 2024
1 parent 11fc9d8 commit 928484d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 25 deletions.
23 changes: 15 additions & 8 deletions src/openforms/js/components/admin/login.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const defaultLogin = document.querySelector('.admin-login-password');
const loginForm = document.querySelector('#login-form');
import {onLoaded} from 'utils/dom';

if (defaultLogin && loginForm) {
defaultLogin.addEventListener('click', e => {
loginForm.style.display = 'block';
defaultLogin.style.display = 'none';
});
}
const addAdminLoginExpand = () => {
const defaultLoginToggle = document.querySelector('.admin-login-option--password');
const loginForm = document.querySelector('#login-form');

if (defaultLoginToggle && loginForm) {
defaultLoginToggle.addEventListener('click', e => {
e.preventDefault();
loginForm.classList.toggle('login-form--enabled');
defaultLoginToggle.classList.toggle('admin-login-option--disabled');
});
}
};

onLoaded(addAdminLoginExpand);
42 changes: 27 additions & 15 deletions src/openforms/scss/admin/_app_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Generic overrides should go in _admin_theme.scss
*/
@use 'microscope-sass/lib/bem';
@import '~microscope-sass/lib/responsive';
@import '~microscope-sass/lib/util';

Expand Down Expand Up @@ -96,31 +97,42 @@ $djai-padding--tablet: 30px;
text-align: center;
clear: both;
padding-top: 1em;

@include bem.modifier('disabled') {
display: none;
}
}

.admin-login-divider {
text-align: center;
clear: both;
padding-top: 1em;

width: 100%;
text-align: center;
border-bottom: 1px solid #ccc;
line-height: 0.1em;
margin: 10px 0 10px;

span {
background: #fff;
padding: 0 10px;
display: flex;
flex-direction: row;
align-items: center;
padding-block-start: 1em;
&:after,
&:before {
content: '';
display: block;
border-bottom: 1px solid var(--border-color);
flex-grow: 1;
}
> span {
flex-shrink: 0;
padding-inline: 10px;
}
}

/**
* mozilla-django-oidc-db
* hide the regular admin login form by default if OIDC is enabled
*/
#login-form:has(~ .admin-login-oidc) {
display: none;
#login-form {
&:has(~ .admin-login-option--oidc) {
display: none;
}

&.login-form--enabled {
display: block;
}
}

/* Styling for react-jsonschema-form */
Expand Down
4 changes: 2 additions & 2 deletions src/openforms/templates/maykin_2fa/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{% block extra_login_options %}
{% get_solo 'mozilla_django_oidc_db.OpenIDConnectConfig' as oidc_config %}
{% if oidc_config.enabled %}
<div class="admin-login-option admin-login-password">
<div class="admin-login-option admin-login-option--password">
<a href="#">{% trans "Login with application account" %}</a>
</div>
<div class="admin-login-divider"><span>{% trans "or" %}</span></div>
<div class="admin-login-option admin-login-oidc">
<div class="admin-login-option admin-login-option--oidc">
<a href="{% url 'oidc_authentication_init' %}">{% trans "Login with organization account" %}</a>
</div>
{% endif %}
Expand Down

0 comments on commit 928484d

Please sign in to comment.