Skip to content

Commit

Permalink
fix (theme): add missing alert, fix GutenbergBlockWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
n-langle committed Jul 29, 2024
1 parent af8ecbf commit 1a9c952
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions wp-dsfr-theme/patterns/fr-alert-informations.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@
<p><?php esc_html_e( 'Quatre types d\'alerte sont disponibles, info, success, error et warning :', 'wp-dsfr-theme' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><?php esc_html_e( 'Alerte par défaut :', 'wp-dsfr-theme' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:group {"className":"fr-alert","layout":{"type":"constrained"}} -->
<div class="wp-block-group fr-alert">
<!-- wp:heading {"className":"fr-alert__title","level":3,"placeholder":"<?php esc_attr_e( 'Ajouter un titre', 'wp-dsfr-theme' ); ?>"} -->
<h3 class="wp-block-heading fr-alert__title"></h3>
<!-- /wp:heading -->

<!-- wp:paragraph {"placeholder":"<?php esc_attr_e( 'Ajouter un texte', 'wp-dsfr-theme' ); ?>"} -->
<p></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->

<!-- wp:paragraph -->
<p><code>fr-icon-lock-fill</code> :</p>
<!-- /wp:paragraph -->

<!-- wp:group {"className":"fr-alert fr-icon-lock-fill","layout":{"type":"constrained"}} -->
<div class="wp-block-group fr-alert fr-icon-lock-fill">
<!-- wp:heading {"className":"fr-alert__title","level":3,"placeholder":"<?php esc_attr_e( 'Ajouter un titre', 'wp-dsfr-theme' ); ?>"} -->
<h3 class="wp-block-heading fr-alert__title"></h3>
<!-- /wp:heading -->

<!-- wp:paragraph {"placeholder":"<?php esc_attr_e( 'Ajouter un texte', 'wp-dsfr-theme' ); ?>"} -->
<p></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->

<?php
$available_classes = [
'fr-alert--info',
Expand Down
6 changes: 6 additions & 0 deletions wp-dsfr-theme/src/js/classes/GutenbergBlockWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ class GutenbergBlockWrapper {
{
value: currentClass,
onChange: (value) => {
// if the user start to edit class in text field, do nothing
if (currentClass && !attributes.className.split(' ').includes(currentClass)) {
currentClass = ''
return
}

let className = attributes.className.replace(currentClass, '').replace(/\s+/g, ' ').trim()

if (value !== '') {
Expand Down
1 change: 1 addition & 0 deletions wp-dsfr-theme/src/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ blockGroupFrAlert.addSidebarPanelBody('dsfr-panel', { title: 'DSFR' })
blockGroupFrAlert.addSidebarClassSelector('dsfr-panel', {
label: "Classe css du type d'alerte",
options: [
{ value: '', label: 'Défaut' },
{ value: 'fr-alert--info', label: 'Information' },
{ value: 'fr-alert--success', label: 'Succès' },
{ value: 'fr-alert--error', label: 'Erreur' },
Expand Down

0 comments on commit 1a9c952

Please sign in to comment.