<?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>DEV Community: Marcos Vargas</title>
    <description>The latest articles on DEV Community by Marcos Vargas (@mar_gus).</description>
    <link>https://dev.to/mar_gus</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4243457%2Fcee80b8a-c48f-48c2-a2b3-623ca9eb2df2.jpg</url>
      <title>DEV Community: Marcos Vargas</title>
      <link>https://dev.to/mar_gus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mar_gus"/>
    <language>en</language>
    <item>
      <title>I Built a Bilingual Hanukkah Menorah in 2D and 3D — and One Candle Refused to Sync</title>
      <dc:creator>Marcos Vargas</dc:creator>
      <pubDate>Thu, 03 Dec 2026 13:09:50 +0000</pubDate>
      <link>https://dev.to/mar_gus/i-built-a-bilingual-hanukkah-menorah-in-2d-and-3d-and-one-candle-refused-to-sync-55c3</link>
      <guid>https://dev.to/mar_gus/i-built-a-bilingual-hanukkah-menorah-in-2d-and-3d-and-one-candle-refused-to-sync-55c3</guid>
      <description>&lt;p&gt;Every December I think about making something for Hanukkah. This year I finally did it: a web app that shows the menorah, tells you the exact candle-lighting time for your city, lets you light the candles in the correct ceremonial order, and even simulates them burning down in real time. I built it in pure HTML, CSS and JavaScript, and I did the whole thing on a tablet. It was the most educational project I've made so far, mostly because of the bugs that refused to die. Here's the story.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the app does
&lt;/h2&gt;

&lt;p&gt;The app has two views of the same menorah. The first is a 2D SVG candelabrum with nine candles: eight for the nights plus the Shamash, the helper candle in the center. You tap a candle to light it, and the app enforces the real halakhic order — Shamash first, then the newest candle, working left to right. If you tap the wrong one, the correct candle glows gold and a message tells you to light it first. Each lit candle flickers, throws tiny sparks, drips wax, and slowly shrinks over four hours, which is how long a real Hanukkah candle burns. There's a demo mode that compresses those four hours into three minutes so you can practice the ritual without waiting.&lt;/p&gt;

&lt;p&gt;The second view is a 3D Three.js menorah with the same nine candles, PBR textures for the wax, an HDR environment for the reflections on the gold, and orbit controls so you can spin it with your finger. Both views are fully bilingual — Spanish and English — and they share the same state, so a candle you light in 2D is lit in 3D and vice versa.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real lighting times for real cities
&lt;/h2&gt;

&lt;p&gt;The hardest "feature" wasn't the graphics, it was the clock. Hanukkah candles are lit at nightfall, which depends on where you are and what day of the week it is. On Friday the candles go up before sunset to respect Shabbat, and on Saturday after Shabbat ends. So I implemented the NOAA sunset algorithm in plain JavaScript, fed it the latitude, longitude and timezone of the selected city, and added the weekday offsets. The result is that a user in Caracas and a user in Jerusalem get different, correct times for the very same night. I also built a date table that covers Hanukkah from 2024 to 2124, so the countdown doesn't stop after this year — when one festival ends, the app quietly starts counting down to the next one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bugs that taught me the most
&lt;/h2&gt;

&lt;p&gt;I want to be honest about the bugs, because they taught me more than any tutorial.&lt;/p&gt;

&lt;p&gt;First, the 3D scene loaded but the camera controls crashed with "Cannot access 'controls' before initialization". The cause was the temporal dead zone: I was calling a function that read a const variable before that variable had been declared. The fix was to declare it with let, initialize it to null, and guard every use with if (controls). Lesson: with const, order matters more than you think.&lt;/p&gt;

&lt;p&gt;Second, my OrbitControls and RGBELoader files threw "Cannot use import statement outside a module". I had downloaded the ES-module versions but was loading them with plain  tags. Lesson: know which build of a library you&amp;amp;#39;re grabbing.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Third, and most painful, the 2D and 3D candelabros wouldn&amp;amp;#39;t sync. The event &amp;amp;#39;storage&amp;amp;#39; only fires between different tabs, not when you navigate from index.html to 3d.html in the same tab. So I added a &amp;amp;#39;focus&amp;amp;#39; listener that re-reads localStorage every time the page regains attention. Lesson: browser events have hidden scopes.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Fourth, the central Shamash candle. The 2D view started with everything off, but the 3D view kept forcing the Shamash lit on load, and the demo mode didn&amp;amp;#39;t light it either. The bug was a hardcoded litCandles.add(4) in three different places. Removing it made both views start clean and respect whatever the user had saved. Lesson: a default state is still a decision, and it has to be the same decision in every file.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Finally, the cache. On my tablet, Ctrl+F5 simply doesn&amp;amp;#39;t refresh JavaScript. The fix was cache busting: appending ?v=3 to every script and stylesheet link. Lesson: in production, version your assets or you&amp;amp;#39;ll debug ghosts.&amp;lt;/p&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="building-on-a-tablet" href="#building-on-a-tablet" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Building on a tablet
&amp;lt;/h2&amp;gt;

&amp;lt;p&amp;gt;A small note on how this was made. I do all of my development on a tablet, not a desktop. That constraint shaped the project: I avoided build tools, frameworks and package managers, and stuck to files I could edit, upload and test directly. No bundler, no npm, just vanilla HTML, CSS and JavaScript plus the Three.js build. It&amp;amp;#39;s slower in some ways and clearer in others, because every line is something I had to understand, not just install. If you&amp;amp;#39;re a beginner or you work on limited hardware, please know that &amp;amp;quot;no computer&amp;amp;quot; is not &amp;amp;quot;no project&amp;amp;quot;. The web is open and it runs on the device in your hands.&amp;lt;/p&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="closing" href="#closing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Closing
&amp;lt;/h2&amp;gt;

&amp;lt;p&amp;gt;The whole thing is live on GitHub Pages, free, with no backend and no tracking. It&amp;amp;#39;s a small tool for a real holiday, and it&amp;amp;#39;s also my way of keeping my hands busy with code I actually care about. If you celebrate Hanukkah, I hope the lighting times and the ceremonial order make your evenings a little easier. If you don&amp;amp;#39;t, I hope the bug stories make you smile, because every single one of them was a moment where I wanted to throw the tablet out the window and didn&amp;amp;#39;t.&amp;lt;/p&amp;gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>css</category>
      <category>showdev</category>
    </item>
    <item>
      <title>I Built a Two-Language Christmas Game in Pure JavaScript — and Here's What It Taught Me</title>
      <dc:creator>Marcos Vargas</dc:creator>
      <pubDate>Mon, 23 Nov 2026 23:49:44 +0000</pubDate>
      <link>https://dev.to/mar_gus/i-built-a-two-language-christmas-game-in-pure-javascript-and-heres-what-it-taught-me-5c35</link>
      <guid>https://dev.to/mar_gus/i-built-a-two-language-christmas-game-in-pure-javascript-and-heres-what-it-taught-me-5c35</guid>
      <description>&lt;p&gt;Hi, I'm Marcos, an independent digital creator from Venezuela. I build interactive web experiences with plain HTML, CSS, and JavaScript, and I share my journey one project at a time. Today's project is a little Christmas game: you decorate a tree or assemble a nativity scene by dragging ornaments and characters onto a stage, and the app scores how correct your arrangement is.&lt;/p&gt;

&lt;p&gt;You can play it right here: &lt;a href="https://margus20.github.io/decoracion-navidad/" rel="noopener noreferrer"&gt;https://margus20.github.io/decoracion-navidad/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea behind the scoring
&lt;/h2&gt;

&lt;p&gt;The trick of the whole game is that it does not check for a fixed picture. It checks for relationships. Each piece has a position stored as a percentage of the stage, and the rules are spatial: the star must be near the top, the nutcracker near the feet of the tree, the ornaments must not pile on top of each other, and the visual order from top to bottom has to be coherent. The same idea powers the nativity: baby Jesus in the crib, the crib inside the manger, the star above it, Mary and Joseph close to the scene, the animals on the ground and balanced on opposite sides.&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;// A rule is just a boolean over the pieces' positions&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ruleStarOnTop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figures&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;figures&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;personaje&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'estrella'&lt;/span&gt;&lt;span class="p"&gt;)&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="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;parseFloat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// top quarter of the stage&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each rule contributes points, and when the total reaches one hundred the game celebrates. I love this approach because it rewards understanding instead of memorizing coordinates, and it makes the same engine work for two different scenes with different rule sets.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bilingual system, and the cache trap it exposed
&lt;/h2&gt;

&lt;p&gt;The game switches between Spanish and English with a small dictionary I wrote myself, no i18n library. The interesting part is the color palette for the bow, the bulb, and the valance. At first the panel translated everything except the color names, and the title showed up as a raw key in capital letters. The culprit was not the code, it was the browser cache: one file had loaded fresh while another was still the old version in memory, so the two files were out of sync.&lt;/p&gt;

&lt;p&gt;The fix that ended the whole fight was to stop depending on a second file for the palette. I gave the palette its own tiny dictionary inside the file that draws it, so the translation lives right next to the UI that needs it.&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="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;PALETA_EN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;rojo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Red'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amarillo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Yellow'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;anaranjado&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Orange'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;azul&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Blue'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;morado&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Purple'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;plateado&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Silver'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;original&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Original'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;tColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nombreOriginal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;clave&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nombreOriginal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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;span class="nf"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'NFD'&lt;/span&gt;&lt;span class="p"&gt;)&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="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;\&lt;span class="n"&gt;u0300&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;\&lt;span class="n"&gt;u036f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="no"&gt;PALETA_EN&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;clave&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;nombreOriginal&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 lesson: when a feature looks broken in a way that contradicts your code, suspect the cache before you suspect the logic. Bumping a version query on the script tag, like &lt;code&gt;?v=23&lt;/code&gt;, is the cheapest way to force a fresh download.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pinch to resize, without losing drag
&lt;/h2&gt;

&lt;p&gt;Pieces are dragged with one finger or the mouse, but I wanted people to also grow and shrink a piece with a two-finger pinch, the way you would expect on a phone. The catch is that the same touch handler must decide in real time whether two fingers mean "pinch" or one finger means "drag". I track the distance between the two touch points and scale the zoom relative to the starting distance, clamped to the same limits the sliders use.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;distanciaDosDedos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;touches&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hypot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clientX&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t&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="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clientX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clientY&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t&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="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clientY&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;span class="c1"&gt;// in the move handler, when two fingers are down:&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;nuevoZoom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;zoomPinchInicial&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;distanciaDosDedos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;distPinchInicial&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;nuevoZoom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nuevoZoom&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;span class="n"&gt;elemento&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zoom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nuevoZoom&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sliders update themselves to reflect the new size, so touch and the control panel never disagree.&lt;/p&gt;

&lt;h2&gt;
  
  
  Music that survives page changes
&lt;/h2&gt;

&lt;p&gt;The game has three pages: a cover, the tree, and the nativity. The problem with music on a multi-page site is that every time you navigate, the browser tears down the old page and the audio stops. The solution is to remember the play state in &lt;code&gt;localStorage&lt;/code&gt;. When a page loads, it reads that flag and resumes automatically if the user had left the music on.&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;// save the state whenever the user toggles it&lt;/span&gt;
&lt;span class="n"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'musicaActiva'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activo&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'false'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// on page load, resume if it was on&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;estado&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'musicaActiva'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'true'&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;estado&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reproducir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&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;One more detail I learned the hard way: the audio files I first used were really video files renamed to &lt;code&gt;.mp3&lt;/code&gt;, and the browser refused them with a "no supported format" error. Renaming an extension does not change what is inside the file. Switching to real audio sources fixed it instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protecting the user from an accidental exit
&lt;/h2&gt;

&lt;p&gt;Because a game has progress, I added a confirmation before leaving. The browser's own exit dialog is the one you see when closing a tab or reloading, and by design it cannot be styled or translated, so I built my own modal for the in-game "back" button instead, matching the game's gold-on-dark palette and the Bebas Neue font, and reading the current language.&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="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;TXT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;titulo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'CONFIRMAR SALIDA'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancelar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'CANCELAR'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;aceptar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'SALIR'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;en&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;titulo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'LEAVE GAME?'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancelar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'CANCEL'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;aceptar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'LEAVE'&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;The honest takeaway: some dialogs belong to the browser and you cannot dress them up. The right move is to control the moments you can control, like the buttons inside your own page.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;This project taught me more than a tutorial ever did, because every bug was a real constraint. The cache desync taught me to isolate dependencies. The fake mp3 taught me that a file is its bytes, not its name. The pinch gesture taught me that a touch handler can be a state machine, not just a single action. And the exit dialog taught me to accept the limits of the platform and design around them.&lt;/p&gt;

&lt;p&gt;If you want to play with it, the source is on my GitHub and the live demo is the link above. If you build your own scoring rules for a different scene, or you improve the flame or the drag, I would love to hear about it in the comments. Thanks for reading, and happy building from Venezuela.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>css</category>
      <category>showdev</category>
    </item>
    <item>
      <title>I Built a Candle That Burns Down in Real-Time as the Year Passes</title>
      <dc:creator>Marcos Vargas</dc:creator>
      <pubDate>Fri, 13 Nov 2026 19:03:09 +0000</pubDate>
      <link>https://dev.to/mar_gus/i-built-a-candle-that-burns-down-in-real-time-as-the-year-passes-1636</link>
      <guid>https://dev.to/mar_gus/i-built-a-candle-that-burns-down-in-real-time-as-the-year-passes-1636</guid>
      <description>&lt;p&gt;Hi everyone! I'm Marcos, an independent digital creator from Venezuela. Today I want to share a small project I built entirely from scratch: a web page where a candle slowly consumes itself second by second, showing exactly how much time is left until the New Year.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Idea
&lt;/h2&gt;

&lt;p&gt;I wanted to create something visual, calming, and slightly philosophical — a way to &lt;em&gt;feel&lt;/em&gt; the year passing by instead of just reading a countdown. So I built &lt;strong&gt;The Year Candle&lt;/strong&gt;: a single web page where a green candle with a golden holder burns down mathematically, in perfect sync with the calendar.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;The math is simple but elegant. The script calculates the percentage of the year that has already passed (from January 1st to December 31st) and applies that percentage to the height of the candle. Every second, the candle shrinks a tiny bit. By the time December 31st at 11:59:59 PM arrives, the candle is completely gone.&lt;/p&gt;

&lt;p&gt;The best part? &lt;strong&gt;It works automatically for every visitor in their own local timezone.&lt;/strong&gt; Someone in Tokyo, someone in Madrid, and someone in Caracas all see the candle burning according to their own clock. No server, no database, just pure client-side JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features I'm Proud Of
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A "ghost" shadow&lt;/strong&gt; behind the candle shows the original full height, so you can visually see how much has been consumed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A flickering green flame&lt;/strong&gt; with occasional magical sparks that rise from it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wax drips&lt;/strong&gt; that slowly slide down the sides of the candle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic New Year celebration&lt;/strong&gt;: when the clock strikes midnight on December 31st, the page detects the year change &lt;em&gt;without reloading&lt;/em&gt;, fireworks explode across the screen, the new year number appears big at the top, slides down, and the candle rebuilds itself from scratch to start burning again for the new year.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A donate button&lt;/strong&gt; in the corner, because I'm trying to build a sustainable path as an independent creator.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Tech Stack
&lt;/h2&gt;

&lt;p&gt;Just the classics, no frameworks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTML5&lt;/strong&gt; for the structure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSS3&lt;/strong&gt; with gradients, animations, and keyframes for all the visuals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vanilla JavaScript&lt;/strong&gt; for the math, the canvas-based fireworks, and the automatic year detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also split the code into three separate files (&lt;code&gt;index.html&lt;/code&gt;, &lt;code&gt;css/style.css&lt;/code&gt;, &lt;code&gt;js/script.js&lt;/code&gt;) to keep things clean and maintainable. The whole project is hosted for free on &lt;strong&gt;GitHub Pages&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;You can watch the candle burning right now at:&lt;br&gt;
👉 &lt;a href="https://margus20.github.io/the-lucky_year-candle/" rel="noopener noreferrer"&gt;&lt;strong&gt;The Year Candle&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Support My Work
&lt;/h2&gt;

&lt;p&gt;I'm building small, useful, and aesthetic digital experiences, one project at a time. If you enjoyed this or found it interesting, you can support my independent work here:&lt;br&gt;
☕ &lt;a href="https://ko-fi.com/mar_gus" rel="noopener noreferrer"&gt;&lt;strong&gt;Buy me a coffee on Ko-fi&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;I'm planning to build more mini web tools — a breathing guide, a focus timer, maybe an interactive map. If you have ideas or suggestions, I'd love to hear them in the comments.&lt;/p&gt;

&lt;p&gt;Thanks for reading, and happy coding! 🕯️✨&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
