<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Michel</title>
    <description>The latest articles on Forem by Michel (@michelc).</description>
    <link>https://forem.com/michelc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F234783%2F5ac7a691-8d3a-4e0f-8e36-430a0a3a2afa.jpeg</url>
      <title>Forem: Michel</title>
      <link>https://forem.com/michelc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/michelc"/>
    <language>en</language>
    <item>
      <title>Web component</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Thu, 29 May 2025 11:46:49 +0000</pubDate>
      <link>https://forem.com/michelc/web-component-2pci</link>
      <guid>https://forem.com/michelc/web-component-2pci</guid>
      <description></description>
      <category>webcomponents</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>ui</category>
    </item>
    <item>
      <title>Gérer des clés étrangères avec SQLite</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Wed, 16 Aug 2023 17:22:18 +0000</pubDate>
      <link>https://forem.com/michelc/gerer-des-cles-etrangeres-avec-sqlite-5175</link>
      <guid>https://forem.com/michelc/gerer-des-cles-etrangeres-avec-sqlite-5175</guid>
      <description>&lt;p&gt;Pour les petits trucs en .NET Core, le plus simple est d'utiliser une base de données &lt;a href="https://www.sqlite.org/"&gt;SQLite&lt;/a&gt;. Mais si on veut gérer correctement les clés étrangères, il faut penser à tenir compte de quelques particularités, d'où ce billet pour ne pas oublier...&lt;/p&gt;

&lt;p&gt;Dans l'exemple qui suit, la clé étrangère permet de décrire la relation entre les deux tables "Blogs" (les parents) et "Posts" (les enfants) et d'assurer l'intégrité des données afin qu'il n'y ait pas d'enfants sans un parent. Toute tentative d'insertion d'une ligne dans la table "Posts" qui ne correspondrait pas à une ligne de la table "Blogs" génèrera une erreur SQL. De la même façon, on provoquera une erreur SQL si on essaie de supprimer une ligne de la table "Blogs" alors qu'il y a des données qui en dépendent dans la table "Posts".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;Blogs&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;Blog_ID&lt;/span&gt;     &lt;span class="nb"&gt;INTEGER&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;Title&lt;/span&gt;       &lt;span class="nb"&gt;TEXT&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;Posts&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;Post_ID&lt;/span&gt;     &lt;span class="nb"&gt;INTEGER&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;Blog_ID&lt;/span&gt;     &lt;span class="nb"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;Content&lt;/span&gt;     &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;FOREIGN&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Blog_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="n"&gt;Blogs&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Blog_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SQLite permet de définir des clés étrangères sans problème. La difficulté c'est que par défaut les contraintes liées aux clés étrangères sont désactivées (pour rester compatible avec les premières versions de SQLite).&lt;/p&gt;

&lt;p&gt;Concrètement, ça veut donc dire qu'on peut créer des clés étrangères avec SQLite, mais qu'elles ne servent à rien ! Et donc qu'on pourra sans problème insérer des données sans clé étrangère "parent" ou supprimer des données "parents" pourtant utilisées par des enregistrements "enfants" :(&lt;/p&gt;

&lt;p&gt;Heureusement, il est possible d'activer les contraintes liées aux étrangères. On ne peut pas faire cela de façon "globale", mais uniquement au niveau de la connexion à la base de données. Sous SQlite, on réalise ça avec la commande "PRAGMA" :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;sqlite&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;foreign_keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Avec ADO.NET ou Entity Framework, c'est encore plus simple (ou pas) puisqu'il suffit d'ajouter "Foreign Keys=true" à la chaine de connexion. Ce qui a pour effet d'envoyer automatiquement la commande &lt;code&gt;PRAGMA foreign_keys = 1&lt;/code&gt; immédiatement après l'ouverture de la connexion à la base de données.&lt;/p&gt;

&lt;p&gt;Grâce à cette modification toute simple, il ne sera plus possible d'ajouter un "enfant" sans référencer un "parent" existant. Ou de supprimer un parent qui a un enfant...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;Blogs&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Blog_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Mon nouveau blogue'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;COMMIT&lt;/span&gt;

&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;Posts&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Post_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Blog_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Mon premier billet'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;FOREIGN&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="k"&gt;constraint&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt;

&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;Posts&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Post_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Blog_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Mon premier billet'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;COMMIT&lt;/span&gt;

&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Blogs&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;Blog_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;FOREIGN&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="k"&gt;constraint&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Attention&lt;/strong&gt; : Avec EF Core, la clause &lt;code&gt;ON DELETE&lt;/code&gt; des clés étrangères est définie à &lt;code&gt;CASCADE&lt;/code&gt; par défaut... De quoi alimenter un autre billet de blogue !&lt;/p&gt;




&lt;p&gt;Billet publié à l'origine sur &lt;a href="https://blog.pagesd.info/2023/08/16/sqlite-cles-etrangeres/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;br&gt;
Illustration: &lt;a href="https://littlekendra.com/2016/09/22/indexing-foreign-keys-guidelines/"&gt;C'est quoi le pire : un index inutile ou une clé étrangère non indexée ?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>csharp</category>
      <category>french</category>
    </item>
    <item>
      <title>Générer un badge / avatar en C#</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Mon, 14 Aug 2023 10:29:56 +0000</pubDate>
      <link>https://forem.com/michelc/generer-un-badge-avatar-en-c-4272</link>
      <guid>https://forem.com/michelc/generer-un-badge-avatar-en-c-4272</guid>
      <description>&lt;p&gt;J'ai récemment eu besoin d'afficher à nouveau des avatars, et j'ai voulu en profiter pour essayer une autre façon de faire par rapport à ce que j'avais fait il y a 2 ans avec "&lt;a href="https://dev.to/michelc/comment-creer-un-badge-avatar-en-css-20e0"&gt;Créer un badge / avatar en CSS&lt;/a&gt;".&lt;/p&gt;

&lt;p&gt;Et donc, plutôt que de faire ça avec du bon vieux code HTML et CSS, je génère automatiquement une image pour les personnes qui n'ont pas de "vrai" avatar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Renvoyer une image statique
&lt;/h2&gt;

&lt;p&gt;Les images des avatars sont stockées dans le dossier "/wwwroot/avatars" pour les cas où il existe un avatar.&lt;/p&gt;

&lt;p&gt;Chaque avatar est enregistré en JPG, avec un nom de la forme "trigramme.prenom.nom.jpg".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;trigramme = initiale du prénom + initiale du nom + lettre finale du nom (donc 3 lettres au total)&lt;/li&gt;
&lt;li&gt;prenom = le prénom en minuscule sans accents, espaces, tirets... de la personne&lt;/li&gt;
&lt;li&gt;nom = le nom en minuscule sans accents, espaces, tirets... de la personne&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Par conséquent, un nom de fichier est composé uniquement des 26 lettres "a" à "z", avec un "." pour séparer les différentes parties : "tsk.tony.stark.jpg", "bbr.bruce.banner.jpg", "srs.steve.rogers.jpg", etc...&lt;/p&gt;

&lt;p&gt;De cette façon, lorsqu'il existe un "vrai" avatar pour une personne, j'utilise simplement l'URL de l'image "/avatars/tsk.tony.stark.jpg" et le middleware "UseStaticFiles()" renvoie cette image sans chercher plus loin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Renvoyer une image dynamique
&lt;/h2&gt;

&lt;p&gt;Dans les cas où il n'existe pas d'image, j'ai une route qui prend le relai et qui renvoie une image générée à la volée. Ce qui donne au niveau de mon fichier "Program.cs" :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Middleware pour les fichiers statiques&lt;/span&gt;
&lt;span class="c1"&gt;// =&amp;gt; renvoie entre autre les images utilisées pour les avatars&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseStaticFiles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="c1"&gt;// Route par défaut pour une application MVC basique&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapControllerRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"{controller=Home}/{action=Index}/{id?}"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Route spécifique pour générer des avatars&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapControllerRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"avatars"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"/avatars/{id}.jpg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Avatars"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Index"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Puis, dans le contrôleur "AvatarsController.cs", je n'ai plus qu'à générer une image en fonction de l'identifiant de l'image, à savoir une chaine de la forme "trigramme.prenom.nom.jpg".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="nf"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;trigramme&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;ToUpper&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;GetColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trigramme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;avatar&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;GetBitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;trigramme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Convertir l'image en tableau de bytes (byte array)&lt;/span&gt;
    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MemoryStream&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;MemoryStream&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ImageFormat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Jpeg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;imageBytes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToArray&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// Renvoyer l'image directement comme réponse HTTP avec le type de contenu approprié&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;File&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imageBytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"image/jpg"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Je commence par récupérer le trigramme de la personne car il va me permettre de générer une couleur de fond pour l'avatar, via la fonction &lt;code&gt;GetColor(trigramme)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Puis j'appelle la méthode &lt;code&gt;GetImage(color, trigramme)&lt;/code&gt; qui est chargée de générer l'image correspondant à l'avatar.&lt;/p&gt;

&lt;p&gt;Et enfin, je renvoie cette image au navigateur. Je peux alors utiliser la route de cette image "/avatars/tsk.tony.stark.jpg" exactement comme si c'état un fchier statique.&lt;/p&gt;

&lt;h2&gt;
  
  
  Afficher l'avatar
&lt;/h2&gt;

&lt;p&gt;Côté HTML, je n'ai donc pas à me préoccuper de savoir s'il s'agit d'une image statique ou dynamique et je peux me contenter d'afficher une image basique :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"round-avatar"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/avatars/@(user.Trigramme).@(user.Prenom).@(user.Nom).jpg"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Puis quelques lignes de CSS pour donner un look "fini" à l'avatar :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Avatars ronds */&lt;/span&gt;
&lt;span class="nc"&gt;.round-avatar&lt;/span&gt; &lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;64px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;64px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* Bordure au survol */&lt;/span&gt;
&lt;span class="nc"&gt;.round-avatar&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Générer l'avatar en C
&lt;/h2&gt;

&lt;p&gt;La fonction &lt;code&gt;GetColor()&lt;/code&gt; est un peu tarabiscottée et me permet de définir une couleur en fonction du trigramme. Je ferais peut-être un autre billet pour expliquer comment je procède...&lt;/p&gt;

&lt;p&gt;La fonction &lt;code&gt;GetImage()&lt;/code&gt; génère un carré avec le fond de la couleur demandée et les initiales de la personne en blanc. Pour cela, j'utilise &lt;code&gt;System.Drawing&lt;/code&gt; de façon assez basique :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Drawing.Drawing2D&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Drawing.Imaging&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;Bitmap&lt;/span&gt; &lt;span class="nf"&gt;GetBitmap&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;trigramme&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Créer une image avec le fond de la couleur demandée&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Bitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;400&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Graphics&lt;/span&gt; &lt;span class="n"&gt;gfx&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Graphics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SmoothingMode&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SmoothingMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AntiAlias&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Clear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Ajouter les 2 initiales du trigramme centré au milieu de l'image&lt;/span&gt;
    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Graphics&lt;/span&gt; &lt;span class="n"&gt;gfx&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Graphics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Font&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Font&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Calibri"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;128&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FontStyle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bold&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;Brush&lt;/span&gt; &lt;span class="n"&gt;brush&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;SolidBrush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;White&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;StringFormat&lt;/span&gt; &lt;span class="n"&gt;format&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;StringFormat&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Alignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LineAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trigramme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;brush&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;400&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Renvoie l'image générée&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;C'était pas très compliqué à coder et c'est amusant d'avoir un truc simple capable d'afficher des avatars sans avoir à faire la distinction entre les personnes pour lesquelles il existe un "vrai" avatar et celles pour lesquelles il n'y en a pas.&lt;/p&gt;




&lt;p&gt;Billet publié à l'origine sur &lt;a href="https://blog.pagesd.info/2023/08/14/generer-avatar-csharp/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>french</category>
    </item>
    <item>
      <title>Array.every() et new Set() sauvent LeMOT</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Wed, 18 Jan 2023 13:43:16 +0000</pubDate>
      <link>https://forem.com/michelc/arrayevery-et-new-set-sauvent-lemot-3h3m</link>
      <guid>https://forem.com/michelc/arrayevery-et-new-set-sauvent-lemot-3h3m</guid>
      <description>&lt;h2&gt;
  
  
  Y'a comme un bug ?
&lt;/h2&gt;

&lt;p&gt;Hier j'ai eu un petit problème dans mon jeu de Wordle en français. Comme dans le Wordle d'origine, j'utilise 2 listes de mots :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;la première avec tous les mots de 5 lettres acceptés par mon jeu : "jouables"&lt;/li&gt;
&lt;li&gt;la seconde avec les mots à trouver : "gagnants"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Contrairement à Josh Wardle, je n'ai pas préparé cette liste une fois pour toute lorsque j'ai créé le jeu. Dans la pratique, je la complète tous les 2 ou 3 mois, en ajoutant entre 50 et 100 mots à chaque fois. Je prends des mots au hasard dans la liste principale et je fais quelques ajustements pour éviter les mots trop compliqués ou pas très heureux...&lt;/p&gt;

&lt;p&gt;Une fois ces nouveaux mots trouvés, je vérifie qu'ils n'ont pas déjà été proposés (pas de doublons) et aussi qu'ils existent bien dans la liste des mots acceptés (pas de mots introuvables). Je fais ça parce qu'il m'arrive de faire une faute de frappe quand je fais mes derniers petits ajustements.&lt;/p&gt;

&lt;p&gt;Malheureusement c'est quelque chose que je fais manuellement et la dernière fois, j'ai dû rater une étape. Lundi, le mot à trouver était "MONOI" ("monoï" avec la bonne orthographe), mais bizarrement ce mot ne faisait pas parti de la liste des mots jouables reconnus par l'application !&lt;/p&gt;

&lt;p&gt;Et donc rien à faire, même en jouant bien on ne pouvait que perdre puis s'entendre dire que la solution était "MONOI" alors que ça nous avait été refusé juste avant ! 😠😡&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feo65c1zag0tivk9flo7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feo65c1zag0tivk9flo7m.png" alt="" width="416" height="615"&gt;&lt;/a&gt;&lt;br&gt;Le bug en action...
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Prudence est mère de sûreté...
&lt;/h2&gt;

&lt;p&gt;Aussi pour éviter que cela ne se reproduise, j'ai désormais automatisé ça directement dans le code. Cela affiche un message lorsque il y a des mots "gagnants" qui n'existent pas dans la liste des mots "jouables" (donc des mots inconnus qui ne seront pas trouvables). Et un autre message si la liste des mots "gagnants" contient des doublons (en cas de mots déjà proposés).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// Vérifie que tous les mots gagnants existent dans les mots jouables&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gagnants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;jouables&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gagnants inconnus !&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Vérifie qu'il n'y a pas de doublon dans les mots gagnants&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gagnants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gagnants&lt;/span&gt;&lt;span class="p"&gt;)].&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gagnants doublons !&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Les zexplications de ChatGPT :
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Vérifie que tous les mots gagnants existent dans les mots jouables&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gagnants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;jouables&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gagnants inconnus !&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Ce code vérifie si tous les éléments de l'array "gagnants" apparaissent dans l'array "jouables". Si ce n'est pas le cas, le message "gagnants inconnus !" est affiché dans la console. La méthode "every()" parcourt chaque élément de l'array "gagnants" et vérifie si cet élément existe dans l'array "jouables" en utilisant la méthode "includes()". Si tous les éléments de "gagnants" existent dans "jouables", la fonction "every()" renvoie "true" et le code dans la condition if ne sera pas exécuté, sinon elle renvoie "false" et le code dans la condition if sera exécuté.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Vérifie qu'il n'y a pas de doublon dans les mots gagnants&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gagnants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;gagnants&lt;/span&gt;&lt;span class="p"&gt;)].&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gagnants doublons !&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Cette ligne de code vérifie s'il y a des doublons dans l'array "gagnants". Elle utilise le "!==" pour vérifier si la longueur de l'array "gagnants" est différente de celle de l'array créé par la combinaison de "new Set()" et de l'opérateur de décomposition "[...]". La méthode "Set()" crée un nouvel objet Set qui contient les éléments uniques de l'array passé en paramètre, l'opérateur de décomposition "[...]" permet de convertir ce nouvel objet en array.&lt;br&gt;
Si la longueur de l'array "gagnants" est égale à celle de l'array créé par la combinaison de "new Set()" et de l'opérateur de décomposition "[...]", cela signifie qu'il n'y a pas de doublons dans "gagnants" et la condition if ne sera pas exécuté. Sinon, il y a des doublons dans "gagnants" et le message "gagnants doublons !" sera affiché dans la console.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Que le jeux continue !
&lt;/h2&gt;

&lt;p&gt;Heureusement, c'est arrivé une seule fois en un peu plus d'un an de jeu.&lt;/p&gt;

&lt;p&gt;Mais au moins, maintenant, si on perd ça ne sera plus que la faute à pas de chance : &lt;a href="https://www.solitaire-play.com/lemot/" rel="noopener noreferrer"&gt;https://www.solitaire-play.com/lemot/&lt;/a&gt; :)&lt;/p&gt;




&lt;p&gt;Billet publié à l'origine sur &lt;a href="https://blog.pagesd.info/2023/01/17/array-every-new-set-sauvent-lemot/" rel="noopener noreferrer"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>discuss</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Replace Windows 10's emoji</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Tue, 20 Sep 2022 17:55:11 +0000</pubDate>
      <link>https://forem.com/michelc/replace-windows-10s-emoji-4o2n</link>
      <guid>https://forem.com/michelc/replace-windows-10s-emoji-4o2n</guid>
      <description>&lt;p&gt;Lately, I've been back on developing a sort of Twitter client / application to help me track interactions around my &lt;a href="https://www.solitaire-play.com/lemot/"&gt;French Wordle game&lt;/a&gt; (and the 3 other games that I developed later).&lt;/p&gt;

&lt;p&gt;This weekend, to take my mind off things a bit, I tried to improve the look of the emojis.&lt;/p&gt;

&lt;p&gt;Initially, since it's a web application, they are displayed with the default Windows 10 font for emojis, which isn't super great:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" alt="" width="400" height="600"&gt;&lt;/a&gt;&lt;br&gt;Basic emoji for Windows 10
  &lt;/p&gt;

&lt;h2&gt;
  
  
  1st try: "Segoe UI Emoji" from Windows 11
&lt;/h2&gt;

&lt;p&gt;To make it easier, I tried to install the latest version of the "Segoe UI Emoji" font from Windows 11 and see what happened... Not much actually!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" alt="" width="400" height="600"&gt;&lt;/a&gt;&lt;br&gt;Still using the original Windows 10 "Segoe UI Emoji" font :(
  &lt;/p&gt;

&lt;p&gt;I now have two "Segoe UI Emoji" fonts on my PC which doesn't seem to be ready to use the newer one by default.&lt;/p&gt;

&lt;p&gt;However, Firefox has proved to be smarter:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j-1WJ-Rv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x30x4zbnq10u755wzui9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j-1WJ-Rv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x30x4zbnq10u755wzui9.png" alt="" width="400" height="602"&gt;&lt;/a&gt;&lt;br&gt;The new "Segoe UI Emoji" font in Windows 11 :)
  &lt;/p&gt;

&lt;h2&gt;
  
  
  2nd try: "Noto Color Emoji" from Google
&lt;/h2&gt;

&lt;p&gt;Then I saw a new font from Google: "Noto Color Emoji" (&lt;a href="https://fonts.google.com/noto/specimen/Noto+Color+Emoji"&gt;https://fonts.google.com/noto/specimen/Noto+Color+Emoji&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;After downloading it, I could have try to use it as a "system" font for emojis... But there was no reason for it to do better than Microsoft's "Segoe UI Emoji".&lt;/p&gt;

&lt;p&gt;And there is nothing at the HTML/CSS level to indicate how emojis should be displayed using a particular font. If I want that, the easiest way is to include the emojis to be displayed inside a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag with a class to later define its font. Something like &lt;code&gt;&amp;lt;span class="font-emoji"&amp;gt;🥳&amp;lt;/span&amp;gt;&lt;/code&gt; for example...&lt;/p&gt;

&lt;p&gt;I wrote a quick code so that the emojis would be displayed using this font. To do this, I wrapped all the emojis in a "pseudo" &lt;code&gt;&amp;lt;e&amp;gt;&lt;/code&gt; tag by using the following function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nf"&gt;MakePrettyEmojis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;runes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;EnumerateRunes&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;runes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"\u2b1c"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;e&amp;gt;"&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;/e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"\u26aa"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;e&amp;gt;"&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;/e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IsBmp&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;e&amp;gt;"&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;/e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pretty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;/e&amp;gt;&amp;lt;e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;pretty&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: As all emojis are apparently not on the same boat, I will have to try a little harder to manage all the existing emojis (something like a &lt;code&gt;Regex&lt;/code&gt; certainly).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;e&amp;gt;&lt;/code&gt; tag does not exist but browsers do not seem to be disturbed. And so, &lt;code&gt;&amp;lt;e&amp;gt;🥳&amp;lt;/e&amp;gt;&lt;/code&gt; will be  more "soft" than a long &lt;code&gt;&amp;lt;span class="font-emoji"&amp;gt;🥳&amp;lt;/span&amp;gt;&lt;/code&gt; :)&lt;/p&gt;

&lt;p&gt;I update my CSS to define that &lt;code&gt;&amp;lt;e&amp;gt;&lt;/code&gt; elements must be displayed with the "Noto Color Emoji" font:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;e&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Noto Color Emoji"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the result is finally there, whatever the browser!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GlRB0vU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n12p5gzss095n7y6dnra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GlRB0vU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n12p5gzss095n7y6dnra.png" alt="" width="400" height="615"&gt;&lt;/a&gt;&lt;br&gt;Finally more cute emojis!!!
  &lt;/p&gt;

&lt;p&gt;But I'm not a big fan of this little 3D effect. It feels like being back in the days of Windows 3.1 :)&lt;/p&gt;

&lt;h2&gt;
  
  
  3rd try: "Segoe UI Emoji" the return
&lt;/h2&gt;

&lt;p&gt;Of course, I'll take a chance on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;e&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Segoe UI Emoji"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But since there are 2 "Segoe UI Emoji" fonts on my Windows, the new one still doesn't override the old one... Unless there is a &lt;code&gt;font-version&lt;/code&gt; somewhere...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" alt="" width="400" height="600"&gt;&lt;/a&gt;&lt;br&gt;Back to square one (except Firefox)
  &lt;/p&gt;

&lt;h2&gt;
  
  
  4th try: "Twitter Color Emoji SVGinOT Font" by ???
&lt;/h2&gt;

&lt;p&gt;I'm looking if there are other emoji fonts and I find one based on Twitter emojis, even though it looks more like DIY than official stuff: &lt;a href="https://github.com/eosrei/twemoji-color-font"&gt;https://github.com/eosrei/twemoji-color-font&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I download, install and then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;e&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Twitter Color Emoji"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And oops...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--308qU7hm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fij3b8dmpr6ud50mpz8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--308qU7hm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fij3b8dmpr6ud50mpz8.png" alt="" width="400" height="610"&gt;&lt;/a&gt;&lt;br&gt;All emojis are light gray...
  &lt;/p&gt;

&lt;h2&gt;
  
  
  5th try: "Emoji for everyone" from Twitter!!!
&lt;/h2&gt;

&lt;p&gt;However, it led me to the "Twemoji" page: &lt;a href="https://twemoji.twitter.com/"&gt;https://twemoji.twitter.com/&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Twitter's open source emoji has you covered for all your project's emoji needs. With support for the latest Unicode emoji specification, featuring 3,245 emojis, and all for free.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Wait, that's awesome!&lt;/p&gt;

&lt;p&gt;It looks like this is exactly what I'm looking for! Something not complicated that can replace all the emojis of a page with the image of the corresponding Twitter emoji. That's good, cause I really like Twitter emojis :)&lt;/p&gt;

&lt;p&gt;I delete my "MakePrettyEmojis" function and my piece of CSS to return to the starting situation.&lt;/p&gt;

&lt;p&gt;I add some JavaScript to my "_Layout.cshtml" file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://twemoji.maxcdn.com/v/latest/twemoji.min.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;crossorigin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;anonymous&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// https://gist.github.com/Armster15/db063ab0dc5be699ae07a067a7333752&lt;/span&gt;
        &lt;span class="c1"&gt;// Parses the document body and&lt;/span&gt;
        &lt;span class="c1"&gt;// inserts &amp;lt;img&amp;gt; tags in place of Unicode Emojis&lt;/span&gt;
        &lt;span class="nx"&gt;twemoji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;ext&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// This is to specify to Twemoji to use SVGs and not PNGs&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I size the emojis with CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.emoji&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AaLNBeAX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iywdf7op82xt7w72op2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AaLNBeAX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iywdf7op82xt7w72op2i.png" alt="" width="400" height="616"&gt;&lt;/a&gt;&lt;br&gt;Tada! It's perfectly perfect.
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Initially, my plan was to replace the Windows 10 emojis with more modern ones (and the latest ones from Microsoft were fine for me). But with the difficulties and to avoid having to "hack" my system, I preferred to just modify my application so that it displays the pretty emojis from Twitter instead.&lt;/p&gt;




&lt;p&gt;This post was originally published on &lt;a href="https://blog.pagesd.info/2022/09/20/replace-windows-10-emoji/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>twitter</category>
      <category>html</category>
    </item>
    <item>
      <title>Remplacer les émojis de Windows 10</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Mon, 19 Sep 2022 18:35:24 +0000</pubDate>
      <link>https://forem.com/michelc/remplacer-les-emojis-de-windows-10-15ii</link>
      <guid>https://forem.com/michelc/remplacer-les-emojis-de-windows-10-15ii</guid>
      <description>&lt;p&gt;Ces derniers temps, je me suis remis sur le développement d'une sorte d'application / client Twitter pour me faciliter le suivi des interactions autour de mon jeu de &lt;a href="https://www.solitaire-play.com/lemot/"&gt;Wordle en français&lt;/a&gt; (et des 3 autres que j'ai développés depuis).&lt;/p&gt;

&lt;p&gt;Ce week-end, pour me changer un peu les idées, j'ai décidé d'améliorer le rendu des émojis.&lt;/p&gt;

&lt;p&gt;Au départ, comme il s'agit d'une application web, ils sont affichés avec la police par défaut de Windows 10 pour les émojis, ce qui n'est pas super génial :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" alt="" width="400" height="600"&gt;&lt;/a&gt;&lt;br&gt;Les émojis de base pour Windows 10
  &lt;/p&gt;

&lt;h2&gt;
  
  
  1er essai : "Segoe UI Emoji" de Windows 11
&lt;/h2&gt;

&lt;p&gt;Pour faire au plus simple, j'ai essayé d'installer la dernière version de la police "Segoe UI Emoji" de Windows 11 et de voir ce que ça donnait... Pas grand chose en fait !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" alt="" width="400" height="600"&gt;&lt;/a&gt;&lt;br&gt;Toujours les émojis de la police "Segoe UI Emoji" d'origine de Windows 10 :(
  &lt;/p&gt;

&lt;p&gt;J'ai maintenant deux polices "Segoe UI Emoji" sur mon PC qui ne semble pas très chaud pour utiliser la plus récente par défaut.&lt;/p&gt;

&lt;p&gt;Malgré tout, Firefox s'est montré plus malin :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j-1WJ-Rv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x30x4zbnq10u755wzui9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j-1WJ-Rv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x30x4zbnq10u755wzui9.png" alt="" width="400" height="602"&gt;&lt;/a&gt;&lt;br&gt;Les nouveaux émojis de la police "Segoe UI Emoji" de Windows 11 :)
  &lt;/p&gt;

&lt;h2&gt;
  
  
  2ème essai : "Noto Color Emoji" de Google
&lt;/h2&gt;

&lt;p&gt;Puis j'ai vu passer une nouvelle police de chez Google : "Noto Color Emoji" (&lt;a href="https://fonts.google.com/noto/specimen/Noto+Color+Emoji"&gt;https://fonts.google.com/noto/specimen/Noto+Color+Emoji&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Après l'avoir téléchargée, je pouvais essayer de l'utiliser comme police "système" pour les émojis... Mais il n'y avait pas de raison qu'elle se débrouille mieux que la "Segoe UI Emoji" de Microsoft himself.&lt;/p&gt;

&lt;p&gt;Et il n'existe rien au niveau HTML / CSS pour indiquer qu'il faut afficher les émojis en utilisant une police particulière. Si on veut y arriver, le plus simple est d'englober les émojis à afficher dans une balise &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; avec une classe particulière pour pouvoir définir sa police. Quelque chose comme &lt;code&gt;&amp;lt;span class="font-emoji"&amp;gt;🥳&amp;lt;/span&amp;gt;&lt;/code&gt; par exemple...&lt;/p&gt;

&lt;p&gt;Alors j'ai bricolé vite fait un truc pour que les émojis soient affichés en utilisant cette police. Pour cela, j'ai encadré tous les émojis dans une "pseudo" balise &lt;code&gt;&amp;lt;e&amp;gt;&lt;/code&gt; grâce à la fonction suivante :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nf"&gt;MakePrettyEmojis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;runes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;EnumerateRunes&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;runes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"\u2b1c"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;e&amp;gt;"&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;/e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"\u26aa"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;e&amp;gt;"&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;/e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IsBmp&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;e&amp;gt;"&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;/e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
            &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;pretty&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pretty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;/e&amp;gt;&amp;lt;e&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;pretty&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note : Comme tous les émojis ne sont apparemment pas logés à la même enseigne, il faudra me creuser un peu plus les méninges pour réussir à gérer correctement tous les émojis existants (quelque chose dans le genre &lt;code&gt;Regex&lt;/code&gt; certainement).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;La balise &lt;code&gt;&amp;lt;e&amp;gt;&lt;/code&gt; n'existe pas mais elle ne semble pas perturber les navigateurs. Et donc, &lt;code&gt;&amp;lt;e&amp;gt;🥳&amp;lt;/e&amp;gt;&lt;/code&gt; sera quand même plus "discret" qu'un long &lt;code&gt;&amp;lt;span class="font-emoji"&amp;gt;🥳&amp;lt;/span&amp;gt;&lt;/code&gt; :)&lt;/p&gt;

&lt;p&gt;Je complète mon fichier CSS pour y indiquer que les éléments &lt;code&gt;&amp;lt;e&amp;gt;&lt;/code&gt; doivent être affichés avec la police "Noto Color Emoji" :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;e&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Noto Color Emoji"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Et le résultat est enfin là, quelque soit le navigateur !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GlRB0vU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n12p5gzss095n7y6dnra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GlRB0vU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n12p5gzss095n7y6dnra.png" alt="" width="400" height="615"&gt;&lt;/a&gt;&lt;br&gt;Enfin de plus jolis émojis !!!
  &lt;/p&gt;

&lt;p&gt;Mais j'aime moyen ce petit effet 3D. On se croirait revenu au temps de Windows 3.1 :)&lt;/p&gt;

&lt;h2&gt;
  
  
  3ème essai : "Segoe UI Emoji" le retour
&lt;/h2&gt;

&lt;p&gt;Bien entendu je tente le coup avec :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;e&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Segoe UI Emoji"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mais comme il y a 2 polices "Segoe UI Emoji" sur mon Windows, la nouvelle ne prend toujours pas le dessus sur l'ancienne... A moins qu'il existe un &lt;code&gt;font-version&lt;/code&gt; quelque part...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7MxaNlf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l9k7a7vlakkya54kpjb.png" alt="" width="400" height="600"&gt;&lt;/a&gt;&lt;br&gt;Retour à la case départ (à part Firefox)
  &lt;/p&gt;

&lt;h2&gt;
  
  
  4ème essais : "Twitter Color Emoji SVGinOT Font" de ???
&lt;/h2&gt;

&lt;p&gt;Je cherche s'il existe d'autre polices d'emojis et je tombe sur celle de Twitter, même si cela ressemble plus à du bricolage qu'à un truc officiel : &lt;a href="https://github.com/eosrei/twemoji-color-font"&gt;https://github.com/eosrei/twemoji-color-font&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Je télécharge, installe puis :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;e&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Twitter Color Emoji"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Et oups...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--308qU7hm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fij3b8dmpr6ud50mpz8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--308qU7hm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fij3b8dmpr6ud50mpz8.png" alt="" width="400" height="610"&gt;&lt;/a&gt;&lt;br&gt;Tous les émojis sont gris clair...
  &lt;/p&gt;

&lt;h2&gt;
  
  
  5ème essai : "Emoji for everyone" de Twitter !!!
&lt;/h2&gt;

&lt;p&gt;Par contre, ça m'a conduit sur la page de "Twemoji" : &lt;a href="https://twemoji.twitter.com/"&gt;https://twemoji.twitter.com/&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;L'emoji open source de Twitter répond à tous les besoins de votre projet en matière d'emoji. Il prend en charge la dernière spécification Unicode des emojis et propose 3 245 emojis, le tout gratuitement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Mais c'est génial !&lt;/p&gt;

&lt;p&gt;Il semblerait bien que cela soit pile ce que je cherche ! Quelque chose de pas compliqué du tout qui remplace tous les émojis d'une page par l'image de l'émoji Twitter correspondant. Ca tombe bien, il me plaisent beaucoup les émojis de Twitter moi :)&lt;/p&gt;

&lt;p&gt;Je vire ma fonction "MakePrettyEmojis" et mon bout de CSS pour revenir à la situation de départ.&lt;/p&gt;

&lt;p&gt;J'ajoute un peu de JavaScript dans mon fichier "_Layout.cshtml" :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://twemoji.maxcdn.com/v/latest/twemoji.min.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;crossorigin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;anonymous&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// https://gist.github.com/Armster15/db063ab0dc5be699ae07a067a7333752&lt;/span&gt;
        &lt;span class="c1"&gt;// Parses the document body and&lt;/span&gt;
        &lt;span class="c1"&gt;// inserts &amp;lt;img&amp;gt; tags in place of Unicode Emojis&lt;/span&gt;
        &lt;span class="nx"&gt;twemoji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;ext&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// This is to specify to Twemoji to use SVGs and not PNGs&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Et je dimensionne les émojis dans mon CSS :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.emoji&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AaLNBeAX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iywdf7op82xt7w72op2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AaLNBeAX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iywdf7op82xt7w72op2i.png" alt="" width="400" height="616"&gt;&lt;/a&gt;&lt;br&gt;Tada ! C'est parfaitement parfait.
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Au départ, je comptais remplacer les émojis de Windows 10 pour en utiliser de plus modernes (et les derniers de Microsoft m'allaient très bien). Mais devant les difficultés et pour éviter d'avoir à "hacker" mon système, j'ai préféré me contenter de modifier mon application pour qu'elle affiche les jolis émojis de Twitter à la place.&lt;/p&gt;




&lt;p&gt;Billet publié à l'origine sur &lt;a href="https://blog.pagesd.info/2022/09/19/remplacer-emojis-windows-10/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>twitter</category>
      <category>french</category>
      <category>html</category>
    </item>
    <item>
      <title>Dark mode for French Wordle</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Wed, 02 Feb 2022 20:56:39 +0000</pubDate>
      <link>https://forem.com/michelc/dark-mode-for-french-wordle-1cdm</link>
      <guid>https://forem.com/michelc/dark-mode-for-french-wordle-1cdm</guid>
      <description>&lt;p&gt;Last Sunday, I added a dark theme to LeMOT, my &lt;a href="https://www.solitaire-play.com/lemot/"&gt;French Wordle&lt;/a&gt;. Some players seemed to want it and it was a good opportunity for me to see how to do it without too many fuss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Colors for light mode
&lt;/h2&gt;

&lt;p&gt;To start with, I looked for the colors used in my CSS file and I found about ten of them. But in practice, this corresponds to the following 12 use cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; for the general white background&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#333&lt;/code&gt; for the general near-black text&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; for slightly lighter text in italics&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ddd&lt;/code&gt; for text watermark&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ccc&lt;/code&gt; light gray for the background of unused keyboard keys&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; white to display the letters once played in the boxes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ffb000&lt;/code&gt; the famous orange for the background of well placed letters :)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#648fff&lt;/code&gt; the blue for the background of misplaced letters&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ddd&lt;/code&gt; a slightly lighter gray for the background of the letters missing from the word to guess&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#bbb&lt;/code&gt; not very light gray for icons&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#dc267f&lt;/code&gt; a purple background for the "unknown word" message&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; white text for the "unknown word" message&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Done!&lt;/p&gt;

&lt;h2&gt;
  
  
  Colors for dark mode
&lt;/h2&gt;

&lt;p&gt;I then searched what colors to use when in dark mode. It wasn't too difficult, since you just have to look at the original &lt;a href="https://powerlanguage.co.uk/wordle/"&gt;Wordle&lt;/a&gt; for inspiration... After a few tries, I came up with these colors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#222&lt;/code&gt; for a very black general background&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#333&lt;/code&gt; for a very white general text&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; for a less white italic text&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#444&lt;/code&gt; for the watermark text in grey / black&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; a "medium" gray for the background of the unused keyboard keys&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; white to display the letters once played in the boxes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ffb000&lt;/code&gt; the famous orange for the background of well placed letters :)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#648fff&lt;/code&gt; the blue for the background of misplaced letters&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#444&lt;/code&gt; a gray / black for the background of the letters absent from the word to guess&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; a "medium" gray for the icons&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#dc267f&lt;/code&gt; a purple background for the message "unknown word"&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; white text for the "unknown word" message&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As I display links in bright blue (&lt;code&gt;#00f&lt;/code&gt;), I had to find another one that would look good in both dark and light modes. I took the blue &lt;code&gt;#2962ff&lt;/code&gt; from one of my other sites, but I probably have to improve it because I'm not very happy with it...&lt;/p&gt;

&lt;p&gt;Dark colors, done!&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting light or dark theme
&lt;/h2&gt;

&lt;p&gt;Now, either I was finally starting to code a settings screen, or I was cheating by relying on the &lt;code&gt;prefers-color-scheme&lt;/code&gt; media directive. This directive detects the user's choice of theme preference (dark or light).&lt;/p&gt;

&lt;p&gt;Of course I did the easiest one. But also the most normal one in my opinion: why force people to repeat in my game what they have already set on their phone or browser!&lt;/p&gt;

&lt;p&gt;And so now, my CSS file starts with a bunch of CSS variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Thèmes
   ========================================================================== */&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--fond-general&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Fond blanc général */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte quasi noir */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-clair&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte plus clair pour notes */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-jouee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte blanc une fois la lettre jouée */&lt;/span&gt;
  &lt;span class="py"&gt;--filigrane&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c"&gt;/* Couleur du texte en filigrane */&lt;/span&gt;
  &lt;span class="py"&gt;--message-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#dc267f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Fond mauve pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--message-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Texte blanc pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ccc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Fond gris clair pour touche inutilisée */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte quasi noir pour touche en général */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-correct&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ffb000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Orange pour les lettres bien placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-present&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#648fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Bleu pour les lettres mal placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-absent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Gris clair pour les lettres absentes */&lt;/span&gt;
  &lt;span class="py"&gt;--couleur-icone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bbb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Gris pas très clair pour icones */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-lien&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2962ff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Bleu pour les liens */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefers-color-scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dark&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--fond-general&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#222&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Fond très noir général */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#eee&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte très blanc */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-jouee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte blanc une fois la lettre jouée */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-clair&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte moins blanc pour notes */&lt;/span&gt;
  &lt;span class="py"&gt;--filigrane&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c"&gt;/* Couleur du texte en filigrane */&lt;/span&gt;
  &lt;span class="py"&gt;--message-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#dc267f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Fond mauve pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--message-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Texte blanc pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Fond gris moyen pour touche inutilisée */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte blanc pour touche en général */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-correct&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ffb000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Orange pour les lettres bien placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-present&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#648fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Bleu pour les lettres mal placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-absent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Gris-noir pour les lettres absentes */&lt;/span&gt;
  &lt;span class="py"&gt;--couleur-icone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Gris moyen pour icones */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-lien&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2962ff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Bleu pour les liens */&lt;/span&gt;
&lt;span class="p"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A good thing done!&lt;/p&gt;

&lt;h2&gt;
  
  
  A last one for the road...
&lt;/h2&gt;

&lt;p&gt;I use an antiquity to compress CSS (&lt;a href="https://github.com/Microsoft/ajaxmin"&gt;Microsoft Ajax Minifier&lt;/a&gt;) and it didn't hold up against CSS variables :( So for now, I went to the first comer, namely &lt;a href="https://github.com/css/csso"&gt;CSSO&lt;/a&gt;, via its &lt;a href="https://github.com/css/csso-cli"&gt;csso-cli&lt;/a&gt; version to do the job.&lt;/p&gt;

&lt;p&gt;I wonder if it would be possible to compress the CSS variable names, so that &lt;code&gt;--fond-general&lt;/code&gt; is shortened to &lt;code&gt;--a&lt;/code&gt;, &lt;code&gt;--texte-normal&lt;/code&gt; becomes &lt;code&gt;--b&lt;/code&gt;, etc...&lt;/p&gt;

&lt;p&gt;This is something I'll definitely have to review some day to make an informed decision about what I'll use from now on...&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Anyway, another weekend well spent, since it is finally possible to enjoy &lt;strong&gt;LeMOT&lt;/strong&gt; to its fullest, even if you prefer to use a dark mode!&lt;/p&gt;

&lt;p&gt;And to play, it's still there: &lt;a href="https://www.solitaire-play.com/lemot/"&gt;https://www.solitaire-play.com/lemot/&lt;/a&gt; :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F67Pgec7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sn8zazga4w6rd0o0of9r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F67Pgec7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sn8zazga4w6rd0o0of9r.png" alt="Dark mode for LeMOT" title="Not so bad, i guess!" width="505" height="605"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;This post was originally published on &lt;a href="https://blog.pagesd.info/2022/02/02/dark-mode-french-wordle/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>wordle</category>
    </item>
    <item>
      <title>Mode sombre pour Wordle en français</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Tue, 01 Feb 2022 12:15:09 +0000</pubDate>
      <link>https://forem.com/michelc/mode-sombre-pour-wordle-en-francais-3j98</link>
      <guid>https://forem.com/michelc/mode-sombre-pour-wordle-en-francais-3j98</guid>
      <description>&lt;p&gt;Dimanche dernier, j'ai ajouté un thème sombre (dark mode en anglais) sur LeMOT, mon &lt;a href="https://www.solitaire-play.com/lemot/"&gt;Wordle en français&lt;/a&gt;. Certains joueurs semblaient y tenir et c'était l'occasion pour moi de voir comment faire ça sans trop me compliquer la vie.&lt;/p&gt;

&lt;h2&gt;
  
  
  Couleurs en mode clair (light mode)
&lt;/h2&gt;

&lt;p&gt;Pour commencer, j'ai recherché quelles étaient les couleurs utilisées dans mon fichier CSS et j'en ai trouvé une dizaine. Mais en pratique, cela correspond aux 12 cas d'utilisation suivants :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; pour le fond blanc général&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#333&lt;/code&gt; pour le texte général en quasi noir&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; pour le texte un peu plus clair en italique&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ddd&lt;/code&gt; pour le texte en filigrane&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ccc&lt;/code&gt; du gris clair pour pour le fond des touches du clavier inutilisées&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; du blanc pour afficher les lettres une fois jouées dans les cases&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ffb000&lt;/code&gt; le célèbre orange pour le fond des lettres bien placées :)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#648fff&lt;/code&gt; le bleu pour le fond des lettres mal placées&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ddd&lt;/code&gt; un gris un peu plus clair pour pour le fond des lettres absentes du mot à deviner&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#bbb&lt;/code&gt; du gris pas très clair pour les icones&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#dc267f&lt;/code&gt; un fond mauve pour le message "mot inconnu"&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; le blanc du texte pour le message "mot inconnu"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ca c'est fait !&lt;/p&gt;

&lt;h2&gt;
  
  
  Couleurs en mode sombre (dark mode)
&lt;/h2&gt;

&lt;p&gt;J'ai ensuite recherché quelles couleurs utiliser quand on est en mode sombre. Ca n'a pas été trop compliqué, puisqu'il suffit de regarder du côté du &lt;a href="https://powerlanguage.co.uk/wordle/"&gt;Wordle&lt;/a&gt; d'origine pour l'inspiration... Après quelques essais, je suis arrivé à ces couleurs :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#222&lt;/code&gt; pour un fond général très noir&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#333&lt;/code&gt; pour un texte général très blanc&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; pour un texte italique moins blanc&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#444&lt;/code&gt; pour le texte des filigranes en gris / noir&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; du gris "moyen" pour pour le fond des touches du clavier inutilisées&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; du blanc pour afficher les lettres une fois jouées dans les cases&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#ffb000&lt;/code&gt; le célèbre orange pour le fond des lettres bien placées :)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#648fff&lt;/code&gt; le bleu pour le fond des lettres mal placées&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#444&lt;/code&gt; un gris / noir pour pour le fond des lettres absentes du mot à deviner&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#888&lt;/code&gt; du gris "moyen" pour les icones&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#dc267f&lt;/code&gt; un fond mauve pour le message "mot inconnu"&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#fff&lt;/code&gt; le blanc du texte pour le message "mot inconnu"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Comme jusqu'à présent j'affichais les liens en bleu pétant (&lt;code&gt;#00f&lt;/code&gt;), j'ai dû en trouver un autre qui rendrait bien dans les deux modes sombres et clair. J'ai repris le bleu &lt;code&gt;#2962ff&lt;/code&gt; d'un de mes autres sites, mais sans doute à améliorer parce que je n'en suis pas super satisfait...&lt;/p&gt;

&lt;p&gt;Les couleurs sombres, c'est fait !&lt;/p&gt;

&lt;h2&gt;
  
  
  Paramétrage du thème clair ou sombre
&lt;/h2&gt;

&lt;p&gt;Là, ou bien j'attaquais enfin l'écran de paramétrage de LeMOT, ou bien je trichais en me basant sur la directive média &lt;code&gt;prefers-color-scheme&lt;/code&gt;. Celle-ci permet de détecter le choix de l'utilisateur quant à ses préférences en ce qui concerne le thème à utiliser (sombre ou clair).&lt;/p&gt;

&lt;p&gt;J'ai bien entendu fait le plus facile des 2. Mais aussi le plus normal selon moi : pourquoi obliger les gens à devoir redire dans mon jeu ce qu'ils ont déjà paramétré sur leur téléphone ou leur navigateur !&lt;/p&gt;

&lt;p&gt;Et donc désormais, mon fichier CSS commence par une palanquée de variables CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Thèmes
   ========================================================================== */&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--fond-general&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Fond blanc général */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte quasi noir */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-clair&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte plus clair pour notes */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-jouee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte blanc une fois la lettre jouée */&lt;/span&gt;
  &lt;span class="py"&gt;--filigrane&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c"&gt;/* Couleur du texte en filigrane */&lt;/span&gt;
  &lt;span class="py"&gt;--message-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#dc267f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Fond mauve pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--message-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Texte blanc pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ccc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Fond gris clair pour touche inutilisée */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte quasi noir pour touche en général */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-correct&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ffb000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Orange pour les lettres bien placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-present&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#648fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Bleu pour les lettres mal placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-absent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Gris clair pour les lettres absentes */&lt;/span&gt;
  &lt;span class="py"&gt;--couleur-icone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bbb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Gris pas très clair pour icones */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-lien&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2962ff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Bleu pour les liens */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefers-color-scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dark&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--fond-general&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#222&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Fond très noir général */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#eee&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte très blanc */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-jouee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte blanc une fois la lettre jouée */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-clair&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Texte moins blanc pour notes */&lt;/span&gt;
  &lt;span class="py"&gt;--filigrane&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c"&gt;/* Couleur du texte en filigrane */&lt;/span&gt;
  &lt;span class="py"&gt;--message-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#dc267f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Fond mauve pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--message-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Texte blanc pour les messages */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-fond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Fond gris moyen pour touche inutilisée */&lt;/span&gt;
  &lt;span class="py"&gt;--touche-texte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c"&gt;/* Texte blanc pour touche en général */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-correct&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ffb000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Orange pour les lettres bien placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-present&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#648fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* Bleu pour les lettres mal placées */&lt;/span&gt;
  &lt;span class="py"&gt;--fond-absent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c"&gt;/* Gris-noir pour les lettres absentes */&lt;/span&gt;
  &lt;span class="py"&gt;--couleur-icone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#888&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Gris moyen pour icones */&lt;/span&gt;
  &lt;span class="py"&gt;--texte-lien&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2962ff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;/* Bleu pour les liens */&lt;/span&gt;
&lt;span class="p"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Une bonne chose de faite !&lt;/p&gt;

&lt;h2&gt;
  
  
  Un petit dernier pour la route...
&lt;/h2&gt;

&lt;p&gt;J'utilise une antiquité pour compresser les CSS (&lt;a href="https://github.com/Microsoft/ajaxmin"&gt;Microsoft Ajax Minifier&lt;/a&gt;) et elle n'a pas tenu le coup face aux variables CSS :( Alors pour l'instant, je suis passé au premier venu, à savoir &lt;a href="https://github.com/css/csso"&gt;CSSO&lt;/a&gt;, via sa version &lt;a href="https://github.com/css/csso-cli"&gt;csso-cli&lt;/a&gt; pour faire le boulot.&lt;/p&gt;

&lt;p&gt;Je me demande quand même s'il ne lui serait pas possible de compresser le nom des variables CSS, pour que &lt;code&gt;--fond-general&lt;/code&gt; soit raccourci en &lt;code&gt;--a&lt;/code&gt;, &lt;code&gt;--texte-normal&lt;/code&gt; devienne &lt;code&gt;--b&lt;/code&gt;, etc...&lt;/p&gt;

&lt;p&gt;De toute façon, c'est un truc que je devrai revoir un jour ou l'autre pour décider de façon éclairée de ce que je vais utiliser désormais...&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Quoiqu'il en soit, encore un week-end bien employé, puisqu'il est enfin possible d'apprécier &lt;strong&gt;LeMOT&lt;/strong&gt; à sa juste valeur, même si vous préférez utiliser un mode sombre !&lt;/p&gt;

&lt;p&gt;Et pour jouer, c'est toujours par là : &lt;a href="https://www.solitaire-play.com/lemot/"&gt;https://www.solitaire-play.com/lemot/&lt;/a&gt; :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d6_kQxmX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m43g60229giz6v2r9215.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d6_kQxmX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m43g60229giz6v2r9215.png" alt="Le thème sombre de LeMOT" title="Pas mal du tout, je trouve :)" width="505" height="605"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Billet publié à l'origine sur &lt;a href="https://blog.pagesd.info/2022/02/01/mode-sombre-wordle-francais/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>wordle</category>
      <category>french</category>
    </item>
    <item>
      <title>Share the French Wordle grid</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Sun, 23 Jan 2022 19:27:28 +0000</pubDate>
      <link>https://forem.com/michelc/share-the-french-wordle-grid-5aec</link>
      <guid>https://forem.com/michelc/share-the-french-wordle-grid-5aec</guid>
      <description>&lt;p&gt;Until last Sunday, it wasn't very clear that we could share the results in my &lt;a href="https://www.solitaire-play.com/lemot/"&gt;French Wordle&lt;/a&gt; game. Thankfully, I just need a simple screen to solve this problem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0mQuEvi1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8qv62g29njmbd0hav3le.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0mQuEvi1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8qv62g29njmbd0hav3le.png" alt="Share the LeMOT grid" title="Share the LeMOT grid" width="495" height="551"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At least now it is obvious for everyone that it's possible to share the result of his game. And even that you are strongly invited to do so :)&lt;/p&gt;

&lt;p&gt;Before this update, I displayed a short message for 2 or 3 seconds that said "Bravo! Result copied to the clipboard". So you had to be a bit careful to understand that it was possible to share your result, like with the original &lt;a href="https://powerlanguage.co.uk/wordle/"&gt;Wordle&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Not to mention that it's better than automatically paste the grid into the clipboard, without notifying the player. But that's okay, at first I wanted to deploy quickly.&lt;/p&gt;

&lt;p&gt;And it's not to brag, but I do feel that shares on Twitter have increased after this small improvment :)&lt;/p&gt;

&lt;p&gt;So, don't be afraid to play &lt;a href="https://www.solitaire-play.com/lemot/"&gt;LeMOT&lt;/a&gt; and share your game!&lt;/p&gt;




&lt;p&gt;This post was originally published on &lt;a href="https://blog.pagesd.info/2022/01/23/share-french-wordle-grid/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>wordle</category>
    </item>
    <item>
      <title>Partager la grille de Wordle en français</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Sat, 22 Jan 2022 11:15:53 +0000</pubDate>
      <link>https://forem.com/michelc/partager-la-grille-de-wordle-en-francais-2k3i</link>
      <guid>https://forem.com/michelc/partager-la-grille-de-wordle-en-francais-2k3i</guid>
      <description>&lt;p&gt;Jusqu'à dimanche dernier, il n'était pas super évident qu'on pouvait partager les résultats dans mon &lt;a href="https://www.solitaire-play.com/lemot/"&gt;Wordle en français&lt;/a&gt;. Heureusement, il a suffit d'ajouter un écran tout simple pour résoudre ce problème.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YwXCsHzM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nyqb2691jufo4kngv6m1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YwXCsHzM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nyqb2691jufo4kngv6m1.png" alt="Partager la grille LeMOT" title="Partager la grille LeMOT" width="495" height="551"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Au moins, maintenant il est clair pour tout le monde qu'il est possible de partager le résultat de sa partie. Et même qu'on y est fortement invité :)&lt;/p&gt;

&lt;p&gt;Avant, j'affichais un simple message pendant 2 ou 3 secondes qui annonçait "Bravo ! Résultat copié dans le presse-papiers". Il fallait donc être un peu attentif pour se rendre compte qu'il était alors possible de partager son résultat comme avec le &lt;a href="https://powerlanguage.co.uk/wordle/"&gt;Wordle&lt;/a&gt; original.&lt;/p&gt;

&lt;p&gt;Sans compter que c'est quand même mieux que de coller automatiquement la grille de résultat dans le presse-papier, sans demander auparavant l'avis du joueur. Mais bon, au début, j'étais pressé...&lt;/p&gt;

&lt;p&gt;Et ce n'est pas pour me vanter, mais j'ai bien l'impression que les partages sur Twitter ont augmenté après cette petite modification :)&lt;/p&gt;

&lt;p&gt;Alors, n'hésitez pas à jouer à &lt;a href="https://www.solitaire-play.com/lemot/"&gt;LeMOT&lt;/a&gt; et à pargager votre partie !&lt;/p&gt;




&lt;p&gt;Billet publié à l'origine sur &lt;a href="https://blog.pagesd.info/2022/01/22/partage-grille-wordle-francais/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>wordle</category>
      <category>french</category>
    </item>
    <item>
      <title>Adding SVG Icons to my French Wordle</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Wed, 19 Jan 2022 13:01:32 +0000</pubDate>
      <link>https://forem.com/michelc/adding-svg-icons-to-my-french-wordle-51jn</link>
      <guid>https://forem.com/michelc/adding-svg-icons-to-my-french-wordle-51jn</guid>
      <description>&lt;p&gt;Just after I modified my &lt;a href="https://www.solitaire-play.com/lemot/"&gt;French Wordle&lt;/a&gt; game to use accessible colors, I took a little time to add SVG icons.&lt;/p&gt;

&lt;h2&gt;
  
  
  My first "icons"
&lt;/h2&gt;

&lt;p&gt;Initially, I only used simple Ascii or Unicode characters to represent the game actions or the keyboard keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"?" for the Help menu&lt;/li&gt;
&lt;li&gt;"⚙" for the Settings menu&lt;/li&gt;
&lt;li&gt;"↵" for Enter key&lt;/li&gt;
&lt;li&gt;"⌫" for Backspace key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's simple, it works, and considering that I've rarely had the opportunity to use SVG icons, this was the most practical solution to quickly create &lt;strong&gt;LeMOT&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sEvC0ZYr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rta17dw0l5206gxi495.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sEvC0ZYr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rta17dw0l5206gxi495.png" alt="Original icons" title="Original «icons»" width="250" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was decent, but it didn't look the same depending on what you're playing on: Windows PC, phone, iPhone, ... And then I had to tweak some CSS to give a "button" look to my menu icons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.menu&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;24px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;35px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;35px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;user-select&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.menu&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bbb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Switching to SVG icons
&lt;/h2&gt;

&lt;p&gt;Regardless, I had planned from the beginning to look at SVG icons to improve &lt;strong&gt;LeMOT&lt;/strong&gt;. As I had a number of SVG icon sets bookmarks, I looked for one that would be the best fit.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://feathericons.com/"&gt;Feather – Simply beautiful open source icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://antonreshetov.github.io/vue-unicons/"&gt;Vue Unicons – 1000+ Pixel-perfect svg icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://iconoir.com/"&gt;Iconoir – An Open-Source SVG Icons Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://heroicons.com/"&gt;Heroicons – Beautiful hand-crafted SVG icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://phosphoricons.com/"&gt;Phosphor Icons – A flexible icon family&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Though in the end these are not the icons I selected, I listed them here because they are all very good. But I had some difficulties finding icons to represent the Enter and Backspace keys. Also, just at that time, Josh Wardle had added a new icon in the menu to view stats.&lt;/p&gt;

&lt;p&gt;Also, because I was impatient, I had trouble finding explanations for how to color or resize them.&lt;/p&gt;

&lt;p&gt;Luckily, I finally tilted and thought again about &lt;a href="https://icons.getbootstrap.com/"&gt;Bootstrap icons&lt;/a&gt; that I sometimes use as icon fonts! And there we are, everything I needed, plus they were easily customizable with a bit of CSS.&lt;/p&gt;

&lt;p&gt;To set the color:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;svg&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To resize them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;svg&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The icing on the cake, using the "em" unit allows them to be sized proportionally to the font size.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F_LcdKs6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8gwvmrflo8hkktp9wk0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F_LcdKs6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8gwvmrflo8hkktp9wk0.png" alt="SVG icons" title="SVG icons" width="250" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem with clicking on SVG icons
&lt;/h2&gt;

&lt;p&gt;As it was late and I hadn't tested enough (or not at all?), it bugged :(&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--sqQjPnqJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/985603691129556992/OkpCqMjS_normal.jpg" alt="Guillaume profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Guillaume
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @yomz
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/ms_michel"&gt;@ms_michel&lt;/a&gt; hello je te signale un bug impossible d’effacer des lettres le jeu est planté
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      00:17 AM - 14 Jan 2022
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1481782505309192194" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1481782505309192194" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1481782505309192194" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;On the phones, it was no longer possible to go back and correct a letter or to validate the word entered! All of this because my code was still relying on the Unicode characters "↵" and "⌫" to detect which key had been used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;touche&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;↵&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;validerLigne&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;touche&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;⌫&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;retourArriere&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or something like that...&lt;/p&gt;

&lt;p&gt;Never mind, I just had to add a &lt;code&gt;data-attribute&lt;/code&gt; on the 2 keys and problem solved!&lt;/p&gt;

&lt;p&gt;Unfortunately, when you click on an SVG, the &lt;code&gt;event.target&lt;/code&gt; given by the "click" event doesn't necessarily correspond to the DOM element "button" that represents the key. It can be the "SVG" element or even the "PATH" element depending on the exact place where you clicked...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Most certainly on a phone it will always fall on the "button" (unless you have a super thin finger), but I don't want to leave anything to chance.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Fortunately, this is a well-known problem that I had already encountered in my previous run-ins with event delegation. In his post "&lt;a href="https://gomakethings.com/detecting-click-events-on-svgs-with-vanilla-js-event-delegation/"&gt;Detecting click events on SVGs with vanilla JS event delegation&lt;/a&gt;", Chris Ferdinandi gives two solutions to solve the problem.&lt;/p&gt;

&lt;p&gt;Of course, I took the simpler solution and added a &lt;code&gt;pointer-events: none;&lt;/code&gt; to my CSS file.&lt;/p&gt;

&lt;p&gt;And that's why it's now possible to play &lt;a href="https://www.solitaire-play.com/lemot/"&gt;French Wordle&lt;/a&gt; on a phone and with pretty icons.&lt;/p&gt;




&lt;p&gt;This post was originally published on &lt;a href="https://blog.pagesd.info/2022/01/19/adding-svg-icons-french-wordle/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>wordle</category>
    </item>
    <item>
      <title>Ajout d'icônes SVG à mon Wordle français</title>
      <dc:creator>Michel</dc:creator>
      <pubDate>Sun, 16 Jan 2022 10:49:13 +0000</pubDate>
      <link>https://forem.com/michelc/ajout-dicones-svg-a-mon-wordle-francais-4fff</link>
      <guid>https://forem.com/michelc/ajout-dicones-svg-a-mon-wordle-francais-4fff</guid>
      <description>&lt;p&gt;Juste après avoir modifié ma version de &lt;a href="https://www.solitaire-play.com/lemot/"&gt;Wordle en français&lt;/a&gt; pour utiliser des &lt;a href="https://dev.to%20link%20michelc/des-couleurs-accessibles-pour-lemot-11he%20"&gt;couleurs accessibles&lt;/a&gt;, j'ai pris un petit moment pour ajouter de véritables icônes SVG.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mes premières "icônes"
&lt;/h2&gt;

&lt;p&gt;Au départ, je m'étais contenté d'utiliser de simples caractères Ascii ou Unicode pour représenter les actions du jeu ou les touches du clavier :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"?" pour le menu Aide&lt;/li&gt;
&lt;li&gt;"⚙" pour le menu paramétrage&lt;/li&gt;
&lt;li&gt;"↵" pour la touche Entrée&lt;/li&gt;
&lt;li&gt;"⌫" pour la touche Retour arrière&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;C'est simple, ça marche et comme jusqu'à présent j'ai rarement eu l'occasion d'utiliser des icônes au format SVG, c'était la solution la plus pratique pour créer &lt;strong&gt;LeMOT&lt;/strong&gt; super rapidement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9t9HGKEF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jgby9tpacvqtera9eny2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9t9HGKEF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jgby9tpacvqtera9eny2.png" alt="Les icônes d'origine" title="Les «icônes» d'origine" width="250" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;C'était pas mal, mais ça ne rendait pas pareil selon sur quoi on joue : un PC sous Windows, un téléphone, un iPhone, ... Et puis j'avais dû bidouiller du CSS pour réussir à donner un aspect "bouton" aux icônes du menu.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.menu&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;24px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;35px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;35px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;user-select&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.menu&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bbb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Changement pour des icônes SVG
&lt;/h2&gt;

&lt;p&gt;Malgré tout, j'avais prévu dès le début de regarder du côté des icônes SVG pour améliorer &lt;strong&gt;LeMOT&lt;/strong&gt;. Comme j'avais sous le coude un certain nombre de jeux d'icônes SVG, j'ai cherché lequel conviendrait mieux.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://feathericons.com/"&gt;Feather – Simply beautiful open source icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://antonreshetov.github.io/vue-unicons/"&gt;Vue Unicons – 1000+ Pixel-perfect svg icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://iconoir.com/"&gt;Iconoir – An Open-Source SVG Icons Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://heroicons.com/"&gt;Heroicons – Beautiful hand-crafted SVG icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://phosphoricons.com/"&gt;Phosphor Icons – A flexible icon family&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Même si au final ce ne sont pas les icônes que j'ai sélectionnées, je les ai listées ici parce qu'elles sont toutes très bien. Par contre j'ai eu quelquefois un problème pour trouver des icônes qui représentent les touches Entrée et Retour arrière. En plus, juste à ce moment-là, Josh Wardle avait ajouté une nouvelle icône dans le menu pour consulter les statistiques.&lt;/p&gt;

&lt;p&gt;Et aussi, comme j'étais un peu impatient, j'ai eu un peu de mal à trouver des explications pour savoir comment les colorer ou les dimensionner.&lt;/p&gt;

&lt;p&gt;Par chance, j'ai fini par tilter et j'ai repensé aux &lt;a href="https://icons.getbootstrap.com/"&gt;icônes Bootstrap&lt;/a&gt; que j'utilise quelquefois sous forme de police d'icônes ! Et là, il y avait tout ce dont j'avais besoin et en plus elles étaient facilement personnalisables avec un peu de CSS.&lt;/p&gt;

&lt;p&gt;Pour définir la couleur :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;svg&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pour les dimensionner :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;svg&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cerise sur le gâteau, le fait d'utiliser l'unité de mesure "em" permet de les dimensionner proportionnellement à la taille de la police.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DUgiWJi3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n22bknwvsz17dhmtnbo9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DUgiWJi3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n22bknwvsz17dhmtnbo9.png" alt="Les icônes SVG" title="Les «icônes» SVG" width="250" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Un problème de clic sur les icônes SVG
&lt;/h2&gt;

&lt;p&gt;Comme il était tard et que je n'avais pas suffisamment (ou pas du tout ?) testé, ça a bugué :(&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--sqQjPnqJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/985603691129556992/OkpCqMjS_normal.jpg" alt="Guillaume profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Guillaume
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @yomz
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/ms_michel"&gt;@ms_michel&lt;/a&gt; hello je te signale un bug impossible d’effacer des lettres le jeu est planté
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      00:17 AM - 14 Jan 2022
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1481782505309192194" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1481782505309192194" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1481782505309192194" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;Sur les téléphones, il n'était plus possible de revenir en arrière pour corriger une lettre ou de valider le mot saisi ! Tout ça parce que mon code se basait toujours sur les caractères Unicode "↵" et "⌫" pour détecter quelle touche avait été utilisée.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;touche&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;↵&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;validerLigne&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;touche&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;⌫&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;retourArriere&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ou quelque chose dans le genre...&lt;/p&gt;

&lt;p&gt;Qu'à cela ne tienne, je n'avais qu'à ajouter un &lt;code&gt;data-attribut&lt;/code&gt; sur les 2 touches concernées et problème résolu !&lt;/p&gt;

&lt;p&gt;Malheureusement, quand on clique sur un SVG, le &lt;code&gt;event.target&lt;/code&gt; que donne l'évènement "click" ne correspond pas obligatoirement à l'élément DOM "button" qui représente la touche. Cela peut être l'élément "SVG" ou même l'élément "PATH" en fonction de l'endroit exact où on a cliqué...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note : Très certainement que sur un téléphone ça tombe toujours sur le "button" (à moins d'avoir un doigt super fin), mais autant ne rien laisser au hasard.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Heureusement, c'est un problème bien connu que j'avais d'ailleurs déjà rencontré lors de mes précédents accrochages avec la délégation d'évènement. Dans son article "&lt;a href="https://gomakethings.com/detecting-click-events-on-svgs-with-vanilla-js-event-delegation/"&gt;Detecting click events on SVGs with vanilla JS event delegation&lt;/a&gt;", Chris Ferdinandi donne deux solutions pour résoudre le problème.&lt;/p&gt;

&lt;p&gt;Bien entendu, j'ai pris la solution la plus simple et j'ai ajouté un &lt;code&gt;pointer-events: none;&lt;/code&gt; à mon fichier CSS.&lt;/p&gt;

&lt;p&gt;Et c'est pour cela que maintenant, il est possible de &lt;a href="https://www.solitaire-play.com/lemot/"&gt;jouer à Wordle en français&lt;/a&gt; sur un téléphone et avec de jolies icônes.&lt;/p&gt;




&lt;p&gt;Billet publié à l'origine sur &lt;a href="https://blog.pagesd.info/2022/01/16/ajout-icones-svg_wordle-francais/"&gt;blog.pagesd.info&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>wordle</category>
      <category>french</category>
    </item>
  </channel>
</rss>
