<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Seth Corker</title>
    <description>The latest articles on Forem by Seth Corker (@darthknoppix).</description>
    <link>https://forem.com/darthknoppix</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F143663%2Fcc30232f-654f-4c00-84c1-bdd186a81ea1.jpeg</url>
      <title>Forem: Seth Corker</title>
      <link>https://forem.com/darthknoppix</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/darthknoppix"/>
    <language>en</language>
    <item>
      <title>How to organise React components</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Sun, 17 Jan 2021 14:45:26 +0000</pubDate>
      <link>https://forem.com/darthknoppix/how-to-organise-react-components-5d8k</link>
      <guid>https://forem.com/darthknoppix/how-to-organise-react-components-5d8k</guid>
      <description>&lt;p&gt;React’s popularity was its ease of use, it didn’t tell you where to put anything which made it easier than frameworks like Angular which had an expectation of your apps structure and dictated it more forcibly. This is also one of the hidden complexities of React, you can easily add it to your project, and it starts simple, but you’ll see pretty quickly that without some guidelines on where components and supporting files should be placed, it can get messy fast.&lt;/p&gt;

&lt;p&gt;Here’s a common approach I used when I started writing React, organisation by type. Then, I’ll show you what I moved toward as projects grew. It’s a simple technique that allows for a nice developer experience as projects inevitably grow. First, let’s see why this problem exists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why React is great and why React is terrible
&lt;/h2&gt;

&lt;p&gt;As a developer, the appeal of React was its position within the context of Model-View-Controller architecture. Originally, it was the “View”. Handle your business logic and domain modelling however you like and pass it to React to display it. This made it effortless to adopt because you didn’t have to change what you were doing too much. You could bring your own models and controller layer. React is still very much a library rather than a framework. This is its biggest strengths, but it’s also a weakness when it comes organisation.&lt;/p&gt;

&lt;p&gt;React doesn’t define any conventions on where your components should go or how they should be organised within a larger system. This is a freedom the developer has to decide. This freedom can be terrifying for new developers. There is no right answer, so you get fragmentation of best practices.&lt;/p&gt;

&lt;p&gt;I’ll show you two approaches to organising React components, this isn’t specific to just React and will work with many other component-based libraries and frameworks. There are tradeoffs with both approaches, as there always is, and it may not suit everyone’s taste, but it’s what I’ve found to be useful working on many different projects over the years. Let’s jump into the first approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with organising by type
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EywdgouW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/static/e792c6c152d4e6119928c1a2d242df1f/b70ce/by-type.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EywdgouW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/static/e792c6c152d4e6119928c1a2d242df1f/b70ce/by-type.png" alt="Screenshot of VSCode filesystem showing organisation by type" title="Screenshot of VSCode filesystem showing organisation by type"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Organising components by type is a common approach to take and why wouldn’t it be? We’ve been doing it since React’s inception. Even the maintainers of React have recommended separation by containers and components. Ruby on Rails developers are familiar with the standard hierarchy and scaffolding that maps perfectly from filesystem to Model-View-Controller. It’s obvious where each type of file needs to go. Organising by type works well for small projects. With a few components, you’re not going to get lost, and it’s easy to keep track of everything. Let’s take a look at how we might organise files in a React app when organising by type.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does it work?
&lt;/h3&gt;

&lt;p&gt;The reasoning behind organising by type is that everything that’s similar should live in the same place. Your React components should live in a &lt;code&gt;components&lt;/code&gt; folder. Tests, in a &lt;code&gt;tests&lt;/code&gt; folder. CSS styles, in a styles folder and so on. Sometimes there might be some changes to this structure if you’re using CSS-in-JS solutions or opting for tests closer to the component than the top-level directory but, for the most part, this structure can be seen in many React projects. Once you have more than 10 components, things might start to get more challenging. At larger sizes, it can be overwhelming.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why it can be problematic
&lt;/h3&gt;

&lt;p&gt;The biggest challenges I’ve faced when working with structures like this become apparent as a project grows. In the beginning, it’s great. You know where everything goes, every component, container, stylesheet and test has its place. As time goes on and the project grows, it becomes more challenging to work with individual components.&lt;/p&gt;

&lt;h4&gt;
  
  
  Developer experience and scaling is impacted
&lt;/h4&gt;

&lt;p&gt;Let’s say you want to edit a button component. Open the component’s file and start editing away. Then you need to edit your styles, so you also navigate to your styles folder, find the button and open that. Now the component is updated, the tests are broken and some stories need to be updated. You navigate to those respective folders and open &lt;code&gt;tests/button.test.js&lt;/code&gt; and &lt;code&gt;stories/button.story.jsx&lt;/code&gt; too. What happens when you now want to open up the components that consume the button and make changes to them too?&lt;/p&gt;

&lt;p&gt;When organising components by type, I often find myself bouncing back and forward in different files in different places to get changes made. I don’t want to close certain files because I might need to navigate back to them again, so I just end up with a cluttered workspace with a multitude of tabs open in my editor. In this example it’s not so bad but as the level of nesting grows, it can become challenging to find what you need. At that point, it’s often easier to search for files and ignore the structure in day-to-day development completely.&lt;/p&gt;

&lt;h4&gt;
  
  
  What am I missing?
&lt;/h4&gt;

&lt;p&gt;An issue arises when components don’t all have the same files associated with them. Your standard components might have stories, styles, tests and the component itself but what if it doesn’t? It’s not easy to figure out at a glance. Did you notice the screenshot I included is missing a test? Maybe, what if there were 10 components or 100? You have to rely on other tools or investigation to figure out the dependencies for your components. If a test is missing, it’s not obvious.&lt;/p&gt;

&lt;h4&gt;
  
  
  Where do I put it?
&lt;/h4&gt;

&lt;p&gt;What happens when you decide there’s some component logic that only relates to your header component, and you want to break it out into an utils file? The current structure doesn’t allow for this. The obvious thing to do is create a new top-level folder called utils. So let’s do that. We’ve made a new &lt;code&gt;utils/header.js&lt;/code&gt; file, but we’ve also made a commitment to where files go in the future. We’ve created a signal for other engineers who will continue to expand on this concept and maybe even break up existing components to meet this new structure. This exacerbates the problem I mentioned earlier, not all components will share the same dependencies and knowing this involves manual investigation. It’s clear where to put files when the folder already exists but it’s unclear what warrants a new folder’s creation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Components are movable
&lt;/h4&gt;

&lt;p&gt;Organising files by type makes it more awkward to move components within the project or to pull them out. You have to go through and find the dependencies for a component that live in very different places across the filesystem, update the dependencies and hope you didn’t miss anything. Your imports are often predictable but lengthy and a chore to change. It’s not a big deal as refactoring the location of components is unlikely to happen often but when it doesn’t, it can be error prone.&lt;/p&gt;

&lt;p&gt;So what’s a better approach as a project scales?&lt;/p&gt;

&lt;h2&gt;
  
  
  Organising components by locality
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gdC0ew25--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/static/f044776b79896c9bc36ef7bd16b99b3d/b70ce/locality.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gdC0ew25--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/static/f044776b79896c9bc36ef7bd16b99b3d/b70ce/locality.png" alt="Screenshot of VSCode filesystem showing organisation by locality" title="Screenshot of VSCode filesystem showing organisation by locality"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How does it work?
&lt;/h3&gt;

&lt;p&gt;Organising by locality is an extension of encapsulation. Everything that a component relies on lives as close to the component as possible. This makes it easy to see the dependencies of a React component because the named folder contains the component itself alongside tests, utils, stories and styles. The names chosen, include the component name, the type of file it is and the extension.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why I like this folder structure for components
&lt;/h3&gt;

&lt;p&gt;There are many ways to organise components in React and other component-based libraries. This one is one of my favourites because I find it the most flexible. It can start of simple and grow as your project grows. It’s easy to use and offers a nice developer experience.&lt;/p&gt;

&lt;h4&gt;
  
  
  It’s clear what’s missing
&lt;/h4&gt;

&lt;p&gt;When organising by type, it’s not immediately obvious if there is a test or style associated with each component. When organising by locality, it’s obvious. If a component doesn’t have an associated test, stylesheet or story, looking in a single place tells us. Adding these files is easy too, it all happens in the same place.&lt;/p&gt;

&lt;h4&gt;
  
  
  Scaling is easy
&lt;/h4&gt;

&lt;p&gt;Adding a new component is easy. Create a folder with the component name and add your supporting files. As your project grows, these component folders can begin to take on different shapes depending on requirements. A button component might start off being enough but eventually requires different components or styles for different purposes. You could extend this structure without breaking the core organisation principle. All the variants of the buttons are still buttons and have coupling with styles and tests, so they can all live within the same hierarchy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nx9wqbRA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/static/f69cfb3893391b13406f83eb24195e2f/b70ce/button-variants.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nx9wqbRA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/static/f69cfb3893391b13406f83eb24195e2f/b70ce/button-variants.png" alt="Screenshot of VSCode filesystem showing additional variants for a button" title="Screenshot of VSCode filesystem showing additional variants for a button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This gives developers more flexibility when needed, a component can be as simple or complex as it needs to be while still following a consistent structure. If one component needs different stylesheets depending on use, it can have them and the complexity is contained within the component’s domain. If you need an utils file just for one component, you can add it to just that component’s folder without any obligation to keep adding utils for components that don’t need them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Components are movable
&lt;/h4&gt;

&lt;p&gt;As you project grows, these components can be moved around easily. If your supporting styles, and utils are imported using relative imports, it doesn’t matter where the component folder moves to. The references won’t change. Likewise, your stories and tests can import the files under test using relative imports too. There’s no need to follow paths throughout your codebase trying to corral the various spread out dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoiding index.js
&lt;/h2&gt;

&lt;p&gt;In both approaches, I got rid of one of the most annoying issues, &lt;code&gt;index.js&lt;/code&gt;. It’s common to find widespread usage of &lt;code&gt;index.js&lt;/code&gt; in projects to clean up file paths when importing projects and to act as an entry point for a particular folder. In practice, this can be a pain. Navigating through definitions and landing on an &lt;code&gt;index.js&lt;/code&gt; means another layer of indirection. You end up importing and exporting files from these files to make a nicer public interface for consuming components and there’s nothing worse than looking at your editor trying to find a file when everything is called &lt;code&gt;index.js&lt;/code&gt;. This is also why both approaches include the component name as the prefix followed by the intent of the file and ending in an extension. This is more easily searchable across the codebase and helpful when editing multiple files to avoid confusion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extending this approach
&lt;/h2&gt;

&lt;p&gt;It can be difficult to find the right structure for your project. There may be things you don’t like and that’s okay. Change it. Organising by locality can be combined with organisation by type when necessary too. This helps with certain frameworks like Next.js where you might want to keep your pages directory, business logic and components separate. It can be applied to atomic design philosophy where your components folder could contain atoms, molecules and organisms. Then within each of those divisions, lives the component folder.&lt;/p&gt;

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

&lt;p&gt;Organising components by locality is my favourite approach so far. It’s flexible and scalable. It offers a nice developer experience and isn’t difficult to transition to. Organising by locality creates clear boundaries around components which can be useful when you simply want to transplant your components into its own component library. If it doesn’t work for you, expand upon it and combine it with what you need. Every team works differently and projects can benefit from different styles of organisation that better suit the teams that work on them. In the end, it doesn’t matter how you choose to organise your React app, as long as you choose something.&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>First Code Component in Framer Web</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Thu, 03 Dec 2020 18:42:23 +0000</pubDate>
      <link>https://forem.com/darthknoppix/first-code-component-in-framer-web-gkp</link>
      <guid>https://forem.com/darthknoppix/first-code-component-in-framer-web-gkp</guid>
      <description>&lt;p&gt;Hi all 👋,&lt;/p&gt;

&lt;p&gt;If you like creating prototypes with Framer Web and want to achieve more complex interactions, this is the tutorial for you! I've worked on this short tutorial series to help you understand code components in Framer Web. This is the beginning of that journey.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/cbYOSD9DMvw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  ❓ What we'll make
&lt;/h2&gt;

&lt;p&gt;Throughout the series, we'll be making some screens you might see in a mobile banking app. The code components we'll build together in this part is a line item and bar chart. We'll build these in code and then put them onto the canvas like any other component.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔨 Why is it useful
&lt;/h2&gt;

&lt;p&gt;Framer Web is a great prototyping tool but it can be even better when you know a little bit of code. I'll help you take the first step. If you've coded a little bit, this will be a breeze. If you're a professional web developer or have React knowledge then you'll see how you can leverage your existing skills in Framer Web. &lt;/p&gt;

&lt;p&gt;We’ll cover the basics of a React component, styling your components in JSX and how to leverage default props all within the context of Framer Web. The skills you learn here are applicable to React apps too. You can take your prototypes from Framer Web into code and that’s just what we’ll be doing throughout the series.&lt;/p&gt;

&lt;h2&gt;
  
  
  🗺️ Where to go from here
&lt;/h2&gt;

&lt;p&gt;The skills you learn here are applicable to Framer Web but they're also many of the same skills you'll need if you want to create React components. I even show you how to go beyond Framer Web and take your project into a separate code project. This makes handoff to other developers easy and will help you build better collaboration between design and engineering.&lt;/p&gt;




&lt;p&gt;I hope you found this useful and can't wait to see what you create! If you're new to Framer Web, give it a shot. If you're a long time user, I hope this is useful for trying something new.&lt;/p&gt;

&lt;p&gt;🙌 &lt;strong&gt;Thanks for reading and watching!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>framer</category>
      <category>typescript</category>
      <category>react</category>
    </item>
    <item>
      <title>GROQ vs. GraphQL?</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Thu, 03 Dec 2020 12:17:57 +0000</pubDate>
      <link>https://forem.com/darthknoppix/groq-vs-graphql-21io</link>
      <guid>https://forem.com/darthknoppix/groq-vs-graphql-21io</guid>
      <description>&lt;p&gt;&lt;a href="https://www.sanity.io/docs/overview-groq"&gt;Sanity CMS supports query language called GROQ&lt;/a&gt; but you can also query data with GraphQL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/26gR0YFZxWbnUPtMA/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/26gR0YFZxWbnUPtMA/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This got me thinking, what does GROQ give me that GraphQL doesn't. I'm interested in hearing your thoughts if you've used one, the other or both! What's the deal with GROQ?&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What's your experience of GROQ and is there a reason to use it over a plain GraphQL query?&lt;/strong&gt;  &lt;/p&gt;

</description>
      <category>discuss</category>
      <category>sanity</category>
      <category>cms</category>
      <category>graphql</category>
    </item>
    <item>
      <title>ABCs for Web Developers</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Tue, 01 Dec 2020 20:31:25 +0000</pubDate>
      <link>https://forem.com/darthknoppix/abcs-for-web-developers-bc4</link>
      <guid>https://forem.com/darthknoppix/abcs-for-web-developers-bc4</guid>
      <description>&lt;p&gt;For the holiday season I thought I'd do something a bit different. Why not make a ABCs website for web developers?&lt;/p&gt;

&lt;h2&gt;
  
  
  What is this?
&lt;/h2&gt;

&lt;p&gt;In the style of alphabet learning books of childhood, ABCs for Web Developers has a little rhyme and web technology associated with it. Over the next 25 days I'll be adding a new letter to the website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;This is a bit of fun, not to be taken too seriously. There are lots of great technologies that I could have chosen for each letter but I'm limiting it to just one. Let's see what happens next year, until then I hope you enjoy.&lt;/p&gt;

&lt;p&gt;Stay up to date with the rest of the letters, I'll add one daily until the 26th of December.&lt;/p&gt;

&lt;p&gt;Watch the videos or visit the link to see the original web version.&lt;/p&gt;




&lt;h1&gt;
  
  
  A is for Angular
&lt;/h1&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/czRgWTsYSjM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://abcs-for-web-developers.sethcorker.com/2020/a"&gt;View the web version of A&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  B is for Babel
&lt;/h1&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/RLIFI7oqd1w"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://abcs-for-web-developers.sethcorker.com/2020/b"&gt;View the web version of B&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  C is for CSS
&lt;/h1&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ESxP6KhXDvo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://abcs-for-web-developers.sethcorker.com/2020/c"&gt;View the web version of C&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  D is for div
&lt;/h1&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZLCdYFB3_pE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://abcs-for-web-developers.sethcorker.com/2020/d"&gt;View the web version of D&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Check back daily for the next one in the series.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>showdev</category>
      <category>coding</category>
      <category>react</category>
    </item>
    <item>
      <title>Animate Styled Components with Framer Motion!</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Mon, 30 Nov 2020 07:43:36 +0000</pubDate>
      <link>https://forem.com/darthknoppix/animate-styled-components-with-framer-motion-2202</link>
      <guid>https://forem.com/darthknoppix/animate-styled-components-with-framer-motion-2202</guid>
      <description>&lt;p&gt;I love Framer Motion because it's a library that's easy to use and powerful. I've created page transitions within &lt;a href="https://blog.sethcorker.com/shared-layout-page-transitions-nextjs-framer-motion"&gt;Next.js&lt;/a&gt; and cool &lt;a href="https://blog.sethcorker.com/react-animation-tap-to-expand"&gt;interactions like tap to expand&lt;/a&gt;. It's a very versatile library for animation in React and it's not just limited to building from scratch.&lt;/p&gt;

&lt;p&gt;If you're using a CSS-in-JS library then it might not be immediately obvious how to integrate Framer Motion smoothly but once you know, it's as easy as 🥧.&lt;/p&gt;

&lt;p&gt;Watch this short tutorial on how you can add animations and gestures like drag, to an existing UI library built on top of &lt;a href="https://styled-components.com"&gt;styled-components&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/sKmV2FV-krY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The core concepts
&lt;/h2&gt;

&lt;p&gt;Here's a quick reference to help you out!&lt;/p&gt;

&lt;h3&gt;
  
  
  Turning a styled-component into something animatable
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;as&lt;/code&gt; prop and specify &lt;code&gt;motion.div&lt;/code&gt; or another &lt;code&gt;motion.&amp;lt;some html element&amp;gt;&lt;/code&gt; to start using Framer Motion for that component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyComponent&lt;/span&gt; &lt;span class="na"&gt;as&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Animating it's as easy as adding the &lt;code&gt;animate&lt;/code&gt;, &lt;code&gt;transition&lt;/code&gt;,  and other props you're used to adding directly to motion elements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Making your own styled-components and integrating with Framer Motion
&lt;/h3&gt;

&lt;p&gt;Define your styled component but instead of passing an html element as the first argument, give it a motion element instead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyCustomComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;`
  width: 2rem;
  background-color: tomato;
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need to add drag functionality? Simply pass in the prop when you use it!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyCustomComponent&lt;/span&gt; &lt;span class="na"&gt;drag&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyCustomComponent&lt;/span&gt; &lt;span class="na"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;It's as easy as that. If you use styled-components to build your React apps then I hope you this helps you develop rich experiences with animation and interactivity without the hassle. Framer Motion is my favourite library for tinkering with animations and it's versatile enough to be used with a variety of different frontend technology.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Want to &lt;a href="https://github.com/React95/React95"&gt;create something cool in React95&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;Check out &lt;a href="https://www.framer.com/motion/"&gt;Framer Motion for animating React components&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Learn more &lt;a href="https://blog.sethcorker.com/scroll-animation-with-framer-motion"&gt;cool animations you can achieve including animations on scroll&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>framermotion</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How it feels to write a web page from scratch in 2020</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Sun, 29 Nov 2020 16:39:04 +0000</pubDate>
      <link>https://forem.com/darthknoppix/how-it-feels-to-write-a-web-page-from-scratch-in-2020-4bl2</link>
      <guid>https://forem.com/darthknoppix/how-it-feels-to-write-a-web-page-from-scratch-in-2020-4bl2</guid>
      <description>&lt;p&gt;In a world of build tools and web frameworks, it’s not often you just sit down and code a webpage from scratch. No CSS framework. No auto-prefixing. No webpack config or dependency manager. No intermediary steps involved. Not even a line of JavaScript. Just me, my editor, my browser and the raw materials of the modern web. It’s been a serene experience that feels unfamiliar in 2020.&lt;/p&gt;

&lt;p&gt;I’m a software engineer living and working in London. In my daily work my primary tools for the web are React, Next.js, GraphQL and Emotion for CSS. In my personal projects, I often play around with different technologies like Gatsby, Svelte and whatever else looks interesting at the time. I don’t often get the chance to write plain HTML and CSS. It’s not that I avoid it but it just never seems to be part of my workflow like it once was. I decided to take a step back and start a project with the core building blocks of the web, it’s been a novel experience.&lt;/p&gt;

&lt;p&gt;When you get used to something like React, it becomes comfortable, it becomes the de facto tool for the job. Need a new blog? Use Gatsby. Want a marketing site? I’ll use Next.js. Need styling for a quick admin interface? Take your pick of CSS frameworks and/or component libraries. There’s a plethora of choices, a tool for every job that all fits into the React ecosystem and more broadly, the ecosystem of the web. To ignore that for a moment, however brief, is a breath of fresh air. To forget all of it and go back to basics, to code like the early web, it’s liberating.&lt;/p&gt;

&lt;p&gt;So, why did I do it? I wanted to try out variable fonts and I didn’t need any reactivity, I just wanted to tinker with a static webpage. That’s why I avoided Create React App. I avoided all of the tools I’ve relied on over the past 5 years and just did it. This is what, I discovered along the way and a few reasons why you might want to give it a go every now and then.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--103lnTqm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d2cv9vdd7nbtfhpgawky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--103lnTqm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d2cv9vdd7nbtfhpgawky.png" alt="Blue CSS3 logo beside thumbs up" title="Blue CSS3 logo beside thumbs up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hand crafted CSS
&lt;/h2&gt;

&lt;p&gt;Before the explosion of JavaScript into the behemoth it is today, there were few things more contentious than CSS. A language that is loved and hated with equal measure. There have been many systems created to make CSS easier to wield like BEM, SMACSS and OOCSS. There are preprocessors that aim to add features and fix the flaws like LESS and SASS. Now with the rise of React, there are countless ways of including CSS in your app from simple imports to CSS-in-JS solutions.&lt;/p&gt;

&lt;p&gt;I left this all behind to hand-craft some CSS. Here’s what I learned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dev tools are wondrous
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aRNSn3vC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/toeqn5kj26t8hp43024q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aRNSn3vC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/toeqn5kj26t8hp43024q.png" alt="screenshot of editing box shadow in dev tools" title="Box Shadow editor in Chrome dev tools"&gt;&lt;/a&gt;Box Shadow editor in Chrome dev tools&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HCexPC3Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b14pont9l34jlztik3gj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HCexPC3Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b14pont9l34jlztik3gj.png" alt="screenshot of colour picker in dev tools" title="Colour picker in Chrome dev tools"&gt;&lt;/a&gt;Colour picker in Chrome dev tools&lt;/p&gt;

&lt;p&gt;Working in the browser’s dev tools is great. The developer tools from Firefox, Chrome and Safari are excellent. The best part is that they just come with browser. There’s nothing to find, add and configure unless you really want to. CSS is one of the primitives of the web and dev tools can make working with it a dream. My favourite feature is the ability to live edit your CSS with workspaces. Changes made in dev tools are synced with your project on your filesystem. It’s almost like an evolution of Dreamweaver for the modern era. You can inspect gradients, create box shadows without trying to remember which order values should be in and all from within the browser. It’s the ultimate WYSIWYG, there’s no guessing what your page will look like - you’re editing it live, zero delay.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/GkJX5MoHNvU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Vendor prefixes are becoming less relevant
&lt;/h3&gt;

&lt;p&gt;One downside of editing your CSS by hand is the lack of auto-prefixing. With every year and every new release of browsers, this is becoming less relevant. Browser support in a much better place than it was a few years back and the majority of what you need to do is supported. Jumping through hoops to get a nice developer experience with modern tooling feel antiquated when a great solution already exists. It might not meet all the needs of browser compatibility out of the box, but the experience is great and the feedback, instantaneous.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1WcURNo3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kgg2es2mage78iq95u03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1WcURNo3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kgg2es2mage78iq95u03.png" alt="Orange HTML5 logo beside hand gesturing small" title="Orange HTML5 logo beside hand gesturing small"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Artisanal HTML
&lt;/h2&gt;

&lt;p&gt;I’ve been writing React components for over 5 years now. Before that, I used to write a lot of HTML, a lot of CSS and a lot &lt;em&gt;less&lt;/em&gt; JavaScript. In the past, there was often a templating language that generated HTML. Templates with Ruby on Rails, ASP.NET or Pug. There was never a need to write HTML by hand for the majority of products I’ve worked on. So what was it like?&lt;/p&gt;

&lt;h3&gt;
  
  
  Wait, how do I do this again?
&lt;/h3&gt;

&lt;p&gt;It feels unfamiliar writing plain HTML again. Years of React has made me forget some of the differences between JSX and HTML. Writing &lt;code&gt;class&lt;/code&gt; instead of &lt;code&gt;className&lt;/code&gt; feels out of the ordinary. I had to delve into the recesses of my mind to remember the proper way to link a stylesheet; when you’re doing React, you’re often used to a transpile step and more likely to add CSS to the build chain. These little differences throw you off for a while as you re-acclimatise to that estranged markup language.&lt;/p&gt;

&lt;h3&gt;
  
  
  Separation of concerns
&lt;/h3&gt;

&lt;p&gt;The most refreshing thing about writing HTML from scratch and CSS from scratch is the separation of concerns. I miss it. Writing markup in one file and how it looks in another, loosely coupled with class names is great. The product I work on professionally uses Emotion, which means styling is added directly to the element and is pulled into the head of the document on build. It’s useful in some circumstances and isn’t as noticeable when hidden away in reusable components but it’s always present. When parsing code, looking at the semantic structure isn’t as easy when styles are essentially inlined for the majority of elements. Your markup, styles and logic are smooshed into a Frankenstien’s monster that we call a React component. There’s also a gap between what you write and what’s produced, a class name is automatically generated for each element so tracing a style from a production build back to the source can be challenging.&lt;/p&gt;

&lt;p&gt;A separate CSS file and HTML file make it easier to parse both files. It’s just more readable. It’s not necessarily the best method for a component based frontend but a lot of webpages, it works so well. There is some back and forward when inspecting classes in HTML and the implementation in CSS but it’s nothing that can’t be eased by using dev tools or a split editor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--POLQ8oMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nlh83tlzdjv417bw0k4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--POLQ8oMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nlh83tlzdjv417bw0k4o.png" alt="Yellow JS logo beside hand pointing" title="Yellow JS logo beside hand pointing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Zero JS
&lt;/h2&gt;

&lt;p&gt;I often don’t get a chance to just write a static web page, and if I do I often include JavaScript to add little enhancements here and there. As a daily React developer, my mind is constantly aware of where interactivity could be added. There’s often a need for interactivity and JS is the goto tool. For my experiment, I didn’t write a line of JavaScript. The most complex thing on the page is some stateless animations which are achieved with CSS. It’s useful to remember that CSS is a really powerful language. It may be difficult to master but once you have a good understanding of it, you can make web pages more interactive and feature rich. You can go a long way before JS is necessary.&lt;/p&gt;

&lt;p&gt;The most fun from not using CSS is the constraints it adds. Constraints make the most interesting decisions, they force you to think with the tools you have and push the boundaries further than you normally would. Setting myself an artificial constraint of not using JS was fun because it forced me to use CSS for animations and focus on the look and feel rather than functionality. You’re not tempted to add additional libraries because you can’t. You’re not attempting to manage state within a component because there is little to no state. Constraints give you a framework to work within, to the push the limits of and to embrace.&lt;/p&gt;

&lt;h2&gt;
  
  
  You should try it
&lt;/h2&gt;

&lt;p&gt;I don’t often get the chance to write HTML, CSS or plain JS in day to day life and I don’t think I’m alone. In my job, HTML is rarely written by hand because external requirements often mean that markup is generated by data. It’s generated by a CMS or piped into React components so it can be made interactive. There’s an expectation of compatibility because you’re serving a large audience with different devices and it has to work consistently across all of them. This results in CSS being generated rather than hand crafted. It’s safer. It’s more compatible. It’s more scalable. Your styles are auto-prefixed, to work with multiple browsers, deduped and minified for faster loading. JavaScript is often the result of a pipeline that starts with TypeScript and/or JSX. The source code makes its way towards something safer, more compatible and easier to maintain . It’s very rare to write JavaScript from scratch with no changes between the source we write and the bundle the client receives.&lt;/p&gt;

&lt;p&gt;Should you stop using modern tooling, throw caution to the wind and code like it’s 1999? &lt;em&gt;Probably&lt;/em&gt; not.&lt;/p&gt;

&lt;p&gt;Modern tooling gives us superpowers for manipulating the raw elements that make up the web but it’s a layer of abstraction. That’s not a bad thing. The modern approach to web development takes some of the tedium out of frontend development. It’s allowed us to move faster than ever before and create experiences which are feature rich and delightful to use on more devices than ever before. Having said this, sometimes it’s nice to have a break. Everything is a tradeoff and sometimes it’s nice to revaluate. It’s a breath of fresh air to just sit down and whip up a simple webpage without ever waiting for a build step. Never installing a package via npm. Having full control over the output.&lt;/p&gt;

&lt;p&gt;It takes away certain decisions like which package manager to use, how to bundle assets, which CSS-in-JS method is the best. It adds constraints. You’re not thinking of what package could solve a problem, you’re tinkering directly with the web and working with its quirks and limitations. It’s not bad or good, it’s just different. It harks back to times where we had different problems and different concerns.&lt;/p&gt;

&lt;p&gt;I challenge you to go out of your comfort zone and give it a go. See what it’s like to code from scratch in 2021, you might learn something new or gain an appreciation for how far we’ve come.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you enjoyed this and would like to read more articles like this as soon as they come out, &lt;a href="https://blog.sethcorker.com"&gt;check out my blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>browser</category>
      <category>opinion</category>
    </item>
    <item>
      <title>Page Transitions in Next.js with Framer Motion</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Mon, 16 Nov 2020 09:28:45 +0000</pubDate>
      <link>https://forem.com/darthknoppix/page-transitions-in-next-js-with-framer-motion-1e4i</link>
      <guid>https://forem.com/darthknoppix/page-transitions-in-next-js-with-framer-motion-1e4i</guid>
      <description>&lt;h2&gt;
  
  
  What we’re building
&lt;/h2&gt;

&lt;p&gt;I’ll help you start adding more delight to your Next.js app &lt;a href="https://blog.sethcorker.com/page-transitions-in-react-router-with-framer-motion" rel="noopener noreferrer"&gt;(or other React apps) with transitions between pages&lt;/a&gt;. We’re going to use the &lt;code&gt;AnimateSharedLayout&lt;/code&gt; component from the Framer Motion API to make pages blend between each other seamlessly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://next-page-transitions-framer-motion.sethcorker.com" rel="noopener noreferrer"&gt;See the demo&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;The web is a powerful platform that has a lot to offer. By adding seamless transitions between webpages, we begin to shift towards a more native feeling UI which delights user’s and brings your website or web app into a class of its own.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Next.js?
&lt;/h3&gt;

&lt;p&gt;Next.js is a popular framework for building web apps and for good reason. It builds upon React to offer a great developer experience. One of the most obvious features we’re leveraging is the built in routing. We’re going to build our transitions upon what’s already built in to Next. If you’d like to apply this technique to an existing project, it should be easy to do so.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Framer Motion?
&lt;/h3&gt;

&lt;p&gt;Framer motion is an easy-to-use library which can achieve our desired transition effect quickly and is powerful. It gives us the ability to mix a variety of different animation types and can be a good foundation for making your pages even more delightful for users. When combined with Next.js, it offers a rich user experience and developer experience that I love.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we need to start animating
&lt;/h2&gt;

&lt;p&gt;The two key ingredients are Next.js and Framer Motion. If you’re not using Next.js and instead are using another React router library, you’ll still get and idea of how this could fit in. It’s not exclusive to Next.js or Framer Motion, these are just two of my favourites that work well together. Feel free to mix and match.&lt;/p&gt;

&lt;h3&gt;
  
  
  About the project
&lt;/h3&gt;

&lt;p&gt;The project contains two pages which we will animate between. The elements that are not shared between pages will animate in while the elements that are shared will animate between pages instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Page transition tutorial
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqw41b4v92x36j19912pl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqw41b4v92x36j19912pl.png" alt="Features page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgdtrrv7wba4qf81b0ztv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgdtrrv7wba4qf81b0ztv.png" alt="Home page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Identify the elements that stay the same
&lt;/h3&gt;

&lt;p&gt;For our example we’re going to animate between two pages. The first page is a simple landing page with an image, a title, a paragraph and a button. Clicking on the button will navigate to our other page. A features page with the same title and image but it’s surrounded but other icons and feature descriptions.&lt;/p&gt;

&lt;p&gt;We can’t transition between all of these elements because they aren’t all on both pages. The title and image are the same so these are the most obvious candidates. The button looks like it could work but the text content differs, it’s possible with a bit of work to create something that looks passable but I’ll skip the layout transition for this element.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the AnimateSharedLayout to &lt;code&gt;_app&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The first step is to set and forget our &lt;code&gt;AnimateSharedLayout&lt;/code&gt; component. The component enables us to animate layout changes between different components and tell Framer which elements are shared and therefore should transition to the new state. To set this up, inside &lt;code&gt;_app&lt;/code&gt; we’ll import it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { AnimateSharedLayout } from "framer-motion";&lt;/code&gt; then wrap our &lt;code&gt;Component&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;_app&lt;/code&gt; looks like this. I’m using the Bulma CSS library and SASS along with FontAwesome icons. The &lt;code&gt;Component&lt;/code&gt; prop in the context of &lt;code&gt;MyApp&lt;/code&gt; is the whatever page we are currently on. In Next.js, this acts as a layout which is used across our pages. It’s especially useful for our purposes because we want to be able to animate seamlessly between all the pages in our app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../styles/theme.sass&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@fortawesome/fontawesome-free/css/all.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;AnimateSharedLayout&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;framer-motion&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pageProps&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AnimateSharedLayout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Component&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;pageProps&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AnimateSharedLayout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;MyApp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ve added &lt;code&gt;AnimateSharedLayout&lt;/code&gt; but nothing has changed, let’s turn our title and image elements into motion components.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using layoutId to setup the transitions
&lt;/h3&gt;

&lt;p&gt;On our first page, &lt;code&gt;index.js&lt;/code&gt;, let’s import the motion component from framer-motion, &lt;code&gt;import { motion } from "framer-motion";&lt;/code&gt;. This component allows us to turn normal html elements into animatable components. Usually, we’d add the &lt;code&gt;animate&lt;/code&gt; prop, so we can define the animation but the only thing we need for the transition is the &lt;code&gt;layoutId&lt;/code&gt; prop. It’s a string which will be unique across our app.&lt;/p&gt;

&lt;p&gt;Our title will go from this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title has-text-weight-bold is-1 is-size-2-mobile is-spaced"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  The only Todo App you'll ever need
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;
  &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title has-text-weight-bold is-1 is-size-2-mobile is-spaced"&lt;/span&gt;
  &lt;span class="na"&gt;layoutId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title"&lt;/span&gt;
&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  The only Todo App you'll ever need
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ll do the same with the figure element that wraps our image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;figure&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"image"&lt;/span&gt; &lt;span class="na"&gt;layoutId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"image"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Image&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/assets/task.png"&lt;/span&gt; &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"responsive"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;780&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;501&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;figure&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s replace the matching elements on our &lt;code&gt;features.js&lt;/code&gt; page too. When the page transitions from &lt;code&gt;/&lt;/code&gt; to &lt;code&gt;/features&lt;/code&gt;, framer will treat the elements on one page with the elements on the second page as the same if they share an identical &lt;code&gt;layoutId&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Try it out, and we’ll see the title and image moves smoothly across the screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  Completing the look with motion
&lt;/h3&gt;

&lt;p&gt;The approach is very cool because it allows us to go forward and back between pages and the transition works as expected. This is a good starting point, and we’ve achieved the core effect but I think it needs a bit more. Let’s finish the look off by utilising Framer Motion to add an intro animation to elements that aren’t shared across pages.&lt;/p&gt;

&lt;p&gt;For elements that are unique to a page, we’ll fade them in.&lt;/p&gt;

&lt;p&gt;Here’s an example of the subtitle on the index page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;
  &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"subtitle"&lt;/span&gt;
  &lt;span class="na"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a straightforward fade in animation that starts with an opacity of zero and animates to an opacity of 1 after a delay of 200ms.&lt;/p&gt;

&lt;p&gt;But what happens when the user first visits a page? Can we animate all elements in? With Framer Motion, yes we can. We can add the &lt;code&gt;animate&lt;/code&gt; prop to have an intro animation that will play when the user opens the page and this won’t affect the transition to the next page.&lt;/p&gt;

&lt;p&gt;Here’s our animation, a fade in with a slight scale up effect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;
  &lt;span class="na"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title has-text-weight-bold is-1 is-size-2-mobile is-spaced"&lt;/span&gt;
  &lt;span class="na"&gt;layoutId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title"&lt;/span&gt;
&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s see the final product:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/bUUsifAKQDM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to now?
&lt;/h2&gt;

&lt;p&gt;We’ve created some cool effects that really breath life into the app with pretty minimal effort for the developer. Framer Motion allows us to create these complex layout animations easily and without compromise. It’s easy to tweak how pages animate in or out as well as the transition between pages. I hope you’ve learned something new and will apply some of these techniques to your projects.&lt;/p&gt;

&lt;p&gt;The web is a platform that can do so much more than static webpages. As a platform for rich user experience, we have the opportunity to craft more imaginative user interfaces that really react to the user’s actions and exceed expectations. Animation through page transitions is one of the tools we have available to enrich experiences, and they’re easy with Next.js and Framer Motion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://next-page-transitions-framer-motion.sethcorker.com" rel="noopener noreferrer"&gt;See the demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Read more about how this works and more uses cases, &lt;a href="https://www.framer.com/api/motion/animate-shared-layout/" rel="noopener noreferrer"&gt;Framer Motion API: AnimateSharedLayout documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Find the &lt;a href="https://github.com/Darth-Knoppix/next-page-transitions-framer-motion" rel="noopener noreferrer"&gt;completed project repo on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Follow along and make your own adjustments with my &lt;a href="https://github.com/Darth-Knoppix/next-page-transitions-framer-motion/tree/starting-project" rel="noopener noreferrer"&gt;starter project repo on GitHub&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;If you enjoyed this and would like to learn more about Framer Motion or web development in React, check out my &lt;a href="https://blog.sethcorker.com" rel="noopener noreferrer"&gt;Benevolent Bytes blog&lt;/a&gt;. I also have a &lt;a href="https://www.youtube.com/channel/UCBZseZ5y5P8sK-87Kqj8MJQ" rel="noopener noreferrer"&gt;YouTube channel, Coding with Seth&lt;/a&gt;, where I make video tutorials to help you craft better web experiences&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>framermotion</category>
      <category>animation</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>How to animate scroll position in React</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Mon, 15 Jun 2020 08:53:46 +0000</pubDate>
      <link>https://forem.com/darthknoppix/how-to-animate-scroll-position-in-react-3fem</link>
      <guid>https://forem.com/darthknoppix/how-to-animate-scroll-position-in-react-3fem</guid>
      <description>&lt;h2&gt;
  
  
  What we’re animating in React
&lt;/h2&gt;

&lt;p&gt;I’ll walk you through how I created the following animation with Framer Motion and React. It’s shows an envelope which as you scroll down, a letter slides out before sliding down over the envelope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;See the &lt;a href="https://framer-motion-stories.sethcorker.com/?path=/story/framer-motion-scroll--letter"&gt;letter animation example in Framer Motion&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the iframe above isn’t working, you can also see &lt;a href="https://framer-motion-stories.sethcorker.com/?path=/story/framer-motion-scroll--letter"&gt;the letter animation example in Framer Motion here&lt;/a&gt;.We’re creating a simple effect where a letter looks like it’s being drawn from an envelope. The animation happens when scrolling up or down.&lt;/p&gt;

&lt;p&gt;If you’re looking for some more guides with examples of how to use Framer Motion, take a look at how you can &lt;a href="https://blog.sethcorker.com/spinner-animation-in-react"&gt;create a spinner loading animation&lt;/a&gt; or a &lt;a href="https://blog.sethcorker.com/react-animation-tap-to-expand"&gt;tap to expand animation&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to control animations on scroll with &lt;code&gt;useViewportScroll&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;useViewportScroll&lt;/code&gt; hook is one of my favourite features of Framer Motion. It allows us to control animations based on the scroll position.The way achieve this simple letter opening animation is by mapping time to the scroll position so when the scrollbar is at the top of the page, our animation is at the first frame.When the scrollbar is at the bottom of the page, our animation is at the last frame. Scrolling back up the page will reverse the animation.This is a simple effect but it’s possible to create complex animations and base them entirely on where the X and Y scroll position is.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do we use it?
&lt;/h3&gt;

&lt;p&gt;For our letter example, we are basing the animation on just the Y position so we just use the hook like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;scrollYProgress&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useViewportScroll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This hook returns &lt;code&gt;scrollY&lt;/code&gt;, &lt;code&gt;scrollX&lt;/code&gt;, &lt;code&gt;scrollYProgress&lt;/code&gt; and &lt;code&gt;scrollXProgress&lt;/code&gt;. I chose not to use &lt;code&gt;scrollY&lt;/code&gt; because I don’t really care about how many pixels we’ve scrolled down the page.I just want to know where we are in the animation from 0 to 100% complete that’s why I use &lt;code&gt;scrollYProgress&lt;/code&gt; which gives us a value between 0 and 1, then we transform that however we need to with the &lt;code&gt;useTransform&lt;/code&gt; hook below.&lt;/p&gt;

&lt;h2&gt;
  
  
  What &lt;code&gt;useTransform&lt;/code&gt; does and how to use it
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;useTransform&lt;/code&gt; hook is useful for transforming one value to another. What does this mean?It allows us to take our &lt;code&gt;scrollYProgress&lt;/code&gt; which is between 0 and 1 and get a different set of values like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;scrollYProgress&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useViewportScroll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scaleAnim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;yPosAnim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;What you’ll notice is that the first argument is &lt;code&gt;scrollYProgress&lt;/code&gt;, this is what we want to transform.The second argument is a series of numbers that we want to transform between. We know &lt;code&gt;scrollYProgress&lt;/code&gt; can be 0 at the minimum (we haven’t scrolled down the page at all) and 1 at the maximum (we reached the bottom of the page).So why do we use three values? Well, it’s because the animation we want to create has three distinct keyframes.So if look at his example for our Y position, &lt;code&gt;useTransform(scrollYProgress, [0, 0.4, 1], [0, -250, -100])&lt;/code&gt;, we are saying at the beginning Y position 0 should transform to 0. No change.When we are 40% down the page (0.4), the Y position should be -250px upwards. Finally, when we reach the end of the page, the Y position should be at -100px.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tip for using the &lt;code&gt;useTransform&lt;/code&gt; hook
&lt;/h3&gt;

&lt;p&gt;When you use the &lt;code&gt;useTransform&lt;/code&gt; hook this way, make sure you have the same number of input values as output values so if you need three keyframes then make sure you use two arrays of values as the second and third arguments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breakdown of the letter animation example
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The structure of the example
&lt;/h3&gt;

&lt;p&gt;Let’s walk through the example, I’ll breakdown the steps used to create letter animation and why certain decisions were made.I’m using CSS-in-JS to keep the style as close to the code as possible, you don’t have to do this and Framer Motion doesn’t demand you do it either.It’s possible to use CSS modules, plain old CSS or a combination of all the above.&lt;/p&gt;

&lt;h4&gt;
  
  
  Laying out the scene
&lt;/h4&gt;

&lt;p&gt;First, I created some high level components to match the mental model of what we’re trying to achieve. An envelope with a letter inside it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;letterSceneStyle&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Envelope&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Letter&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Envelope&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The style for the container div is to give us enough space to scroll. A larger height will make the animation slower because the user has to scroll more for it to reach 100%. I chose a comfortable speed/viewport size of &lt;code&gt;200vh&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;letterSceneStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;200vh&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Creating the envelope
&lt;/h4&gt;

&lt;p&gt;Now we get into how the animation works. The only prop the envelope accepts is &lt;code&gt;children&lt;/code&gt;, in our case. This is the &lt;code&gt;&amp;lt;Letter /&amp;gt;&lt;/code&gt;.A benefit of having the letter within the envelope is any animation we apply to the envelope will affect the letter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Envelope&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;ffLayer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setFfLayer&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;scrollYProgress&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useViewportScroll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scaleAnim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;yPosAnim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;zRotAnim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setFfLayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;envelopeStyle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;scaleAnim&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;yPosAnim&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;rotateZ&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;zRotAnim&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;frontfaceStyle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;zIndex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ffLayer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Open Me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We make extensive use of the &lt;code&gt;useTransform&lt;/code&gt; hook to transform &lt;code&gt;scrollYProgress&lt;/code&gt; into the values we need.In the case of &lt;code&gt;scaleAnim&lt;/code&gt;, we want it to start at 100% scale then get larger halfway through the animation and small at the end.We also move the envelope down the screen with &lt;code&gt;yPosAnim&lt;/code&gt; and perform a slight tilt with &lt;code&gt;zRotAnim&lt;/code&gt;. To hook up the animation, we simply use a &lt;code&gt;&amp;lt;motion.div/&amp;gt;&lt;/code&gt; component and set the &lt;code&gt;style&lt;/code&gt; prop.If any of the values change, we’ll see a smooth animation thanks to Framer Motion. There are a few other things we need to do to achieve the effect which isn’t immediately obvious.&lt;/p&gt;

&lt;h5&gt;
  
  
  What’s the &lt;code&gt;ffLayer&lt;/code&gt; state?
&lt;/h5&gt;

&lt;p&gt;The effect I wanted to achieve is a letter being pulled out of an envelope so &lt;code&gt;ffLayer&lt;/code&gt; is to keep track of the front face of the envelope. The reason we need this is so that after the letter is ‘pulled’ out, it can then slide down over the envelope.The &lt;code&gt;scrollYProgress&lt;/code&gt; is a motion value so we can add an &lt;code&gt;onChange&lt;/code&gt; handler to trigger the state change 50% though the animation.Once we are half-way though, we change the &lt;code&gt;z-index&lt;/code&gt; of the envelope front face so it will be behind the letter.&lt;/p&gt;

&lt;h5&gt;
  
  
  How does the button scroll cause a smooth scroll?
&lt;/h5&gt;

&lt;p&gt;As a way to showcase the animation, I added &lt;code&gt;&amp;lt;button onClick={() =&amp;gt; window.scrollTo(0, 1500)}&amp;gt;Open Me&amp;lt;/button&amp;gt;&lt;/code&gt; to the envelope to allow for a smooth scroll.This works by scrolling the page down 1500px. Just this alone &lt;em&gt;won’t&lt;/em&gt; give us the effect we need. The next step is to make sure we add the following CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;scroll-behavior&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;smooth&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Creating the letter
&lt;/h4&gt;

&lt;p&gt;The letter animation makes use of the same hooks we’re familiar with from before. This time we animate the scale and the Y position.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Letter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;scrollYProgress&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useViewportScroll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scaleAnim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;yPosAnim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollYProgress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;letterStyle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;scaleAnim&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;yPosAnim&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* The contents of the letter goes here */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Setup styles with CSS-in-JS
&lt;/h3&gt;

&lt;p&gt;The most important thing to achieve the envelope and letter effect are some basic styles before we apply the animation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Envelope Styles
&lt;/h4&gt;

&lt;p&gt;We set a defined with and height of the envelope and position it on the page. Notice, we always want to see the animation take place in the center of the screen regardless of where the user has scrolled to so we use &lt;code&gt;position: fixed&lt;/code&gt;.The front face style is very simple too. It just needs to be the same size as the envelope and have a &lt;code&gt;backgroundColor&lt;/code&gt; so it hides the letter while still inside the envelope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;envelopeStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;28rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;15rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fixed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;calc(50% - 14rem)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;boxShadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`rgba(0, 0, 0, 0.5) 0px 0px 150px 10px`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;frontfaceStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100%&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100%&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#debda1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;justifyContent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;alignItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Letter style
&lt;/h4&gt;

&lt;p&gt;The only important properties of the letter is the dimensions and position.The position is absolute so we can position it within the envelope. The size is also slightly smaller so it looks as though the letter fits within the envelope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;letterStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;calc(100% - 1rem)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;calc(100% - 1rem)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0.5rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0.5rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f8efd5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;boxSizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;border-box&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Where to go from here
&lt;/h2&gt;

&lt;p&gt;Although it’s a silly example, a letter coming out of an envelope, this is a good example to see how to take advantage of the capabilities Framer Motion offers.If you want a more practical application of &lt;code&gt;useViewportScroll&lt;/code&gt;, you could do one of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Show a progress bar of how far through someone is reading a webpage.&lt;/li&gt;
&lt;li&gt;Highlight headings in a sidebar depending on if they are reading that section or not.&lt;/li&gt;
&lt;li&gt;Have elements appear and disappear easily on scroll&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The possibilities are boundless, think of some cool ways you can orchestrate animations based on the scroll position.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.framer.com/api/motion/motionvalue/#useviewportscroll"&gt;&lt;code&gt;useViewportScroll&lt;/code&gt; on Framer Motion API docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.framer.com/api/motion/motionvalue/#usetransform"&gt;&lt;code&gt;useTransform&lt;/code&gt; on Framer Motion API docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://framer-motion-stories.sethcorker.com/?path=/story/framer-motion-scroll--letter"&gt;The letter animation example in Framer Motion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Darth-Knoppix/framer-motion-stories/blob/master/src/scenes/letter/index.js"&gt;The full source code for the letter example on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>animation</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What is Blitz.js?</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Mon, 25 May 2020 08:36:39 +0000</pubDate>
      <link>https://forem.com/darthknoppix/what-is-blitz-js-iem</link>
      <guid>https://forem.com/darthknoppix/what-is-blitz-js-iem</guid>
      <description>&lt;h2&gt;
  
  
  What is Blitz.js?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://blitzjs.com/"&gt;Blitz.js&lt;/a&gt; is a new framework that's built on &lt;a href="https://nextjs.org/"&gt;Next.js&lt;/a&gt;.It's positioned as a Rails-like framework, it's monolithic and focused on developer productivity while using the modern JavaScript tech you're used to.Although new, I'm watching Blitz.js as I believe it has great potential to refresh JS fullstack development, it looks like a great way to dive in without the hassle of decision fatigue and complicated configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does Blitz.js exist?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TnmI01DS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/okl8il5oaspumrjvskwi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TnmI01DS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/okl8il5oaspumrjvskwi.png" alt="illustration of woman in lotus pose hovering above yoga mat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Web development has evolved a lot over the past decade.There are more libraries and frameworks for JavaScript than ever before but there's been a trend to opt for smaller libraries, decoupling and microservices.These all have benefits but one of the tradeoffs is productivity. Blitz.js is a reaction to this, it want's to bring back the simplicity of the web with modern tooling.It takes some of the powerful tools you use today and packages them up into a nice and easy to work with bundle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Simplicity
&lt;/h3&gt;

&lt;p&gt;I enjoy the modern web. There's many ways to get things done the way you need to.You can choose the right libraries for your particular project and requirements.One critique of this however, is decision fatigue. With so many options, what do you choose?When starting a new project you will constantly make decisions about each and every library, tool and weight their strengths and weaknesses.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Should you make a SPA or use SSR?&lt;/li&gt;
&lt;li&gt;Will you use REST or &lt;a href="https://graphql.org/"&gt;GraphQL&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;How will you manage your state? Redux? &lt;a href="https://dev.toa-peek-at-state-management-with-mobx"&gt;MobX&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;What view layer do you want to use, React, Vue or maybe Svelte?&lt;/li&gt;
&lt;li&gt;How will the project be built? Webpack? Rollup?&lt;/li&gt;
&lt;li&gt;Which features of JS do I want to use and which babel plugins do I need to add?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These decisions are before you've written a line of actual application code, it's all setup.It's no wonder beginners can get overwhelmed and web veterans have can get disenchanted with the direction modern web development is going.Tools like Create React App are a reaction to this just like Blitz.js. The benefit is simplicity while maintaining the right to pick and choose.&lt;/p&gt;

&lt;h3&gt;
  
  
  Small companies
&lt;/h3&gt;

&lt;p&gt;A lot of existing libraries are created for large companies that have different problems to smaller companies.Sometimes it doesn't make sense to adopt certain technologies because they just don't solve the problems small companies are trying to solve.Technologies like GraphQL and frameworks like Relay or Apollo fit together to solve problems which you might only run into at large scale.Blitz.js looks to be your-go to tool until you need to scale.Even then, it's built on other technologies that are proven at scale so the leap might not even be that great.It's a foundation that grows with your needs when you need to grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why am I excited?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8KR0DrM7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/afih7k1zqw0zyr23h1s7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8KR0DrM7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/afih7k1zqw0zyr23h1s7.png" alt="illustration of person in jetpack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;em&gt;good&lt;/em&gt; old days of web development
&lt;/h3&gt;

&lt;p&gt;I started my career as a web developer redesigning and maintaining websites.During the early days I did everything by hand. The HTML was handcrafted, so was the CSS.What little JS which was added was mainly for a sticky header or some mobile optimizations.Once I had a version which was ready to deploy, I'd connect to the server over FTP and copy the files over.Where they simpler times? Probably. Was I more productive than I am today, not really.It may have been simpler but there was a lot of intensive processes around the code.Adding a header and footer to every page was manual, the changes to would require a massive find and replace across every HTML file.I never knew about source control so manual backups had to take place after every change.Over time, I evolved my process and new tools came out to make it easier to achieve.Copy and pasting header HTML was replaced with templating and a build step.I traded some additional complexity for developer productivity.Over time I integrated Gulp and Bower to ease minification, browser compatibility compilation of SCSS.Why am I telling you this? Everything in programming is a tradeoff and you need to find the right tradeoffs for the things you're building.I evolved over time as a developer and my tooling evolved too.Blitz.js looks like a way to bring back the simplicity you remember having with modern tools and the benefits that come with them.&lt;/p&gt;

&lt;h3&gt;
  
  
  My first fullstack experience
&lt;/h3&gt;

&lt;p&gt;My first foray into fullstack development was Ruby on Rails.The reason I chose it despite not knowing Ruby at the time was developer productivity.I needed to create something I had never done before, I needed a new approach because my cobbled together web tools only took me so far and I'd never worked with databases, an API or CRUD outside of the classroom.Despite the odds stacked against me, I managed to learn and be productive with Rails.It was batteries included and I owe it a lot.It was flexible enough to allow you to get stuff done and opinionated enough that made it easy to figure out the &lt;em&gt;right&lt;/em&gt; way to do it.&lt;/p&gt;

&lt;p&gt;This was a big contrast to my next job where React powered the frontend, the backend was a RESTful API with no ORM.There were benefits but there were also times I missed the simplicity of Rails.I thought of going back for side projects but I'm too invested in the JS ecosystem, that's where I'm most productive and I don't want to leave it behind. Blitz.js might be the best of both worlds.A different take on Rails for JS. It's Rails but with React built in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does Blitz.js have a future?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gQbzYqkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l1eg595p0um0w3mkpe3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gQbzYqkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l1eg595p0um0w3mkpe3w.png" alt="illustration of person holding a laptop while being lifted up by three arrows"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The JS ecosystem is vast and powerful, there is great tooling and libraries available to suit almost any need but the challenge comes in choosing these tools, configuring them correctly and combining them while being productive.Blitz.js does this work for you, the tools exist and they've been configured for you.What I think gives Blitz.js a good future is that it is built on what already exists.It leverages other ecosystems to thrive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next.js
&lt;/h3&gt;

&lt;p&gt;Next.js is a powerful framework in its own right. By leveraging this, Blitz.js can build on top of this solid foundation and get TypeScript support, routing, code splitting and more for free.As Next.js evolves, Blitz.js can too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prisma 2
&lt;/h3&gt;

&lt;p&gt;Blitz.js piggybacks off the work done by Prisma. Rails had a great ORM which I liked a lot, Prisma is step above that which allows for more flexible data modelling and is setup to work well with TypeScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  CLI
&lt;/h3&gt;

&lt;p&gt;My favorite feature of Rails is the CLI scaffolding.As a beginner to fullstack development, Rails made it easy to generate everything you needed to get an entire working MVC setup.With a single command a model would be created along with a controller and all the CRUD views you desired. The CLI is what brings everything Blitz.js has to offer, together in one easy to use place.&lt;/p&gt;

&lt;h3&gt;
  
  
  Community evolution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/blitz-js/blitz/blob/canary/MANIFESTO.md#7-community-over-code"&gt;Blitz.js has a manifesto&lt;/a&gt; which defines one of the most important tenants, &lt;a href="https://github.com/blitz-js/blitz/blob/canary/MANIFESTO.md"&gt;"Community over Code"&lt;/a&gt;.This is a simple idea but it's powerful, it sets the stage for a constructive community that learns from other communities rather than competing with them.Part of this commitment includes some transparent development practices, there already exists an &lt;a href="https://github.com/blitz-js/blitz/blob/rfc-architecture/rfc-docs/01-architecture.md"&gt;RFC for the Blitz App architecture&lt;/a&gt;.This means you can have a say in how Blitz.js evolves and what choices should be made.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is it ready for production?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XUtewYx_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v9wuwu8hd3c63nug67g4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XUtewYx_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v9wuwu8hd3c63nug67g4.png" alt="person in parachute steering"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No. Blitz.js still lacks maturity. It's early days so expect the APIs to change a lot.The documentation is limited but if you're brave though, Blitz.js utilizes existing tech so much that you'll probably be able to make something production ready with some extra time and effort.Nevertheless, I'm excited to see Blitz.js grow and evolve - I hope it can be the Rails for JS developers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Resources
&lt;/h4&gt;

&lt;p&gt;If you're interested in finding out more, take a look at some of the official places down below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/blitz-js/blitz"&gt;Blitz.js Repo on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/blitz-js/blitz/blob/canary/USER_GUIDE.md"&gt;User Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://www.manypixels.co/gallery/"&gt;Illustrations provided by ManyPixels&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Check out my blog, &lt;a href="https://blog.sethcorker.com/"&gt;Benevolent Bytes&lt;/a&gt; for more articles on web development and to &lt;a href="https://blog.sethcorker.com/what-is-blitz-js"&gt;read What is Blitz.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For more about web development, follow me, &lt;a href="https://twitter.com/Darth_Knoppix"&gt;Seth Corker (@Darth_Knoppix) on Twitter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>React devs, why did you start using React?</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Wed, 15 Apr 2020 10:53:33 +0000</pubDate>
      <link>https://forem.com/darthknoppix/react-devs-why-did-you-start-using-react-8gn</link>
      <guid>https://forem.com/darthknoppix/react-devs-why-did-you-start-using-react-8gn</guid>
      <description>&lt;p&gt;I started using React over 4 years ago because I was interviewing for a job where I would be using it for all new projects. Up until then, I'd mainly used jQuery, Ember and plain old JavaScript.&lt;/p&gt;

&lt;p&gt;Today, I still use React and I still enjoy it over the cumbersome mess of trying to build interactive apps with jQuery. I remember hours of frustration finding the root of bugs caused by manually keeping track of UI on the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/P2xf5nPyu5WP6/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/P2xf5nPyu5WP6/giphy.gif" alt="Buggs Bunny hammering a rock"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;It felt like banging my head against a brick wall, hoping to break through.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As a developer using React today, why did you start using it and what problem did React solve for you?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discuss</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>What's the biggest tech-stack change you've had?</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Sat, 11 Apr 2020 08:31:18 +0000</pubDate>
      <link>https://forem.com/darthknoppix/what-s-the-biggest-tech-stack-change-you-ve-had-4d94</link>
      <guid>https://forem.com/darthknoppix/what-s-the-biggest-tech-stack-change-you-ve-had-4d94</guid>
      <description>&lt;p&gt;For the past few years, I've been using C# and ASP.NET professionally. I got used to the way it felt. I became comfortable with the tools and the libraries to use in each situation. I invested in the ecosystem to learn more and be better at my job.&lt;/p&gt;

&lt;p&gt;A few months ago, I changed jobs. With a new job came a new tech-stack and it's wild. Today I'm using Python and maintaining a Django app. I haven't used Python since high school and I've never used it professionally until now. If you're familiar with both languages, you may know how different they are.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/11thnyggFkrmmc/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/11thnyggFkrmmc/giphy.gif" alt="Aladin and Jasmine, a whole new world"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Python is a joy to read compared with C# code. There are things I miss and gaps in knowledge where Python has evolved over the years. It's new and exciting, I feel like the change has helped inspire me again and take me out of my comfort zone.&lt;/p&gt;

&lt;h1&gt;
  
  
  What's the biggest tech-stack change in your career and what did you gain from it?
&lt;/h1&gt;

</description>
      <category>discuss</category>
      <category>python</category>
      <category>csharp</category>
      <category>career</category>
    </item>
    <item>
      <title>Making Magic in Framer Motion 2</title>
      <dc:creator>Seth Corker</dc:creator>
      <pubDate>Sat, 28 Mar 2020 18:12:15 +0000</pubDate>
      <link>https://forem.com/darthknoppix/making-magic-in-framer-motion-2-2ceh</link>
      <guid>https://forem.com/darthknoppix/making-magic-in-framer-motion-2-2ceh</guid>
      <description>&lt;p&gt;&lt;em&gt;This article has been updated to reflect API changes in Framer Motion 2.0.x Beta&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.framer.com/motion/"&gt;Framer Motion&lt;/a&gt; is my go-to animation library for React. &lt;a href="https://twitter.com/mattgperry"&gt;Matt Perry&lt;/a&gt;, the creator of the library and its predecessor Pose, has been tweeting about version 2 (still in beta at the time of writing) so I decided to check it out. It has some great new features I can't wait to use when it's released. Until then, let's take a look at one of my favourites - AnimateSharedLayout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I4OTuk84--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.sethcorker.com/content/images/2020/03/framer-motion-magic-expand-rec.2020-03-28-17_15_50.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I4OTuk84--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.sethcorker.com/content/images/2020/03/framer-motion-magic-expand-rec.2020-03-28-17_15_50.gif" alt="Making Magic in Framer Motion 2"&gt;&lt;/a&gt;An animation made with Framer Motion using the AnimateSharedLayout component (previously MagicMotion)&lt;/p&gt;

&lt;h3&gt;
  
  
  What is AnimateSharedLayout?
&lt;/h3&gt;

&lt;p&gt;Framer Motion is introducing a new component, &lt;code&gt;&amp;lt;AnimateSharedLayout /&amp;gt;&lt;/code&gt;. It allows for animating between components easily. Matt Perry's tweet illustrates a great usage of it here. The code is easy to understand and doesn't require a lot of setup to achieve.&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media ltag__twitter-tweet__media__video-wrapper"&gt;
        &lt;div class="ltag__twitter-tweet__media--video-preview"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0y0nCZLZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/ext_tw_video_thumb/1243538090221809666/pu/img/aIRzOVO8BiWKbyKg.jpg" alt="unknown tweet media content"&gt;
          &lt;img src="/assets/play-butt.svg" class="ltag__twitter-tweet__play-butt" alt="Play butt"&gt;
        &lt;/div&gt;
        &lt;div class="ltag__twitter-tweet__video"&gt;
          
            
          
        &lt;/div&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--yrLgV8tz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1001388766400049152/dsAMRQfa_normal.jpg" alt="Matt Perry profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Matt Perry
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="comment-mentioned-user" href="https://dev.to/mattgperry"&gt;@mattgperry&lt;/a&gt;

      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      🎩🐇In &lt;a href="https://twitter.com/framer"&gt;@framer&lt;/a&gt; Motion 2, a component can be given a magicId. When a new &lt;a href="https://twitter.com/reactjs"&gt;@reactjs&lt;/a&gt; component with the same magicId is added, it will appear to animate from the old one.&lt;br&gt;&lt;br&gt;It makes stuff like this underline animation as simple as a boolean. Here's the code: &lt;a href="https://t.co/qHCJRP8J3A"&gt;codesandbox.io/s/framer-motio…&lt;/a&gt; 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      14:08 PM - 27 Mar 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1243540350427332609" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1243540350427332609" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      69
      &lt;a href="https://twitter.com/intent/like?tweet_id=1243540350427332609" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      518
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;The &lt;em&gt;magic&lt;/em&gt; fits all with a few lines of code!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AnimateSharedLayout&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;framer-motion&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;selected&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setSelected&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MagicMotion&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ol&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;screens&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;
            &lt;span class="na"&gt;magic&lt;/span&gt;
            &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
            &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`title &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;selected&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;selected&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
            &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;selected&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#333&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
            &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;setSelected&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;selected&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
                &lt;span class="na"&gt;magicId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"underline"&lt;/span&gt;
                &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"underline"&lt;/span&gt;
                &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
              &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;ol&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;MagicMotion&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
Code sample from the Magic Motion underline menu demo





&lt;p&gt;Wrap the animation in MagicMotion (now AnimateSharedLayout) and assign a magicId (now layoutId) prop to the components you want to animate between. So let's jump into another example and I'll break it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Experimenting with AnimateSharedLayout in Framer Motion
&lt;/h2&gt;

&lt;p&gt;I decided to get a better idea of how this works and see what it can do by making my own experiment. The codesandbox is below to play around with. Click on the dates to show an expanded view.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/framer-motion-magic-expand-hwugd"&gt;
&lt;/iframe&gt;Calendar animation codesandbox shown in the title card animation
&lt;/p&gt;

&lt;p&gt;In version 1, this would require a bit more setup to get right and we would be limited to a single component to perform the animation. This new approach gives developers more flexibility as it allows for different components to be used. The transition can then be linked together with a global identifier.&lt;/p&gt;
&lt;h3&gt;
  
  
  How does it work?
&lt;/h3&gt;

&lt;p&gt;Two components make up the core of the interaction, &lt;code&gt;&amp;lt;ExpandedCard/&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;CompactCard/&amp;gt;&lt;/code&gt; they both contain &lt;code&gt;&amp;lt;motion.div/&amp;gt;&lt;/code&gt; components with the same &lt;code&gt;layoutId&lt;/code&gt; prop set to &lt;code&gt;expandable-card&lt;/code&gt;. Let's take a look at the components in their entirety.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;ExpandedCard&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onCollapse&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
        &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"card expanded"&lt;/span&gt;
        &lt;span class="na"&gt;layoutId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"expandable-card"&lt;/span&gt;
        &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onCollapse&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;
        &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"card expanded secondary"&lt;/span&gt;
        &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onCollapse&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;6rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Today is clear
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;CompactCard&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onExpand&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
      &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"card compact"&lt;/span&gt;
      &lt;span class="na"&gt;layoutId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"expandable-card"&lt;/span&gt;
      &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;onExpand&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
Code sample from a Framer Motion experiment





&lt;p&gt;The CSS for the two components defines the two states we want to animate between. The expanded card also contains some more information but we animate this separately so it doesn't just appear, instead, it slides in from the bottom.&lt;/p&gt;

&lt;p&gt;Transitioning between the two components is as easy as wrapping them in a &lt;code&gt;&amp;lt;AnimateSharedLayout /&amp;gt;&lt;/code&gt; component and conditionally rendering the one you want to show. The transition will be handled automgically like so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AnimateSharedLayout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isExpanded&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ExpandedCard&lt;/span&gt; &lt;span class="na"&gt;onCollapse&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;collapseDate&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;day&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;day&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="na"&gt;day&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;day&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ExpandedCard&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CompactCard&lt;/span&gt; &lt;span class="na"&gt;onExpand&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;expandDate&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;day&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;day&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="na"&gt;day&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;day&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;CompactCard&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AnimateSharedLayout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We store in state whether the component is expanded or collapsed and render either the &lt;code&gt;&amp;lt;ExpandedCard/&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;CompactCard/&amp;gt;&lt;/code&gt; respectively. When the component which is currently rendering changes, the layoutId ensures a transition happens between them. The key properties which are changing in the experiment are the corner radius, position, size and background colour.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.expanded&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;navy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;150%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.compact&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The expanded class is re-positioned and enlarged. The shape changes from a circle to a square with moderately rounded corners and from white to navy blue. There is also another trick we use to ensure the date within the card component animates too.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;Content /&amp;gt;&lt;/code&gt; component displays the day which changes colour depending on whether it is in a disabled, collapsed or expanded state. To ensure the transition happens, we assign a layoutId so even though we render different it in two different places, within a &lt;code&gt;&amp;lt;ExpandedCard/&amp;gt;&lt;/code&gt; or a &lt;code&gt;&amp;lt;CompactCard/&amp;gt;&lt;/code&gt;, framer-motion can handle the transition smoothly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;
      &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title"&lt;/span&gt;
      &lt;span class="na"&gt;layoutId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title"&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;day&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
The Content React component





&lt;p&gt;The disabled state is shown here using an inline style but CSS classes handle the expand and collapse states.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.title&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;navy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;800&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.expanded&lt;/span&gt; &lt;span class="nc"&gt;.title&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.compact&lt;/span&gt; &lt;span class="nc"&gt;.title&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
CSS for the Content component





&lt;p&gt;Framer Motion handles the colour transition and size change without any additional changes. &lt;code&gt;AnimateSharedLayout&lt;/code&gt; is a great addition to this already powerful animation library. It makes complex animations much simpler to implement in React and should allow more fluid transitions on the web which we are usually more accustomed to on native platforms. I hope this has whetted your appetite. If it has, take a look at how to get access to the beta version and start hacking.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use the beta version of framer-motion library
&lt;/h3&gt;

&lt;p&gt;At the time of writing, &lt;code&gt;2.0.0-beta.31&lt;/code&gt; is the latest version. (The article has been updated to work with beat 42)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SMVlUP0_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/content/images/2020/03/Screenshot-2020-03-28-at-16.27.20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SMVlUP0_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.sethcorker.com/content/images/2020/03/Screenshot-2020-03-28-at-16.27.20.png" alt="Making Magic in Framer Motion 2"&gt;&lt;/a&gt;Viewing the version history of framer-motion on npm&lt;/p&gt;

&lt;p&gt;You can specify the version you'd like to use in your &lt;code&gt;package.json&lt;/code&gt; like so and start hacking.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"using-framer-motion-beta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"16.12.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"16.12.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"3.0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"framer-motion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2.0.0-beta.31"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Should I use it?
&lt;/h3&gt;

&lt;p&gt;Framer Motion version 2 is still in beta, although it seems pretty stable it should be used with caution. The API is unlikely to change but don't go building something meant for production right away. I haven't encountered anything unexpected yet but I've only played around with the beta in a limited capacity. If you're interested in playing around with it right now and don't mind the lack of documentation then go ahead. Changes are likely to be minor between now and release and it's great to see what it's capable of right now. If you're looking for stability, stick with version 1 for now and wait for the official release.&lt;/p&gt;

&lt;p&gt;If you'd like to delve into more Framer Motion experiments, take a look at these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/darthknoppix/react-animation-tap-to-expand-57ga"&gt;React Animation: Tap to Expand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.sethcorker.com/page-transitions-in-react-router-with-framer-motion/"&gt;Page Transitions in React Router with Framer Motion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>react</category>
      <category>animation</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
