<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="pretty-atom-feed.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:webfeeds="http://webfeeds.org/rss/1.0" xml:lang="fr">
  <title>Simon Duhem - Articles</title>
  <subtitle>Articles et conférences sur l&#39;accessibilité, les Web Components et le développement front-end.</subtitle>
  <link href="https://simon.duhem.fr/articles/feed/feed.xml" rel="self" />
  <link href="https://simon.duhem.fr/articles/" />
  <link href="https://pubsubhubbub.appspot.com/" rel="hub" />
  <updated>2026-10-16T00:00:00Z</updated>
  <id>https://simon.duhem.fr/articles/</id>
  <icon>https://simon.duhem.fr/512.png</icon>
  <logo>https://simon.duhem.fr/512.png</logo>
  <webfeeds:icon>https://simon.duhem.fr/512.png</webfeeds:icon>
  <author>
    <name>Simon Duhem</name>
    <email>simon@duhem.fr</email>
  </author>
  <entry>
    <title>Music Bridge</title>
    <link href="https://simon.duhem.fr/articles/music-bridge/" />
    <updated>2026-10-16T00:00:00Z</updated>
    <id>https://simon.duhem.fr/articles/music-bridge/</id>
    <content type="html">&lt;h2 id=&quot;au-depart-deezer-link&quot;&gt;Au départ, Deezer Link&lt;/h2&gt;
&lt;p&gt;J&#39;écoute ma musique sur Deezer, dans l&#39;application de bureau.
Quand on m&#39;envoie un lien Deezer, il s&#39;ouvre pourtant dans le navigateur. J&#39;avais donc fait une petite extension, &lt;a href=&quot;https://chromewebstore.google.com/detail/depodknemkobjklhmpemeagnehojilng&quot;&gt;Deezer Link&lt;/a&gt;, qui ouvre ces liens directement dans l&#39;application.&lt;/p&gt;
&lt;p&gt;Mais on m&#39;envoie aussi des liens d&#39;autres plateformes.
Et là, il faut copier le titre, ouvrir Deezer, le chercher...&lt;/p&gt;
&lt;h2 id=&quot;music-bridge&quot;&gt;Music Bridge&lt;/h2&gt;
&lt;p&gt;C&#39;est comme ça qu&#39;est née Music Bridge, fin 2022.&lt;/p&gt;
&lt;p&gt;Le principe est simple : on choisit sa plateforme une fois dans les options, et chaque lien vers un titre ou un album d&#39;une autre plateforme s&#39;ouvre directement sur la sienne.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/music-bridge/heUlFqBqwT-1280.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/music-bridge/heUlFqBqwT-1280.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/music-bridge/heUlFqBqwT-1280.png&quot; alt=&quot;Un lien Spotify ? Ouvert sur Deezer.&quot; width=&quot;1280&quot; height=&quot;800&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Ça marche dans tous les sens, entre Deezer, Spotify, Apple Music, YouTube Music, Amazon Music, YouTube, SoundCloud, Tidal et Pandora.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/music-bridge/IrSXl4SV9B-1280.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/music-bridge/IrSXl4SV9B-1280.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/music-bridge/IrSXl4SV9B-1280.png&quot; alt=&quot;Les plateformes prises en charge&quot; width=&quot;1280&quot; height=&quot;800&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;On peut aussi ouvrir la musique dans l&#39;application de bureau de sa plateforme (Deezer, Spotify ou Apple Music, sur Windows et macOS), et fermer l&#39;onglet resté ouvert.&lt;/p&gt;
&lt;h2 id=&quot;comment-ca-marche&quot;&gt;Comment ça marche&lt;/h2&gt;
&lt;p&gt;Tout repose sur l&#39;API d&#39;&lt;a href=&quot;https://odesli.co/&quot;&gt;Odesli&lt;/a&gt; (anciennement Songlink) : à partir d&#39;un lien, elle retrouve la même musique sur les autres plateformes.&lt;/p&gt;
&lt;p&gt;Je connais Odesli depuis un moment : quand je travaillais chez Deezer, j&#39;avais été mis en contact avec Kurt, son fondateur, et je les avais guidés pour utiliser l&#39;API de Deezer.&lt;/p&gt;
&lt;p&gt;L&#39;extension passe par mon propre service de redirection, qui interroge Odesli et renvoie vers le bon lien.&lt;/p&gt;
&lt;h2 id=&quot;finir-ses-side-projects&quot;&gt;Finir ses side projects&lt;/h2&gt;
&lt;p&gt;Grâce à Claude, je me suis mis à finir tous mes side projects. Music Bridge en faisait partie.&lt;/p&gt;
&lt;p&gt;J&#39;ai regroupé mes extensions dans un seul dépôt et je les ai reconstruites avec &lt;a href=&quot;https://wxt.dev/&quot;&gt;WXT&lt;/a&gt;. Au passage :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Music Bridge est disponible sur Chrome, Edge et Firefox, y compris sur Android ;&lt;/li&gt;
&lt;li&gt;la page d&#39;options s&#39;ouvre à l&#39;installation et explique ce que fait l&#39;extension ;&lt;/li&gt;
&lt;li&gt;elle a été revue pour être simple et accessible ;&lt;/li&gt;
&lt;li&gt;l&#39;option d&#39;application de bureau n&#39;est plus proposée là où elle ne peut pas marcher (Linux, ChromeOS, Android, iOS).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;les-limites&quot;&gt;Les limites&lt;/h2&gt;
&lt;p&gt;Comme Music Bridge utilise l&#39;API d&#39;Odesli, elle se limite elle aussi à rediriger les titres et les albums : pas les artistes ni les playlists.&lt;/p&gt;
&lt;p&gt;Sur Android, si l&#39;application d&#39;une autre plateforme est installée, ses liens s&#39;ouvrent directement dedans, sans passer par le navigateur. L&#39;extension ne peut donc pas les rediriger.&lt;/p&gt;
&lt;h2 id=&quot;on-en-parle&quot;&gt;On en parle&lt;/h2&gt;
&lt;p&gt;Korben a présenté Music Bridge sur son blog : &lt;a href=&quot;https://korben.info/music-bridge-extension-liens-musique.html&quot;&gt;Music Bridge - Pour que les liens musicaux s&#39;ouvrent bien sur votre plateforme favorite&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;essayer-music-bridge&quot;&gt;Essayer Music Bridge&lt;/h2&gt;
&lt;p&gt;Music Bridge est disponible pour :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://chromewebstore.google.com/detail/music-bridge/mbebbcaajfmockkcflajghbambbimpck&quot;&gt;Chrome&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/firefox/addon/music-bridge/&quot;&gt;Firefox&lt;/a&gt;, sur ordinateur et sur Android&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://microsoftedge.microsoft.com/addons/detail/kfbedaeciahfjnknbjkcnjknkbdlcnld&quot;&gt;Edge&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Le code est sur &lt;a href=&quot;https://github.com/smndhm/web-extensions&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;C&#39;est encore jeune, il reste sûrement des cas que je n&#39;ai pas prévus. N&#39;hésitez pas à l&#39;installer et à me dire ce que vous en pensez !&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>LSLT Pebble Watchface</title>
    <link href="https://simon.duhem.fr/articles/lslt-pebble-watchface/" />
    <updated>2025-12-30T00:00:00Z</updated>
    <id>https://simon.duhem.fr/articles/lslt-pebble-watchface/</id>
    <content type="html">&lt;h2 id=&quot;typographie&quot;&gt;Typographie&lt;/h2&gt;
&lt;p&gt;Je me suis toujours intéressé aux polices d&#39;écriture.&lt;/p&gt;
&lt;p&gt;Il y a quelques années, j&#39;en ai même conçue une avec &lt;a href=&quot;https://glyphsapp.com/&quot;&gt;Glyphs&lt;/a&gt; : LSLT Regular.&lt;br&gt;
C&#39;était avant tout un exercice : comprendre comment fonctionne une typographie, tester les ligatures (j&#39;en avais créé beaucoup). Cette police ne m&#39;a jamais vraiment servi, et elle avait d&#39;ailleurs un petit problème de centrage... mais elle m&#39;a énormément appris.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/jJN_a4RcWi-1200.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/jJN_a4RcWi-1200.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/jJN_a4RcWi-1200.png&quot; alt=&quot;Aperçu des ligatures de la police LSLT Regular&quot; width=&quot;1200&quot; height=&quot;320&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Depuis, les polices variables se sont démocratisées. Malheureusement, la version &amp;quot;mini&amp;quot; de Glyphs ne permet pas d&#39;en créer, et 300€ pour un simple sujet de curiosité, c&#39;était un peu trop.&lt;/p&gt;
&lt;p&gt;À Paris Web, j&#39;ai croisé &lt;a href=&quot;https://www.linkedin.com/in/damien-collot-80177845/&quot;&gt;Damien Collot&lt;/a&gt; de chez &lt;a href=&quot;https://www.monotype.com&quot;&gt;Monotype&lt;/a&gt;.&lt;br&gt;
Au fil de la discussion, il m&#39;a parlé de &lt;a href=&quot;https://fontra.xyz/&quot;&gt;Fontra&lt;/a&gt;, une application open source permettant de créer des polices, y compris variables. À ce moment-là, je trouvais ça cool... sans avoir d&#39;idée précise en tête.&lt;/p&gt;
&lt;h2 id=&quot;pebble&quot;&gt;Pebble&lt;/h2&gt;
&lt;p&gt;J&#39;ai eu une montre Pebble assez tôt. J&#39;avais adoré le fait qu&#39;elle soit ouverte aux développeurs. J&#39;y avais développé quelques applications, sans jamais les publier.&lt;/p&gt;
&lt;p&gt;Mon compte développeur étant actif, lors de &lt;a href=&quot;https://www.kickstarter.com/projects/getpebble/pebble-time-awesome-smartwatch-no-compromises&quot;&gt;la seconde campagne Kickstarter&lt;/a&gt;, j&#39;avais même reçu une Pebble Time Developer Edition, avec mon nom gravé dessus.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/27tLPQgQOQ-1200.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/27tLPQgQOQ-1200.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/27tLPQgQOQ-1200.png&quot; alt=&quot;Montre Pebble Time Developer Edition&quot; width=&quot;1200&quot; height=&quot;340&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Mais Pebble n&#39;a pas duré. La marque a été rachetée par Fitbit, elle-même rachetée par Google.&lt;br&gt;
Les serveurs ont fini par être éteints, et la montre a terminé... au fond d&#39;un tiroir.&lt;/p&gt;
&lt;p&gt;Il y a bien eu le projet Rebble pour maintenir l&#39;écosystème en vie, et j&#39;ai plusieurs fois hésité à m&#39;y remettre, mais je trouvais ça un peu compliqué.&lt;/p&gt;
&lt;p&gt;Puis, début d&#39;année, &lt;a href=&quot;https://rebble.io/2025/01/27/the-future-of-rebble.html&quot;&gt;Google a décidé de rendre le code de Pebble open source&lt;/a&gt;. Et Eric Migicovsky, le fondateur, &lt;a href=&quot;https://ericmigi.com/blog/why-were-bringing-pebble-back&quot;&gt;a annoncé le retour des montres&lt;/a&gt; avec de nouvelles Pebble 2, de nouveau disponibles.&lt;/p&gt;
&lt;p&gt;Soudain, tout redevenait simple :
un SDK avec des infos claires pour l&#39;installer, une application, un GitHub Codespace, une extension VS Code... Bref, tout ce qu&#39;il fallait pour me donner envie de ressortir la montre du tiroir.&lt;/p&gt;
&lt;h2 id=&quot;l-idee-de-la-watchface&quot;&gt;L&#39;idée de la watchface&lt;/h2&gt;
&lt;p&gt;La combinaison de ces deux événements m&#39;a donné envie de faire une watchface pour ma Pebble Time fraîchement ressortie du tiroir.&lt;/p&gt;
&lt;p&gt;Je n&#39;avais pas encore d&#39;idée très précise, mais
je voulais que les chiffres puissent évoluer visuellement, en passant d&#39;une forme fine (3x11) en Regular à une forme carrée (11x11) en Extra Bold.&lt;/p&gt;
&lt;p&gt;J&#39;ai donc commencé par créer une nouvelle police, la LSLT Variable.
Comme elle était destinée à une montre, je me suis volontairement limité aux chiffres.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/4XvT2SsGuc-1200.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/4XvT2SsGuc-1200.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/4XvT2SsGuc-1200.png&quot; alt=&quot;Dessin de la typographie&quot; width=&quot;1200&quot; height=&quot;420&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Fontra s&#39;est révélé très agréable à utiliser, et j&#39;ai rapidement obtenu exactement ce que j&#39;avais en tête.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/TVgkbXtYSN-640.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/TVgkbXtYSN-640.gif&quot; alt=&quot;Police variable dans fontra&quot; width=&quot;640&quot; height=&quot;389&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;h2 id=&quot;developpement&quot;&gt;Développement&lt;/h2&gt;
&lt;p&gt;Il fallait maintenant passer au développement de cette watchface, et ça a été un peu l&#39;aventure.&lt;/p&gt;
&lt;p&gt;Premier choix à faire : développer en C ou en JS.
Le choix était vite fait, mais j&#39;ai rapidement eu une mauvaise surprise : il n&#39;est pas possible d&#39;utiliser une police externe dans les applications JS.&lt;/p&gt;
&lt;p&gt;On se lance donc dans le développement d&#39;une watchface en C, accompagné de mon agent Copilot 😅&lt;/p&gt;
&lt;p&gt;J&#39;arrive rapidement à avoir une watchface qui utilise ma police, mais elle reste en Regular. Je n&#39;ai pas trouvé comment la faire varier. Déception.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/wJu9HSOqxG-1200.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/wJu9HSOqxG-1200.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/wJu9HSOqxG-1200.png&quot; alt=&quot;Montre utilisant la police LSLT en Regular&quot; width=&quot;1200&quot; height=&quot;800&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Entre-temps, le concept de la watchface est trouvé : faire varier la police en fonction du temps.
Les minutes grossissent en fonction du nombre de secondes, et les heures en fonction des minutes. Il faut donc trouver un moyen de faire varier cette police.&lt;/p&gt;
&lt;p&gt;En contournement, je me lance dans la génération de 60 déclinaisons de la police, pour changer celle utilisée en fonction du temps.
Ce n&#39;est pas très propre, mais ça fonctionne.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/FlqYgKZlqr-1200.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/FlqYgKZlqr-1200.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/FlqYgKZlqr-1200.png&quot; alt=&quot;Montre utilisant la police LSLT Variable&quot; width=&quot;1200&quot; height=&quot;690&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Je me rends vite compte que les caractères ne sont pas affichés assez grand. La taille maximale semble limitée, et la watchface devient assez lourde, rien qu&#39;à l&#39;installation.
Ça ne va pas vraiment avec l&#39;esprit Pebble.&lt;/p&gt;
&lt;p&gt;C&#39;est à ce moment-là que j&#39;ai changé d&#39;approche, les fichiers de Fontra sont assez proches de SVG : pour la version Regular et la Extra Bold, les formes sont les mêmes, seules leurs positions changent.
Pourquoi ne pas reproduire ce fonctionnement, en dessinant et en faisant varier la position des rectangles de chaque caractère en fonction du temps ?&lt;/p&gt;
&lt;p&gt;Avec l&#39;aide de Copilot, c&#39;est ce que j&#39;ai fait.
Ça ne s&#39;est pas fait du premier coup, et j&#39;ai quand même dû mettre le nez dans le code C pour bien calculer les positions et les espacements. Mais au final, j&#39;ai obtenu la watchface que j&#39;avais en tête.&lt;/p&gt;
&lt;h2 id=&quot;resultat&quot;&gt;Résultat&lt;/h2&gt;
&lt;p&gt;Je suis plutôt content du résultat, et même du concept.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/PpXY35-uP8-1200.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/PpXY35-uP8-1200.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/PpXY35-uP8-1200.png&quot; alt=&quot;Montre finale&quot; width=&quot;1200&quot; height=&quot;610&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/OO3GZ8du1i-1200.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/OO3GZ8du1i-1200.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/lslt-pebble-watchface/OO3GZ8du1i-1200.png&quot; alt=&quot;Montre aux couleurs de Noël&quot; width=&quot;1200&quot; height=&quot;760&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Je l&#39;ai publiée sur le store de Rebble. Elle est disponible pour toutes les montres Pebble, anciennes comme nouvelles, rondes comme carrées : &lt;a href=&quot;https://apps.rebble.io/fr_FR/application/69372f6797c9a200096af59e?section=watchfaces&quot;&gt;LSLT | Watchface&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;N&#39;hésitez pas à l&#39;installer et à me dire ce que vous en pensez.&lt;/p&gt;
&lt;p&gt;Si vous avez des idées d&#39;amélioration, n&#39;hésitez pas à me le faire savoir.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Prendre en compte les Web Components dans vos scripts</title>
    <link href="https://simon.duhem.fr/articles/prendre-en-compte-les-web-components-dans-vos-scripts/" />
    <updated>2025-12-09T00:00:00Z</updated>
    <id>https://simon.duhem.fr/articles/prendre-en-compte-les-web-components-dans-vos-scripts/</id>
    <content type="html">&lt;p&gt;Les &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt; sont de plus en plus présents dans nos interfaces. Des &lt;span lang=&quot;en&quot;&gt;design systems&lt;/span&gt; populaires comme &lt;span lang=&quot;en&quot;&gt;Carbon&lt;/span&gt; d’IBM, &lt;span lang=&quot;en&quot;&gt;Spectrum&lt;/span&gt; d’Adobe ou encore Polaris de &lt;span lang=&quot;en&quot;&gt;Shopify&lt;/span&gt; ont aussi pris le parti de les utiliser pour leurs composants. Ce choix répond souvent à une volonté d’être agnostique, c’est-à-dire de proposer des éléments réutilisables quel que soit l’écosystème utilisé : React, Vue, Angular, ou même sans &lt;span lang=&quot;en&quot;&gt;framework&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Techniquement, un &lt;span lang=&quot;en&quot;&gt;Web Component&lt;/span&gt; repose sur trois autres standards : les &lt;span lang=&quot;en&quot;&gt;custom elements&lt;/span&gt;&lt;sup&gt;&lt;a href=&quot;https://developer.mozilla.org/fr/docs/Web/API/Web_components/Using_custom_elements&quot; title=&quot;Utilisation d&#39;éléments personnalisés sur MDN.&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; qui permettent de définir de nouvelles balises ; les &lt;span lang=&quot;en&quot;&gt;HTML templates&lt;/span&gt;&lt;sup&gt;&lt;a href=&quot;https://developer.mozilla.org/fr/docs/Web/API/Web_components/Using_templates_and_slots&quot; title=&quot;Utiliser les éléments template et slot sur MDN.&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; qui servent de base à leur structure ; et le &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt;&lt;sup&gt;&lt;a href=&quot;https://developer.mozilla.org/fr/docs/Web/API/Web_components/Using_shadow_DOM&quot; title=&quot;Utiliser le DOM d’ombre sur MDN.&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; qui encapsule et isole le style et la logique interne du composant.&lt;/p&gt;
&lt;p&gt;Cette isolation est une force, elle garantit qu’un composant ne sera pas impacté par les styles externes. Mais elle complique également la tâche des scripts qui veulent interagir avec le contenu encapsulé.&lt;/p&gt;
&lt;p&gt;Lors de ma conférence « &lt;cite&gt;&lt;a href=&quot;https://www.paris-web.fr/2025/conference/les-web-components-et-laccessibilite&quot;&gt;Les &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt; et l’accessibilité&lt;/a&gt;&lt;/cite&gt; » à Paris Web, j’ai évoqué le fait que certains outils d’accessibilité ne détectent pas les éléments présents dans le &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt;.&lt;br&gt;
Plusieurs personnes m’ont ensuite demandé comment faire pour corriger ça dans leurs propres scripts. Cet article est l’occasion d’y répondre plus en détail.&lt;/p&gt;
&lt;h2 id=&quot;les-particularites-du-shadow-dom&quot;&gt;Les particularités du &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Le contenu d’un &lt;span lang=&quot;en&quot;&gt;Web Component&lt;/span&gt; n’est pas directement accessible avec des sélecteurs habituels comme &lt;code&gt;document.querySelector&lt;/code&gt;.
Pour accéder au contenu d’un &lt;span lang=&quot;en&quot;&gt;Web Component&lt;/span&gt;, il faut d’abord cibler l’élément, puis explorer son &lt;code&gt;shadowRoot&lt;/code&gt; :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Pour accéder au shadow DOM du custom element &amp;lt;24-jours-de-web&gt;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; element &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;24-jours-de-web&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; shadow &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Mais attention, cela ne fonctionne que si le &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt; a été créé en mode &lt;code&gt;open&lt;/code&gt;. En mode &lt;code&gt;closed&lt;/code&gt; le contenu restera inaccessible&lt;sup&gt;&lt;a href=&quot;https://developer.mozilla.org/fr/docs/Web/API/Web_components/Using_shadow_DOM#element.shadowroot_et_loption_%C2%AB_mode_%C2%BB&quot; title=&quot;`Element.shadowRoot` et l&#39;option « mode » sur MDN.&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;Dans la suite de l’article, nous partirons donc du principe que les composants utilisent un &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt; &lt;code&gt;open&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;parcourir-les-web-components-dans-un-script&quot;&gt;Parcourir les &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt; dans un script&lt;/h2&gt;
&lt;p&gt;Pour illustrer la prise en compte des &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt; dans vos scripts, partons d’un cas simple : récupérer tous les champs &lt;code&gt;&amp;lt;input/&amp;gt;&lt;/code&gt; présents dans une page.&lt;/p&gt;
&lt;h3 id=&quot;le-cas-classique&quot;&gt;Le cas classique&lt;/h3&gt;
&lt;p&gt;Quand aucun &lt;span lang=&quot;en&quot;&gt;Web Component&lt;/span&gt; n’est utilisé, les éléments sont directement présents dans le DOM principal.
Dans ce contexte, un sélecteur CSS classique suffit :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; inputs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;input&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;avec-des-web-components&quot;&gt;Avec des &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Les choses se compliquent lorsque des &lt;code&gt;input&lt;/code&gt; se retrouvent encapsulés dans un &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt;.
Dans ce cas, &lt;code&gt;document.querySelectorAll(&#39;input&#39;)&lt;/code&gt; ne les verra pas.&lt;/p&gt;
&lt;p&gt;Pour résoudre le problème, il faut d’abord être capable d’identifier les &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt; présents dans la page.&lt;/p&gt;
&lt;h4 id=&quot;identifier-les-web-components&quot;&gt;Identifier les &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Pour éviter les conflits avec les balises HTML natives, le nom d’un &lt;span lang=&quot;en&quot;&gt;Custom Element&lt;/span&gt; doit obligatoirement contenir un tiret (&lt;code&gt;-&lt;/code&gt;).
C’est une règle du standard et c’est aussi un moyen simple et fiable de les détecter.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;findCustomElements&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// On recherche tous les éléments de la page&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;*&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;elm&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// On ne retourne que ceux dont la balise contient un tiret&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; elm&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tagName&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;-&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cette fonction renvoie tous les &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt; présents dans le DOM principal mais pas leur contenu, qui reste encapsulé dans leur &lt;code&gt;shadowRoot&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&quot;parcourir-leur-shadow-dom&quot;&gt;Parcourir leur &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Une fois un &lt;span lang=&quot;en&quot;&gt;Custom Element&lt;/span&gt; détecté, il faut vérifier qu’il possède un &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt;, puis s’assurer qu’il est en mode &lt;code&gt;open&lt;/code&gt;, condition indispensable pour y accéder depuis un script externe :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;findInputsInShadow&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Si pas de shadowRoot (ou en mode closed), on s’arrête là&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// À partir d’ici, on peut interroger librement le contenu du shadow DOM&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;input&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cette approche fonctionne, mais uniquement à un niveau d’imbrication.&lt;/p&gt;
&lt;p&gt;C’est une situation plutôt courante, un composant peut en contenir un autre, qui lui-même en contient un autre, etc. Et chacun possède potentiellement son propre &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt;.
Il faut donc répéter ce travail à chaque niveau, ce qui impose une approche récursive.&lt;/p&gt;
&lt;h3 id=&quot;recuperer-tous-les-input-dans-le-dom-et-dans-tous-les-shadow-dom&quot;&gt;Récupérer tous les &lt;code&gt;input&lt;/code&gt;, dans le DOM et dans tous les &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Pour couvrir tous les cas, il faut récupérer les champs présents dans le DOM principal et ceux encapsulés dans les &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt; accessibles.
On peut commencer par écrire une première fonction capable de descendre dans tous les niveaux d’imbrication :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;findAllInputs&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;root &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Inputs visibles à ce niveau du DOM&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; inputs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;root&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;input&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Web Components présents à ce même niveau&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; customElements &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;findCustomElements&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;root&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Pour chaque Web Component, on accède au shadowRoot&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; element &lt;span class=&quot;token keyword&quot;&gt;of&lt;/span&gt; customElements&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    inputs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findAllInputs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; inputs&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cette première étape permet déjà de retrouver tous les &lt;code&gt;input&lt;/code&gt; de la page, même ceux encapsulés dans des &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt;.
Mais on peut aller plus loin et généraliser le principe, pourquoi se limiter aux champs ?&lt;/p&gt;
&lt;h3 id=&quot;vers-un-deepqueryselectorall&quot;&gt;Vers un &lt;code&gt;deepQuerySelectorAll()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;L’idée suivante découle assez naturellement, écrire un équivalent de &lt;code&gt;document.querySelectorAll()&lt;/code&gt;, mais capable de traverser tous les &lt;span lang=&quot;en&quot;&gt;Shadow DOM&lt;/span&gt;, quels que soient leur profondeur ou leur nombre.&lt;/p&gt;
&lt;p&gt;La structure va être la même que précédemment, mais on remplace simplement le sélecteur &lt;code&gt;&#39;input&#39;&lt;/code&gt; par n’importe quel sélecteur CSS passé en paramètre :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;deepQuerySelectorAll&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;selector&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; root &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Éléments trouvés dans le DOM courant&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;root&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;selector&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Détection des Custom Elements déjà écrite plus haut&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; customElements &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;findCustomElements&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;root&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// On explore chaque Shadow DOM accessible&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; el &lt;span class=&quot;token keyword&quot;&gt;of&lt;/span&gt; customElements&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;el&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    results&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;deepQuerySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;selector&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; el&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; results&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Avec cette nouvelle fonction, on peut par exemple récupérer tous les boutons d’une page, y compris ceux encapsulés dans le &lt;span lang=&quot;en&quot;&gt;Shadow DOM&lt;/span&gt;. Exactement comme on le ferait naturellement avec &lt;code&gt;document.querySelectorAll()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; buttons &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deepQuerySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;button&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;et-le-queryselectordeep&quot;&gt;Et le &lt;code&gt;querySelectorDeep()&lt;/code&gt; ?&lt;/h3&gt;
&lt;p&gt;La suite logique serait de proposer l’équivalent de &lt;code&gt;document.querySelector()&lt;/code&gt;, qui s’arrête au premier résultat.
Je ne vais pas m’attarder dessus, le principe est le même et je pense que l’idée générale est désormais claire.&lt;/p&gt;
&lt;p&gt;Pour rendre tout cela plus pratique, j’ai regroupé ces fonctions dans une petite librairie dédiée : &lt;a href=&quot;https://www.npmjs.com/package/@dume/webcomp-utils&quot;&gt;@dume/webcomp-utils&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Voici à quoi cela ressemble :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; deepQuerySelectorAll&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; deepQuerySelector &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;@dume/webcomp-utils&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; emailInput &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deepQuerySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; fields &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deepQuerySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.field&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Maintenant que vous avez toutes les clés pour parcourir les &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt;, n’oubliez pas qu’un &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt; n’est accessible que s’il est en mode &lt;code&gt;open&lt;/code&gt;. En &lt;code&gt;closed&lt;/code&gt; son contenu reste totalement isolé et aucun script extérieur ne pourra le toucher.&lt;/p&gt;
&lt;p&gt;L’isolation apportée par le &lt;span lang=&quot;en&quot;&gt;shadow DOM&lt;/span&gt; est volontaire, elle protège le composant et garantit qu’il ne sera pas perturbé par des styles ou scripts externes. Les fonctions que nous avons vues permettent d’accéder au contenu encapsulé, mais elles ne sont pas destinées à le modifier. Utilisez-les avec précaution.&lt;/p&gt;
&lt;p&gt;Avec ces outils en main, vous pouvez désormais aller mettre à jour vos scripts et interagir avec vos &lt;span lang=&quot;en&quot;&gt;Web Components&lt;/span&gt; comme si l’encapsulation n’existait pas. &lt;span role=&quot;img&quot; aria-label=&quot;clin d’œil&quot;&gt;😉&lt;/span&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Conférence : Les Web Components et l&#39;accessibilité</title>
    <link href="https://simon.duhem.fr/slides/paris-web-les-web-components-et-laccessibilite.html" />
    <updated>2025-09-26T00:00:00Z</updated>
    <id>https://simon.duhem.fr/slides/paris-web-les-web-components-et-laccessibilite.html</id>
    <content type="html">
    &lt;p&gt;Conférence à &lt;a href=&quot;https://www.paris-web.fr/2025/conference/les-web-components-et-laccessibilite&quot;&gt;Paris Web&lt;/a&gt;, le 26 septembre 2025.&lt;/p&gt;&lt;p&gt;Le Shadow DOM des Web Components brise les liens ARIA. Deux façons de les rétablir, et comment auditer ces composants quand le RGAA reste flou.&lt;/p&gt;
    &lt;p&gt;&lt;a href=&quot;https://simon.duhem.fr/slides/paris-web-les-web-components-et-laccessibilite.html&quot;&gt;Voir les slides&lt;/a&gt; (&lt;a href=&quot;https://simon.duhem.fr/slides/paris-web-les-web-components-et-laccessibilite.pdf&quot;&gt;PDF&lt;/a&gt;).&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Conférence : Les Web Components et l&#39;accessibilité</title>
    <link href="https://simon.duhem.fr/slides/the-remote-tribe-les-web-components-et-laccessibilite.html" />
    <updated>2025-08-26T00:00:00Z</updated>
    <id>https://simon.duhem.fr/slides/the-remote-tribe-les-web-components-et-laccessibilite.html</id>
    <content type="html">
    &lt;p&gt;Conférence à &lt;a href=&quot;https://www.theremotetribe.co/event/meetup-chez-locservice-sujet-webcomponents-et-l-accessibilite-37&quot;&gt;The Remote Tribe - meetup chez Locservice&lt;/a&gt;, le 26 août 2025.&lt;/p&gt;&lt;p&gt;Shadow DOM et accessibilité : liens ARIA cassés, gestion des événements, outils d&amp;#39;audit qui ignorent les Web Components. Les limites et les solutions.&lt;/p&gt;
    &lt;p&gt;&lt;a href=&quot;https://simon.duhem.fr/slides/the-remote-tribe-les-web-components-et-laccessibilite.html&quot;&gt;Voir les slides&lt;/a&gt; (&lt;a href=&quot;https://simon.duhem.fr/slides/the-remote-tribe-les-web-components-et-laccessibilite.pdf&quot;&gt;PDF&lt;/a&gt;).&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Ajout de l&#39;auto-complétion sur les Web Components avec Stencil</title>
    <link href="https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/" />
    <updated>2024-03-14T00:00:00Z</updated>
    <id>https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/</id>
    <content type="html">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Chez MGDIS, nous mettons à jour nos services en passant de AngularJS, désormais obsolète, à Vue.js. Cependant, avec l&#39;évolution rapide des frameworks et la transition de Vue 2 à Vue 3, ces changements ne sont pas sans difficultés. Pour cela, nous nous sommes tournés vers les &lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/Web_components&quot;&gt;Web Components&lt;/a&gt;, un standard indépendant de tout framework.&lt;/p&gt;
&lt;p&gt;Au sein de la Core UI, nous développons &lt;a href=&quot;https://github.com/MGDIS/core-ui/tree/master/packages/mg-components&quot;&gt;mg-components&lt;/a&gt;, une bibliothèque de Web Components basée sur &lt;a href=&quot;https://stenciljs.com/&quot;&gt;Stencil&lt;/a&gt;. Cette bibliothèque offre une collection de composants conçus pour faciliter le développement et garantir l&#39;accessibilité de nos produits.
Note : Stencil n&#39;est pas un framework mais une librairie qui permet de générer des Web Components.&lt;/p&gt;
&lt;p&gt;Une demande fréquente des développeurs était l&#39;auto-complétion dans leurs IDEs pour notre librairie mg-components. Cependant, les Web Components ne fournissent pas automatiquement cette fonctionnalité car cela nécessite des informations spécifiques sur les éléments et attributs personnalisés. Nous avons donc cherché une solution pour remédier à cette limitation.&lt;/p&gt;
&lt;h2 id=&quot;la-recherche-de-la-solution&quot;&gt;La recherche de la solution&lt;/h2&gt;
&lt;p&gt;Nous avons d&#39;abord exploré les options pour VS Code, nous avons rapidement découvert que Stencil propose l&#39;export &lt;a href=&quot;https://stenciljs.com/docs/docs-vscode&quot;&gt;VS Code Documentation&lt;/a&gt;, basé sur les &lt;a href=&quot;https://github.com/microsoft/vscode-custom-data&quot;&gt;custom data&lt;/a&gt;, un format pris en charge par VS Code. Une fois le fichier généré, l&#39;intégration est simple : il suffit d&#39;ajouter un fichier de configuration dans le projet utilisant la librairie pour que l&#39;auto-complétion fonctionne.&lt;/p&gt;
&lt;p&gt;Cependant, nous avons également des développeurs qui utilisent WebStorm, pour lequel Stencil ne propose pas d&#39;export de documentation. Pour contourner ce problème, nous avons utilisé les &lt;a href=&quot;https://github.com/JetBrains/web-types&quot;&gt;web types&lt;/a&gt; de JetBrains, qui sont un équivalent des custom data mais pour WebStorm.
Avec le package &lt;a href=&quot;https://github.com/nielsboogaard/stenciljs-web-types-generator&quot;&gt;stenciljs-web-types-generator
&lt;/a&gt; nous sommes en mesure de générer ce fichier. Il suffit ensuite de le référencer à la propriété &amp;quot;web-types&amp;quot; dans le &lt;code&gt;package.json&lt;/code&gt; de la librairie pour que le projet bénéficie de l&#39;auto-complétion.&lt;/p&gt;
&lt;p&gt;Ces solutions permettent d&#39;obtenir l&#39;auto-complétion pour les principaux IDE utilisés chez MGDIS mais dans l&#39;idéal, nous souhaiterions également accéder aux informations détaillées sur les attributs, propriétés, événements et méthodes disponibles pour chaque élément, ainsi que connaître les valeurs possibles ou le type attendu par un attribut. Avoir des liens vers la documentation et le code source des composants serait aussi un gros plus.&lt;/p&gt;
&lt;h2 id=&quot;le-developpement-de-la-solution&quot;&gt;Le développement de la solution&lt;/h2&gt;
&lt;p&gt;Pour générer nos deux fichiers, nous utilisons le build &lt;a href=&quot;https://stenciljs.com/docs/docs-custom&quot;&gt;docs-custom&lt;/a&gt; proposé par Stencil. Cette fonctionnalité nous permet d&#39;accéder à un JSON représentant la documentation de nos composants.
Ce JSON est ensuite transformé pour obtenir les formats attendus pour les custom data et web types.&lt;/p&gt;
&lt;p&gt;Le générateur pour VS Code :&lt;/p&gt;
&lt;pre class=&quot;language-ts&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/**
 * Generate custom HTML datasets for VS Code
 * @param version - Library version
 * @param storybookBaseUrl - Storybook Base Url
 * @param jsonDocs - Stencil JSON doc
 * @returns custom HTML datasets
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;vsCodeGenerator&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;version&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; jsonDocs&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; JsonDocs&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; storybookBaseUrl&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sourceBaseUrl&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  version&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  tags&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; jsonDocs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;components&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; references &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getReferences&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;storybookBaseUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sourceBaseUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;filePath&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tag&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      description&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getElementDescription&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      attributes&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;attr &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        description&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getAttributeDescription&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        values&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getValues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        references&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      references&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  globalAttributes&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  valueSets&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le générateur pour WebStorm :&lt;/p&gt;
&lt;pre class=&quot;language-ts&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/**
 * Generate Web Types metadata for IntelliJ&#39;s IDE
 * @param name - Library name
 * @param version - Library version
 * @param storybookBaseUrl - Storybook Base Url
 * @param jsonDocs - Stencil JSON doc
 * @returns Web Types metadata
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;webTypesGenerator&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; version&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; jsonDocs&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; JsonDocs&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; storybookBaseUrl&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token string-property property&quot;&gt;&#39;$schema&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;https://json.schemastore.org/web-types&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  version&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string-property property&quot;&gt;&#39;description-markup&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;markdown&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string-property property&quot;&gt;&#39;contributions&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    html&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      elements&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; jsonDocs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;components&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; docUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getStorybookUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;storybookBaseUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;filePath&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token string-property property&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tag&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token string-property property&quot;&gt;&#39;description&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getElementDescription&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token string-property property&quot;&gt;&#39;doc-url&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; docUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token string-property property&quot;&gt;&#39;attributes&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;props
            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;attr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;attr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;description&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getAttributeDescription&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;doc-url&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; docUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;value&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;default&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                required&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;required&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token string-property property&quot;&gt;&#39;js&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            properties&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;description&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getAttributeDescription&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;doc-url&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; docUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token string-property property&quot;&gt;&#39;value&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;default&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                required&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;required&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            events&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;events&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              description&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;docs&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous avons centralisé la génération des descriptions des éléments et des attributs dans les méthodes &lt;code&gt;getElementDescription&lt;/code&gt; et &lt;code&gt;getAttributeDescription&lt;/code&gt; pour garantir une expérience uniforme sur les deux IDEs, celles-ci seront disponibles au survol.&lt;/p&gt;
&lt;p&gt;Code mutualisé :&lt;/p&gt;
&lt;pre class=&quot;language-ts&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/**
 * Get Component element description
 * @param component - Component
 * @returns Component element description
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; getElementDescription &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; JsonDocsComponent&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Init description&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; description &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;overview &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;overview&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Attributes&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; attributes &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; attr &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; attr &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;attributes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Attributes:&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; attributes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; attr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; docs &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;- &#92;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;attr&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;`: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;docs&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Properties&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; properties &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; attr &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; attr &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;properties&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Properties:&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; properties&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; docs &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;- &#92;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;`: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;docs&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Methods&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;methods&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Methods:&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;methods&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; docs &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;- &#92;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;`: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;docs&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Events&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;events&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Events:&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;events&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; docs &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;- &#92;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;`: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;docs&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Listeners&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;listeners&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Listeners:&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;listeners&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; event &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;- &#92;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;`&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Slots&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;slots&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Slots:&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;slots&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; docs &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;- &#92;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;`: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;docs&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    description &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#92;n&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Return&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; description&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/**
 * Get Props Description
 * @param prop - Component Property
 * @returns Props Description
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; getAttributeDescription &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; JsonDocsProp&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;docs&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&#92;nType: &#92;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;`&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A MGDIS nous avons deux librairies de Web Components réalisées avec Stencil : une pour le design system et l&#39;autre pour les composants métier spécifiques à nos applications.
Afin d&#39;éviter la duplication de code, nous avons centralisé le code de ces &amp;quot;générateurs&amp;quot; dans le package &lt;a href=&quot;https://github.com/MGDIS/core-ui/tree/master/packages/mg-components-helpers&quot;&gt;@mgdis/stencil-helpers&lt;/a&gt; de notre monorepo Core UI.&lt;/p&gt;
&lt;h2 id=&quot;integration-dans-les-projets&quot;&gt;Intégration dans les projets&lt;/h2&gt;
&lt;p&gt;La mise en place de l&#39;auto-complétion varie selon l&#39;IDE utilisé. Pour VS Code, il est nécessaire d&#39;ajouter aux projets utilisant la librairie un fichier &lt;code&gt;settings.json&lt;/code&gt; dans le dossier &lt;code&gt;.vscode&lt;/code&gt; avec la propriété suivante :&lt;/p&gt;
&lt;pre class=&quot;language-json&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;html.customData&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;packages/mg-components/ide/vscode/html-custom-data.json&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pour IntelliJ, le processus est plus simple. Nous avons ajouté la propriété &amp;quot;web-types&amp;quot; dans le &lt;code&gt;package.json&lt;/code&gt; de la librairie avec le lien vers le fichier, ainsi tout projet qui charge la librairie profite de l&#39;auto-complétion :&lt;/p&gt;
&lt;pre class=&quot;language-json&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    ...
    &lt;span class=&quot;token property&quot;&gt;&quot;web-types&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ide/intellij/web-types.json&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    ...
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Avec ces configurations en place, les projets utilisant la librairie auront l&#39;auto-complétion et des éléments de documentation au survol, offrant ainsi une intégration simple et efficace.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/U5ZV98QB7h-1152.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/U5ZV98QB7h-1152.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/U5ZV98QB7h-1152.png&quot; alt=&quot;Documentation au survol de l&#39;élément&quot; width=&quot;1152&quot; height=&quot;402&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/wUn4aU6eGN-1124.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/wUn4aU6eGN-1124.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/ajout-de-lauto-completion-sur-les-web-components-avec-stencil/wUn4aU6eGN-1124.png&quot; alt=&quot;Documentation au survol de l&#39;attribut&quot; width=&quot;1124&quot; height=&quot;280&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;L&#39;ajout de l&#39;auto-complétion et des éléments de documentation s&#39;est révélé être une tâche relativement simple. Cependant, il est dommage que chaque IDE propose une solution différente.&lt;/p&gt;
&lt;p&gt;J&#39;ai apprécié l&#39;approche d&#39;IntelliJ, qui semble plus proche de la réalité en distinguant les attributs et propriétés, et en offrant une intégration transparente sans nécessiter de configuration supplémentaire.
D&#39;un autre côté, j&#39;ai trouvé la flexibilité et la personnalisation des liens proposés par VS Code plus intéressantes.
Idéalement, il faudrait avoir une norme commune pour tous les IDEs.&lt;/p&gt;
&lt;p&gt;Il est également à noter que ces deux standards permettent aussi de documenter le CSS.
Nous travaillons sur un package pour les styles, il est probable que nous allons apporter une configuration similaire à celle que nous avons mise en place pour les Web Components.&lt;/p&gt;
&lt;p&gt;Enfin, ce serait une amélioration intéressante si Stencil proposait aussi les web-types comme format dans ses exports de documentation.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Simplifier l&#39;intégration des icônes depuis Figma : De la conception au design system</title>
    <link href="https://simon.duhem.fr/articles/simplifier-lintegration-des-icones-depuis-figma-de-la-conception-au-design-system/" />
    <updated>2024-02-19T00:00:00Z</updated>
    <id>https://simon.duhem.fr/articles/simplifier-lintegration-des-icones-depuis-figma-de-la-conception-au-design-system/</id>
    <content type="html">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Les icônes jouent un rôle crucial dans un design system, mais leur intégration peut être un processus fastidieux.&lt;/p&gt;
&lt;p&gt;L&#39;équipe Core UI de MGDIS se compose de deux développeurs frontend, deux designers et un alternant designer qui partagent leur temps entre le produit et le design system. Les designers créent les maquettes et les composants sur Figma, tandis que les développeurs travaillent sur un monorepo organisé en différents packages pour les composants, les styles, les images, etc.&lt;/p&gt;
&lt;p&gt;Pour ajouter une seule icône à la bibliothèque du design system, le designer la concevait sur Figma, l&#39;exportait au format SVG pour l&#39;ajouter au ticket Jira. Ensuite, l&#39;équipe de développement devait intervenir : télécharger l&#39;icône, la nettoyer, ajouter les attributs nécessaires et mettre à jour les tests. Cette chaîne de tâches fastidieuses nous a poussés à chercher une solution pour automatiser le processus, de la conception à l&#39;intégration dans le design system.&lt;/p&gt;
&lt;h2 id=&quot;a-la-decouverte-de-l-api-de-figma&quot;&gt;A la découverte de l&#39;API de Figma&lt;/h2&gt;
&lt;p&gt;Parmi les différentes API proposées par Figma, c&#39;est l&#39;API REST qui va nous intérésser. Elle va nous permettre d&#39;acceder au fichier Figma, d&#39;en extraire les propriétés et récupérer les images.&lt;/p&gt;
&lt;p&gt;La documentation de l&#39;API REST de Figma s&#39;est avérée plutôt claire, et nous avons commencé par générer un access token. Bien qu&#39;il soit possible d&#39;en générer un automatiquement depuis la documentation, il est important de noter que celui-ci est programmé pour ne durer qu&#39;une journée. Il vaut donc mieux &lt;a href=&quot;https://www.figma.com/developers/api#access-tokens&quot;&gt;suivre les instructions&lt;/a&gt; pour obtenir un access token qui n&#39;expire pas.&lt;/p&gt;
&lt;p&gt;&lt;picture&gt;&lt;source type=&quot;image/avif&quot; srcset=&quot;https://simon.duhem.fr/articles/simplifier-lintegration-des-icones-depuis-figma-de-la-conception-au-design-system/NNKdpjEUIq-984.avif&quot;&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://simon.duhem.fr/articles/simplifier-lintegration-des-icones-depuis-figma-de-la-conception-au-design-system/NNKdpjEUIq-984.webp&quot;&gt;&lt;img loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://simon.duhem.fr/articles/simplifier-lintegration-des-icones-depuis-figma-de-la-conception-au-design-system/NNKdpjEUIq-984.png&quot; alt=&quot;Ecran de création d&#39;un access token&quot; width=&quot;984&quot; height=&quot;1090&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;Dans notre cas, le seul scope dont nous avions besoin était &amp;quot;File content&amp;quot; en lecture seule. Avec l&#39;access token en main, nous pouvons maintenant explorer les différents endpoints de la partie &amp;quot;Files&amp;quot; de l&#39;API.&lt;/p&gt;
&lt;h3 id=&quot;endpoints&quot;&gt;Endpoints&lt;/h3&gt;
&lt;p&gt;La partie &amp;quot;Files&amp;quot; de l&#39;API propose &lt;a href=&quot;https://www.figma.com/developers/api#files-endpoints&quot;&gt;quatre endpoints&lt;/a&gt; :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;file&lt;/code&gt; : pour avoir des informations sur l&#39;ensemble d&#39;un fichier,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;file nodes&lt;/code&gt; : pour avoir des informations sur des nœuds spécifiques,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;image&lt;/code&gt; : pour avoir des rendus d&#39;images à partir d&#39;un fichier,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;image fills&lt;/code&gt; : pour avoir des liens de téléchargement pour les images présentes dans le document Figma.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pour utiliser ces endpoints, l&#39;access token doit être inclus dans l&#39;en-tête des appels, en utilisant la clé &lt;code&gt;X-FIGMA-TOKEN&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Deux paramètres nous intéressent ici, l&#39;identifiant du document &lt;code&gt;:key&lt;/code&gt; et l&#39;id de la page &lt;code&gt;:ids&lt;/code&gt; où sont les icônes que nous souhaitons importer.
Pour l&#39;URL suivante &lt;code&gt;https://www.figma.com/file/blubliblobla/Design-System-MGDIS?node-id=16:64&lt;/code&gt; nous aurons &lt;code&gt;:key&lt;/code&gt; qui vaut &lt;code&gt;blubliblobla&lt;/code&gt; et &lt;code&gt;:ids&lt;/code&gt; qui vaut &lt;code&gt;16:64&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour accéder aux informations du document, nous avons choisi le &lt;code&gt;file&lt;/code&gt; endpoint avec l&#39;utilisation du paramètre &lt;code&gt;ids&lt;/code&gt;, permettant de cibler la page contenant les icônes souhaitées. Avec ce paramètre la réponse est passée de 22 Mo à 400 Ko et nous permet de nous assurer que seules les icônes nécessaires sont renvoyées. Bien que le &lt;code&gt;file nodes&lt;/code&gt; endpoint aurait pu être une alternative, nous avons préféré la structure de réponse du &lt;code&gt;file&lt;/code&gt; endpoint.&lt;/p&gt;
&lt;pre class=&quot;language-sh&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;X-FIGMA-TOKEN: figd_blublu&#39;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;https://api.figma.com/v1/files/blubliblobla?ids=16:64&#39;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-json&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;document&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0:0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Document&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;DOCUMENT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;scrollBehavior&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;SCROLLS&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;children&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;components&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;544:5714&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0b2def94349533e0123459c6c5484868b03b7249&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Fill=true&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;remote&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;componentSetId&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;544:5715&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;documentationLinks&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;544:5713&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;f6e9220714ce66f47d259a6df2b638214daa0ad5&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Fill=false&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;remote&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;componentSetId&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;544:5715&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;documentationLinks&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;componentSets&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;544:5715&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cf0c91d6be16254a549f0e66e3d482e6e0f99769&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;briefcase&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;documentationLinks&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;styles&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Design System MGDIS&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;lastModified&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2024-02-15T13:43:30Z&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;thumbnailUrl&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;viewer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editorType&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;figma&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;linkAccess&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;view&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Les propriétés qui nous intéressent dans la réponse sont &lt;code&gt;components&lt;/code&gt; et &lt;code&gt;componentSets&lt;/code&gt;. Toutes nos icônes se trouvent sous &lt;code&gt;components&lt;/code&gt; et peuvent exister en deux variantes : &amp;quot;pleine&amp;quot; (fill) ou &amp;quot;contour&amp;quot; (outline). Nous utiliserons le &lt;code&gt;componentSetId&lt;/code&gt; pour retrouver le nom du fichier final avec les &lt;code&gt;componentSets&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Maintenant, nous pouvons utiliser le &lt;code&gt;image&lt;/code&gt; endpoint pour obtenir les liens de téléchargement de nos icônes au format SVG en fournissant &lt;code&gt;:key&lt;/code&gt;, les &lt;code&gt;:ids&lt;/code&gt; des composants icônes et le &lt;code&gt;format&lt;/code&gt; souhaité.&lt;/p&gt;
&lt;pre class=&quot;language-sh&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;X-FIGMA-TOKEN: figd_blublu&#39;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;https://api.figma.com/v1/images/blubliblobla?ids=544:5714,544:5713&amp;amp;format=svg&#39;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-json&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;err&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token null keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;images&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;544:5714&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://figma-alpha-api.s3.us-west-2.amazonaws.com/images/...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;544:5713&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://figma-alpha-api.s3.us-west-2.amazonaws.com/images/...&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous sommes désormais prêts à passer à la partie code !&lt;/p&gt;
&lt;h2 id=&quot;script&quot;&gt;Script&lt;/h2&gt;
&lt;p&gt;En résumé, le script doit :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Utiliser le &lt;code&gt;file&lt;/code&gt; endpoint pour récupérer la liste des composants icônes.&lt;/li&gt;
&lt;li&gt;Utiliser le &lt;code&gt;image&lt;/code&gt; endpoint pour obtenir les liens des fichiers images.&lt;/li&gt;
&lt;li&gt;Télécharger les images.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Voici le premier script fonctionnel que nous avons réalisé :&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Utilisation d&#39;Axios pour les appels API, fs pour écrire les fichiers téléchargés.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; axios &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;axios&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; writeFile &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fs&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;promises&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Création d&#39;une instance Axios pour les appels API.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; instance &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; axios&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;baseURL&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;https://api.figma.com/v1/&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token string-property property&quot;&gt;&#39;X-FIGMA-TOKEN&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;figd_blublu&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Document et node Figma où l&#39;on souhaite récuperer les icônes.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; figmaFileKey &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;blubliblobla&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; figmaNodeId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;16:64&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Appel du `file endpoint` pour obtenir les composants icônes.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; dataFileEndpoint &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; instance&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;files/&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;figmaFileKey&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;ids&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; figmaNodeId &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Récuperation des ids des nodes components.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; nodeComponentsIds &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dataFileEndpoint&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;components&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Appel du `images endpoint` pour obtenir les liens de téléchargement des images.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; dataImageEndpoint &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; instance&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;files/&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;figmaFileKey&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;ids&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; nodeComponentsIds&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;,&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;svg&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Pour chaques liens images présents dans la réponse :&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; url&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;of&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;entries&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dataImageEndpoint&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;images&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// On récupère le nom de fichier.&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; filename &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; dataFileEndpoint&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;components&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// Les composants avec une variante dépendent d&#39;un componentSet.&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dataFileEndpoint&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;components&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;componentSetId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token comment&quot;&gt;// Dans ce cas c&#39;est lui qui porte le bon nom de fichier.&lt;/span&gt;
        filename &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; dataFileEndpoint&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;componentSets&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;componentSetId&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token comment&quot;&gt;// Et il faut différencier en fonction du variant défini&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dataFileEndpoint&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;components&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Fill=false&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          filename &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;-outline&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

      &lt;span class=&quot;token comment&quot;&gt;// On télecharge l&#39;image SVG.&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; svgSrc &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; instance&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

      &lt;span class=&quot;token comment&quot;&gt;// Et on termine par l&#39;écrire.&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;writeFile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;icons/&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;filename&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;.svg&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; svgSrc&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;ERROR&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ce script nous a permis de rapidement valider la mécanique et est actuellement intégré à notre monorepo, avec quelques ajustements, notamment pour formater et optimiser les SVG téléchargés avant de les enregistrer.&lt;/p&gt;
&lt;h2 id=&quot;formatage-des-svgs-telecharges&quot;&gt;Formatage des SVGs téléchargés&lt;/h2&gt;
&lt;p&gt;Les icônes sont importées telles quelles avec une couleur prédéfinie, généralement en noir. Cependant, nous souhaitons permettre la surcharge de cette couleur. Pour y parvenir, nous devons modifier le code téléchargé avant d&#39;enregistrer le SVG.&lt;/p&gt;
&lt;p&gt;Nous avons opté pour l&#39;utilisation de la bibliothèque &lt;a href=&quot;https://www.npmjs.com/package/jsdom&quot;&gt;jsdom&lt;/a&gt; afin de manipuler le DOM et de remplacer les valeurs de couleur par &lt;code&gt;currentColor&lt;/code&gt;. Cette méthode offre la possibilité de personnaliser facilement la couleur des icônes via CSS.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Utilisation de la bibliothèque JSDOM&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSDOM&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;jsdom&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Création d&#39;un objet JSDOM avec le contenu du SVG téléchargé&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; window &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;JSDOM&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;svgSrc&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;contentType&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;image/svg+xml&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; document &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; window&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Modification de tous les attributs fill dont la valeur n&#39;est pas &quot;none&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; pathElements &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;[fill]:not([fill=&quot;none&quot;])&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
pathElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;pathElement&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  pathElement&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fill&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;currentColor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Modification de tous les attributs stroke&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; strokeElements &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;[stroke]&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
strokeElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;pathElement&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  pathElement&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;stroke&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;currentColor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Le document contient maintenant le SVG modifié&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le SVG étant maintenant formaté, la prochaine étape consiste à l&#39;optimiser avant de l&#39;enregistrer. Pour cela, nous avons utilisé &lt;a href=&quot;https://www.npmjs.com/package/svgo&quot;&gt;svgo&lt;/a&gt;, une bibliothèque spécialisée dans la compression des images SVG.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Utilisation de la bibliothèque svgo&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; optimize &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;svgo&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Optimisation du SVG&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; optimizedSVG &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;optimize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;documentElement&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;outerHTML&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Nous pouvons maintenant enregistrer l&#39;icône.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;En combinant ces méthodes, nous avons automatisé le processus d&#39;importation des icônes depuis Figma, garantissant ainsi leur préparation pour une utilisation dans nos applications. Le script final que nous utilisons aujourd&#39;hui est disponible &lt;a href=&quot;https://github.com/MGDIS/core-ui/blob/master/packages/img/src/tools/import-figma.ts&quot;&gt;sur notre monorepo&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;limites-de-l-automatisation&quot;&gt;Limites de l&#39;automatisation&lt;/h2&gt;
&lt;p&gt;Bien que l&#39;importation automatisée des SVGs soit désormais gérée par le package dédié aux images, certaines étapes requièrent toujours une intervention manuelle.&lt;/p&gt;
&lt;p&gt;Par exemple, une fois les icônes importées, le package des composants doit mettre à jour sa liste pour refléter les nouvelles icônes disponibles. Cette mise à jour est généralement effectuée lors du processus de build. Cependant, en raison de notre volonté de fournir une couverture de tests complète, chaque nouvelle icône nécessite la création de snapshots Jest et de captures d&#39;écran Playwright. De même, lorsqu&#39;une icône existante est modifiée, il est nécessaire de mettre à jour ces snapshots et captures d&#39;écran, ainsi que ceux des composants utilisant ces icônes.&lt;/p&gt;
&lt;p&gt;Cette étape manuelle reste nécessaire car elle permet de vérifier visuellement que les icônes sont conformes aux attentes. Le script d&#39;import des icônes est donc également exécuté manuellement.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Nous avons considérablement amélioré notre processus en simplifiant l&#39;intégration des icônes dans notre design system. En utilisant l&#39;API de Figma et des outils comme jsdom et svgo, nous avons automatisé plusieurs étapes, ce qui nous a fait gagner un temps précieux.&lt;/p&gt;
&lt;p&gt;Notre travail ne va pas s&#39;arrêter là. Nous souhaitons maintenant poursuivre dans cette direction en exploitant davantage les possibilités offertes par Figma. Les prochaines étapes seront certainement de faire la même chose pour l&#39;importation des illustrations, puis celle des variables.&lt;/p&gt;
&lt;p&gt;Vous pouvez explorer notre collection complète d&#39;icônes et de composants dans &lt;a href=&quot;https://mgdis.github.io/core-ui/?path=/docs/style-icons--docs&quot;&gt;notre Storybook&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
</feed>
