<?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 Katarina Ljungdahl on Medium]]></title>
        <description><![CDATA[Stories by Katarina Ljungdahl on Medium]]></description>
        <link>https://medium.com/@ljngdahl?source=rss-3fea333fa907------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KHbzKOGiJzaafnWLhnpJjw.jpeg</url>
            <title>Stories by Katarina Ljungdahl on Medium</title>
            <link>https://medium.com/@ljngdahl?source=rss-3fea333fa907------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 16:10:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ljngdahl/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[Using BEM when naming CSS classes]]></title>
            <link>https://medium.com/@ljngdahl/using-bem-when-naming-css-classes-8981a2bd6e67?source=rss-3fea333fa907------2</link>
            <guid isPermaLink="false">https://medium.com/p/8981a2bd6e67</guid>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Katarina Ljungdahl]]></dc:creator>
            <pubDate>Tue, 29 Nov 2016 19:48:50 GMT</pubDate>
            <atom:updated>2016-11-29T19:56:30.731Z</atom:updated>
            <content:encoded><![CDATA[<p>For about a month now, I have been spending most of my time learning git and trying to figure out the best way to share code in a team of code newbies. One thing I quickly realised, was how easily the CSS grew into something that was the opposite of DRY thinking.</p><p>Even though we are just code newbies (or maybe because of that fact) each team member had their own, unique way of naming CSS classes when we started working together. At best, this meant lots of repeating code. But in the worst cases, we accidentally overrode each other’s classes — classes that weren’t supposed to be overridden. As you can imagine, this meant a lot of frustration for everyone involved. Then, we got a little help from BEM.</p><p>BEM, or <em>Block Element Modifier</em>, is a way of thinking when creating reusable components. Although it looks suspiciously a lot like repeating code, it is really not — once you get your head around it. For me, BEM has been helpful when discovering repeating patterns which I have then been able to scale down to much smaller, reusable components.</p><p>There are probably lots of other cool ways to do this besides BEM, but I definitely think it is worth checking out.</p><h3>So how does it work?</h3><p>When using BEM, you divide your CSS classes into <em>Blocks</em>, <em>Elements</em> and <em>Modifiers</em>. <strong>A block</strong> is an entity that is meaningful on its own. Think of it as a component that needs its own special styling. It is written in lowercase letters, and can contain both digits and dashes. In CSS, it could be called something like “<em>.user-card”</em>. <br> <br><strong> An element</strong> is a part of a block. The element’s name consists of the block name plus two underscores plus the element name. In CSS, it could be called something like “<em>.user-card__image”</em>.</p><p><strong>A modifier</strong> could be described as a flag on either a block, or an element. To name a modifier, you use the block’s (or the element’s) name, followed by two dashes and then the modifier name. In CSS, it could be called something like “<em>.user-card — red”</em>.</p><h3>HTML example</h3><pre>&lt;div class=”user-card”&gt; &lt;!-- Block --&gt;<br>&lt;div class=”user-card__image”&gt; &lt;!-- Element --&gt;<br>&lt;div class=”user-card--red”&gt; &lt;!-- Modifier --&gt;</pre><p>If you want to learn about BEM, the <a href="http://getbem.com/">Get BEM website</a> has a much better (and more thorough) explanation. Check it out!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8981a2bd6e67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Styling an input element for file uploads]]></title>
            <link>https://medium.com/@ljngdahl/styling-an-input-element-for-file-uploads-84f5a41ab0cd?source=rss-3fea333fa907------2</link>
            <guid isPermaLink="false">https://medium.com/p/84f5a41ab0cd</guid>
            <category><![CDATA[code-of-the-day]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Katarina Ljungdahl]]></dc:creator>
            <pubDate>Thu, 27 Oct 2016 15:04:38 GMT</pubDate>
            <atom:updated>2016-10-27T15:08:34.719Z</atom:updated>
            <content:encoded><![CDATA[<p>As a learning experience, I recently built a website for uploading selfies. Since I am a code newbie with limited knowledge about all the awesomeness in CSS, I struggled quite a bit with styling an input element for file uploads. Thankfully, I am friends with a lot of smart people who help me out in times of need, and I would therefore like to pass it on.</p><p>When styling an input element for file uploads, I first of all added a <em>required attribute</em> to my input element. In HTML it looks like this:</p><pre>&lt;input class=”choose-file” type=”file” id=”choose-file” required&gt;<br>&lt;label for=”choose-file” class=”upload-file”&gt;&lt;/label&gt;</pre><p>By adding the required attribute, you can use it for checking if a user has uploaded a file. In CSS it looks something like this:</p><pre>/* Hide original appearance */<br>.choose-file {<br>  height: 0.1px;<br>  opacity: 0;<br>  overflow: hidden;<br>  position: absolute;<br>  width: 0.1px;<br>  z-index: -1;<br>}</pre><pre>/* Style both input field and label */<br>.choose-file + .upload-file {<br>  background-color: #cf1259;<br>  color: #fff;<br>  padding: 1rem;<br>  text-align: center;<br>}</pre><pre>.choose-file:focus + .upload-file,<br>.choose-file + .upload-file:hover {<br>  background-color: #E5246E;<br>}</pre><pre>label.upload-file::before {<br>  content: &quot;Choose file&quot;;<br>}</pre><pre>.choose-file:valid + .upload-file::before {<br>  content: &quot;1 file chosen&quot;;<br>}</pre><p><em>.choose-file:valid</em> is applied only when the user has chosen a file to upload. You can then use it to change the content in your label (in my case, from “<em>Choose file</em>” to “<em>1 file chosen</em>”).</p><p>This code snippet is also found on <a href="http://codepen.io/ljngdahl/pen/wzbBGa">codepen.io</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84f5a41ab0cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to hash passwords in PHP]]></title>
            <link>https://medium.com/@ljngdahl/how-to-hash-passwords-in-php-23ede15a90f6?source=rss-3fea333fa907------2</link>
            <guid isPermaLink="false">https://medium.com/p/23ede15a90f6</guid>
            <category><![CDATA[code-of-the-day]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[code-newbie]]></category>
            <dc:creator><![CDATA[Katarina Ljungdahl]]></dc:creator>
            <pubDate>Wed, 26 Oct 2016 15:18:41 GMT</pubDate>
            <atom:updated>2016-10-26T20:24:11.385Z</atom:updated>
            <content:encoded><![CDATA[<p>The last few weeks I have been trying to understand how PHP works. Among other things, I have been building a website that allows users to log in and store their latest selfie.</p><p>It has been a lot of late nights, cursing over weird functions and SQL queries that don’t make sense. But I have also learnt lots of things, like how to hash a password in PHP.</p><p>As a part of my <em>Daily Code Newbie Routine</em>, I have decided that I would like to start sharing code snippets that I find useful. Today, I give you: a PHP function which can be used to hash passwords.</p><pre>function hashPassword($password) {<br>  $prefix = &quot;whatever&quot;;<br>  $suffix = &quot;whoknows&quot;;<br>  $salted = &quot;$prefix$password$suffix&quot;;</pre><pre>  $hashed_password = hash(&quot;ripemd128&quot;, $salted);</pre><pre>  return $hashed_password;<br>}</pre><p>The ripemd algorithm returns a 32-character hexadecimal number. Since hash on its own is not enough to protect the passwords, I have added two variables that salts the password ($prefix and $suffix). In my real project, I also store the variabels in another file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23ede15a90f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>