<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Roi Livne on Medium]]></title>
        <description><![CDATA[Stories by Roi Livne on Medium]]></description>
        <link>https://medium.com/@roilivne14?source=rss-ce2bc5cb2cd9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*y617EMAQIOzRhcF99wvkIw.jpeg</url>
            <title>Stories by Roi Livne on Medium</title>
            <link>https://medium.com/@roilivne14?source=rss-ce2bc5cb2cd9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:14:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@roilivne14/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Modular Modals in React]]></title>
            <link>https://roilivne14.medium.com/modular-modals-in-react-2b9bde0c5d9c?source=rss-ce2bc5cb2cd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b9bde0c5d9c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Roi Livne]]></dc:creator>
            <pubDate>Sat, 20 Feb 2021 17:47:47 GMT</pubDate>
            <atom:updated>2021-02-25T16:16:48.278Z</atom:updated>
            <content:encoded><![CDATA[<h4>A guide on how to create multi-purpose, modular &amp; scalable React Modals</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QGs7VU-xNGlzdxG18VIyQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@slgoetz">Simon Goetz</a></figcaption></figure><p>Modals are one of the most used graphical control elements in modern UI designs, thanks to their ability to avoid disrupting the user’s workflow in the main window.</p><p>Unfortunately, sometimes, behind a clean modal, lies some really messy code.</p><p>In this article, we will cover how to create a multi-purpose modal, keep it clean, modular, and scalable for your every needs using React components.</p><h3>Starting out</h3><p>For this guide, you can use any project you already have and want to create your modal in, because we’re going to focus primarily on the modal components.<br>However, feel free to use this <a href="https://github.com/Roi-Livne/modular_modals">Github</a> for the code itself, or just follow along as we create it together.</p><p>Go ahead and open a new project and run the react app template:</p><pre>npx create-react-app &lt;path&gt;</pre><p>Now let&#39;s first edit our <em>App.js </em>file with some buttons to test our Modal:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7dc91c52edf1e5dd38002b507598a271/href">https://medium.com/media/7dc91c52edf1e5dd38002b507598a271/href</a></iframe><p>Next, in your src folder, create a <em>components </em>folder. <br>In it, create a <em>Modal.js</em> file and a <em>modals </em>folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*gRXJ7X4taDZ30BxPT078JQ.png" /><figcaption>Note that the <em>Modal.js</em> is not inside the <em>modals</em> folder</figcaption></figure><h3>Opening the Modal</h3><p>Continuing with our <em>App.js </em>file, we’ll create a state, a context, and an update function to control our Modals from anywhere in our application. <br>We will also remove the default export on App().<br>(You will have to change your import on <em>index.js </em>to<em> </em>import { App } from ‘./App’ for your app to continue working)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b0e96c68662b88d27aa6b0acd3584f8/href">https://medium.com/media/9b0e96c68662b88d27aa6b0acd3584f8/href</a></iframe><p>Now our buttons are configured to update the modal parameters so our <em>Modal.js</em> component will open the correct Modal.</p><h3>The Modals</h3><p>For testing, we’ll create some very basic components in our <em>modals </em>folder: LoginModal.js, SignupModal.js, BuyModal.js, CreditsModal.js.<br>Each one will just return the name of it, like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1402291726043ba67c52b234744080c/href">https://medium.com/media/f1402291726043ba67c52b234744080c/href</a></iframe><h3>Modal.js</h3><p>Now, all we’re left to do is finish our <em>Modal.js</em> file.</p><p>To make this Modal modular and scalable while keeping it as clean as possible, we separated each instance of our Modal into a different file. <br>Thus, allowing our Modal.js file to act as a controller for the different Modals.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f98b83d622cf1b32a0e858b4b666ab09/href">https://medium.com/media/f98b83d622cf1b32a0e858b4b666ab09/href</a></iframe><p>We imported our different modals and context and also added a function to close the modal if the user clicks anywhere outside of it.</p><p>If isOpen is true, we return the appropriate Modal. If not, we return nothing.</p><p>Let’s add some basic CSS to our <em>App.css </em>so our Modal will show over the webpage:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c26e3becd1a8c26787048e09601dafa7/href">https://medium.com/media/c26e3becd1a8c26787048e09601dafa7/href</a></iframe><h3>…and Voilà!</h3><p>A <strong>modular</strong>, <strong>scalable</strong>, and <strong>clean </strong>Modal component to control and operate all of your Modal needs in just one parent component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nbsMK07nPDa_bABE7gG6yw.gif" /><figcaption>Modular React Modals</figcaption></figure><p>Now, if you want to add any other Modal type, you can simply import it and add another conditional to your <em>Modal.js</em> file for seamless integration.</p><h3>Conclusion</h3><p>When you’re working on a project under time pressure, it’s not always easy creating modular or scalable components right from the start.</p><p>By investing time, and adopting these methods or ways of thinking to other parts of your code you could achieve more clean and maintainable code.</p><p>The code is also available on <a href="https://github.com/Roi-Livne/modular_modals">this Github repository</a>.</p><p>If you enjoyed this article and found it helpful, don’t forget to clap :)<br>And of course, if you have any feedback, please write it in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b9bde0c5d9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[:where() :is() — A New CSS]]></title>
            <link>https://roilivne14.medium.com/where-is-a-new-css-8cee1141a5f3?source=rss-ce2bc5cb2cd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cee1141a5f3</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Roi Livne]]></dc:creator>
            <pubDate>Fri, 05 Feb 2021 09:55:35 GMT</pubDate>
            <atom:updated>2021-02-05T09:55:35.257Z</atom:updated>
            <content:encoded><![CDATA[<h3>:where() :is() — A New CSS</h3><h4>Write a cleaner CSS with :where() and :is() pseudo-classes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dhUaNFsYJMVV2d9m6wd2Qw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@goshua13">Joshua Aragon</a></figcaption></figure><p>If you haven’t heard about the :where() and :is() pseudo-classes,<br>don’t feel bad. They were only recently introduced to most browsers.<br>But they just might be your new favorite thing in vanilla CSS!</p><p>In this article, we will learn how to use our new handy tools in writing CSS.</p><h3>:is()</h3><p>Think about when you want to apply the same styling to multiple elements in your HTML. You’d probably end up with something that looks like this:</p><pre>.main h1,<br>.main h2,<br>.main .heading, {<br>  line-height: 1.2;<br>}</pre><pre>.nav li,<br>.nav p {<br>  padding: 5px 10px;<br>}</pre><p>With :is() we can write our CSS in a shorter, quicker, and more elegant way.</p><pre>.main :is(h1, h2, .heading){<br>  line-height: 1.2;<br>}</pre><pre>.nav :is(li, p) {<br>  padding: 5px 10px;<br>}</pre><p>Imagine all the many lines you’re saving!<br>This is very similar to how nesting works with preprocessors such as SCSS.</p><p>The pseudo-class function :is() (AKA “Matches Any”) takes a selector list and selects any element that can be selected by one of the selectors in that list.<br>It can also be chained with other selectors such as :not() , :firstchild() etc.</p><h3>:where()</h3><p>Just like :is(), :where() takes a selector list as its argument and selects any element that can be selected by one of the selectors in that list.<br>Our code from before:</p><pre>.main h1,<br>.main h2,<br>.main .heading, {<br>  line-height: 1.2;<br>}</pre><pre>.nav li,<br>.nav p {<br>  padding: 5px 10px;<br>}</pre><p>After using :where():</p><pre>.main :where(h1, h2, .heading){<br>  line-height: 1.2;<br>}</pre><pre>.nav :where(li, p) {<br>  padding: 5px 10px;<br>}</pre><p>“Wait, this looks exactly the same!”</p><p>Yes, you’re right.</p><h3>So what’s the difference?</h3><h4>Specificity.</h4><p>:is() takes the specificity of its most specific selector.<br>:where() has a specificity of 0.</p><p>It’s important to keep this small yet very important detail in mind when you’re using :is() and :where() in your code to avoid blocking yourself from applying CSS changes in other places.</p><p>As someone that is used to using a preprocessor and nesting, I was really happy to see these two functions being implemented into CSS.</p><p>Most browsers already support them, and I heartily recommend you start getting used to using them and make your code cleaner and faster to write!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cee1141a5f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>