<?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 Yasin Silavi on Medium]]></title>
        <description><![CDATA[Stories by Yasin Silavi on Medium]]></description>
        <link>https://medium.com/@ysilavi?source=rss-e83244b0d3d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uVo2svZUht1FA2KTw7fJ7Q.jpeg</url>
            <title>Stories by Yasin Silavi on Medium</title>
            <link>https://medium.com/@ysilavi?source=rss-e83244b0d3d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 14:45:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ysilavi/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[I Got Tired of Handling Safe Areas Manually, So I Built a Tailwind Plugin]]></title>
            <link>https://medium.com/@ysilavi/i-got-tired-of-handling-safe-areas-manually-so-i-built-a-tailwind-plugin-6aae56cd6b41?source=rss-e83244b0d3d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aae56cd6b41</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <dc:creator><![CDATA[Yasin Silavi]]></dc:creator>
            <pubDate>Mon, 10 Aug 2026 09:18:13 GMT</pubDate>
            <atom:updated>2026-08-10T09:19:56.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j83QnZmtQ0odbkWT7-_tnQ.jpeg" /></figure><p>Modern mobile interfaces are moving toward edge-to-edge layouts.</p><p>Whether you’re building a Progressive Web App, a Capacitor application, a React Native WebView, or a mobile-first website, there’s a good chance you’ve encountered the same problem:</p><p>Your content ends up underneath a notch, status bar, navigation bar, or device-specific system UI.</p><p>The web platform already provides a solution through CSS environment variables such as:</p><pre>env(safe-area-inset-top)<br>env(safe-area-inset-bottom)<br>env(safe-area-inset-left)<br>env(safe-area-inset-right)</pre><p>The problem isn’t that safe areas are difficult.</p><p>The problem is that handling them repeatedly becomes tedious.</p><h3>The Repetitive Reality</h3><p>A typical project often accumulates CSS like this:</p><pre>.header {<br>  padding-top: env(safe-area-inset-top);<br>}</pre><pre>.footer {<br>  padding-bottom: env(safe-area-inset-bottom);<br>}</pre><pre>.drawer {<br>  padding-left: env(safe-area-inset-left);<br>  padding-right: env(safe-area-inset-right);<br>}</pre><p>Then more components appear.</p><p>Then more screens.</p><p>Then another mobile app.</p><p>Before long, safe-area handling becomes scattered throughout the codebase.</p><p>Every project solves the same problem again.</p><h3>What I Wanted</h3><p>I wanted safe areas to feel like a first-class Tailwind utility.</p><p>Something similar to:</p><pre>&lt;div class=&quot;pt-safe&quot;&gt;<br>&lt;div class=&quot;pb-safe&quot;&gt;<br>&lt;div class=&quot;px-safe&quot;&gt;<br>&lt;div class=&quot;top-safe&quot;&gt;</pre><p>No custom CSS.</p><p>No remembering environment variables.</p><p>No copy-pasting snippets between projects.</p><p>Just utilities.</p><h3>Introducing tailwind-safe-areas</h3><p>I created <strong>tailwind-safe-areas</strong>, a Tailwind plugin that generates utilities powered by the browser’s safe-area environment variables.</p><p>The goal is simple:</p><p>Make safe-area handling feel native inside Tailwind.</p><p>Instead of writing:</p><pre>padding-top: env(safe-area-inset-top);</pre><p>you write:</p><pre>&lt;div class=&quot;pt-safe&quot;&gt;</pre><p>Instead of:</p><pre>padding-bottom: env(safe-area-inset-bottom);</pre><p>you write:</p><pre>&lt;div class=&quot;pb-safe&quot;&gt;</pre><p>The browser still uses the native safe-area values.</p><p>The plugin simply provides a cleaner and more maintainable API.</p><h3>Why This Matters More Than Ever</h3><p>Mobile operating systems continue to push applications toward immersive, edge-to-edge experiences.</p><p>Modern devices include:</p><ul><li>Notches</li><li>Dynamic islands</li><li>Rounded screen corners</li><li>Gesture navigation bars</li><li>Floating system UI</li></ul><p>At the same time, mobile browsers and WebViews are exposing more of the screen to applications.</p><p>This creates a better visual experience for users but increases the responsibility of developers to respect safe boundaries.</p><p>Ignoring safe areas can lead to:</p><ul><li>Hidden navigation controls</li><li>Content clipped behind system bars</li><li>Buttons that are difficult to tap</li><li>Inconsistent layouts across devices</li></ul><h3>Ideal Use Cases</h3><p>I originally built this plugin for mobile-focused applications, but it works well in many scenarios.</p><h3>PWAs</h3><p>Applications installed directly from the browser often run in fullscreen or standalone modes where safe areas become critical.</p><h3>Capacitor Applications</h3><p>Capacitor apps frequently use edge-to-edge layouts and benefit from automatic safe-area spacing.</p><h3>Mobile WebViews</h3><p>When embedding web applications inside native Android or iOS apps, safe areas quickly become an important concern.</p><h3>Mobile-First Websites</h3><p>Even traditional websites can benefit from safe-area utilities on modern devices.</p><h3>Example</h3><p>A bottom navigation component can become:</p><pre>&lt;nav class=&quot;pb-safe&quot;&gt;<br>  ...<br>&lt;/nav&gt;</pre><p>A page layout can become:</p><pre>&lt;main class=&quot;pt-safe pb-safe&quot;&gt;<br>  ...<br>&lt;/main&gt;</pre><p>Simple.</p><p>Readable.</p><p>Easy to maintain.</p><h3>The Architecture Analogy</h3><p>When designing buildings, architects don’t place important structures directly against dangerous edges.</p><p>They create margins.</p><p>They define safe zones.</p><p>They respect boundaries.</p><p>Safe areas on mobile devices work exactly the same way.</p><p>The screen may look rectangular, but parts of it are effectively reserved by the operating system.</p><p>Good layouts acknowledge those boundaries.</p><p>Great layouts embrace them.</p><h3>Open Source</h3><p>The plugin is fully open source and available on GitHub:</p><p><a href="https://github.com/freakingeek/tailwind-safe-areas">https://github.com/freakingeek/tailwind-safe-areas</a></p><p>If you’re building mobile-first experiences with Tailwind, I’d love to hear your feedback, feature requests, and real-world use cases.</p><p>What started as a small utility for my own projects turned into something I found myself wanting in every Tailwind codebase.</p><p>Maybe you’ll find it useful too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aae56cd6b41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Iterables and Iterators in JavaScript]]></title>
            <link>https://medium.com/@ysilavi/iterables-and-iterators-in-javascript-cd63d28940c7?source=rss-e83244b0d3d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd63d28940c7</guid>
            <category><![CDATA[iterators]]></category>
            <category><![CDATA[iterables]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[yasin-silavi]]></category>
            <dc:creator><![CDATA[Yasin Silavi]]></dc:creator>
            <pubDate>Sun, 18 Jun 2023 16:02:02 GMT</pubDate>
            <atom:updated>2023-06-18T16:02:02.891Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment">Destructuring Assignment</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax">Spread</a> are popular JavaScript syntaxes you might be familiar with if you write your projects in JavaScript. Let’s examine how these syntaxes work under the hood.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UJ50K6z2TSTDwIjmXA4KQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@albrb?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Alejandro Barba</a></figcaption></figure><h3>What syntaxes are we talking about?</h3><p>You may still be unsure whether you have ever written a Destructuring assignment. If so, let me give you a small example that’ll help clear things up for you!</p><p>You may have seen this code or something similar before:</p><pre>const [count, setCount] = useState(0);</pre><p>This code belongs to the React library, which of course is not important here, and you can replace it with any other similar code.</p><p>As you can see, the <em>useState </em>function returns an array to us after it has done its work; if you pay attention, we use the above syntax instead of doing something like this:</p><pre>const countStateArray = useState(0) // Returns an array of state and set state function<br>const count = countStateArray[0]<br>const setCount = countStateArray[1]</pre><p>In this example and similar syntaxes like Spread, it is easy to understand what is happening; But how this happens is something we are going to find out soon.</p><h3>Iteration</h3><p>We always think of loops when it comes to iteration in programming. In JavaScript, using loops, we can repeat an operation as many times as needed; For example, see the following code:</p><pre>const nums = [1, 2, 3, 4, 5]<br>const rows = Array(2)<br><br>for (let i = 0; i &lt; rows.length; i++) {<br>  rows[i] = nums[i]<br>}<br><br>console.log(rows) // [1, 2]</pre><p>In the example above, I have a number of rows that must be filled with numbers. Of course, my rows are limited (I only have 2 rows) and not all numbers can fit in them; That’s why I start taking numbers from the beginning of the list of numbers and only take those numbers that I can fill my rows with.</p><p>Although this is not exactly what Destructuring assignment does for us, it can be said that there is a connection between Iteration and what we have said so far.</p><p>To prove this connection, it is good to go deeper into Iteration first. Let’s check some more examples of Iteration in JavaScript together.</p><h3>For…of</h3><p>With for…of, we can access the entire array items one by one in the loop without writing any additional boilerplate code. Look at this example:</p><pre>const nums = [0, 5, 1]<br><br>for (const num of nums) {<br>  console.log(num)<br>}</pre><p>As shown in the example, the console displays 0, 5, and 1. This example is much more readable than the for loop in the previous example; of course, this is not the best part!</p><p>The best part is that we don’t have to worry that the index of the loop is greater than the length of the array or that the value we need from the array in that loop is written in an imperative form (e.g., nums[i]); All these things are automatically handled in for…of; But how?</p><p>Do you remember when we said there is a similarity between all these syntaxes we talked about before? Well, this similarity is more obvious in for…of; Because behind the scene, it is using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols">Iteration protocols</a>, which is the magic behind all the other syntaxes We talked about!</p><h3>Iteration Protocols</h3><p>Iteration protocols were originally introduced to standardize iteration in JavaScript. We are dealing with 2 of them, whose names you must have guessed from the title: Iterators and Iterators.</p><h4>Iterables</h4><p>This protocol allows all repeaters to repeat! In simpler terms, all the objects and arrays we use in loops follow a protocol that controls their behavior.</p><p>Each of the iterators has a method <em>@@iterator</em> in themselves (or in their prototype) which, as we said, is responsible for controlling their behavior in iteration. You can access this method by using the <em>[Symbol.iterator]</em> key, or replace it with your own method if you like.</p><blockquote>If you don’t have time to do this, but you are eager to see what happens; I will give you an example! :))</blockquote><h4>Iterators</h4><p>Iterators protocol is the standard method of producing a sequence of values! JavaScript calls any object that it knows has a <em>next </em>method as an iterator, And the method follows a series of principles.</p><p>1. The <em>next </em>method must return an <em>object</em><br>2. The object returned from the <em>next </em>method can include <em>value </em>and <em>done </em>or both keys</p><p>Now we know all the necessary knowledge for the final conclusion (how the writings we talked about and reached here work); But before that, let’s go and see the new things we learned in action!</p><h3>Custom Iterators/Iterables</h3><p>As we said, all iterators have an <em>@@iterator</em> method stored in <em>[Symbol.iterator]</em>, and we know that arrays are one of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#built-in_iterables">JavaScript’s internal iterators</a>; So let’s have some fun!</p><p>See the code snippet below:</p><pre>const nums = [3, 1, 3]<br>console.log(nums[Symbol.iterator]()) // Array Iterator</pre><p>Now we could use the code above to access the method <em>@@iterator</em> of this array and call it. This is the JavaScript world, and in this world, when we can access something, it means we can change it!</p><p>I wrote this piece of code below, which causes all the numbers of this array to be moved randomly every time during iteration! You can also do this and make others spend hours debugging your codes :))</p><pre>const nums = [1, 2, 3, 4, 5];<br>nums[Symbol.iterator] = function () {<br>  let array = this.sort((a, b) =&gt; Math.random() - 0.5)<br>  let index = 0<br><br>  return {<br>    next() {<br>      return { value: array[index++], done: array.length &lt; index };<br>    },<br>  };<br>};<br><br>console.log(...nums); // 2, 1, 4, 3, 5<br>console.log(...nums); // 4, 5, 1, 3, 2</pre><p>Well, now we have seen enough! We talked about both Iterables and Iterators. In addition, we saw what the writings based on Iteration did, and more importantly, how they did it.</p><p>If you still want to follow more advanced topics, you can see them <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols">here</a>, and if you have any opinion or experience in this field, please write it in the comments section.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd63d28940c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>