<?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[Gronda - Medium]]></title>
        <description><![CDATA[Professional network  for hospitality industry - Medium]]></description>
        <link>https://medium.com/gronda?source=rss----b40c11a7ef4c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Gronda - Medium</title>
            <link>https://medium.com/gronda?source=rss----b40c11a7ef4c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:26:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/gronda" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Remote work: what I’ve learned one year later]]></title>
            <link>https://medium.com/gronda/remote-work-what-ive-learned-one-year-later-7181b580d5e5?source=rss----b40c11a7ef4c---4</link>
            <guid isPermaLink="false">https://medium.com/p/7181b580d5e5</guid>
            <category><![CDATA[remote-working]]></category>
            <dc:creator><![CDATA[Ray Roman]]></dc:creator>
            <pubDate>Fri, 20 Sep 2019 06:21:51 GMT</pubDate>
            <atom:updated>2019-09-30T06:21:04.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dhu5Zq18pRkfyiOH" /><figcaption>Photo by <a href="https://unsplash.com/@anniespratt?utm_source=medium&amp;utm_medium=referral">Annie Spratt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Friends and acquaintances often ask me about my work situation, as is part of small talk decorum, and they’ve always looked at me mouth agape when I subtly mention that I work remotely from the comfort of my very own home. “I certainly can’t do that!”, they exclaim, hands thrown in the air, face painted with a tinge of envy. Or they mention that their employment situation requires them to be “on campus”, like engineers, lab technicians, or nurses. (Part of me thinks that a cardiac surgeon ought to <em>not</em> work remotely or from home, anyway). Should they be blessed with the opportunity to take their work on the road with them, I encourage them to try it out.</p><p>I’ve been working remotely for Gronda for a little bit over a year now, starting when I moved four hours east of the office. As I reflect on this past year, I realize that it has been a fairly smooth journey. And I could confidently say that it had been that way since the beginning of my adventure. However, I believe this is an exception rather than the rule. There are challenges that I nonetheless faced, and these challenges will accost anyone new to the home office lifestyle. Here I’ll share some nuggets of wisdom that I have learned on the way.</p><h3>Now more than ever is discipline a virtue</h3><p>Discipline is a garden, and nobody is born with green thumbs. Working from home means that you have a choice between lazing on your sofa and watching Netflix, and working on spreadsheets or a codebase. Faced with this <em>so very difficult</em> choice, discipline is actively deciding you want to do the more traditionally “boring” task instead. It requires a maturity to delay gratification until the afternoon/evening when you can close Slack. And most of all, you’re faced with this choice every workday of your life, and unyieldingly making the same decision. It takes a certain kind of fortitude to shun mental pleasures and instead put in hard work. Yet, if you undertake the “work from home” lifestyle, this is a <a href="https://en.wikipedia.org/wiki/Stanford_marshmallow_experiment">Marshmallow Test</a> you’ll have to take every single day.</p><p>The good news is that this kind of attitude is cultivated. This garden must be cared for over time by regularly checking in on your plants, giving them the right kind of growing environment, and nourishing them with the right kinds of nutrients. Within the first few days of starting your remote work (if you consider it to be a semi- or fully-permanent venture), you can achieve this level of discipline by regularly checking in with your coworkers or superiors. Even just hearing that your coworkers are working hard on their projects will probably inspire you to pick up some slack, too. Touch base with them often, as it is your job to not only prove to yourself <em>but also to the rest of your team</em> that you are still reliable even when you’re away. And by taking the initiative to talk to your coworkers (and especially your superiors), you relieve them of the task of micromanaging you.</p><h3>The word “office” in “home office” is there for a reason</h3><p>So let’s say that you’ve been bestowed with the ability to work from home. How does one make the most of it? The easiest tip: Practice good work hygiene. Its brother, <a href="https://en.wikipedia.org/wiki/Sleep_hygiene">Sleep Hygiene</a>, is probably something you’re already familiar with.</p><p>For starters, keep a separate workspace where you pay attention to work stuff only. In other words, a proper desk, probably somewhere away from the rest of your belongings. This desk should be reserved for professional endeavors only, so no, your bed doesn’t count just because it’s cozier. From my very untrained psychological opinion, I’d say this dovetails with the <a href="https://www.scientificamerican.com/article/why-walking-through-doorway-makes-you-forget/">doorway effect</a>, where having separate physical spaces means <em>something</em> important to your brain. Furthermore, if you’re in the U.S., you <a href="https://turbotax.intuit.com/tax-tips/small-business-taxes/the-home-office-deduction/L1RZyYxzv">deduct</a> your own exclusive office space from your taxes, provided it meets a bunch criteria. Wealth galore!</p><p>Another related habit is to still dress up as if you’re leaving for the office. Remote workers can boast the luxuries of the sweatpants (or no pants) lifestyle, but I’ve noticed that I feel more productive even if I just change out of my lounging clothes and look a tad bit more presentable, even if nobody actually sees me. Again, this change of context <em>probably</em> means something to your brain to help you work more effectively, but then again I got my degrees in biology and mechanical engineering—I’m not qualified to make such pop-psychology comments.</p><h3>Sorry introverts, you still have to communicate with others</h3><p>And that comes with the territory. Especially for introverts like me, someone who would rather condense a Skype meeting into a short email, the altar of personal communication is one we cannot burn down. And over the months, I’ve come to appreciate this as a remote developer. Working remotely means that you lose the ease of communication between you and those you work with. You lose the tone of voice and the hand gestures and the body language and the weirdly endearing off topic comments. Sure, these can be replaced with emojis, but the 😂 emoji doesn’t compare to an actual laugh, at least in terms of human communication. (This emoji is, however, <strong><em>extremely</em></strong> valuable to your off topic/meme Slack channels.)</p><p>Now that I crushed your dreams of avoiding face-to-face contact with humans during your workday, the alternative is to just lean into it. One good habit to get into is to regularly <strong>video</strong> <strong>call</strong> your coworkers. Besides speaking idly about nice watercooler topics, this Herculean task also serves another purpose: It will alleviate any miscommunication that travels easily through written messages. Questions can be answered quickly, feedback can be given (especially if you screen share your updates), and you’ll still feel in the loop with company matters. Even try it with coworkers outside of your team — you won’t be “that guy who works far away, but we never see”, but instead someone with a voice and a face who’ll be recognized as a person!</p><h3>Working remotely has its own (sometimes unavoidable) distractions</h3><p>If your office is an open office plan, then you might celebrate avoiding the murmurs and drones of casual conversation around you by working remotely. On the other hand, you’re trading one type of distraction for one/others that might pull you out of your “zone” nonetheless. Some of them are hard to escape, but thankfully there are others you can easily mitigate.</p><p>For me, my workspace abuts on a small avenue that I imagined as being relatively quiet. That’s true except during the morning and afternoon rush hours, when hundreds of cars use this thoroughfare to get to or from their own office place, and the resulting reverberations and low frequency hums is easily noticeable after a couple of minutes. This is one type of environmental factor that is quite hard to avoid. For you, if you live in an apartment building with children who scream bloody murder, or if you’re at a busy intersection or across a rowdy sports stadium, then your best bet might be to purchase earplugs or listen to music. Or if your upstairs neighbors have children screaming bloody murder, then I <strong>encourage</strong> you to tape some speakers to your ceiling and then play Weird Al Yankovic on maximum volume. All, of course, while you’re wearing the earplugs I suggested. (Why else would I have suggested them?)</p><p>And although you can’t control the loud, rowdy fans at the stadium nearby, there are other local environmental variables you can control. Keep your phone away from your desk, especially if you need to concentrate. If you’re in a separate room, then close your door so nobody disturbs you. If you’re like me with the rumbling avenue due to rush hour traffic, then I simply close my casement windows, and the effects are dramatically reduced.</p><p>Obviously, I took a very relaxed perspective towards preparing you for working remotely, and perhaps that’s the kind of attitude you should have for something like it. After all, you know what kind of worker you are. You know if you like small talk or if you like to focus on your tasks at hand; if you prefer your desk messy or neatly organized; if you prefer working in silence or while listening to lofi hip hop radio — beats to study and relax to. Even if you feel that you don’t have the discipline for starting such an endeavor, I still recommend trying it out. Maybe you can set it up with your employer that you work one day remotely every couple of weeks. Maybe print this article on pamphlets and spread the remote work gospel. And then maybe I can finally achieve my true goal of working from home — having an army of digital nomads at my disposal 👾.</p><p>Follow Gronda <a href="https://medium.com/gronda">here on Medium</a> or <a href="https://www.instagram.com/gronda.eu/">on Instagram</a> 😘</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7181b580d5e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gronda/remote-work-what-ive-learned-one-year-later-7181b580d5e5">Remote work: what I’ve learned one year later</a> was originally published in <a href="https://medium.com/gronda">Gronda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing ARIA attributes with React hooks]]></title>
            <link>https://medium.com/gronda/managing-aria-attributes-with-react-hooks-a7470d572683?source=rss----b40c11a7ef4c---4</link>
            <guid isPermaLink="false">https://medium.com/p/a7470d572683</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Ray Roman]]></dc:creator>
            <pubDate>Sun, 26 May 2019 18:42:35 GMT</pubDate>
            <atom:updated>2019-05-26T18:49:43.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jn4GUwhLr_BSFpKj" /><figcaption>Photo by <a href="https://unsplash.com/@pluyar?utm_source=medium&amp;utm_medium=referral">Shane Aldendorff</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Released some months ago, React hooks were suddenly released, and it became a shiny new toy for front-end developers to play with. Developers have shared their snippets of code, released them into the ether to show the impressive things that can be done with them. Consider this blog post another contribution in the collective headspace, even something that will help out our other-abled users who use our platforms.</p><p>Users who rely on screen readers have tough time trudging through all the static on single page applications unless the developer smartly annotates various DOM elements with attributes like aria-labelledby and aria-describedby. Let’s see how we can use React hooks to master those attributes and provide a signal amidst all the noise. And for this recipe, let’s do a hometown favorite: the Todo app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*EJOzSnbYGOltUeQeLTAW2w.png" /><figcaption>Contrived but accomplished. Plus, Thai food is delicious.</figcaption></figure><p>The most practical way to demarcate this Todo item with the aforementioned attributes is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*ALBqtkx9lzG5pe85sMc15Q.png" /><figcaption>Forgive the poorly drawn arrows. I’m a developer, not an artist.</figcaption></figure><p>Makes sense. The &lt;article&gt; element that we have should be connected with the corresponding describedby and labelledby attributes. This means that we need to generate HTML id attributes for each of those Todo item elements.</p><h3>Automatic generation of ids</h3><p>With only one or two elements, the question of what to name these ids isn’t much of an issue. As our application grows, suddenly the mental burden grows on the developer side about how to name these ids. In a sprawling app, the number could estimate to a magnitude or two more than you expect — something staggering—and maybe you could come up with an <em>ad hoc</em> system to namespace them by their feature.</p><p>But this myopic approach could lead to catastrophically large strings that might span 30-plus characters in length. Even worse, you might be tempted to save each id as a string constant in your src/global/id-reference.js file and furiously import { TODO_FEED_ITEM_TITLE_ID_LARGE } from &#39;../../../../global/id-reference.js&#39;;. And then you’d have to search your project files to make sure those instances aren’t used anywhere else. Neither seems to be palatable.</p><p>An alternative way to generate these ids without any mental effort is simply by using Lodash’s _.uniqueId <a href="https://lodash.com/docs/#uniqueId">method</a>. It accepts a string as an argument as a namespace prefix, and you don’t ever have to worry about keeping these ids in mind. The React class-friendly version would ultimately be</p><pre>constructor() {<br>  super();<br>  this.FINAL_ID = _.uniqueId(&#39;todo-item-title:&#39;);<br>}</pre><pre>render() {<br>  return &lt;div id={this.FINAL_ID}&gt;{ this.props.children }&lt;/div&gt;;<br>}</pre><p>which would render a &lt;div&gt;with the attribute id={todo-item-title:[x]}, where x is the number of times that you invoked _.uniqueId (again, without any headache from the developer).</p><p>Note that it’s declared as an <strong>instance variable</strong> because it is bound to a specific class instance. In other words, upon each render, it will still be the same string, todo-item-title:[x], and not todo-item-title:[x + 1], <em>ad infinitum</em>. Unfortunately, this can only work for classes. Functional components in React don’t have such a luxury; they’re merely functions (as their namesake implies) that spit out a DOM tree once they receive some prop data. And upon every render, you invoke _.uniqueId over and over again, changing the value of id that you’re using.</p><p>Thanks to React hooks, however, we’re able to preserve the benefits of instance variables, but using different syntax. We no longer have to worry about affecting some external state (Lodash’s external state, to be specific) upon each render.</p><p>A recipe to generate the final id that will be used is here:</p><pre>const finalId = React.useMemo(<br>  () =&gt; props.id || _.uniqueId(&#39;todo-item-title&#39;), [props.id]<br>);</pre><p>A few notes:</p><ol><li>If props.id ever changes, so will the output for finalId. (But without the developer headache.)</li><li>Normally useMemo is spouted for “memoizing functions that do heavy lifting”. An alternative, niche use case would be right here: in case there’s any kind of external state that shouldn’t be modified upon render, then useMemo ensures that the global state would be unaffected. That means _.uniqueId won’t be called every render.</li></ol><p>But if you aren’t a fan of installing a large utility library, then you can try to install <a href="https://github.com/dylang/shortid">a small UUID module</a> like shortid to perform some of the heavy lifting. And if you’re not a fan of installing any unnatural dependency like that, then you can always keep an instance variable outside your component. For example, Angular Material keeps a variable outside of their components, and keeps it as an instance variable inside their component so that it is automatically incremented.</p><pre>// Outside the component<br>let uid = 1;</pre><pre>// Inside the component<br>this.uid = `todo-item-title:${uid++}`;</pre><p>And if you’re such a big fan of vanilla JavaScript, then part of me wonders what you’re doing here in an article about React.</p><h4>Can too many ids spoil the DOM?</h4><p>As your application grows, and more and more elements float around in the DOM, the proverbial “elephant in the room” grows commensurately. Can having hundreds of ids in your application act as a performance bottleneck? Thankfully not. This “pachyderm in the platform” might be of practical concern if we were directly pressing our hands against the DOM via document.getElementById and other methods, but since we’re not (except maybe in ReactDOM.render and auxiliary libraries that require DOM modification), the point is moot. <a href="https://stackoverflow.com/a/9193338">Read more about it here</a>.</p><h3>Recipes for ARIA attributes</h3><p>Even if we use useId in every component for our Todo item in our feed, the task still remains. We still have to connect them to the parent wrapper as the accessible labels and descriptions. The following recipe shows exactly how to do that. Here, I’ll show you how to use it for keeping the aria-describedby attribute automatically in sync.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cb6cdcf8e166e9176d108c5ec65dc9b/href">https://medium.com/media/0cb6cdcf8e166e9176d108c5ec65dc9b/href</a></iframe><p>A couple points to note here:</p><ul><li>We’re passing down a function that automatically determines if we’re adding or removing a string finalId from the array of ids. That way, in each element that provides a description, we can simply pass { add: finalId } or { remove: finalId } without worrying about the underlying implementation.</li><li>We don’t have to take care of the dependencies in useCallback because we’re using the useState(arg: Function) signature within. Less of a headache right there.</li></ul><p>For the &lt;Description&gt; component, the consuming logic is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebb19a82acd39b4696829324f565ee1d/href">https://medium.com/media/ebb19a82acd39b4696829324f565ee1d/href</a></iframe><p>We pass the value for finalId as the argument for register, which is also a dependency used in useEffect. Because of how useEffect works, any changes to finalId will automatically deregister the old id and register the new one. (<a href="https://reactjs.org/docs/hooks-effect.html">See more here</a>.) This logic is much the same for the rest of the components in the Todo item, like the &lt;Updated&gt; component and &lt;Complete&gt; components.</p><p>Finally, the &lt;TodoItem&gt; component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37e69186af5c7e5ebc05f5a78c4b662d/href">https://medium.com/media/37e69186af5c7e5ebc05f5a78c4b662d/href</a></iframe><p>The value for aria-describedby is the array of ids that we finally have, but turned into a string. Here’s what the DOM will show:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*F-qzEuMMg_4ERCmXYPJN1A.png" /><figcaption>Note how the attributes correspond to the automatically generated ids in the child components.</figcaption></figure><p>And here is what the accessibility tab in Firefox shows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*AwS0pjq_wtyn8WUgbHupZw.png" /><figcaption>We’re labeled by one item and described by a set of other items. As is expected!</figcaption></figure><p>And now, our Todo item is properly labeled. As an added bonus, we now have a component that works compactly without the overhead of class construction.</p><p>Another salient point to mention: Some feed items have a “revealing” pattern such that <em>dense</em> feed items show less information (fewer DOM/description elements) than their less compact counterparts. This recipe ensures that we don’t have to manually manage which ids correspond to elements that actually, presently exist. The register function automatically takes care of that for us. So your aria-describedby won’t point to anything that isn’t on the screen already.</p><h3>Further improvements</h3><p>Why stop here? I encourage you, the reader, to take this recipe even further, adding your own spices to it. Here are some good starting points for ways to continue this recipe:</p><ul><li>Consider using context to avoid diluting the props for each component that describes the Todo item. (Why should the &lt;Description&gt; component compare about a prop called “register”, something completely unrelated to rendering a description?)</li><li>Within the &lt;Updated&gt; and &lt;Complete&gt; components, the registering logic is pretty much the same. We can probably turn that into another hook.</li><li>We’ve managed aria-describedby but how about aria-labelledby? We can make another recipe, or we can adapt the current one to accept an ariaType argument somewhere.</li><li>The current implementation does not worry about the <em>ordering </em>of the aria-describedby ids. Note that in the above screenshot, the first description item is “updated at 7:48 AM”. We can probably modify the useAriaDescribedBy hook to accept a list of “suggested order” of elements in the attribute, such as [&quot;description&quot;, &quot;completed&quot;, &quot;updated&quot;].</li><li>Utilize a page-level UI reducer and context combination. You can reference these automatically generated ids in places like aria-controls (active tabs, search filters), aria-labelledby (<em>e.g.</em>, for feeds), and other things. That way, you don’t have to worry about storing your id variables in some constants file somewhere.</li></ul><h3>Final words</h3><p>Suddenly the front-end development world became awash with myriad libraries and frameworks, and our collective attention span has focused more on the issues immediately in our IDE: Redux? MobX? How do I figure out routing? And what about this GraphQL/Apollo stuff? And it’s good that we have several new toys to experiment with to let our creativity flow. But despite the growing number of choices we have as developers, there will still be users who need us to develop with accessibility in mind.</p><p>This recipe can hopefully ease the development burden so that we can have a smooth development process while also caring for our other-abled users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7470d572683" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gronda/managing-aria-attributes-with-react-hooks-a7470d572683">Managing ARIA attributes with React hooks</a> was originally published in <a href="https://medium.com/gronda">Gronda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Illusion of Speed: Loading States with React]]></title>
            <link>https://medium.com/gronda/the-illusion-of-speed-loading-states-with-react-1c676ccce484?source=rss----b40c11a7ef4c---4</link>
            <guid isPermaLink="false">https://medium.com/p/1c676ccce484</guid>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ray Roman]]></dc:creator>
            <pubDate>Fri, 18 May 2018 10:50:34 GMT</pubDate>
            <atom:updated>2018-05-18T10:50:33.849Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Illusion of Speed: Skeleton Screens with React</h3><p>Waiting for information to load on a website draws several parallels to waiting in real life—whether that’s for the train, for your freshly pressed dress clothes from the dry cleaners down the street, or for the nearest nurse to quit triaging the guy with the broken rib and take a look at your sore throat. And whether the waiting, waiting, waiting you do is virtual or in real life, we can all agree on one thing: It sucks.</p><p>Although visitors to your website may file the act of waiting as one of life’s certainties—alongside death and taxes—you can help mitigate this tortuous experience with some clever, visual illusions. This blog post covers a nice little exercise in slimming the perceptive barrier of “Waiting” between your users and their data.</p><p>The solution from, say, 2002 prescribes dropping a loading spinner GIF or some other circular image or progress bar to signify that things are taking a bit longer than expected, so sorry for the delay. Thankfully, this trend has fallen out of fashion for reasons similar to <a href="https://www.intechnic.com/blog/why-you-should-never-use-stock-photography-on-your-website/">why you should never use stock images on your website</a>: They’re impersonal, unoriginal, and they bridge no connection between your user and the sexy content on your platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*2coTHp9LGNAopoWokXFFtg.png" /><figcaption>Loading state from <a href="http://uigarage.net/loading-screen-ui-inspiration-interface-ios/">UIGarage.net</a>.</figcaption></figure><p>Nowadays, websites have begun using loading screens that are more in tune with the platform’s vision: If they fall back to platitudinous progress bars, at least they spice it up with the product’s general aesthetic. Take a look at this progress indicator: There are some commonalities between the platform’s theme and the loading GIF. (And although the simple design may not promote the depth of the app’s capabilities, at least the user can develop a mental image/design motif for what kinds of patterns and themes to expect throughout the app).</p><h3>Bringing placeholders closer to their content</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*2Yp5jazUs36NLuROQS6oRQ.png" /><figcaption>Inspiration for Gronda loading states: straight from <a href="https://redux.js.org/">redux.js.org</a>.</figcaption></figure><p>Take a look above at the loading state for the ReduxJS website. What can we predict about the content? Well, there’s a button containing an icon and some text on the top right; there’s a section with a heading and a paragraph of text. Top left we have some kind of quote or navigation with a blurb and description text. What does this translate into?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*B1YFTv3I3wLVZB265X60hQ.png" /><figcaption>Actual content from the ReduxJS website. Note the form similarities to the loading state.</figcaption></figure><p>Surprisingly apt, you are! All those placeholder elements are more or less exactly what we expect: the button, the navigation blurb, and the paragraph. But this act of pulling words and icons out of grey boxes isn’t just a mere magic trick borne out of the Gestalt school of psychology. This technique helps bridge the gap between loading and data—a very attractive consequence is that it reduces the cognitive load on the user: Not only will they know that <em>something</em> is loading, but they can predict <em>the type of content that will load</em>. For first time users, it engenders a helpful mental model of the platform. “Okay, boxes containing this type of information are about this big; I should expect some kind of subtitle underneath a main heading; there’s a button here that might have relevant information to me later on.”</p><p>The UX world has christened these states as “skeleton screens” or “skeleton loading”.</p><h3>Developing skeleton screens in React</h3><p>A simple solution to recreating skeleton screens like above would be from the <a href="http://buildo.github.io/react-placeholder/#reactplaceholder">React Placeholder</a> package. But we’re developers here: We like to make our tasks needlessly complicated and sacrifice our nasty, brutish, and short lives to the altar of user experience. So let’s season this bad boy.</p><p>Here we would like to introduce a library that we’ve dev—just kidding. You need nothing more than react-transition-group for this. (Our platform uses styled-components as well, but these can be accomplished with vanilla CSS.)</p><p>We assume you already have familiarity with react-transition-group. If not, the <a href="http://reactcommunity.org/react-transition-group/">documentation</a> is a nice place to start. We begin by utilizing &lt;TransitionGroup /&gt; to handle all of the “states” we have, like “loading”, “data”, “empty”, and “error”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYTdJq0GaRgpMZQ_8b5cjA.png" /><figcaption>The components are arbitrary; focus on the organization of the Transition components.</figcaption></figure><p>Note that &lt;TransitionGroup /&gt; requires all the direct children to be &lt;Transition /&gt; components with a specific key. In the above example, we waffle between the “loading” &lt;Transition /&gt; and the “data” one. If the data is loaded, show this data-filled component; if not, show that one. (If you’re only slightly familiar with react-transition-group, note that &lt;TransitionGroup /&gt; handles all of the in={Boolean} props that should be on the &lt;Transition /&gt; children behind the scenes.)</p><p>Copy and paste the above code several times, change some stuff in between, and what does this translate to?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AIukGUVVWtjHIUgEuTpPPQ.png" /><figcaption>Sexy, sexy, skeleton screens.</figcaption></figure><p>So according to this placeholder, there’s an avatar in the top left with two lines of text (the top one being more prominent); there are message boxes. On the top left of each message box is a square (probably an indicator or avatar of some sort) with associated text. The top right has a string of text: perhaps some link or metadata; finally, each box has a paragraph.</p><p>And what’s really rendered?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*yrILzV59Nv1OH8HvZsnmLQ.png" /><figcaption>Not bad!</figcaption></figure><p>Of course the transition state can be improved, but it’s definitely close to what’s actually rendered on screen!</p><h3>Miscellaneous tricks with skeleton screens</h3><p>Our toolbox/magician’s hat is ever expanding, and to impart some knowledge to you, dear reader, we’ll share some tricks to embellish your skeleton screen beyond its bare-bones implementation.</p><h4>Fake words</h4><p>Paragraphs are made of words, and words are splotches of ink on a page that would like to convey some information by one person to another through light waves (in the case of a computer screen). These words are composed of letters, and each word is of different length. Words tend to be separated by spaces in many languages. So from the bottom-up, we need to create an element that is variable in width (not necessarily height), has some margin, and can replicate the appearance of ink on paper (or screen).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*3AFSMnUOxH4XGGstIO8GsA.png" /><figcaption>Lots of words that make up a fake word.</figcaption></figure><p>Again, we use styled-components for this guy. Note how we opt to pass height and width as attributes to create a style object rather than as something passed to the template string. Learning the hard way, we discovered that styled-components generates classes for every different combination of props. So the class hash for width={36} will be completely different from that of width={35} though their widths differ by only one pixel. Hundreds of classes would be generated for no good reason. Keep it simple and pass those highly variable props to the style object.</p><h4>Fake paragraphs</h4><p>And since paragraphs are just strings of words, let’s string them together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLqenA32p0hiSSaqhfbQbQ.png" /><figcaption>Is a paragraph really a paragraph without a double carriage return? If so, then this is a couple of paragraphs that creates a paragraph.</figcaption></figure><p>Note that the line-height CSS property is changed as well. This is to compress the lines of “text” placeholder.</p><h4>Transition animations</h4><p>Where this becomes oh-so charming is by having react-transition-group animate the entrances and exits of these components, like a beautifully choreographed, although sometimes jittery, dance on your webpage. We leverage the render prop of the &lt;Transition /&gt; component to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nLuYFEzjO0OAoaEt3BQtrQ.png" /><figcaption>Passing the transitioning state as a dataset attribute makes choreographing transitions much easier.</figcaption></figure><p>Note how that the &lt;AnimatedPlaceholder /&gt; component passes the render prop as data-state. Rather than muck around with a cacophony of booleans like</p><pre>className={<br>  state === &#39;entered&#39; &amp;&amp; state !== &#39;exiting&#39; ?<br>    &#39;class-name&#39; : state === &#39;entering&#39; ?<br>       &#39;another-class-name&#39; : null<br>}</pre><p>we assert the transitioning state as data-state={state}.</p><p>Using styled-components makes targeting these transition states much easier. (Of course, there are some <a href="https://stackoverflow.com/questions/31946406/are-there-any-performance-or-otherwise-differences-concerning-attributes-vs-c">performance considerations</a> apropos of targeting attributes versus class selectors, but as always, benchmark before you optimize!)</p><h3>Considerations</h3><p>This method is not without caveats, however. Here’s a list, though definitely not an exhaustive one.</p><h4>You’re increasing the amount of manageable code…</h4><p>Note that integrating transition states and auxiliary components adds much more code to what was originally a simple React component. In some cases it might be easier to wrap everything in <a href="https://github.com/buildo/react-placeholder">React Placeholder</a>, since that API is much more manageable and predictable. But for edge cases, it might be best to develop an in-house solution.</p><p>This is even more apparent when you’re integrating more than one kind of “state” for your placeholder. The above example only considers the “data” and the “loading” states—essentially a binary “yes, data is here” or “no, data isn’t”. Just two data states, and it takes what was originally three lines (the &lt;Link /&gt; tag sandwich) and blows it up it like an aggressive patch of kudzu.</p><h4>…that might be a nightmare to debug</h4><p>And whoever has to untangle the ruthless knots and twigs and vines of your kudzu code has to know react-transition-group (or insert placeholder library here) on a deep level.</p><h4>Change the component? Change the placeholder, too</h4><p>This might go without saying, but if you decide to introduce skeleton screens or something similar on your platform, make sure everyone’s on board and is comfortable with authoring parallel changes between component style and placeholder style. But this may not provide to be a huge problem. If the placeholder kinda, sorta, “yeah maybe” looks like the actual component <em>when you’re squinting</em>, then you’re fine.</p><h4>You may have to manually manage element dimensions</h4><p>The above example requires adding a bunch of empty &lt;span /&gt; tags, and without any content, those elements have no height. If the end goal is having a 1:1 correspondence between your loading states and your components, you should have a pretty solid idea of e.g., how tall the text tags will be, the precise dimensions of images, the average paragraph length, among other things. The implementation on Gronda has a dynamic number of “words” for each placeholder paragraph, but we had to figure out at a later moment that the placeholder&lt;span /&gt; height had to be in the 8–12 pixel ballpark range. If you’re unsure, you may be making some guesses here and there about e.g., the average length of a string, which in turn might affect how far you transform: translateY(...).</p><h4>Animation (unsurprisingly) adds another layer of complexity</h4><p>Our implementation of the User Avatar loading state is a relatively positioned div that has the placeholder div absolutely positioned inside it. If the structure of your components is sensitive to HTML semantics, then you might have to deeply consider whether the “overhead” of having an intercalating layer is worth it. (Some instance I can think of off the top of my head include the accessibility side effects of having a ul &gt; div.transition-layer &gt; li kind of hierarchy. Or animating &lt;table/&gt; rows. But again, YMMV.)</p><p>Be sensitive to the engine you’re working on as well! Sometimes the Blink engine might not save the last frame of a transition asynchronously, or maybe the Webkit engine might render a transition that’s too choppy.</p><h4>Unanimated skeleton screens are truly from beyond the grave</h4><p>Without any signs of motion or behavior, skeleton screens reflect the very same biological detritus it was named after. Unanimated skeleton screens don’t inform the user much with regards to the loading process: Is the website broken, or loading? Remember, the main goal is to reduce the perceptive wait time. And by bringing in the best parts of progress bars and loading spinners — that dynamic movement translates to “hold on just a moment” — we introduce something not too unfamiliar with user experiences.</p><p>Let your placeholder components breathe. Give them a pulsing animation. Cycle the opacity between 0.85–1. Our pulsating User Avatar placeholder has CSS keyframes similar to this:</p><pre>from, to { transform: scale(1); }<br>25% { transform: scale(1.15); }</pre><p>Paired with a nice cubic-bezier transition curve, and by biasing the maximum scaled size closer to one end (instead of at 50%), we paint an animation replicating a human heartbeat—a pattern of nature imbued with the eloquence of the Golden Ratio and with the simplicity of 2 lines of CSS.</p><p>Plus, it’s pretty too.</p><h4>Accessibility</h4><p>Other-abled users who use screen readers may require some kind of ARIA-flavoring inside your placeholder components. Season them with some combination of aria-disabled={true} and aria-label=&quot;loading&quot; or something or other. I’m sure there are better ways to accomplish this, so feel free to comment any kind of recommendations you have!</p><h4>The jury is still out on its effectiveness</h4><p>An interesting article from <a href="https://www.viget.com/articles/a-bone-to-pick-with-skeleton-screens/">Viget</a> raises a firm eyebrow on the effectiveness of skeleton screens; their hard data suggests that skeleton screens may perform <em>worse</em> for perceived loading time than a loading spinner or a blank screen. Some users in <a href="https://twitter.com/smashingmag/status/958287570315763712?lang=en">this Twitter thread</a> voice concern saying that the science isn’t sound, citing small sample size, lack of variation of screens, among other complaints.</p><p>At best, skeleton screens can really help reduce the imagined amount of time a user has waited for their data. But at worst, pouring development time into React-based loading screens might be an exercise in futility. Nothing beats user testing when deciding to go down the beaten path of loading spinners or the road “less traveled” (ha, who am I kidding?) with skeleton screens.</p><h3>The bottom line</h3><p>Experiment a little. Plan a sprint to just implement skeleton screens for one of your website’s/app’s pages. Increase the usability of your website. Cry a little bit when your placeholder animations aren’t cooperating. And if it turns out that this solution isn’t for your team, then so be it. The web is evolving. The bottom line is to make sure your users’ experience isn’t bone dry.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c676ccce484" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gronda/the-illusion-of-speed-loading-states-with-react-1c676ccce484">The Illusion of Speed: Loading States with React</a> was originally published in <a href="https://medium.com/gronda">Gronda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>