<?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: Avishek Dhimal</title>
    <description>The latest articles on DEV Community by Avishek Dhimal (@avishek_dhimal_da92aff5fc).</description>
    <link>https://dev.to/avishek_dhimal_da92aff5fc</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%2F3985808%2F01844289-988b-4c27-803a-c92592969b61.jpg</url>
      <title>DEV Community: Avishek Dhimal</title>
      <link>https://dev.to/avishek_dhimal_da92aff5fc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/avishek_dhimal_da92aff5fc"/>
    <language>en</language>
    <item>
      <title>Your color palette probably fails accessibility. Here's how to check it in 30 seconds</title>
      <dc:creator>Avishek Dhimal</dc:creator>
      <pubDate>Sun, 05 Jul 2026 11:46:44 +0000</pubDate>
      <link>https://dev.to/avishek_dhimal_da92aff5fc/your-color-palette-probably-fails-accessibility-heres-how-to-check-it-in-30-seconds-310i</link>
      <guid>https://dev.to/avishek_dhimal_da92aff5fc/your-color-palette-probably-fails-accessibility-heres-how-to-check-it-in-30-seconds-310i</guid>
      <description>&lt;p&gt;Here's an uncomfortable stat: most color palettes that look great fail the most basic accessibility test — text contrast.&lt;/p&gt;

&lt;p&gt;I learned this the hard way. I built a landing page with a palette I loved: soft coral text on a warm cream background. Beautiful in a screenshot. Then someone told me they literally couldn't read my hero heading on their phone in daylight.&lt;/p&gt;

&lt;p&gt;The palette wasn't the problem. The &lt;em&gt;pairing&lt;/em&gt; was.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 30-second check
&lt;/h2&gt;

&lt;p&gt;Text readability is measured by &lt;strong&gt;contrast ratio&lt;/strong&gt; — how different your text color is from the background behind it. The WCAG standard is simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;4.5:1 minimum&lt;/strong&gt; for normal body text (AA)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;7:1&lt;/strong&gt; for the stricter AAA level&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3:1&lt;/strong&gt; for large text (24px+)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Black on white is 21:1 — maximum contrast. My coral-on-cream disaster? About 2.1:1. Nobody with less-than-perfect vision (or a sunny day) had a chance.&lt;/p&gt;

&lt;p&gt;The fastest way to check: any contrast checker tool, or the one built into Chrome DevTools — inspect a text element, click the color swatch in Styles, and the contrast ratio is right there with AA/AAA badges.&lt;/p&gt;

&lt;h2&gt;
  
  
  The formula, if you're curious
&lt;/h2&gt;

&lt;p&gt;The math behind it is relative luminance:&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;luminance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&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="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;/=&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mf"&gt;0.03928&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;12.92&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;pow&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.055&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;1.055&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;2.4&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="nx"&gt;a&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="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.2126&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;a&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="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.7152&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.0722&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;contrast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rgb1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rgb2&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="nx"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;luminance&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;rgb1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;l2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;luminance&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;rgb2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return &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;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.05&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="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="nx"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;contrast&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// ≈ 18.88&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the exact formula Chrome, Lighthouse, and every checker uses. No magic.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow fix
&lt;/h2&gt;

&lt;p&gt;The real lesson wasn't "run a checker at the end" — it was &lt;strong&gt;choosing pairings up front&lt;/strong&gt;. Now when I pick a palette, I decide immediately: which color is text, which is background, which are decoration-only. The vivid middle tones that fail contrast? They become borders, accents, and illustrations — never words.&lt;/p&gt;

&lt;p&gt;A pattern that always works:&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="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--bg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c"&gt;/* your lightest color */&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c"&gt;/* your darkest color */&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c"&gt;/* the vivid one — buttons, badges, never body text */&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;If your lightest-on-darkest doesn't hit 4.5:1, the palette needs a darker dark or a lighter light. Adjust lightness, not hue — the palette keeps its character.&lt;/p&gt;

&lt;p&gt;I ended up building this check into &lt;a href="https://palettecss.com" rel="noopener noreferrer"&gt;PaletteCSS&lt;/a&gt;, a free palette tool I work on — every palette page shows a WCAG contrast table for all color pairings, so you can see which combos are safe for text before you commit. No signup, if you want to sanity-check your current palette.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Body text needs &lt;strong&gt;4.5:1&lt;/strong&gt; contrast minimum&lt;/li&gt;
&lt;li&gt;Check in DevTools — it's built in&lt;/li&gt;
&lt;li&gt;Assign roles when you &lt;em&gt;pick&lt;/em&gt; colors: text, background, accent&lt;/li&gt;
&lt;li&gt;Vivid mid-tones are for decoration, not words&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your design isn't done when it looks good. It's done when everyone can read it.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>a11y</category>
      <category>css</category>
      <category>design</category>
    </item>
    <item>
      <title>Color theory for developers who can't design</title>
      <dc:creator>Avishek Dhimal</dc:creator>
      <pubDate>Sun, 28 Jun 2026 16:49:51 +0000</pubDate>
      <link>https://dev.to/avishek_dhimal_da92aff5fc/color-theory-for-developers-who-cant-design-4imf</link>
      <guid>https://dev.to/avishek_dhimal_da92aff5fc/color-theory-for-developers-who-cant-design-4imf</guid>
      <description>&lt;p&gt;You can center a div, optimize a query, and ship a feature — but the moment you have to &lt;em&gt;pick colors&lt;/em&gt;, you freeze. Same. Here's the small bit of color theory that gets you 90% of the way, no design degree required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule #1: Start with ONE color
&lt;/h2&gt;

&lt;p&gt;Don't pick five colors. Pick &lt;strong&gt;one&lt;/strong&gt; you like — your accent/brand color — and build everything else around it. Say your accent is:&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;--color-accent&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;#6366&lt;/span&gt;&lt;span class="nt"&gt;f1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* indigo */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now generate the rest from it using the color wheel.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 3 relationships you actually need
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Complementary&lt;/strong&gt; — the color directly opposite on the wheel. Maximum contrast. Use it &lt;em&gt;sparingly&lt;/em&gt; for one highlight (a button, a badge).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#6366f1&lt;/code&gt; → complement ≈ &lt;code&gt;#f1c46a&lt;/code&gt; (warm gold)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Analogous&lt;/strong&gt; — the colors right next to yours. Calm and cohesive. Great for backgrounds and gradients.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#6366f1&lt;/code&gt; → &lt;code&gt;#8b5cf6&lt;/code&gt; and &lt;code&gt;#5c8bf6&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Triadic&lt;/strong&gt; — two colors evenly spaced around the wheel. Vibrant but balanced.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#6366f1&lt;/code&gt; → &lt;code&gt;#f16366&lt;/code&gt; and &lt;code&gt;#66f163&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Rule #2: Most of your UI is neutral
&lt;/h2&gt;

&lt;p&gt;Beginners color &lt;em&gt;everything&lt;/em&gt;. Pros use &lt;strong&gt;one accent + lots of neutrals&lt;/strong&gt;:&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;--color-bg&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="nf"&gt;#f7f7f8&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* off-white, not pure white */&lt;/span&gt;
&lt;span class="nt"&gt;--color-text&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="err"&gt;#1&lt;/span&gt;&lt;span class="nt"&gt;f2937&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* near-black, not pure black */&lt;/span&gt;
&lt;span class="nt"&gt;--color-muted&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="err"&gt;#9&lt;/span&gt;&lt;span class="nt"&gt;ca3af&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;--color-accent&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;#6366&lt;/span&gt;&lt;span class="nt"&gt;f1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pure black on pure white is harsh. Pull both back and everything instantly looks more intentional.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule #3: Check contrast before you ship
&lt;/h2&gt;

&lt;p&gt;A palette can look great and still fail accessibility. Aim for a &lt;strong&gt;4.5:1&lt;/strong&gt; contrast ratio for body text (WCAG AA). Test your text against your background — if it's borderline, darken the text.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shortcut
&lt;/h2&gt;

&lt;p&gt;If you'd rather not do the wheel math by hand, I built a free tool — &lt;a href="https://palettecss.com" rel="noopener noreferrer"&gt;PaletteCSS&lt;/a&gt; — that shows the complementary, analogous and matching colors for any base color and lets you copy them as CSS variables or Tailwind. But honestly, the three rules above get you most of the way.&lt;/p&gt;

&lt;p&gt;What's your go-to for colors when there's no designer on the team? Drop it in the comments — always looking to steal good ones.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>design</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building a "Mate-in-One" Chess Puzzle Solver from Scratch</title>
      <dc:creator>Avishek Dhimal</dc:creator>
      <pubDate>Fri, 26 Jun 2026 04:19:12 +0000</pubDate>
      <link>https://dev.to/avishek_dhimal_da92aff5fc/building-a-mate-in-one-chess-puzzle-solver-from-scratch-4pc0</link>
      <guid>https://dev.to/avishek_dhimal_da92aff5fc/building-a-mate-in-one-chess-puzzle-solver-from-scratch-4pc0</guid>
      <description>&lt;p&gt;Chess puzzles are incredibly addictive, but have you ever wondered how software instantly verifies if a move is a genuine checkmate? &lt;/p&gt;

&lt;p&gt;While full chess engines like Stockfish look dozens of moves ahead using complex neural networks and alpha-beta pruning, writing an algorithm to detect a simple &lt;strong&gt;Mate-in-One&lt;/strong&gt; is actually a fantastic, approachable exercise in graph theory and data modeling. &lt;/p&gt;

&lt;p&gt;Here is a look at the exact step-by-step logic required to build a lightweight, fast mate-in-one puzzle detector.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Representing the Board: The FEN String
&lt;/h2&gt;

&lt;p&gt;Before your code can calculate a move, it needs to understand the current state of the board. In computer chess, we use a standard string notation called &lt;strong&gt;FEN (Forsyth-Edwards Notation)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A typical FEN looks like this:&lt;br&gt;
&lt;code&gt;r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 1 3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This single string tells your program exactly where every piece is, whose turn it is (&lt;code&gt;w&lt;/code&gt; or &lt;code&gt;b&lt;/code&gt;), castling rights, and move counts. To parse this, our code converts the string into an 8x8 matrix (a 2D array) representing the squares.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Step 1: The "Candidate Move" Generator
&lt;/h2&gt;

&lt;p&gt;To find a mate-in-one, your algorithm first needs to know every single legal move the attacking player can make right now.&lt;/p&gt;

&lt;p&gt;The program iterates through the 8x8 grid, finds all pieces belonging to the current player, and calculates their theoretical movement paths based on traditional chess rules (e.g., Knights move in L-shapes, Rooks move in straight orthogonal lines).&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;getCandidateMoves&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;board&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;activeColor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;moves&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="c1"&gt;// 1. Loop through all 64 squares&lt;/span&gt;
  &lt;span class="c1"&gt;// 2. Identify active pieces&lt;/span&gt;
  &lt;span class="c1"&gt;// 3. Generate potential target squares based on piece physics&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;moves&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;
  
  
  Step 2: Filter for Genuine Checks
&lt;/h2&gt;

&lt;p&gt;A move can only be a checkmate if it puts the opposing King in immediate danger.&lt;/p&gt;

&lt;p&gt;For every candidate move generated in Step 1, our algorithm creates a virtual clone of the board and executes that move. On this cloned board, it checks if any of the attacking pieces now have a direct line of sight to capture the enemy King.&lt;/p&gt;

&lt;p&gt;If the King is not in check after the move, the algorithm immediately throws that move out. It isn't our winning puzzle answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: The Ultimate Test (Eliminating Escapes)
&lt;/h2&gt;

&lt;p&gt;This is where the magic happens. Just because the King is in check doesn't mean it's checkmate. It is only checkmate if the defending player has zero legal responses to escape the threat.&lt;/p&gt;

&lt;p&gt;For every move that successfully delivers a check, our simulator switches sides to the defender and asks three questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can the King move to an adjacent, safe square that is not under attack?&lt;/li&gt;
&lt;li&gt;Can the threat be blocked by putting a defending piece in the path of the attacker?&lt;/li&gt;
&lt;li&gt;Can the attacking piece be captured and removed from the board entirely?
&lt;/li&gt;
&lt;/ul&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;isCheckmate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;virtualBoard&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;defendingColor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Generate ALL legal moves for the defender on this new board state&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;escapeMoves&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getLegalMoves&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;virtualBoard&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;defendingColor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// If the defender has absolutely no moves left to escape the check...&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;escapeMoves&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="mi"&gt;0&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;If the defender's legal move count drops to absolute zero while their King is actively under attack, your program has successfully discovered the Mate-in-One!&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping Complex Code Architectures Clean
&lt;/h2&gt;

&lt;p&gt;When you build complex, algorithmic tools like chess analyzers or interactive calculators, managing your application's state and keeping your styling decoupled from your logic is half the battle.&lt;/p&gt;

&lt;p&gt;If you're looking for a clean way to structure your design tokens without writing massive boilerplate CSS, I use a utility I built called &lt;a href="https://palettecss.com" rel="noopener noreferrer"&gt;PaletteCSS&lt;/a&gt;. It exports tailored palettes straight into clean CSS variables or Tailwind configs, so you can focus on writing clean, optimized JavaScript instead.&lt;/p&gt;

&lt;p&gt;Have you ever built a game engine or puzzle logic from scratch? What was the hardest edge case you had to solve? Let's discuss in the comments!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why your Tailwind build is bloated (And how to fix it in 3 steps)</title>
      <dc:creator>Avishek Dhimal</dc:creator>
      <pubDate>Fri, 26 Jun 2026 04:09:50 +0000</pubDate>
      <link>https://dev.to/avishek_dhimal_da92aff5fc/why-your-tailwind-build-is-bloated-and-how-to-fix-it-in-3-steps-31j9</link>
      <guid>https://dev.to/avishek_dhimal_da92aff5fc/why-your-tailwind-build-is-bloated-and-how-to-fix-it-in-3-steps-31j9</guid>
      <description>&lt;p&gt;Tailwind CSS is an absolute game-changer for speed, but if you aren't careful, you can end up shipping a massive utility stylesheet to your users. &lt;/p&gt;

&lt;p&gt;If your production CSS file is clocking in at over a few dozen kilobytes, something is wrong with your configuration. Luckily, getting it back down to a lightning-fast size only takes a few adjustments. Here is exactly how to audit and fix a bloated Tailwind build.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Stop using dynamic class strings
&lt;/h2&gt;

&lt;p&gt;The number one reason Tailwind builds balloon or completely miss classes in production is dynamic string interpolation. &lt;/p&gt;

&lt;p&gt;Tailwind’s scanner looks for unbroken, complete strings in your source files. If it sees the full string, it keeps the utility. If you break it up, it skips it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't do this:&lt;/strong&gt;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
javascript
// This will FAIL or cause issues because Tailwind doesn't compile code at runtime
const buttonColor = "indigo";
const classString = `bg-${buttonColor}-600`;

Do this instead:

// Write out the full class names so the static extractor can find them
const buttonColors = {
  primary: "bg-indigo-600 hover:bg-indigo-700",
  secondary: "bg-gray-600 hover:bg-gray-700"
};
If the static scanner can’t see the literal string bg-indigo-600, that class won't be included in your final CSS tree-shaking process.

2. Lock down your content array
Tailwind needs to know exactly which files to watch. If your tailwind.config.js file has an overly broad path, it will parse files it shouldn't, slowing down build times and picking up accidental strings as classes.

Check your configuration file:

JavaScript
module.exports = {
  content: [
    "./src/**/*.{html,js,ts,jsx,tsx,vue}",
    // Avoid tracking entire node_modules directories or backup folders!
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
Make sure you are only targeting your actual source directory. Never point the scanner toward massive compiled build folders like /dist or /build.

3. Don't abuse @apply
The @apply directive is tempting when you want to "clean up" your HTML, but overusing it completely destroys the benefits of Tailwind's design system.

When you use utility classes in your HTML, the same bg-blue-500 class is reused across 100 components, adding zero bytes to your final CSS file. But when you use @apply in a CSS file:

CSS
/* This duplicates CSS declarations behind the scenes */
.btn-primary {
  @apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
}
.card-action {
  @apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
}
Tailwind is forced to generate duplicate raw CSS properties for every custom class name you create, heavily inflating your final bundle size. Stick to utility classes in your component markup whenever possible.

Streamlining your workflow
Keeping your utility workflow clean shouldn't mean copying and pasting raw configuration blocks over and over. If you want to jumpstart a clean architecture, I use a lightweight tool I built called [PaletteCSS](https://palettecss.com/) to quickly grab optimized, pre-formatted theme configurations for Tailwind, SCSS, or vanilla CSS variables without the boilerplate hassle.

What's your biggest pet peeve when working with utility-first CSS? Let's talk shop in the comments!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>tailwindcss</category>
      <category>performance</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>How to turn a color palette into clean CSS variables</title>
      <dc:creator>Avishek Dhimal</dc:creator>
      <pubDate>Thu, 25 Jun 2026 06:40:16 +0000</pubDate>
      <link>https://dev.to/avishek_dhimal_da92aff5fc/how-to-turn-a-color-palette-into-clean-css-variables-3gbg</link>
      <guid>https://dev.to/avishek_dhimal_da92aff5fc/how-to-turn-a-color-palette-into-clean-css-variables-3gbg</guid>
      <description>&lt;p&gt;Picking colors is the fun part. Wiring them into a codebase that stays&lt;br&gt;
maintainable is where most palettes fall apart. Here's the approach I use.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Name colors by role, not value
&lt;/h2&gt;

&lt;p&gt;Don't scatter hex codes everywhere:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
css
.button { background: #6366f1; }
.link   { color: #6366f1; }
Define them once as custom properties, referenced by role:


:root {
  --color-bg:      #f7f7f8;
  --color-surface: #ffffff;
  --color-text:    #1f2937;
  --color-muted:   #9ca3af;
  --color-accent:  #6366f1;
}

.button { background: var(--color-accent); }
.link   { color: var(--color-accent); }
Now re-theming the whole app is a few edits in one place.

2. Skip pure black and pure white
#000 on #fff feels harsh on screens. Pull both back:


--color-text: #1f2937; /* near-black */
--color-bg:   #f7f7f8; /* off-white  */
Most layouts instantly look more intentional.

3. Dark mode is almost free
Because the colors are role-based variables, you just override the values:


@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:      #0f1115;
    --color-surface: #1a1d24;
    --color-text:    #e5e7eb;
  }
}
Every component using var(--color-bg) adapts automatically.

A shortcut
I got tired of hand-converting palettes into this, so I built a free tool,
PaletteCSS, that copies any palette straight out as
CSS variables, Tailwind or SCSS — and has a color palette generator
if you need a starting point. But honestly, the three rules above matter more
than any tool.

What conventions do you use to keep a color system maintainable?
PaletteCSS — a free tool to discover, create and share color palettes and CSS
gradients. Copy any palette as hex, CSS variables, Tailwind or SCSS. No signup.
https://palettecss.com**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>css</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Stop guessing colors: a faster way to add palettes to your CSS</title>
      <dc:creator>Avishek Dhimal</dc:creator>
      <pubDate>Mon, 15 Jun 2026 15:15:11 +0000</pubDate>
      <link>https://dev.to/avishek_dhimal_da92aff5fc/stop-guessing-colors-a-faster-way-to-add-palettes-to-your-css-2hj7</link>
      <guid>https://dev.to/avishek_dhimal_da92aff5fc/stop-guessing-colors-a-faster-way-to-add-palettes-to-your-css-2hj7</guid>
      <description>&lt;p&gt;Every time I start a new project, the same thing happens. I get the layout working, then I completely freeze on colors. I grab a color, drop it in, squint at it, change it, and half an hour later I've got something that's... fine. Maybe.&lt;/p&gt;

&lt;p&gt;If that sounds like you, here's what finally fixed it for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stop inventing colors from scratch
&lt;/h2&gt;

&lt;p&gt;For years my mistake was trying to come up with a color scheme on my own — picking one color, then guessing what goes with it. It almost never looked right, and it ate up so much time.&lt;/p&gt;

&lt;p&gt;The fix was simple: start from a palette that already works, then tweak it. When you begin with colors that are proven to look good together, everything after that is easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where I get my palettes now
&lt;/h2&gt;

&lt;p&gt;These days I grab them from PaletteCSS: &lt;a href="https://palettecss.com" rel="noopener noreferrer"&gt;https://palettecss.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a free library of thousands of hand-picked color palettes (and CSS gradients) for websites. You can browse by color, mood, theme, or industry, find one you like, and copy the CSS or hex codes in one click. No signup, no clutter. I find a palette, paste it into my project, and the part that used to eat my whole afternoon is done in a minute.&lt;/p&gt;

&lt;p&gt;It also has a gradients section, which is great when you want a background that already looks balanced instead of fiddling with one yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;If colors are the scary part of your projects, stop guessing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start from a ready-made palette instead of inventing one.&lt;/li&gt;
&lt;li&gt;Reuse the same colors consistently across your site.&lt;/li&gt;
&lt;li&gt;Lean on tools so you spend your time building, not second-guessing hex codes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That one change made design the easy part instead of the stressful part.&lt;/p&gt;




&lt;p&gt;Full disclosure: I built PaletteCSS to solve this exact problem for myself. I'd genuinely love feedback from this community — what would make it more useful for your projects? Drop a comment below. 🙏&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>design</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
