<?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: EmmahNcodes</title>
    <description>The latest articles on DEV Community by EmmahNcodes (@emmahchinonso).</description>
    <link>https://dev.to/emmahchinonso</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%2F152472%2F540cf669-93f9-4e34-b4f5-464c5da0ca65.jpeg</url>
      <title>DEV Community: EmmahNcodes</title>
      <link>https://dev.to/emmahchinonso</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emmahchinonso"/>
    <language>en</language>
    <item>
      <title>Fix for css grid item Overflow</title>
      <dc:creator>EmmahNcodes</dc:creator>
      <pubDate>Mon, 27 Mar 2023 20:38:35 +0000</pubDate>
      <link>https://dev.to/emmahchinonso/fix-for-css-grid-item-overflow-l0e</link>
      <guid>https://dev.to/emmahchinonso/fix-for-css-grid-item-overflow-l0e</guid>
      <description>&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;I recently ran into an interesting problem when creating scroll containers. I've created a ton of scroll containers but for some reason, I couldn't get this to work. This usually happens when we have a scroll container nested in a grid item.&lt;/p&gt;

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

&lt;p&gt;Even though we have &lt;code&gt;overflow: scroll&lt;/code&gt; and &lt;code&gt;width:100%&lt;/code&gt; set on our flex layout(the nested scroll-container), we still can't scroll, and the layout looks broken. This is because the minimum content size of a grid item is &lt;code&gt;auto&lt;/code&gt;, meaning that a grid item can expand its width to contain its children, which in this case is our scrolling container(without overlapping content). The styles of &lt;code&gt;overflow: scroll&lt;/code&gt; and &lt;code&gt;width:100%&lt;/code&gt; never get applied because the flex scroll container is within our grid item, the rules of &lt;code&gt;minimum-content&lt;/code&gt; on grid items override our attempt to create a scroll container.&lt;/p&gt;

&lt;p&gt;Minimum content size can be said to be the css &lt;code&gt;min-content&lt;/code&gt; keyword. MDN says &lt;code&gt;the min-content sizing keyword represents the intrinsic minimum width of the content. For text content this means that the content will take all soft-wrapping opportunities, becoming as small as the longest word&lt;/code&gt;. The &lt;code&gt;min-content&lt;/code&gt; here is controlled by min-width. &lt;/p&gt;

&lt;p&gt;If we give a div &lt;code&gt;min-width: 400px&lt;/code&gt; and also give it &lt;code&gt;width: min-content&lt;/code&gt; we discover that the size(width) of the div is reduced to our &lt;code&gt;min-width&lt;/code&gt;. Let's look at the UI again.&lt;/p&gt;

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

&lt;p&gt;The minimum content size, &lt;code&gt;min-content&lt;/code&gt; keyword and the &lt;code&gt;min-width&lt;/code&gt; property in a way describes the same thing. We can now say that by default grid items have &lt;code&gt;min-width&lt;/code&gt; of auto, &lt;code&gt;min-width&lt;/code&gt; of auto on a grid item basically means be as wide as your children. &lt;/p&gt;

&lt;p&gt;There are a couple of ways to fix this overflowing grid item problem, the first and second one involves adding a fixed minimum content size.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;use a &lt;code&gt;min-width:0&lt;/code&gt; on the grid item, this prevents the grid item from respecting the default &lt;code&gt;minimum content size&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;use &lt;code&gt;minmax(0, 1fr) minmax(0, 1fr)&lt;/code&gt; not &lt;code&gt;1fr 1fr&lt;/code&gt; when defining grid columns. Using only &lt;code&gt;1fr&lt;/code&gt; for our grid columns allows our grid item to be as wide as they can if they have none overlapping content(e.g a flex layout).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;add an overflow property to the grid item with a value that is not &lt;code&gt;visible&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can play around with the code pen to get a better feeling for this.&lt;/p&gt;

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

&lt;p&gt;After using one of the fixes, try changing the &lt;code&gt;min-width&lt;/code&gt; property of this selector &lt;code&gt;.flex &amp;gt; *&lt;/code&gt; to &lt;code&gt;width&lt;/code&gt;. The child items shrink now because the parent(i.e the grid item) of our flex-layout now has a limit.&lt;/p&gt;

&lt;p&gt;This brings us to a close on this issue, thanks for reading. I'm always open to suggestions, please leave them in the comments.😊&lt;/p&gt;

</description>
      <category>css</category>
      <category>frontend</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Javascript Scope</title>
      <dc:creator>EmmahNcodes</dc:creator>
      <pubDate>Sun, 29 Jan 2023 22:07:52 +0000</pubDate>
      <link>https://dev.to/emmahchinonso/understanding-javascript-scope-4bgo</link>
      <guid>https://dev.to/emmahchinonso/understanding-javascript-scope-4bgo</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---mqBa2-j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syc66c0f5r9h1h65qzu2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---mqBa2-j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syc66c0f5r9h1h65qzu2.png" alt="scope overview" width="822" height="670"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is scope
&lt;/h2&gt;

&lt;p&gt;Scope in javascript refers to rules that guide where variables are stored and how variable look ups(reading variables) happen. We can take scope as a container where whatever details we put in cannot be accessed outside of the container, scope helps us hide details(values) that we don't want to be globally accessible in a file.&lt;/p&gt;

&lt;p&gt;Before ES6 the smallest unit of scope was the function scope, we could group javascript scope into global and function scope. The introduction of &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; in ES6 helped introduce a new unit of scope &lt;strong&gt;Block scope&lt;/strong&gt;. Whatever variables we define in the global scope are readily available anywhere in a file, this can easily lead to mistakenly overwriting variable values and sometimes hard to debug errors.&lt;/p&gt;

&lt;p&gt;Function scope helped introduced the concept of local scope and hiding implementation details. Variables defined in a local scope are only available within that local scope and when we try to access those variables outside of their scope container, we get a reference error if that variable does not exist in the global scope.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sZaluKbK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6pgkm6pzgmnjgg2xj2j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sZaluKbK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6pgkm6pzgmnjgg2xj2j.png" alt="scope presentation" width="880" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scopes can be nested, local scopes nested in other local scopes and finally enclosed by the global scope. When reading or assignng values to a variable in a function, the function scope would be checked first to see if that variable exists. In the case of reading a variable value, if it exists in the scope we use that value else the JS engine checks the enclosing scope(i.e goes up by a level), we get a reference error if that variable does not exist in any of the enclosing scopes. If we are not in strict mode and we try assigning a value to a variable that does not exist in the function scope, we go up by a level until we find the variable and if we evntually get to the global scope and still can't find the variable we automatically get one created for us in the global scope, else we get  reference error in strict mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tf8THXmL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxtqxjma2hlijlg1gs75.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tf8THXmL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxtqxjma2hlijlg1gs75.png" alt="nested scopes" width="880" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;I'll be writing a continuation of this article to explain block scope with more examples, this was meant to be a very short article that just helped break down javascript scope😅. please let me know if there is anything that confuses you as you read.&lt;/p&gt;

&lt;p&gt;Things to note: &lt;br&gt;
&lt;code&gt;var&lt;/code&gt; when not used in a function automatically creates a global scope variable.&lt;br&gt;
&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; hijacks scopes and forcefully creates a block scope when used in forloops or other non function blocks.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Explain X Like I'm Five</title>
      <dc:creator>EmmahNcodes</dc:creator>
      <pubDate>Fri, 10 May 2019 20:05:16 +0000</pubDate>
      <link>https://dev.to/emmahchinonso/explain-x-like-i-m-five-21ld</link>
      <guid>https://dev.to/emmahchinonso/explain-x-like-i-m-five-21ld</guid>
      <description></description>
      <category>explainlikeimfive</category>
    </item>
  </channel>
</rss>
