See "img upload" in sidebar snet/molecules for variants, or go to info panel and look for it in "references" (@snet-img-upload)
Refer to modal frame found in view tab for complete structure without content.
A modal's default size is 640px
Modifier classes for modals
A modal with a content loading component behaves as follows:
<div class="sds-modal modal fade -bodySecondary06" id="raccourcisModal" aria-labelledby="raccourcisModalTitle" aria-modal="true" role="dialog" tabindex="-1">
<div class="sds-modal__dialog modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="sds-modal__content modal-content">
<div class="sds-modal__header modal-header">
<div class="sds-modal__title modal-title" id="raccourcisModalTitle">Nouveau message</div>
<button type="button" class="sds-btn -iconBtn -btnSecondary -ghost sds-modal__close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" class="sds-icon sds-icon-close"></span>
</button>
</div>
<div class="sds-modal__body modal-body">
<div class="sds-stackLg">
<div class="sds-box -insetLg">
<div class="sds-stackXl">
<form>
<div class="form-group">
<label for="" class="sds-label -labelForm">
Catégorie
</label>
<div class="sds-select">
<select id="" class="sds-select form-control">
<option value="opt-0">Option 1</option>
<option value="opt-1">Option 2</option>
<option value="opt-2">Option 3</option>
</select>
<span class="sds-select__arrow sds-icon sds-icon-chevrondown" aria-hidden="true"></span>
</div>
</div>
<div class="form-group">
<label for="" class="sds-label -labelForm">
Objet
</label>
<div class="sds-input">
<input id="" class="sds-input form-control" type="text" placeholder="{Placeholder}" value="">
</div>
</div>
<div class="form-group">
<label for="" class="sds-label -labelForm -labelOptional">
{Label}
<span class="sds-label__helper"><span>0</span><span>/3500</span></span>
</label>
<div class="sds-textarea">
<div class="sds-textarea__inner">
<textarea class="form-control" id="" rows="1" placeholder="{Placeholder}"></textarea>
</div>
</div>
</div>
<div class="form-group">
<button type="button" class="sds-btn -btnSecondary">
<span class="sds-icon sds-icon-clip"></span>
<span class="sds-btn__text">
Joindre document
</span>
</button>
</div>
</form>
<div class="d-flex align-items-center justify-content-end">
<button type="button" class="sds-btn -btnPrimary">
<span class="sds-btn__text">
Envoyer
</span>
</button>
</div>
</div>
</div>
<div class="sds-box -insetLg">
<div class="sds-stackLg">
<div>
<h3 class="h3">
Raccourcis
</h3>
<p class="h3 sds-headingLight">Un doute, une question ? Ne vous inquiétez pas, nous vous indiquons le chemin.</p>
</div>
<div>
<div class="d-flex flex-column-reverse">
<div class="text-center">
<button type="button" class="sds-btn -btnSecondary -btnSmall -collapseTrigger" data-toggle="collapse" data-target="#raccourcisModalCollapse">
<span class="sds-icon sds-icon-plus"></span>
<span class="sds-btn__text">
Voir raccourcis
</span>
</button>
</div>
<div class="collapse" id="raccourcisModalCollapse">
<div class="sds-collapse__insetBottomLg">
<ul class="sds-stackSm -stackBorder list-unstyled">
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-financialmarkets.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Accéder aux marchés financiers</p>
<p>{Description}</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-cardreceive.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Demander une carte de paiement</p>
<p>Choisissez et commandez la carte qui vous convient en quelques clics.</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-rib.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Relevé d'identité bancaire (RIB)</p>
<p>Téléchargez votre relevé d'identité bancaire.</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-accounts.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Modifier la limite de ma carte Visa</p>
<p>Accédez à la gestion de votre carte afin de modifier la limite de paiement.</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-profile.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Modifier mes données personnelles</p>
<p>Accédez à votre espace client afin de mettre à jour vos données personnelles.</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-rdvonlinesimp.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Prendre un rendez-vous</p>
<p>Prenez et gérez vos rendez-vous depuis votre espace personnel.</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-recurringpayment.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Créer ou modifier un ordre permanent</p>
<p>Vous souhaitez faire des virements réguliers ou modifier un ordre permanent existant ?</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-switchingon.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Activer ou bloquer une domiciliation</p>
<p>Vous ne souhaitez plus que votre prestataire de service encaisse automatiquement vos factures ?</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
<li>
<a href="" class="sds-banner sds-hoverContentSecondary sds-outOfBounds">
<img class="sds-banner__img" src="https:/design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-reachinglimit.svg" alt="">
<div class="sds-banner__content">
<p class="sds-banner__title h4">Limite de paiement S-Net</p>
<p>Augmentez votre limite de paiement S-Net pour une durée temporaire.</p>
</div>
<span class="sds-iconCircle -secondary10 sds-hoverContentSecondary__icon" aria-hidden="true">
<span class="sds-icon sds-icon-chevronrightdouble"></span>
</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sds-banner -bannerHighlight" data-scope-wrapper="section" data-scope="inverted">
<div class="d-flex flex-grow-1 align-items-center sds-staticInlineXl">
<div class="sds-media -mediaMd -mediaHasBg">
<img src="https://design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-questioning.svg" alt="">
</div>
<div class="sds-stackXxs">
<h2 class="h4">Envie d'en savoir plus ? Découvrez notre Help-Center.</h2>
<p class="sds-textHelper">Retrouvez ici tous les guides utilisateurs des fonctionnalités S-Net.</p>
</div>
</div>
<button type="button" class="sds-btn -iconBtn -btnSecondary">
<span aria-hidden="true" class="sds-icon sds-icon-arrownext"></span>
<div class="sr-only">Découvrir</div>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% extends "@snet-modal-base-frame" %}
{% block header %}
<div class="{{ namespace }}modal__title modal-title" id="{{ modalTitleID }}">{{ title }}</div>
{% endblock %}
{% block body %}
<div class="{{ namespace }}stackLg">
<div class="{{ namespace }}box -insetLg">
<div class="{{ namespace }}stackXl">
<form>
{% render '@form-group--select', {
labelText: "Catégorie"
}, true %}
{% render '@form-group', {
labelText: "Objet",
placeholder: "{Placeholder}"
}, true %}
{% render '@form-group--textarea', {
labelText: "{Label}",
textOptional: "<span>0</span><span>/3500</span>",
placeholder: "{Placeholder}"
}, true %}
<div class="form-group">
{% render "@btn-secondary--icon-left",{
icon: "icon-clip",
text: "Joindre document"
},true %}
</div>
</form>
<div class="d-flex align-items-center justify-content-end">
{% render '@btn-primary', {
text: "Envoyer"
}, true %}
</div>
</div>
</div>
<div class="{{ namespace }}box -insetLg">
<div class="{{ namespace }}stackLg">
{% render "@heading--h3-subtext", {
text: "Raccourcis",
subText: text
}, true %}
<div>
<div class="d-flex flex-column-reverse">
<div class="text-center">
{% render "@btn-secondary--icon-left-collapse-trigger",{
icon: "icon-plus",
text: "Voir raccourcis",
attrs: {
"data-toggle": "collapse",
"data-target": "#raccourcisModalCollapse"
}
},true %}
</div>
<div class="collapse" id="raccourcisModalCollapse">
<div class="{{ namespace }}collapse__insetBottomLg">
<ul class="{{ namespace }}stackSm -stackBorder list-unstyled">
{% for key, item in modalRaccourcisBannerList %}
<li>
{% render '@snet-banner-old', {
externalImg: true,
img: item.img,
title: item.title,
text: item.text,
classes: [namespace +"outOfBounds"]},true %}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
{% render "@banner--highlight", {
mediaImg: "https://design.spuerkeess.lu/media/illustrations/svg750x560/hero/sdsillu-questioning.svg",
title: "Envie d'en savoir plus ? Découvrez notre Help-Center.",
text: "Retrouvez ici tous les guides utilisateurs des fonctionnalités S-Net."
},true %}
</div>
{% endblock %}
export default class ModalTrap {
constructor() {
// select all modals with the dialog role and modal classe.
// this ensures that only modals with the right attributes are selected
this.modals = document.querySelectorAll("[role='dialog'].modal");
// select all modal trigger buttons that don't have a data-dismiss attribute
// buttons with data-dismiss and data-toggle are typically only used within modals to trigger another modal
// we want to exclude these from the selection
this.modalToggles = document.querySelectorAll("[data-toggle='modal']:not([data-dismiss='modal'])");
// list of focusable elements inside a modal
this.focusableElements = [
"a[href]",
"button:not([disabled])",
"textarea:not([disabled])",
"input:not([disabled])",
"select:not([disabled])",
"[tabindex]:not([tabindex='-1'])"
];
// this will ensure that any modal with the dialog-scrollable modifier gets the intended behaviour
// all other modals will get ignored
this.modalScrollBody = ".modal-dialog-scrollable .modal-body"
// modal trigger element with same data-target value as id of triggered modal
this.modalTriggerElement = null;
// Used to store keydown handlers per modal
this.focusHandlers = new WeakMap();
this.init();
}
init() {
// loop over all modal trigger buttons
this.modalToggles.forEach(btn => {
// if data target value is erroneous or doesn't match any modal ID, return false
const targetSelector = btn.getAttribute('data-target');
if ((targetSelector === "#") || (!targetSelector)) return;
// on modal trigger interaction, set the modal trigger element's value to that of its DOM representation
// and store it
btn.addEventListener('click', (e) => {
e.preventDefault();
this.modalTriggerElement = e.target;
});
});
// loop over all modals
this.modals.forEach(modal => {
const closeBtn = modal.querySelector('.sds-modal__close');
// when a modal shown event is fired:
$(modal).on('shown.bs.modal', (e) => {
// check if a close button exists and focus it if so
if (closeBtn) {
closeBtn.focus();
}
else {
// if no close is present focus first focusable element instead
let focusableElements = this.getFocusableElements(modal);
let first = focusableElements[0];
first.focus()
}
// check for a scrollable body element inside the modal
// set focus trap inside modal while open
this.checkScrollabilityAndSetFocusTrap(modal);
/*
* if the modal gets shown through the bootstrap method instead of
* through a trigger element interaction, store the value of the trigger element
* so it can be focused when closing the modal
*
* this will ensure that no matter how the modal is shown,
* there's always an element to put the focus back on when closed
*
* closing a modal after navigating from modal to modal will also put the focus back on
* the initial modal trigger element or corresponding modal's trigger element, if applicable
* for this purpose, modal trigger elements inside modals that have the data-dismiss="modal" attribute are ignored
*/
let lastFocusedElement = document.querySelector("[data-toggle='modal']:not([data-dismiss='modal'])[data-target='#"+ e.target.getAttribute("id") +"']");
if (lastFocusedElement) {
this.modalTriggerElement = lastFocusedElement;
}
});
$(modal).on('hidden.bs.modal', (e) => {
// if it exists focus the modal's trigger element upon closing the modal
if (this.modalTriggerElement) {
this.modalTriggerElement.focus();
}
});
});
}
checkScrollabilityAndSetFocusTrap(modal) {
const modalBodySelector = this.modalScrollBody;
// check if the modal scrollable modifier is applied to the current modal
// if not, the last element to receive focus will be the modal itself
const modalBody = modal.querySelector(modalBodySelector) ? modal.querySelector(modalBodySelector) : modal;
// add or remove tabindex depending on whether the modal body area is scrollable
function setScrollability () {
const isScrollable = modalBody.scrollHeight > modalBody.clientHeight;
if (isScrollable) {
// Ensure it's focusable
if (!modalBody.hasAttribute('tabindex')) {
modalBody.setAttribute('tabindex', '0');
}
} else {
if (modalBody.hasAttribute('tabindex')) {
modalBody.removeAttribute('tabindex');
}
}
}
// check if modal body is scriollable or not on page load
setScrollability();
// Initial trap
this.trapFocus(modal);
// Observe scrollability changes
const observer = new ResizeObserver(() => {
// check if modal body becomes scrollable on resize
setScrollability();
this.trapFocus(modal);
});
// Required to detect resizing/scrollability
observer.observe(modalBody);
}
// trap the kesyboard focus navigfation inside the modal while it is shown
trapFocus(modal) {
const focusable = this.getFocusableElements(modal);
// abort if no focusable elements are found inside modal
if (!focusable.length) return;
// define first and last focusable elements inside modal
const first = focusable[0];
const last = focusable[focusable.length - 1];
// Remove old handler if exists
if (this.focusHandlers.has(modal)) {
modal.removeEventListener('keydown', this.focusHandlers.get(modal));
}
// move focus from first to last and vice-versa when using tab or shift+tab
const handleKeydown = (e) => {
if (e.key !== 'Tab') return;
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
}
};
modal.addEventListener('keydown', handleKeydown);
this.focusHandlers.set(modal, handleKeydown);
}
// function to get list of focusable elements in modal
getFocusableElements(container) {
// stringify list of focusable element to pass it to querySelectorAll
const selector = this.focusableElements.join();
return container.querySelectorAll(selector);
}
}