-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add discoverability indicator form (#304)
* feat: ✨ add discoverability indicator * feat: 👔 remove feedback form button from header and footer
- Loading branch information
1 parent
3476c27
commit 6c68dd0
Showing
12 changed files
with
101 additions
and
25 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
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
63 changes: 63 additions & 0 deletions
63
udata_front/theme/gouvfr/assets/js/components/vanilla/dialog.js
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,63 @@ | ||
/** | ||
* | ||
* @param {HTMLElement} dialog | ||
*/ | ||
function showDialog (dialog) { | ||
if (dialog) { | ||
dialog.classList.remove("fr-hidden"); | ||
} | ||
}; | ||
|
||
/** | ||
* | ||
* @param {HTMLElement} dialog | ||
*/ | ||
function closeDialog (dialog) { | ||
if (dialog) { | ||
dialog.classList.add("fr-hidden"); | ||
} | ||
window.localStorage.setItem(dialog.id, "true"); | ||
}; | ||
|
||
/** | ||
* | ||
* @param {HTMLElement} dialog | ||
* @param {number} triggerCount | ||
* @param {string} startsWithString | ||
*/ | ||
function triggerDialog(dialog, triggerCount = 3, startsWithString = '/') { | ||
const path = window.location.pathname; | ||
const dialogId = dialog.id; | ||
const hasAlreadyBeenTriggered = window.localStorage.getItem(dialogId) || false; | ||
if (hasAlreadyBeenTriggered) { | ||
return; | ||
} | ||
|
||
if (path.indexOf(startsWithString) === -1) { | ||
return; | ||
} | ||
|
||
// page-view counter increment | ||
const pvKey = 'pv-' + dialogId; | ||
let pageViewCount = parseInt(window.sessionStorage.getItem(pvKey) || "0", 10); | ||
|
||
if (pageViewCount >= triggerCount) { | ||
showDialog(dialog); | ||
} | ||
pageViewCount++; | ||
window.sessionStorage.setItem(pvKey, pageViewCount.toFixed(0)); | ||
} | ||
|
||
/** | ||
* @type {NodeListOf<HTMLElement>} | ||
*/ | ||
const dialogs = document.querySelectorAll("[data-dialogs]"); | ||
dialogs.forEach((dialog) => { | ||
triggerDialog(dialog); | ||
const buttons = dialog.querySelectorAll("[data-dialogs-close]"); | ||
buttons.forEach((button) => { | ||
if(button instanceof HTMLElement) { | ||
button.addEventListener("click", () => closeDialog(dialog)); | ||
} | ||
}); | ||
}); |
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,15 @@ | ||
{% if config.DISCOVERABILITY_FORM_URL %} | ||
<div class="bg-alt-blue-cumulus fr-p-3v border-bottom border-2 border-blue-400 fr-hidden" data-dialogs id="feedback-banner"> | ||
<div class="fr-container"> | ||
<div class="fr-grid-row fr-grid-row--middle"> | ||
<div class="fr-my-0"> | ||
<a class="fr-link" href="{{ config.DISCOVERABILITY_FORM_URL }}" target="_blank" data-dialogs-close> | ||
{{_("Did you find what you were looking for?")}}</a> | ||
</div> | ||
<button class="fr-btn fr-btn--close" data-dialogs-close> | ||
{{_("Don't show this message again")}} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} |
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,9 +1,5 @@ | ||
<div class="bg-contrast-warning fr-py-3v fr-px-1w"> | ||
<div class="fr-container"> | ||
<div class="fr-grid-row fr-grid-row--middle text-align-center-sm"> | ||
<p class="text-default-warning"> | ||
{{ _('Due to security reasons, the creation of new content is currently disabled.') }} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
{% from theme('macros/banner_warning.html') import banner_warning %} | ||
{{ banner_warning( | ||
"fr-icon-alert-line", | ||
_('Due to security reasons, the creation of new content is currently disabled.') | ||
)}} |
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
10 changes: 6 additions & 4 deletions
10
udata_front/theme/gouvfr/templates/macros/banner_warning.html
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,8 +1,10 @@ | ||
{% macro banner_warning(icon, text) %} | ||
<div class="bg-alt-green-tilleul-verveine fr-p-3v fr-mb-1w"> | ||
<p class="fr-grid-row fr-grid-row--middle fr-my-0"> | ||
<span class="{{ icon }} fr-mr-1w" aria-hidden="true"></span> | ||
{{ text }} | ||
</p> | ||
<div class="fr-container"> | ||
<p class="fr-grid-row fr-grid-row--middle fr-my-0"> | ||
<span class="{{ icon }} fr-mr-1w" aria-hidden="true"></span> | ||
{{ text }} | ||
</p> | ||
</div> | ||
</div> | ||
{% endmacro %} |