<?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 Einar Birgir Einarsson on Medium]]></title>
        <description><![CDATA[Stories by Einar Birgir Einarsson on Medium]]></description>
        <link>https://medium.com/@einarbirgir?source=rss-b74cb3e029b3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4Okrn2RtymRnRX9qWpkxaA.jpeg</url>
            <title>Stories by Einar Birgir Einarsson on Medium</title>
            <link>https://medium.com/@einarbirgir?source=rss-b74cb3e029b3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:59:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@einarbirgir/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[Dear Ueno: How do you plan your React components?]]></title>
            <link>https://medium.com/ueno/dear-ueno-how-do-you-plan-your-react-components-1fbe538faac7?source=rss-b74cb3e029b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fbe538faac7</guid>
            <category><![CDATA[dearueno]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Einar Birgir Einarsson]]></dc:creator>
            <pubDate>Tue, 22 Oct 2019 16:01:33 GMT</pubDate>
            <atom:updated>2019-10-23T09:08:11.790Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Dear Ueno is an advice column for people who for some weird reason think we know what we’re doing. Read </em><a href="https://medium.com/ueno/dear-ueno-b6946471b26a"><em>more about all this</em></a><em>, or check out our </em><a href="https://loremipsum.ueno.co/dear-ueno/"><em>old advice</em></a><em>.</em></p><p><strong><em>A question from Gaz Jones, a developer in the UK, via email:</em></strong></p><blockquote>Developing in React, we sometimes find it difficult to plan how many components to use and how to split up our projects into components. How do you plan your React components?</blockquote><p><strong><em>Einar Birgir Einarsson, a developer at Ueno Reykjavík, literally couldn’t wait to answer:</em></strong></p><p>Hey Gaz, thanks for the question.</p><p>Here’s what we do: First we write a component, then we refactor it about 50 times, and finally we delete it when the design changes. (Just kidding. But not really.)</p><p>Let me try to explain what has worked for us, and hopefully you can glean something useful from my ramblings.</p><h4>1. Think of the design in components!</h4><p>The first thing we usually do is going through the whole design to map out the components. We try to spot elements that appear repeatedly throughout the design, and look for variations or modifiers on those elements.</p><p>As a rule of thumb, we keep things small and tidy. The larger the component, the harder it usually is to work with. We try to follow the principle of <a href="https://en.wikipedia.org/wiki/Separation_of_concerns">separation of concerns</a> and <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">single responsibility</a>, so we break things down when possible.</p><p>Ideally each component should only be responsible for <strong>one</strong> thing. Components tend to grow too much, and when you notice that happening, jump in and refactor — decompose and break it into smaller components.</p><p>As you work, keep an eye on which components you keep revisiting or changing. That’s usually a hint that you might have to refactor things.</p><h4>2. Create tickets!</h4><p>In our project management tool we keep a dedicated board for each project. We create tickets for each section of a page, and sometimes even for each component<em>, </em>often adding screenshots for clarity.</p><p>The number of tickets we create at this stage never adds up to the eventual number of components we build, and it doesn’t need to. We start with broader strokes. For example, we would create a single ticket for a Carousel component, even though we know that the carousel will probably be composed of a few components (see Step 3, below).</p><p>Breaking the design into many component-based tickets is a good foundation for planning your components. Here are some of the benefits:</p><ul><li>You easily spot shared and re-used components, along with their variations.</li><li>Everybody on the dev team has a good sense of the scope of work ahead.</li><li>Stakeholders have a better view of the project status during development.</li><li>Any developer can to jump in, pick an isolated component from the backlog, code it, and add to the Project Elements page (see <em>step 7</em>).</li></ul><h4>3. Code the components!</h4><p>Let the coding commence! By this stage, we have a big list of tickets for possible components in the “to-do” column of our project management tool.</p><p>One of those tickets might look like this carousel bit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_lHMvdxh8yDvFYfrAmYAA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFGenjiB_Fp728X22aK2eA.jpeg" /><figcaption>Break it down.</figcaption></figure><p>At a quick glance, we can spot a bunch of components and sub-components:</p><ul><li>At the top, there’s a TextBlock<strong> </strong>with a heading and some copy.</li><li>Then there’s the Carousel itself, including several carousel items,</li><li>each of which looks like a Card<strong> </strong>component of some sort.</li><li>On the bottom left we have the CarouselButtons,</li><li>and on the bottom right we have the beautiful yellow CTA<strong> </strong>button.</li></ul><p>We could easily break this down a lot more, but this is a pretty good start.</p><p>For more on how to analyze and dissect a component, take a look at the technical run-through in the <a href="https://reactjs.org/docs/thinking-in-react.html">official React documentation</a>.</p><h4>4. Care for the component hierarchy!</h4><p>Now that we’ve identified the components, we organize them into a hierarchy of components and sub-components.</p><p>We’ve noticed that the TextBlock,<strong> </strong>Card (used as a carousel item) and the CTA button are used throughout the design, making them fit perfectly into the top-level component bracket. The CarouselButton however was only used once, in that particular carousel, making it fit nicely as a child-component of the Carousel component.</p><p>So, we might end up with a project structure like this:</p><pre>.<br>├── node_modules<br>├── src<br>│   ├── assets<br>│   ├── components<br>│   │   ├── button<br>│   │   ├── card<br>│   │   ├── carousel<br>│   │   │   ├── Carousel.tsx<br>│   │   │   └── CarouselButton.tsx<br>│   │   ├── header<br>│   │   ├── layout<br>│   │   └── footer<br>│   ├── containers<br>│   ├── hooks<br>│   ├── pages<br>│   │   ├── home<br>│   │   ├── about<br>│   │   │   └── components<br>│   │   │       └── collage<br>│   ├── styles<br>│   ├── utils<br>├── ...</pre><p>In this example, let’s say we also have an image Collage component that is only used on the <em>About</em> page. Components that are only used on a single page (like the one you may have noticed buried in the /pages/about/components/ folder-tree above) are grouped in a components folder at the page-level.</p><p>So, in short:</p><ul><li>/components:<strong><em> </em></strong>All shared or main components go into the top-level components<strong> </strong>folder.</li><li>/containers:<strong> </strong>For our — yes, you guessed it — container components. Container components don’t handle any presentation directly, but are comprised of presentational components, and pass data down into them.</li><li>/pages/{page-route}/components/: This is for components that are local to one particular page, and not re-used anywhere else. Down the line, if things change, for example if a designer has re-used a page-level component elsewhere, we just refactor it up to the top-level component folder afterward.</li></ul><p>This folder-structure is very handy for our code-splitting setup, helps us keep things tidy, and mitigates component-naming issues.</p><p>(As you know, naming stuff can be hard, especially in large projects. For example, <a href="http://ueno.co/">Ueno.co</a>, has around 60+ unique pages. Some of those pages have unique intro sections, and since “intro” is a pretty good but generic name for a component we’ve ended up with nine different components called Intro. With a route-based directory structure, there’s no need to pollute the top-level components folder with ‘intro-privacy’, ‘intro-homepage’ directories. Each Intro component can just reside in peace as a standalone component specific to its context/page.)</p><h4><strong>5. Keep it simple! And remember the layout components!</strong></h4><p>We try to keep components as layout-agnostic as possible. An individual item — the Card component, for example — would only be responsible for its own UI/presentation elements, while a parent component would take care of positioning it on the page.</p><p>For common layout patterns, we often use generic layout components. They have global positioning and dimension values that put our items in the right spots, which is their only purpose. Some examples of generic components: Container to add spacing to either side of a group of child items; Grid to align items in a row with spacing in between; and Section to add padding at the top and bottom of some items.</p><p>The JSX structure of a typical React component could look something like this:</p><pre>&lt;Section&gt;<br>  &lt;Container&gt;<br>    &lt;Grid&gt;<br>      &lt;Card /&gt;<br>      &lt;Card /&gt;<br>      &lt;Card /&gt;<br>    &lt;/Grid&gt;<br>  &lt;/Container&gt;<br>&lt;/Section&gt;</pre><p>To get up and running as fast as possible the dev team at Ueno created the super great <a href="https://github.com/ueno-llc/create-ueno-app">create-ueno-app</a> starter. We think it’s <em>the</em> easiest and fastest way to create new web projects with next, gatsby, create-react-app and mobile projects with react-native. All of them are powered with Ueno’s configs, and they include some of the basic layout components that we use in most of our projects.</p><p>Read all about <a href="https://loremipsum.ueno.co/new-year-a-new-tech-stack-37dca10735a5">our starter-kit here</a>. And then try it for yourself!</p><h4>6. Beware of prop creep</h4><p>A few words of caution about “prop creep” (a phrase I literally just coined, by the way). Designers change their designs. Sometimes this happens late in the game, but more often changes creep up, one by one, over the lifespan of a project. What was initially a small and simple card component can expand, change functionality, or get all kinds of nice-looking variations.</p><p>Down the line our simple Card component might need the headline to be above the card-image, but only sometimes. Sometimes it might need a purple background. Sometimes the headline needs to be just a tiny bit smaller and copy text bigger. Sometimes the card wants to have an amazing box-shadow. And so on, and so on.</p><p>Adding a boolean/modifier prop for different variations might work perfectly fine at the start, but can get terribly out of hand with more changes to the design. You can end up with a monster of a component.</p><p>Perhaps it’s better to break it down instead of creating one huge Card component to rule them all. Endless flexibility can sometimes bring endless, agonizing hours of work for tiny changes.</p><p>Just food for thought, alright? Use your judgment. You’re smart!</p><h4>7. Create an Elements page for all your components!</h4><p>For each project, we create an “Elements” page. It’s a simple page that usually contains an example of all our components and how their props affect them. It’s a great reference page and usually our starting point for every project. It can also help other developers to quickly see what’s available at the top-level.</p><p>We slowly build up our Elements page and once we’re done implementing our components we can build up the main pages one by one, out of our components.</p><p>Like all of my advice, this approach is highly recommended!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNP0keLs_PPIFVD4j0ch0A.jpeg" /><figcaption>Elementary, my dear Gaz.</figcaption></figure><p>Life is complicated, and you can’t plan for every eventuality. Having to revisit a component and break it down into more pieces later on is perfectly normal. Just try to keep it simple, think of the wise Mr. Robert C. Martin’s <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">single-responsibility-principle</a>, and break that component into more bits and pieces when needed.</p><p>Now go, and plan your components!</p><p>Hope this has been useful,<br>— Einar Birgir</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Apy8JFE89-h6NyJiTtajw.jpeg" /></figure><p><em>Einar Birgir Einarsson is a developer at Ueno. You may remember him from </em><a href="https://twitter.com/einarbirgir"><em>Twitter</em></a><em>. And from when he told you </em><a href="https://loremipsum.ueno.co/dear-ueno-how-do-you-compress-videos-6657ebd9dd28"><em>how to compress videos</em></a><em>. And from this </em><a href="https://open.spotify.com/playlist/3hBYpwnFkdLPV0qnXDC8M4"><em>playlist he made for you</em></a><em>.</em></p><p><strong>Need advice?</strong> Send your <em>Dear Ueno</em> question to hi@ueno.co or <a href="https://twitter.com/search?q=%23DearUeno&amp;src=typed_query&amp;f=live">via Twitter</a>.<br><strong>Want to get a silly profile photo?</strong> Because <a href="https://www.ueno.co/careers">Ueno is hiring</a>.<br><strong>Want more email?</strong> Because <a href="https://www.ueno.co/newsletter">Ueno has a newsletter</a>.<br><strong>Want even more answers?</strong> Because we have <a href="https://loremipsum.ueno.co/dear-ueno/">even more answers</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fbe538faac7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ueno/dear-ueno-how-do-you-plan-your-react-components-1fbe538faac7">Dear Ueno: How do you plan your React components?</a> was originally published in <a href="https://medium.com/ueno">Ueno.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dear Ueno: How do you compress your videos?]]></title>
            <link>https://medium.com/ueno/dear-ueno-how-do-you-compress-videos-6657ebd9dd28?source=rss-b74cb3e029b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6657ebd9dd28</guid>
            <category><![CDATA[video-compression]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[dearueno]]></category>
            <category><![CDATA[videos]]></category>
            <dc:creator><![CDATA[Einar Birgir Einarsson]]></dc:creator>
            <pubDate>Wed, 04 Apr 2018 17:10:14 GMT</pubDate>
            <atom:updated>2018-08-16T12:52:26.537Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Dear Ueno is an advice column for people who for some weird reason think we know what we’re doing. Read </em><a href="https://medium.com/ueno/dear-ueno-b6946471b26a"><em>more about all this</em></a><em>, or check out our </em><a href="https://loremipsum.ueno.co/dear-ueno/"><em>old advice</em></a><em>.</em></p><p><strong><em>Malte Michels from Germany asks:</em></strong></p><blockquote>“How the hell do you compress your videos for web usage? They are so tiny but also so great to look at.”</blockquote><p><strong><em>Einar Birgir Einarsson, developer at Ueno Reykjavík, dictated this reply to Siri while driving to work one morning:</em></strong></p><p>Hey Malte — thanks for the mail and that nice comment.</p><p>There’s no true optimal universal compression-quality setting. It’s all about finding a balance between aesthetics and performance. For us this means a mix of testing/tweaking presets, and “trial-and-encode” (sorry). The result always depends on the video content and your own criteria, such as the tradeoff between file-size and artefacts by the compression.</p><p>Here are some basic recommendations.</p><h4>Use MP4/H.264</h4><p>For our web videos we use the MP4 format and the H.264 compression standard (MP4/H.264). It’s got great performance, file-size and quality, and most importantly it behaves well on almost all browsers, platforms and devices.</p><h4>Pick your tool</h4><p>There are a few tools out there that take care of the heavy lifting. At Ueno we’ve mostly used <a href="https://www.ffmpeg.org/">FFmpeg</a>, <a href="https://www.adobe.com/products/media-encoder.html">Adobe Media Encoder</a> and <a href="https://handbrake.fr/">HandBrake</a>. They all work equally well, but I’ll focus on HandBrake in what follows, because it’s free, has a nice GUI, and uses the great x264 encoder. If you prefer command line then you can go for FFmpeg.</p><h4>Don’t overthink it</h4><p>The HandBrake interface might look somewhat intimidating at a first glance, but don’t worry. That’s what presets are for. There are presets for most of your needs, and they’re pretty great. For example, you select <em>720p30,</em> HandBrake will automatically translates that to the perfectly acceptable <em>x264 Unparse: level=3.1:ref=2:vbv-maxrate=14000:8x8dct=0:vbv-bufsize=14000:subme=6:weightp=1:rc-lookahead=30, </em>which, luckily, you really don’t have to think about, unless you want to become a hardcore encoding enthusiast.</p><h4>Tick the “Web Optimized” checkbox</h4><p>Sometimes referred to as “Fast Start,” this places the MP4 container header at the start of the file, letting the browser start streaming the file quicker.</p><h4>Silence, please</h4><p>If you are displaying video without any audio, make sure you remove all the audio tracks when encoding. It’s tempting to just slab the ‘muted’ attribute on the video element in your code, but removing the audio tracks can trim down the file-size a lot. (In HandBrake go to the <em>Audio</em> tab, then select <em>Tracks -&gt; Remove all tracks</em>.)</p><h4>Think small</h4><p>Make sure you are exporting it only at the maximum resolution of that you need for the video — there’s no need to go overboard for some tiny in-page video. Use your judgment: Is this a prominent ‘hero’ video or some secondary video that appears on some fringe hover-state behaviour? A good rule of thumb: stop compressing when you start noticing a visible difference compared to the source file.</p><h4>Tweak and tune</h4><p>We usually start with the following default values, and then adjust for each case:</p><ul><li><em>Video Encoder: H.264 (x264)</em></li><li><em>Quality: Constant Quality with RF: 25</em></li></ul><p>Now, bitrates. If you want to target a specific file size, you can select Two-Pass Average Bit Rate (ABR), but we usually go for Constant Rate Factor (CRF) instead, giving us a variable bitrate, but overall good quality. We usually experiment a bit with the RF values, but usually end up somewhere between 20 and 30 on the quality-slider. (If you’re interested, here’s a great post about <a href="http://slhck.info/video/2017/03/01/rate-control.html">different rate control modes</a>.)</p><p>Regarding the frame rates (FPS) — it depends on the preset and your source video but make sure you have Peak Frame-rate (VFR) option enabled, as it works like a threshold. For example, if you’ve got 25<em> </em>FPS (frames per second) selected, portions of the stream that are below 25<em> </em>FPS are unchanged, portions above that value are limited to max 25<em> </em>FPS.</p><p>Finally, you can also specify what type of video content you’re working with in the <em>Tune</em> options — ‘animation’ for 2D animated content, ‘film’ for real-life footage and so on. If you are unsure, you can just leave this option at ‘none’.</p><h4>You can make it complicated, but you don’t have to</h4><p>There are so many variables to adjust and tinker with, it’s easy to fall down a rabbit hole pushing for the perfect outcome. But there’s no need to make things more complicated than they are.</p><p>Thanks for reading. Hope this has been useful! <br> — Einar Birgir</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S3n4LOtJ3kHsMtAZRUpmtw.jpeg" /></figure><p><em>Einar Birgir Einarsson is a developer at Ueno. He’s a very serious person who has never slipped on a banana peel. Want to work with him? Check out </em><a href="https://www.ueno.co/careers"><em>available positions at Ueno</em></a><em>.</em></p><p><em>To ask us questions, email </em><a href="/service/mailto:hi@ueno.co"><em>hi@ueno.co</em></a><em> with the subject line “Dear Ueno,” or </em><a href="https://twitter.com/uenodotco"><em>tweet at us</em></a><em> with the hashtag #DearUeno. Include your name, location, and profession — real or fake. Ok, thanks.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6657ebd9dd28" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ueno/dear-ueno-how-do-you-compress-videos-6657ebd9dd28">Dear Ueno: How do you compress your videos?</a> was originally published in <a href="https://medium.com/ueno">Ueno.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>