<?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 Hugh Rowland on Medium]]></title>
        <description><![CDATA[Stories by Hugh Rowland on Medium]]></description>
        <link>https://medium.com/@hugh.m.rowland?source=rss-864fafd5b935------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xPZlJ7zEIIBSizCF_OzMrA.jpeg</url>
            <title>Stories by Hugh Rowland on Medium</title>
            <link>https://medium.com/@hugh.m.rowland?source=rss-864fafd5b935------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 19:34:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hugh.m.rowland/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[Styling in JSX React]]></title>
            <link>https://medium.com/@hugh.m.rowland/styling-in-jsx-react-3abeabd3aabf?source=rss-864fafd5b935------2</link>
            <guid isPermaLink="false">https://medium.com/p/3abeabd3aabf</guid>
            <category><![CDATA[style]]></category>
            <category><![CDATA[jsx]]></category>
            <category><![CDATA[putin]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Hugh Rowland]]></dc:creator>
            <pubDate>Wed, 12 Sep 2018 15:39:09 GMT</pubDate>
            <atom:updated>2018-09-12T15:39:09.606Z</atom:updated>
            <content:encoded><![CDATA[<h3>TLDR;</h3><p><em>const myStyle = { color : ‘red’ }</em></p><p><em>return( &lt;div style={myStyle}&gt;&lt;/div&gt;</em></p><p>This will cover why it is important to know how to style in JSX, when you should/shouldn’t use JSX for styling and of course how to style in JSX.</p><h3>Why use JSX?</h3><p>Sometimes you may not be styling something as simply as the above example. You may have user input that determines the CSS property that you want to manipulate. We can’t inject that variable into CSS, but we can do it very easily in JSX.</p><p><em>const colorChoice = prompt(‘Your Color’);</em></p><p><em>const myStyle = { color : colorChoice }</em></p><p><em>return( &lt;div style={myStyle}&gt;&lt;/div&gt; )</em></p><h4>The run through</h4><p>Give the user a prompt // color picker // any input, and save the variable in a constant (name it what you like).</p><p>Create an object, (name it what you like), and give the key a CSS property. As the attribute, pass in your constant that you just created.</p><p>Finally, in your return method, target the element you want to give the CSS property to and pass in the style property.</p><p>Open some curly bracers ‘{}’ (this lets JSX know you are using JavaScript) and pass in your object variable.</p><p>That’s it! You have now created a style that is dependent on a variable!</p><h4>Advanced</h4><p>You may have noticed that we have not previously defined the variable “colorChoice” in the above example. This can cause as issue as the color that will be rendered will be “undefined” and will inherit it’s parent’s color.</p><p>To solve this, you can change the constant to a let and define it immediately after, but before your input.</p><p><em>let colorChoice = ‘red’;</em></p><p><em>colorChoice = prompt(‘Your Color’);</em></p><p><em>const myStyle = { color : colorChoice }</em></p><p>This isn’t best practice, as let variables are mutable and cause issues later if you redefine it by accident.</p><h4>The solution — Use a Turnery Operator and save in state</h4><p>The Turnery Operator is the JSX go to if you need an ‘if’ // ‘else’ statement. It works like this =&gt; IsThisTrue ? DoThis : DoThisInstead</p><p>The question mark checks if the previous statement is true. If it is, it will complete the middle block. If it isn’t, it will complete the last block.</p><p><em>? = if it is true</em></p><p><em>: = else, do this</em></p><p>To save in state, we simply use the constructor method inside our render function and create an object // key value that we want to set.</p><p>The we use the setState() method to change a key value.</p><p>eg. setState({color: variable})</p><h4>Let’s see it in action</h4><p><em>constructor() { super (); this.state={color: undefined} }</em></p><p>Because the color is undefined to start, I will pass in undefined. I could put a value in here as a fallback, but our turnery will deal with that issue anyways.</p><p><em>const colorChoice = this.state.color ? this.state.color : ‘red’</em></p><p><em>const myStyle = { color : colorChoice }</em></p><p><em>return( &lt;div style={myStyle}&gt;&lt;/div&gt; )</em></p><p>Now, when the page loads, it will check to see if there is a value inside the state key value of ‘color’. In this case it is undefined and will return false. That means it will pass the style of ‘red’ to colorChoice =&gt; into the object myStyle =&gt; into the style property on the div.</p><p>As soon as the user changes the state of color to something new, React will see the change and pass the variable back down the chain.</p><p><strong>‘color’ state=&gt;</strong></p><p><strong>colorChoice constant =&gt;</strong></p><p><strong>myStyle object =&gt;</strong></p><p><strong>style property</strong></p><p>As always, I recommend giving it a go, practice makes perfect. You can mix regular CSS in with JSX styling. Just don’t repeat the same CSS properties on JSX and CSS!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3abeabd3aabf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS repeating-gradient( )]]></title>
            <link>https://medium.com/@hugh.m.rowland/css-repeating-gradient-767637489e4c?source=rss-864fafd5b935------2</link>
            <guid isPermaLink="false">https://medium.com/p/767637489e4c</guid>
            <category><![CDATA[gradient]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Hugh Rowland]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 21:44:08 GMT</pubDate>
            <atom:updated>2018-08-10T13:33:57.935Z</atom:updated>
            <content:encoded><![CDATA[<h3>TLDR;</h3><p>The CSS method repeating-gradient() can be applied to both linear and radial gradients to create an infinite pattern within a single div.</p><p>The method repeating-conic-gradient() is in the beta / testing stages and is not yet supported.</p><p>In this blog, I will go over how to use CSS repeating-gradient(), and how to overcome some issues that come with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*jNG18Yd22ffITE2GPAr0IA.jpeg" /><figcaption>Please don’t use this blog for evil ^^^</figcaption></figure><h3>The Basics</h3><h4>repeating-linear-gradient( )</h4><p>Just like in a regular CSS gradient, you can include a color stop. Below is an example of the CSS syntax used for a repeating-gradient. Remember to separate your attributes with commas. You can write it all on one line, but for readability, I personally prefer multiline statements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*-6tEMCPnmlXiao3Wlr6YTg.jpeg" /><figcaption><em>note* You can assign the property of background || background-image. background-color will not work.</em></figcaption></figure><p><strong>But how does it all work?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*GoasBn7zCd7lh_9-Y-xncA.jpeg" /></figure><p>Let’s take the attributes one by one.</p><p>The first attribute in this case is the ‘90deg’, and it refers to the angle your gradient will display on. By default it will be horizontal or ‘0deg’.</p><p>The next few lines define the color, color start point and color stop point. The lines highlighted in blue refers to the point that the color starts, and the lines highlighted in blue refer to the color stop point.</p><p><em>color start point: The range of influence the color has before blending.</em></p><p><em>color stop point: The point in the pattern that the color stops.</em></p><p>The order of the colors determines the order that the colors will appear and blend.</p><h4>Let’s see this in practice</h4><p>So, if we change the color stop for limegreen to 10px, what will happen?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*y6YsnXVrSHv2bgBAk7Emng.jpeg" /></figure><p>The limegreen section of the pattern will now travel 10px before starting to blend to black. Now that we understand that, we can create solid bars, rather than smooth gradients. To do that, we simply change the start point of black to where the green ends, in this case 10px. (you cannot set it lower than the previous colors stop point).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*AgoSwwIw2CCq9LDaoM8B7Q.jpeg" /></figure><p>Now that our start and stops line up, we have a repeating-linear-gradient, at a 90 degree angle, that alternates between limegreen and black bars that span 10px each!</p><h4>What happens if we add more colors?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*OUSUg7mcVUD76oFBu8TUHg.jpeg" /></figure><p>We technically have 3 colors in the pattern above, but 4 different color start/stop points. 10px limegreen, 5px black, 15px orange, 20px black.</p><p><em>Hold up. Isn’t the black set to 30px?</em></p><p>Yes it is, however, the black stop point is 50px and the previous stop point is 30px. The space left between is only 20px and has no other color influencing it’s area. So, by default, the space left behind is filled in by black. We could technically change all the start values to 0 and the pattern would remain the same.</p><h4>AHHHHH</h4><p>I know, super confusing, but I suggest adding your numbers correctly so you don’t return to your code and get super confused!</p><p>Once you play around and understand this convention, there is no limit to the number of colors you may use in your patterns. You can mix it up too, with harsh lines and smooth gradients. Or make the whole thing blended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*4kEuz1NxskQGTCan2aNmfw.jpeg" /></figure><h3>Next Steps</h3><h4>repeating-radial-gradients( );</h4><p>This CSS style has lots of overlap with repeating-linear-gradients. It also has start and stop points for color as well as abiding by the same syntax. The differences being that it doesn’t take a rotation attribute, but rather a “circle” (position) attribute.</p><p><em>“circle at 0 0,”</em></p><p>The two numbers refer to the x and y coordinates of your div. The first 0 being the far left on the x axis, and the second being the top on the y.</p><p>This is what a repeating-radial-gradient looks like with it’s default position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*jZjqftb3dPMHiB-5wWp17Q.jpeg" /></figure><p>You can see that the centre of the circle’s centre point is in the top left corner. If we want to change the origin point to the centre, we will replace the x and y value with 50% 50%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*5iAFSxHUgF7PEsr5i3AGqA.jpeg" /></figure><p>We can also use pixel values here, for example, you may want the origin of the circle to be 20px from the left and 20px from the top.</p><p>Other than that, the start / stop points and color assignment convention is consistent with repeating-linear-gradients.</p><h3>What’s next?</h3><p>Whatever you want! Use this for your funky backgrounds, creating patterns, hover states or revealing information! Here’s what you can do using position absolute, a hover state and nesting your div inside a container that has overflow:hidden</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-87XviEDbBtgP2s9RNTK9w.gif" /></figure><p>Remember, it’s not totally supported yet, so don’t use this for a vital piece of your site!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgywfz5bOMOHM-lJeZ2nwg.png" /><figcaption><a href="https://caniuse.com/#feat=css-repeating-gradients">https://caniuse.com/#feat=css-repeating-gradients</a></figcaption></figure><p>If you’re looking for further reading, this is where I got the initial notes — <a href="https://css-tricks.com/snippets/css/css-repeating-gradients/">https://css-tricks.com/snippets/css/css-repeating-gradients/</a></p><p>Hopefully this was something new! Go do weird things!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*450OUDh6QGfchIR4NUqbLg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=767637489e4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parallax Scrolling]]></title>
            <link>https://medium.com/@hugh.m.rowland/parallax-scrolling-b213b0358093?source=rss-864fafd5b935------2</link>
            <guid isPermaLink="false">https://medium.com/p/b213b0358093</guid>
            <category><![CDATA[parallax]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Hugh Rowland]]></dc:creator>
            <pubDate>Sun, 05 Aug 2018 00:51:14 GMT</pubDate>
            <atom:updated>2018-08-05T00:51:14.969Z</atom:updated>
            <content:encoded><![CDATA[<p>The concept of “Parallax” was initially conjured up by animators in the 1930s who wanted to create the illusion of a 3D space using 2D elements. It wasn’t until 2011 that Parallax scrolling was adopted as a common practice in web development.</p><p>Below there are two animations: The one on the left is a true Parallax effect, whereas the one on the right is not. The key difference is the object in the middle, or mid-ground point of reference. This difference is usually overlooked and many people refer to any on-scroll effect as “Parallax”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*msvXJsimW3Bd-WVwWTpJAg.gif" /><figcaption>credit: <a href="https://fueled.com/blog/the-troublesome-misconception-of-parallax-in-webdesign/">https://fueled.com/blog/the-troublesome-misconception-of-parallax-in-webdesign/</a></figcaption></figure><p>Just in case it hasn’t yet sunk in, here’s another example of Parallax in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*AB6sQtQdHLkRDB7LCKHZ7g.gif" /><figcaption>credit: <a href="https://wplift.com/parallax-wordpress-themes">https://wplift.com/parallax-wordpress-themes</a></figcaption></figure><p>Foreground: Interactive game sprites (Mario / bricks / coins /etc)</p><p>Mid-ground(object): Mountains (in this case, multiple instances / speeds)</p><p>Background: Clouds and sky</p><p>The Foreground moves the fastest, and everything you want to appear further away moves slower.</p><h3>A little science…</h3><p>Because we have a binocular vision (two points of origin for sight), we go through a process called “Stereopsis”. Stereopsis is when our brain takes the image from each eye and uses them together to approximate depth. Ever wondered why pigeons bob their head so much? It’s because their eyes are on either side of their head, and as there is no overlap they cannot use Stereopsis, so they use the bobbing to see depth.</p><p>That’s enough theory, here’s how you can implement Parallax into your code</p><h3>The how to</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kx5JkV5JmUL045w_DA5QYg.png" /></figure><p><strong>Your Elements</strong></p><p>Main container = window // Container = Left side // Foreground = Chopper // mid-ground = mountains // background = aurora borealis</p><p>First thing you want to do is set your window, or “master container” to position: relative; Every other element will be set to position:absolute;</p><p>Next create your container element. This will act as the window into the scene you are creating. Set the width and height, you can make it pixel based or responsive, it doesn’t matter. Be sure to add overflow:hidden; You don’t want the container’s children running around your page!</p><p>Once you’ve done that, set the initial position for your foreground, mid-ground and background element(s). Adjust their z-index, so anything that is in the foreground has a higher number in relation to it’s siblings.</p><p>Now for the magic. Using Jquery, (be sure to load the cdn), you will use this function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H81gcyIYl8nyW9ThIzQ5Jw.png" /></figure><p><strong>Breakdown:</strong></p><p><em>$(window).scroll(function () { — X— });</em></p><p>When your browser window is in a scroll state, run this function (X)</p><p><em>let scrollval = $(this).scrollTop();</em></p><p>Create a variable that is equal to your element’s scroll distance from the top.</p><p><em>$(‘element’).css(‘transform’, `translate(0px, ${scrollval / 2}px)`);</em></p><p>Target your element and apply the CSS property “transform” and the apply a translate attribute that is equal to your “scrollval” value divided by 2.</p><p>The higher the number, the slower your object will move. So, unlike your z-index, your foreground will have a smaller number here than your background.</p><p>You don’t need to create a separate function for every new element, simply pop them together, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*BdTnFEX5IeR2BcMnScQcbQ.png" /></figure><p>This isn’t the only way to implement the Parallax effect, but in my personal opinion, it is the most straight-forward.</p><h3>Potential issues with Parallax</h3><p>Sure, it’s visually appealing and interactive, but there can be some drawbacks and here are the big ones to think about.</p><ol><li><strong>Load time</strong></li></ol><p>The current trend is to have single page websites, and because Parallax is so image heavy, load time can be effected. 30% of North Americans use their phone for all web searches and if you have 30 massive images on your site, it will take a long time to load. In fact, when it comes to load-time more than half of users will leave a page if it takes longer than 3 seconds. That’s shorter than the attention of a goldfish.</p><p>Not only that, but google checks for load-time of sites, and longer load-times will negatively effect your Google search rating. (SEO)</p><p><strong>2. SEO</strong></p><p>Not only do google check your load-times, but they check your markup. Parallax sites tend to have unconventional markup, with a lack of traditional semantic structure and often no navigation. Not only does this make it hard for users to move back and forth through your site, but Google scans your HTML and may automatically mark your site as being “amateur”, again lowering your search score.</p><p><strong>3. Accessibility</strong></p><p>The last big point is accessibility issues caused by Parallax sites. As mentioned, they often have unconventional structures with little to no navigation. This is a huge problem for people who navigate sites without the use of a mouse or scroll. If people can’t move through your site, they will leave it.</p><p>Another issue, easily avoided is overly dynamic Parallax effects that have been known to cause headaches, exacerbate existing eyesight problems and even nausea. In a case study, 30% of people over 40 felt nauseas after scrolling through a Parallax site.</p><h3>Moving forward</h3><p>Knowing this, there are things we can keep in mind when using Parallax with our own sites.</p><p>If load time or image file size is an issue consider limiting your Parallax effects, optimize images, and use SVGs as an alternative to images.</p><p>Keep conventional code, especially if you are worried about SEO and always include a clear navigation on your site. A navigation element doesn’t only help people who navigate without a mouse, but it helps all users hop to and from points of interest on your page.</p><p>Check your target demographic, don’t use Parallax because you think it looks cool. Make sure it’s not only appropriate for your site, but serves a purpose.</p><p>Check colour contrast and the degree of motion felt on your site. It’s not a rollercoaster, it’s a website.</p><p>Here’s a handy tool for checking colour contrast ratios on your site — <a href="http://contrast-ratio.com/#%23555-on-white">contrast-ratio.com</a></p><h3>End note</h3><p>You made it! Hopefully, by making it this far, you learned something. There are lots of resources out there, if you want to do some further reading on issues with Parallax, check this site out :</p><p><a href="https://fueled.com/blog/the-troublesome-misconception-of-parallax-in-webdesign/">https://fueled.com/blog/the-troublesome-misconception-of-parallax-in-webdesign/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b213b0358093" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>