[beta7] Missing pattern info-bulle/tooltip

Created on 30 November 2023, 12 months ago
Updated 21 April 2024, 7 months ago

Problem/Motivation

The version v1.10.2 of DSFR introduce the info-bulle/tooltip
https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/in...

Proposed resolution

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇫🇷France musa.thomas France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @musa.thomas
  • 🇫🇷France pdureau Paris

    It seems, this component has 3 props and no slots:

    • label textfield, instead of a slot, because only plain text is allowed
    • tooltip_id machine name, with random generation if empty
    • placement select, with top, left, center...

    This little component looks tricky to implement:

    • the default state is "hidden", so using it for site-building from the front theme may be difficult
    • there are 2 parts in the markup, the trigger and the tooltip. Only the tooltip belongs to the component, but it doesn't make sense to use it without the trigger.

    I will not be against considering this component as out of ui_suite_dsfr scope.

  • Status changed to Postponed 10 months ago
  • 🇫🇷France pdureau Paris

    Humble draft:

    --- a/templates/patterns/button/button.ui_patterns.yml
    +++ b/templates/patterns/button/button.ui_patterns.yml
    @@ -62,6 +62,11 @@ button:
             left: Right
             right: Left
           preview: left
    +    tooltip:
    +      type: textfield
    +      label: Tooltip
    +      description: https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/infobulle/
    +      preview: Lorem [...] elit ut
         social:
           type: select
           label: Social networks
    diff --git a/templates/patterns/button/pattern-button.html.twig b/templates/patterns/button/pattern-button.html.twig
    index 534f478..805914d 100644
    --- a/templates/patterns/button/pattern-button.html.twig
    +++ b/templates/patterns/button/pattern-button.html.twig
    @@ -20,6 +20,12 @@
       {% set attributes = attributes.setAttribute('disabled', true) %}
     {% endif %}
     
    +{% if tooltip %}
    +  {% set tooltip_id = "tooltip-" ~ random() %}
    +  {% set attributes = attributes.addClass('fr-btn--tooltip').setAttribute("aria-describedby", tooltip_id) %}
    +  <span class="fr-tooltip fr-placement" id="{{ tooltip_id }}" role="tooltip" aria-hidden="true">Lorem [...] elit ut.</span>
    +{% endif %}
    +
     {% if url or attributes.href %}
       {% set url = url|default(attributes.href) %}
       {% if external %}
    
    
  • Status changed to Active 8 months ago
  • First commit to issue fork.
  • Assigned to yassrzg
  • Status changed to Needs work 8 months ago
  • Status changed to Needs review 8 months ago
  • Assigned to pdureau
  • Issue was unassigned.
  • Status changed to Fixed 8 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024