<?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: Yoav Kadosh</title>
    <description>The latest articles on DEV Community by Yoav Kadosh (@ykadosh).</description>
    <link>https://dev.to/ykadosh</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%2F578177%2F31be140b-5d2e-42b8-997d-0f2b13084227.jpg</url>
      <title>DEV Community: Yoav Kadosh</title>
      <link>https://dev.to/ykadosh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ykadosh"/>
    <language>en</language>
    <item>
      <title>Gradient.art - Designing and Inspecting Complex CSS Gradients</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Thu, 02 Sep 2021 13:12:46 +0000</pubDate>
      <link>https://dev.to/ykadosh/gradient-art-designing-and-inspecting-complex-css-gradients-4b06</link>
      <guid>https://dev.to/ykadosh/gradient-art-designing-and-inspecting-complex-css-gradients-4b06</guid>
      <description>&lt;p&gt;I've recently launched &lt;a href="https://gra.dient.art" rel="noopener noreferrer"&gt;gra.dient.art&lt;/a&gt; - an advanced online CSS gradient editor that has support for background layering, design tools, free cloud storage, and a growing list of examples. And the best part - it's totally free!&lt;/p&gt;

&lt;p&gt;With this editor, you can create your own unique designs, from basic patterns and icons to more complex illustrations and art, all using pure CSS. You can also explore the various different projects on the site if you're looking to use some existing designs, or just learn how it's done.&lt;/p&gt;

&lt;h2&gt;
  
  
  The editor
&lt;/h2&gt;

&lt;p&gt;The editor was designed to provide a photoshop-like experience, with a toolbar on the left, and panels on the right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fnu15e9vmakdnyq9h77by.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fnu15e9vmakdnyq9h77by.png" alt="The Gradient.art editor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Toolbar
&lt;/h3&gt;

&lt;p&gt;In the left toolbar, you can find tools for moving, scaling and rotating a gradient background:&lt;/p&gt;

&lt;p&gt;You can move a gradient:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fods93h6v2rq279hylkos.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fods93h6v2rq279hylkos.gif" alt="Moving a gradient - gra.dient.art"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scale it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fz70ytutv9k2uyfz3d9vx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fz70ytutv9k2uyfz3d9vx.gif" alt="Scaling a gradient - gra.dient.art"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And rotate it (only for conic/linear gradients):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F4mb6hyci7w1y6ca5vlmp.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F4mb6hyci7w1y6ca5vlmp.gif" alt="Rotating a gradient - gra.dient.art"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Panels
&lt;/h3&gt;

&lt;p&gt;On the right of the editor you can find a few panels. Each panel is dedicated for a different aspect of the project.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Gradients Panel
&lt;/h4&gt;

&lt;p&gt;The Gradients panel is where you can see all of your gradients, and add/remove/rename/reorder them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Ffk0zz1h7jc38fusnzr3y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ffk0zz1h7jc38fusnzr3y.png" alt="Gradient.art - The Gradients panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The Properties Panel
&lt;/h4&gt;

&lt;p&gt;The Properties panel is where you can modify the selected gradient. All of the CSS properties for all the 3 gradient types are supported.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F7s1su0eraw3514q4tdqh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F7s1su0eraw3514q4tdqh.png" alt="Gradient.art - The Properties panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The Code Panel
&lt;/h4&gt;

&lt;p&gt;The Code panel displays the generated CSS code for your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fnkfvjmilpyqjz5ky1mik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fnkfvjmilpyqjz5ky1mik.png" alt="Gradient.art - The Code panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The Document Panel
&lt;/h4&gt;

&lt;p&gt;The document panel is used for configuring project-wide things like canvas size, title, description &amp;amp; keywords. Good title &amp;amp; description will help other users find your project when they search for examples on the site. You can use special keywords if you want your project to be featured on one of the project pages. For example, use the  &lt;code&gt;pattern&lt;/code&gt; keyword if you  want your project to appear under &lt;a href="https://gra.dient.art/explore/patterns" rel="noopener noreferrer"&gt;gra.dient.art/explore/patterns&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Ft9cz0wtdr3yp3si4g16m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ft9cz0wtdr3yp3si4g16m.png" alt="Gradient.art - The Document panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Resizing the panels
&lt;/h3&gt;

&lt;p&gt;The panels are resizable, so you can change the layout to your convenience. As a side note, getting the panels to stack when they resize beyond their siblings was a bit of a challenge, but I love the result 😎. You can see how it looks below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fk3ehcezciw8l6ls48a2l.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fk3ehcezciw8l6ls48a2l.gif" alt="Resizable panels in gra.dient.art"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;Below are some projects you can find on &lt;a href="https://gra.dient.art" rel="noopener noreferrer"&gt;gra.dient.art&lt;/a&gt;. Click on any of the images to open it in the editor and inspect it. You can find many more projects  &lt;a href="https://gra.dient.art/explore" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gra.dient.art/editor/mq54ntrzsr" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgradient-art-og-image.vercel.app%2Fapi%2Fmq54ntrzsr"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gra.dient.art/editor/ggu4968jj0" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgradient-art-og-image.vercel.app%2Fapi%2Fggu4968jj0"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gra.dient.art/editor/lhk0fierr8" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgradient-art-og-image.vercel.app%2Fapi%2Flhk0fierr8"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gra.dient.art/editor/jzxjb65uaj" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgradient-art-og-image.vercel.app%2Fapi%2Fjzxjb65uaj"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gra.dient.art/editor/b14o5f7qx0" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgradient-art-og-image.vercel.app%2Fapi%2Fb14o5f7qx0"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Roadmap
&lt;/h2&gt;

&lt;p&gt;In the near future, and depending on the popularity and demand, I plan to add support for the following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Variables&lt;/strong&gt; - defining and using variables for colors and units, using CSS custom properties. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elements&lt;/strong&gt; - currently, the CSS is applied to a single element, and the most you can do is stack multiple backgrounds to it. This feature will allow the user to create a tree of elements for more complex designs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformations&lt;/strong&gt; - Once elements are fully supported, this feature will add support for CSS transforms on the elements - rotate, scale, skew, and translate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open sourcing&lt;/strong&gt; - I would like to expose some of the components as open source, so that other developers can use them and contribute back.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Technology
&lt;/h2&gt;

&lt;p&gt;Under the hood, Gradient.art uses the following libraries/services, and I would like to express my gratitude to the people behind those projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://next-auth.js.org/" rel="noopener noreferrer"&gt;NextAuth.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://recoiljs.org/" rel="noopener noreferrer"&gt;Recoil.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://webrix.amdocs.com/" rel="noopener noreferrer"&gt;Webrix.js&lt;/a&gt; (disclosure - i'm the developer behind this library)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vercel.com/" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/" rel="noopener noreferrer"&gt;MongoDB&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;I hope you find this tool useful, and i'm looking forward to seeing your designs on &lt;a href="https://gra.dient.art" rel="noopener noreferrer"&gt;gra.dient.art&lt;/a&gt;! If you encounter any issue, or would like to request some new features, feel free to &lt;a href="https://gra.dient.art/contact" rel="noopener noreferrer"&gt;contact us&lt;/a&gt; or &lt;a href="https://github.com/GradientArt/issues/issues" rel="noopener noreferrer"&gt;file a bug&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>css</category>
      <category>gradients</category>
    </item>
    <item>
      <title>Generative Linear Gradients Background</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Wed, 30 Jun 2021 06:42:47 +0000</pubDate>
      <link>https://dev.to/ykadosh/generative-linear-gradients-background-141k</link>
      <guid>https://dev.to/ykadosh/generative-linear-gradients-background-141k</guid>
      <description>&lt;p&gt;This background is made from a set of linear gradients that are stacked on top of each other, and are applied to a single &lt;code&gt;div&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;The gradients are made by generating a random color within the given hue range, and generating a set of random color stops, from transparent to the selected color and back.&lt;/p&gt;

&lt;p&gt;Being made of gradients, this background is infinitely scalable.&lt;/p&gt;

&lt;p&gt;Finally, the gradients are animated by changing the angle of each gradient, using the new CSS Houdini &lt;code&gt;@property&lt;/code&gt; syntax.&lt;/p&gt;

&lt;p&gt;You can click on the button to generate a new background.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ykadosh/embed/RwVbdxM?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>gradient</category>
      <category>css</category>
      <category>glassmorphism</category>
    </item>
    <item>
      <title>How I Created These Generative Underline Pen Strokes</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Wed, 23 Jun 2021 19:02:23 +0000</pubDate>
      <link>https://dev.to/ykadosh/underline-pen-strokes-randomly-generated-53k7</link>
      <guid>https://dev.to/ykadosh/underline-pen-strokes-randomly-generated-53k7</guid>
      <description>&lt;p&gt;&lt;em&gt;(Scroll down to see a live demo, or see it on &lt;a href="https://codepen.io/ykadosh/pen/bGqJKqJ"&gt;CodePen&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I created a small React component that adds a randomly generated pen stroke underline to a given word.&lt;/p&gt;

&lt;p&gt;The strokes are rendered using an SVG &lt;code&gt;&amp;lt;path/&amp;gt;&lt;/code&gt; element. They vary in thickness and shape, and they take the width of the text that they underline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rendering The Strokes
&lt;/h3&gt;

&lt;p&gt;I used an SVG element with a single &lt;code&gt;&amp;lt;path/&amp;gt;&lt;/code&gt; to render the strokes. The &lt;code&gt;&amp;lt;path/&amp;gt;&lt;/code&gt; has a &lt;code&gt;d&lt;/code&gt; attribute specifying a series of commands and coordinates, defining the shape of the path. The &lt;code&gt;path&lt;/code&gt; element is the most powerful SVG element, and I use it often when creating SVG graphics. You can learn more about it in &lt;a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths"&gt;this great MDN tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm using the &lt;code&gt;Q&lt;/code&gt; command, which is a simple command for generating curves. I'm randomly generating a series of 2-4 curves alternating from left to right, each of which is angled a bit differently, and placed a bit lower that the previous one.&lt;/p&gt;

&lt;p&gt;Here's the code:&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;// Draw the lines&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;line&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;lines&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;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;line&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Draw every line lower than the previous one&lt;/span&gt;
  &lt;span class="nx"&gt;d&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;` Q &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="c1"&gt;// The x coordinate of the curve's center&lt;/span&gt;
       &lt;span class="s2"&gt;` &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="c1"&gt;// The y coordinate of the curve's center&lt;/span&gt;
       &lt;span class="s2"&gt;` &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;line&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&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="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;105&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="c1"&gt;// The x coordinate of the curve's end, alternating between right to left based on the current line number&lt;/span&gt;
       &lt;span class="s2"&gt;` &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// The y coordinate of the curve's end&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Maintaining Stroke Width Consistency
&lt;/h3&gt;

&lt;p&gt;SVG elements can scale up/down, but they maintain the ratio given by their &lt;code&gt;viewBox&lt;/code&gt; attribute. That includes the stroke width.&lt;/p&gt;

&lt;p&gt;For example, if our &lt;code&gt;viewBox&lt;/code&gt; is defined to be a &lt;code&gt;100x100&lt;/code&gt; square (i.e. &lt;code&gt;viewBox="0 0 100 100"&lt;/code&gt;), and we set the &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; of the element to be &lt;code&gt;200x200&lt;/code&gt;, everything inside the SVG will scale by a factor of 2. A &lt;code&gt;stroke-width&lt;/code&gt; of &lt;code&gt;10px&lt;/code&gt; will be rendered as &lt;code&gt;20px&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Since the SVG element takes the width of the given word, the stroke width can scale up or down based on the word's length. To avoid that, i'm using the following CSS rule:&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;vector-effect&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;non-scaling-stroke&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Maintaining Stroke Height Consistency
&lt;/h3&gt;

&lt;p&gt;The issue described above can also affect the coordinates of the &lt;code&gt;&amp;lt;path/&amp;gt;&lt;/code&gt; itself, not just the width of the stroke.&lt;/p&gt;

&lt;p&gt;In my case, I wanted the SVG's height to remain consistent, and let the width change based on the word's length instead of maintaining the ratio given in &lt;code&gt;viewBox&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To do that, I used the following attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;svg&lt;/span&gt; &lt;span class="na"&gt;preserveAspectRatio&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See it live on CodePen:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ykadosh/embed/bGqJKqJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>sketch</category>
      <category>react</category>
      <category>svg</category>
    </item>
    <item>
      <title>Color Picker (React + Webrix)</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Tue, 27 Apr 2021 10:41:31 +0000</pubDate>
      <link>https://dev.to/ykadosh/color-picker-react-webrix-b41</link>
      <guid>https://dev.to/ykadosh/color-picker-react-webrix-b41</guid>
      <description>&lt;p&gt;I made this color picker component using &lt;a href="https://github.com/facebook/react"&gt;React&lt;/a&gt;, &lt;a href="https://github.com/open-amdocs/webrix"&gt;Webrix.js&lt;/a&gt;, and a nice color utility library called &lt;a href="https://github.com/Qix-/color-convert"&gt;color-convert&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's a stateless component that supports 2-way data binding, so it is able to take a &lt;code&gt;color&lt;/code&gt; prop, and update that color via an &lt;code&gt;onChange&lt;/code&gt; handler.&lt;/p&gt;

&lt;p&gt;There are 2 slider components here, one for the shade (2-axis slider) and one for the hue (x-axis slider).&lt;/p&gt;

&lt;p&gt;The shade slider is made of 3 stacked linear gradients, and the hue slider is made of a single linear gradient with multiple stops.&lt;/p&gt;

&lt;p&gt;Initially, I was using &lt;code&gt;canvas.getImageData()&lt;/code&gt; to get the color of the pixel based on the mouse position, but that proved to be problematic. For example, although getting the color based on coordinates is rather easy, getting the coordinates based on color is difficult and CPU intensive.&lt;/p&gt;

&lt;p&gt;Luckily, it turns out that there's a color format that is perfect for this case - HSV. In that format, the 2 first elements are roughly the x/y coordinates of the &lt;code&gt;&amp;lt;ShadePicker/&amp;gt;&lt;/code&gt;, and the 3rd element is the x coordinate of the &lt;code&gt;&amp;lt;HuePicker/&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;See it live on CodePen:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ykadosh/embed/zYNdyOG?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>react</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Isometric Floating Layers (SVG)</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Mon, 05 Apr 2021 13:02:11 +0000</pubDate>
      <link>https://dev.to/ykadosh/isometric-floating-layers-svg-2f42</link>
      <guid>https://dev.to/ykadosh/isometric-floating-layers-svg-2f42</guid>
      <description>&lt;p&gt;I made this SVG animated illustration for a piece I was writing about Webrix.js (you can find it here: &lt;a href="https://webrix.amdocs.com/motivation"&gt;&lt;/a&gt;&lt;a href="https://webrix.amdocs.com/motivation"&gt;https://webrix.amdocs.com/motivation&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;I've made a &lt;code&gt;&amp;lt;Layer/&amp;gt;&lt;/code&gt; component that is completely configurable (size, color, position, text), and you can stack as many as you need together and create your own illustration.&lt;/p&gt;

&lt;p&gt;I'm using 3 &lt;code&gt;&amp;lt;path/&amp;gt;&lt;/code&gt; elements internally to draw each layers and make it appear 3-dimensional: one for the shadow, one for the highlight, and one for the body.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ykadosh/embed/RwKpKGM?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>webdev</category>
      <category>css</category>
      <category>svg</category>
    </item>
    <item>
      <title>How I Made This Realistic Red Switch (Pure CSS)</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Mon, 22 Mar 2021 09:12:59 +0000</pubDate>
      <link>https://dev.to/ykadosh/how-i-made-this-realistic-red-switch-pure-css-49g2</link>
      <guid>https://dev.to/ykadosh/how-i-made-this-realistic-red-switch-pure-css-49g2</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ykadosh/embed/ExNOmZx?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I created this pen last week after stumbling across this &lt;a href="https://dribbble.com/shots/14172039-3D-Red-Switch" rel="noopener noreferrer"&gt;3D Red Switch&lt;/a&gt; design on Dribble. Since then it gained a lot of popularity (much more than I have anticipated!), and a few people have asked me to write a tutorial about how I made it. &lt;/p&gt;

&lt;p&gt;I've used various different CSS techniques in the making of this, including gradients, 3D transformations, animations, and transitions. In this tutorial, I will go over some of these techniques in depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simulating a State
&lt;/h2&gt;

&lt;p&gt;This is probably the oldest trick in the book. A switch has 2 states - on and off, but CSS has no way of maintaining such a state.&lt;/p&gt;

&lt;p&gt;To solve this, we can use one of the native HTML elements. Since we only need to maintain 2 states, a &lt;strong&gt;checkbox&lt;/strong&gt; element is a great choice. We can use the &lt;code&gt;:checked&lt;/code&gt; CSS selector to apply CSS based on whether the checkbox is checked or not.&lt;/p&gt;

&lt;p&gt;We wrap the whole thing in a &lt;code&gt;&amp;lt;label/&amp;gt;&lt;/code&gt; to link the click event of the entire element to the &lt;strong&gt;checkbox&lt;/strong&gt;, and we hide the checkbox itself using CSS.&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;label&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"switch"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.switch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One issue with this is that we can't apply CSS to the &lt;code&gt;&amp;lt;label/&amp;gt;&lt;/code&gt; itself based on the checkbox state, since there's no "ancestor selector" in CSS. Because of that, I placed all the switch elements after the &lt;strong&gt;checkbox&lt;/strong&gt; and used the adjacent sibling selector (&lt;code&gt;+&lt;/code&gt;) to apply CSS to them.&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;label&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"switch"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&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;"button"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.switch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&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="k"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nd"&gt;:checked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nc"&gt;.button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Apply some CSS to .button when the checkbox is checked&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;If you need to simulate an element with more than 2 states, you can use other HTML elements like &lt;strong&gt;radio buttons&lt;/strong&gt; (&lt;code&gt;&amp;lt;input type="radio"/&amp;gt;&lt;/code&gt;). Some people take this technique to the next level and create an entire game using CSS only! Check out this &lt;a href="https://codepen.io/collection/AKkZro" rel="noopener noreferrer"&gt;collection of pure CSS games&lt;/a&gt; on CodePen for some inspiration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making The Black Frame
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fjxy24397o0m5ubyd5dxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fjxy24397o0m5ubyd5dxq.png" alt="Making the black frame using CSS box-shadow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used &lt;code&gt;box-shadow&lt;/code&gt; to simulate the button's frame. &lt;code&gt;box-shadow&lt;/code&gt; is a very powerful CSS property, because it allows you to stack multiple shadow effects separated by a comma.&lt;/p&gt;

&lt;p&gt;I used a set of 5 shadow effects to create the frame, and a &lt;code&gt;border-radius&lt;/code&gt; property to make the shadow round in the corners. Here's the breakdown:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.switch&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;5px&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;10px&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&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="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="n"&gt;surrounding&lt;/span&gt; &lt;span class="nf"&gt;shadow&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="n"&gt;layer&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;1px&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="n"&gt;surrounding&lt;/span&gt; &lt;span class="nf"&gt;shadow&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt; &lt;span class="n"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;inset&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="m"&gt;-2px&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="nb"&gt;top&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt; &lt;span class="s2"&gt;"shine"&lt;/span&gt;
    &lt;span class="nb"&gt;inset&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;2px&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt; &lt;span class="mh"&gt;#47434c&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="n"&gt;light&lt;/span&gt; &lt;span class="no"&gt;gray&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;
    &lt;span class="nb"&gt;inset&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;2px&lt;/span&gt; &lt;span class="m"&gt;22px&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// The internal black shadow&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Making The 3D Button Shape
&lt;/h2&gt;

&lt;p&gt;I used CSS transformations and transitions to make the button appear 3-dimensional.&lt;/p&gt;

&lt;p&gt;The button itself is made of 3 divs (1 div and 2 pseudo-elements to be precise), that are perpendicular to each other, as illustrated below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fdf8n9mxk6gwk2f39swsj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fdf8n9mxk6gwk2f39swsj.jpg" alt="Making a 3D red switch using CSS"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nd"&gt;::before&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;50px&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;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rotateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-90deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nd"&gt;::after&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;50px&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;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;rotateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-90deg&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;Then, I rotated the entire button 25 degrees, and used &lt;code&gt;transform-origin&lt;/code&gt; to set the pivot point away from the div, to make the button appear as if it is rotating around some point deeper inside the button, rather than around the div:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fmjve0r7zy30xiwcij0df.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fmjve0r7zy30xiwcij0df.jpg" alt="Making a 3D red switch using CSS"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.switch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;perspective&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;700px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nc"&gt;.button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$rotation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25deg&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$pivot-distance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform-origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nv"&gt;$pivot-distance&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$pivot-distance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;rotateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;$rotation&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;transform-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;preserve-3d&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;h2&gt;
  
  
  Making The Animation
&lt;/h2&gt;

&lt;p&gt;I used CSS transitions to rotate the switch back and forth. I wanted the transition to appear realistic, by starting slowly and ending quickly. I could've used one of the native easing functions, like &lt;code&gt;ease-in&lt;/code&gt;, but that wasn't producing the right animation, so I used a custom &lt;code&gt;cubic-bezier()&lt;/code&gt; easing function instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;transition: all 0.3s cubic-bezier(1, 0, 1, 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.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%2Fkb8h5909sy6hgx1fuu7u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fkb8h5909sy6hgx1fuu7u.png" alt="Chrome DevTools transition cubic-bezier easing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This curve means that the transition starts slowly, and ends quickly, just like a real switch that slowly turns until it "clicks" towards the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making The I/O Characters
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Ft8427wnzotib5mqne1e0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ft8427wnzotib5mqne1e0.png" alt="Making the I/O characters using CSS gradients"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are multiple tricks I could've used to create the I/O characters. I could've used real letters and apply styling to them, or use a special font. But since those are pretty simple characters to draw, I decided to use gradients to make them.&lt;/p&gt;

&lt;p&gt;CSS gradients are amazing, but I had no idea how powerful they are until I came across this great article about &lt;a href="https://css-tricks.com/drawing-images-with-css-gradients/" rel="noopener noreferrer"&gt;CSS Drawings&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The true power of gradients comes from the fact that they are considered as "images" by CSS, and therefore can benefit from the power of the &lt;code&gt;background&lt;/code&gt; property. backgrounds in CSS can not only be stacked (like shadows), but they can also have custom position and size!&lt;/p&gt;

&lt;p&gt;This means that you can do pretty much &lt;em&gt;everything&lt;/em&gt; with CSS gradients. If you want to understand just how far you can take it, check out &lt;a href="https://a.singlediv.com/" rel="noopener noreferrer"&gt;https://a.singlediv.com/&lt;/a&gt; (every art piece on that site is made with a single div).&lt;/p&gt;

&lt;p&gt;The syntax is pretty simple:&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;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;image&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;position&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;size&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can stack multiple gradients with commas, and add &lt;code&gt;background-repeat: no-repeat&lt;/code&gt; to prevent the gradients from repeating:&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;.image&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&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;I made the characters using a background with 2 gradients.&lt;br&gt;
For the "I" character, I used an all-white &lt;code&gt;linear-gradient()&lt;/code&gt;, and made it narrow and long. For the "O" character I used a &lt;code&gt;radial-gradient()&lt;/code&gt; with 4 color stops, from transparent to white and back to transparent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nf"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="m"&gt;20%&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;5%&lt;/span&gt; &lt;span class="m"&gt;20%&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;White&lt;/span&gt; &lt;span class="n"&gt;vertical&lt;/span&gt; &lt;span class="nf"&gt;line&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"I"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nf"&gt;radial-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;circle&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt; &lt;span class="m"&gt;52%&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt; &lt;span class="m"&gt;70%&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="m"&gt;72%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="m"&gt;80%&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;33%&lt;/span&gt; &lt;span class="m"&gt;25%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// White circle ("O")&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you take a look at the &lt;code&gt;radial-gradient()&lt;/code&gt;, you'll notice that there's a &lt;code&gt;2%&lt;/code&gt; gap between each color stop:&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;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
  &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
  &lt;span class="nt"&gt;white&lt;/span&gt; &lt;span class="err"&gt;52&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
  &lt;span class="nt"&gt;white&lt;/span&gt; &lt;span class="err"&gt;70&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
  &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;72&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the different colors blend together, instead of having a crisp, pixelated transition. To illustrate this, take a look at the image below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fd5kp97c5yd6l7bjmdldm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fd5kp97c5yd6l7bjmdldm.jpg" alt="CSS gradients - blending colors between color stops"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is an inherent CSS gradient behavior - it creates a smooth blend between the colors when there's a gap between the color stops.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making The "LED" Gradient
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fzzcrsdnvaao8vd70ukpx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fzzcrsdnvaao8vd70ukpx.jpg" alt="Making the LED light using CSS gradients and animations"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As seen in the picture above, I stacked 2 gradients to achieve a look of an LED bulb hidden behind a semi-transparent red plastic with small round bumps on it.&lt;/p&gt;

&lt;p&gt;I had to use 2 elements, one for each gradient, since the first gradient had to be none-repeating, and the second one had to be repeating. Additionally, I wanted to make the light "flicker", so I had to separate them.&lt;/p&gt;

&lt;p&gt;The first element is the &lt;code&gt;.light&lt;/code&gt; element, where I used a &lt;code&gt;radial-gradient()&lt;/code&gt; to illustrate a red LED light, with a brighter center (the center is orange, while the surroundings are red).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.light&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;radial-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nf"&gt;adjust-hue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;lighten&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;20%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;35&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;Orange&lt;/span&gt;
    &lt;span class="nv"&gt;$color&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;Red&lt;/span&gt;
    &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="m"&gt;70%&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;blockquote&gt;
&lt;p&gt;Don't be alarmed by &lt;code&gt;adjust-hue()&lt;/code&gt; and &lt;code&gt;lighten()&lt;/code&gt;, I will cover those in the next part. For now, just consider them as hex colors.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The second element is the &lt;code&gt;.dots&lt;/code&gt; element, where I used a repeating &lt;code&gt;radial-gradient()&lt;/code&gt; with a transparent center to create a matrix of round-shaped bumps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.dots&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
    &lt;span class="nf"&gt;radial-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="m"&gt;30%&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;darken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;35%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;70%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;10px&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;Finally, I used animation to create the flickering effect:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fr0fuv44ty5zmvyng8m95.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fr0fuv44ty5zmvyng8m95.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.light&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flicker&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.2s&lt;/span&gt; &lt;span class="n"&gt;infinite&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.3s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="nt"&gt;flicker&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="nv"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;80&lt;/span&gt;&lt;span class="nv"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.8&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;100&lt;/span&gt;&lt;span class="nv"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&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;
  
  
  Controlling The Color Through A Variable
&lt;/h2&gt;

&lt;p&gt;As this pen gained popularity, some people asked to see it in different colors. Initially, I had hardcoded colors throughout my CSS, so I changed those to SASS variables for simple configuration. &lt;/p&gt;

&lt;p&gt;However, I wanted the main color to be easily configurable, so having multiple color variables wasn't good enough. I needed to control all of the colors &amp;amp; shading through a single variable.&lt;/p&gt;

&lt;p&gt;In order to achieve that, I used SASS's built-in color functions: &lt;code&gt;lighten()&lt;/code&gt;, &lt;code&gt;darken()&lt;/code&gt; and &lt;code&gt;adjust-hue()&lt;/code&gt; (&lt;a href="https://sassme.jim-nielsen.com/" rel="noopener noreferrer"&gt;SassMe&lt;/a&gt; is a nice tool for visualizing the output of these functions).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lighten()&lt;/code&gt; and &lt;code&gt;darken()&lt;/code&gt; are pretty self-explanatory. They make a given color lighter or darker based on the given percentage. For example, &lt;code&gt;lighten(black, 50%)&lt;/code&gt; will mix black with 50% white, producing a gray color.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Ftpcueqfb761gqw3bjsq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ftpcueqfb761gqw3bjsq3.png" alt="Making a color lighter using SASS lighten(), visualized by https://sassme.jim-nielsen.com/"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, for the LED light, &lt;code&gt;lighten()&lt;/code&gt; and &lt;code&gt;darken()&lt;/code&gt; were not enough, since the center of the light was orange, while the surroundings were red. That's not a different color shade, it's a different color altogether.&lt;/p&gt;

&lt;p&gt;That's where &lt;code&gt;adjust-hue()&lt;/code&gt; comes in handy. It lets you change the color's hue property by a given degree.&lt;/p&gt;

&lt;p&gt;A color's hue is the color's position on the color wheel and can be represented by a single numerical value, usually in degrees (0 - 360). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fqtrqummd7kuouewfjsor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fqtrqummd7kuouewfjsor.png" alt="Color hue scale"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I used &lt;code&gt;adjust-hue()&lt;/code&gt; to "rotate" the color's hue property 35 degrees to the right:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nt"&gt;adjust-hue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;35&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Producing this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fkq2yqhevam3gr0kmpsc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fkq2yqhevam3gr0kmpsc1.png" alt="Adjusting the color's hue property using SASS adjust-hue(), visualized by https://sassme.jim-nielsen.com/"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So if the color is red, to rotated color will be orange. But if the color is green the rotated color becomes blue!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fy1zd8wy34unwlvfsc69m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fy1zd8wy34unwlvfsc69m.png" alt="Adjusting the color's hue property using SASS adjust-hue(), visualized by https://sassme.jim-nielsen.com/"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now, you can control all the colors in the switch via a single variable &lt;code&gt;$color&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fmraymky496rsk8zlz2ri.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fmraymky496rsk8zlz2ri.gif" alt="Changing the switch main color"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This tutorial turned out to be a bit longer than I anticipated, and it may appear a bit overwhelming at first to see all the different techniques and tricks that were used for making this switch. But when you break it down to its basic elements, these techniques are pretty simple to comprehend. &lt;/p&gt;

&lt;p&gt;I hope I was able to provide some insight into the development process, and I hope you learned some new CSS techniques.&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Realistic Red Switch (Pure CSS)</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Mon, 15 Mar 2021 13:27:37 +0000</pubDate>
      <link>https://dev.to/ykadosh/realistic-red-switch-pure-css-o3e</link>
      <guid>https://dev.to/ykadosh/realistic-red-switch-pure-css-o3e</guid>
      <description>&lt;p&gt;This is my attempt at making a realistic switch using CSS only. I'm using multiple CSS techniques here, including gradients, 3D transformations, animations, and transitions.&lt;/p&gt;

&lt;p&gt;Making realistic 3D elements in CSS is kind of like making a very low-poly version of a high-poly model. In this example, I made the button out of 3 "polygons" (3 divs) that are all at 90 degrees from each other (creating like a square U shape).&lt;/p&gt;

&lt;p&gt;Interested in a tutorial on how I made this? Let me know!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ykadosh/embed/ExNOmZx?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This pen is based on this beautiful Dribbble shot by Voicu Apostol &lt;a href="https://dribbble.com/shots/14172039-3D-Red-Switch"&gt;&lt;/a&gt;&lt;a href="https://dribbble.com/shots/14172039-3D-Red-Switch"&gt;https://dribbble.com/shots/14172039-3D-Red-Switch&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Webrix.js - Building Blocks for Interactive React Apps</title>
      <dc:creator>Yoav Kadosh</dc:creator>
      <pubDate>Wed, 17 Feb 2021 12:34:40 +0000</pubDate>
      <link>https://dev.to/ykadosh/webrix-js-building-blocks-for-interactive-react-apps-4m54</link>
      <guid>https://dev.to/ykadosh/webrix-js-building-blocks-for-interactive-react-apps-4m54</guid>
      <description>&lt;p&gt;For the past 3 years, I've been working with a great team of UI developers on one of Amdocs' flagship products, and in the process, we've faced many challenges.&lt;/p&gt;

&lt;p&gt;To solve these challenges, we developed a set of React components and hooks, each dedicated to solving a single UI challenge.&lt;/p&gt;

&lt;p&gt;Recently, we decided to release these components and hooks as an open-source library, called &lt;a href="https://webrix.amdocs.com/" rel="noopener noreferrer"&gt;webrix.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unlike many other component banks out there that provide feature-packed, fully-branded end-user components, we decided to take a different approach and develop a set of small, single-purpose, unbranded components. This gives you more freedom to develop your own component bank with the UX that best matches your domain.&lt;/p&gt;




&lt;p&gt;Below are some of the components you can find in Webrix.js:&lt;/p&gt;

&lt;h3&gt;
  
  
  Movable
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fpyedt3md7e5lfue5azxq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fpyedt3md7e5lfue5azxq.gif" alt="Webrix.js - Movable"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;&amp;lt;Movable/&amp;gt;&lt;/code&gt; component can be used to create movable elements, with optional constraints. We use &lt;code&gt;&amp;lt;Movable/&amp;gt;&lt;/code&gt; to create things like sliders, resizers, movable modals, scrollbar handles, and more. &lt;a href="https://webrix.amdocs.com/docs/components/movable" rel="noopener noreferrer"&gt;See more &lt;code&gt;&amp;lt;Movable/&amp;gt;&lt;/code&gt; examples here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resizable
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.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%2F06zilqx5875aohhbwsek.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F06zilqx5875aohhbwsek.gif" alt="Webrix.js - Resizable"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;&amp;lt;Resizable/&amp;gt;&lt;/code&gt; component can be used to create resizable elements, with optional constraints. We use &lt;code&gt;&amp;lt;Resizable/&amp;gt;&lt;/code&gt; for creating resizable modals, image editing tools, and resizable layouts. &lt;a href="https://webrix.amdocs.com/docs/components/resizable" rel="noopener noreferrer"&gt;See more &lt;code&gt;&amp;lt;Resizable/&amp;gt;&lt;/code&gt; examples here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Poppable
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fvvr15h5e1lmvyf86ju43.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fvvr15h5e1lmvyf86ju43.gif" alt="Webrix.js - Poppable"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;&amp;lt;Poppable/&amp;gt;&lt;/code&gt; component can be used to create elements that "pop out" of the screen. We use &lt;code&gt;&amp;lt;Poppable/&amp;gt;&lt;/code&gt; for creating popups, menus, tooltips, dropdowns, and more. The &lt;code&gt;&amp;lt;Poppable/&amp;gt;&lt;/code&gt; has a built-in mechanism for overflow avoidance and dynamic z-index calculations. &lt;a href="https://webrix.amdocs.com/docs/components/poppable" rel="noopener noreferrer"&gt;See more &lt;code&gt;&amp;lt;Poppable/&amp;gt;&lt;/code&gt; examples here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scrollable
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.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%2F94pq89hx4nkmj6p01j9w.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F94pq89hx4nkmj6p01j9w.gif" alt="Webrix.js - Scrollable"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;&amp;lt;Scrollable/&amp;gt;&lt;/code&gt; component can be used to create elements with scrollable content and fully-customizable scrollbars. The elements behave just like a natively scrollable element, so working with them is pretty straightforward, and requires no CSS hacks. &lt;a href="https://webrix.amdocs.com/docs/components/scrollable" rel="noopener noreferrer"&gt;See more &lt;code&gt;&amp;lt;Scrollable/&amp;gt;&lt;/code&gt; examples here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Collapsible
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fj7qnwsrrphmd1r661ed6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fj7qnwsrrphmd1r661ed6.gif" alt="Webrix.js - Collapsible"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;&amp;lt;Collapsible/&amp;gt;&lt;/code&gt; component allows you to collapse/expand an element with arbitrary content height and apply a nice transition to it. This is a challenge to achieve with CSS only, so we use a mix of JS &amp;amp; CSS to overcome this (we discuss the solution further in the documentation). &lt;a href="https://webrix.amdocs.com/docs/components/collapsible" rel="noopener noreferrer"&gt;See more &lt;code&gt;&amp;lt;Collapsible/&amp;gt;&lt;/code&gt; examples here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;These are just a few of the available components in Webrix.js&lt;/p&gt;




&lt;p&gt;Since these components are already used by some of Amdocs' products, they are field-tested and have reached a certain maturity level.&lt;/p&gt;

&lt;p&gt;I invite you to visit our &lt;a href="https://webrix.amdocs.com/docs" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; and take a look at some of the &lt;a href="https://webrix.amdocs.com/examples" rel="noopener noreferrer"&gt;examples&lt;/a&gt; that were created using Webrix.js.&lt;/p&gt;

&lt;p&gt;Also, starring our &lt;a href="https://github.com/open-amdocs/webrix" rel="noopener noreferrer"&gt;project on GitHub&lt;/a&gt; will help us a lot! 😁&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>react</category>
      <category>github</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
