<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gavin Foster on Medium]]></title>
        <description><![CDATA[Stories by Gavin Foster on Medium]]></description>
        <link>https://medium.com/@gavinfoster?source=rss-77f320de6c92------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gE-Z6xClYm-nKucuKnI2xw.jpeg</url>
            <title>Stories by Gavin Foster on Medium</title>
            <link>https://medium.com/@gavinfoster?source=rss-77f320de6c92------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:49:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gavinfoster/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[React, Gatsby, & Wordpress Static Site: React Components in Gatsby (part 3)]]></title>
            <link>https://medium.com/@gavinfoster/react-gatsby-wordpress-static-site-react-components-in-gatsby-part-3-cea0cf4af9bc?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/cea0cf4af9bc</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[static-site]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[gatsbyjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Fri, 08 Mar 2019 05:06:39 GMT</pubDate>
            <atom:updated>2019-03-08T05:09:32.460Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn Gatsby conventions and React components</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YGhxLGaDfwekKdeA.jpg" /></figure><p>From our <a href="https://medium.com/@gavinfoster/react-gatsby-wordpress-static-site-gatsby-and-wordpress-setup-part-2-cf98235e465f">previous session</a>, we already have our dev environment setup with <a href="https://www.gatsbyjs.org/starters/GatsbyCentral/gatsby-starter-wordpress/">Gatsby WordPress Starter</a>. My site is going to be incredibly simple, just two pages, so we will trim everything else that we don’t need.</p><h4>Removing Everything Except Pages</h4><p>During the dynamic createPages() call i’m going to remove everything except the allWordpressPage section. Also for the page with a slug of <em>homepage,</em> I’m going to set it’s path to<em> </em><em>/ </em>so that it acts as the homepage (instead of only being seen at /homepage).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b79a8a6c34b1d14b686a2146e35c6be/href">https://medium.com/media/4b79a8a6c34b1d14b686a2146e35c6be/href</a></iframe><p>Note: We are also dynamically setting the page template path.resolve(&#39;./src/templates/${page.slug}.js to the page slug. Therefore, our homepage expects to use a template from /src/templates/homepage.js. Let’s make that template!</p><p>Before moving on though, our gatsby-config.js file should look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1bc8186b4c13414c96c67867f933880/href">https://medium.com/media/b1bc8186b4c13414c96c67867f933880/href</a></iframe><p>Also, please remove all the components and templates as well, since we will be starting from scratch.</p><h4>Creating Our First Template</h4><p>Now we will move on to create the homepage.js template that our homepage WordPress page will use. We’ll be making a graphql query in order to get the page data, and then use a react component to render the data.</p><blockquote><a href="https://www.gatsbyjs.org/docs/querying-with-graphql/">Brush up</a> 🖌on some graphql. It can definitely take some getting used to!</blockquote><p>Our basic template will be a stateless component that has access to page via the data prop. We export the Page component that we have created, along with our graphql query.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2d3331558179686181dbeb9ad96d3c2/href">https://medium.com/media/c2d3331558179686181dbeb9ad96d3c2/href</a></iframe><p>Graphql is verbose, but the nice thing is that one look at my query and you know exactly how the WordPress page data is structured.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/051c805050d32a54b76da45957d11209/href">https://medium.com/media/051c805050d32a54b76da45957d11209/href</a></iframe><p>You can see that I’m using acf (<a href="https://www.advancedcustomfields.com/">Advanced Custom Fields</a>) and defining the field names. name, date, description, etc. are all sub-fields of my projects <a href="https://www.advancedcustomfields.com/resources/repeater/">repeater field</a>. All these props will now be available within my page component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXIAOllIQw0_taG5Z5UBqQ.png" /><figcaption>WordPress admin setup with ACF fields</figcaption></figure><h4>Project Single Component</h4><p>Now that I have an array of projects available in my page data I’m going to create a &lt;ProjectSingle /&gt; component to display each project. I’m just going to pass in the acf fields name, date, description, image, and video to render text or child components (for image and video). One interesting thing happening here is that I’m using react’s newly released <a href="https://reactjs.org/docs/hooks-intro.html"><strong>Hooks</strong></a><strong>.</strong></p><p>Using a React Hook is very nice because I can keep track of state in the parent component. In this case, I want to know if the video is playing so that I can hide the overlaying image and text. I’ve imported useState like<br> import React, { useState } from &#39;react&#39; <br>so below all I need to do is create the variable name and setter function (isPlaying and setIsPlaying, along with a default of false)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5798d2873d6735693db06b3db13fd6d/href">https://medium.com/media/a5798d2873d6735693db06b3db13fd6d/href</a></iframe><p>isPlaying gets used to dynamically set a class to hide the overlaying image and text, so that we can see the video 📹 ! The full &lt;ProjectSingle/&gt; component now looks something like…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf6db9138da7d1a9a0fcd6031ca13b5d/href">https://medium.com/media/cf6db9138da7d1a9a0fcd6031ca13b5d/href</a></iframe><p>Now we have a simple home page with our projects listed out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iRaLtlzQAZNfBxveLsZEWw.gif" /><figcaption>Our homepage.js template, using &lt;ProjectSingle /&gt;</figcaption></figure><h3>Additional Steps</h3><p>That should cover the basics of getting a WordPress page to render. I’ve created a second page, <em>Contact, </em>with separate acf fields (email, phone). You should try to create a second template, contact.js, with a unique graphql to get those acf fields.</p><h4>&lt;Navbar/&gt;</h4><p>The Gatsby WordPress starter comes with a <a href="https://github.com/GatsbyCentral/gatsby-starter-wordpress/blob/master/src/components/Navbar.js">navigation component</a> that you should draw inspiration from.</p><h3>Thanks 👋</h3><p>Feel free to check out my <a href="https://github.com/fostergn/lorenaledezma.com">final repo</a> and please hit me up with any questions or comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cea0cf4af9bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Basics w/ Friends: Hover State]]></title>
            <link>https://medium.com/@gavinfoster/coding-with-friends-hover-state-2e81ecc914c3?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e81ecc914c3</guid>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Thu, 07 Mar 2019 20:03:29 GMT</pubDate>
            <atom:updated>2019-03-08T01:08:07.935Z</atom:updated>
            <content:encoded><![CDATA[<p>Concise guides to web techniques with curious friends. Learn how hover state works with CSS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yz9aDDh5vAlQnS5Z.jpg" /><figcaption>Don’t get trapped in a swamp</figcaption></figure><h3>:hover</h3><p>The :hover selector is used to trigger css changes when an element is moused over. Let’s start with a classic example, <strong>links</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37861d96f7235ffe08e9170e39da7c86/href">https://medium.com/media/37861d96f7235ffe08e9170e39da7c86/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*3RMWg2hvQnj618Cum4_R6g.gif" /><figcaption>Look at that baby rip.</figcaption></figure><p>Here is the hover in action. Very simple, but based on this we can create more complex scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*jQ9J-QG8lsphce4sTFXxrg.gif" /><figcaption>Multiple hover states</figcaption></figure><p>In this scenario we use .project__container:hover .project__link so that when we hover over the blue box container element, we then show (set opacity to 1) the child link element.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdd82125e12133d903d6d6c3514f01f7/href">https://medium.com/media/fdd82125e12133d903d6d6c3514f01f7/href</a></iframe><p>You might notice that we are also using <a href="https://www.w3schools.com/css/css3_transitions.asp">CSS Transition</a> in order to animate the transition of the box-shadow on the blue container.</p><h3>Thanks 🙇</h3><p>I’m just documenting answers to questions friends ask me, so please let me know if you have any additional questions or requests!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e81ecc914c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React, Gatsby, & Wordpress Static Site: Gatsby and Wordpress Setup (part 2)]]></title>
            <link>https://medium.com/@gavinfoster/react-gatsby-wordpress-static-site-gatsby-and-wordpress-setup-part-2-cf98235e465f?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf98235e465f</guid>
            <category><![CDATA[gatsbyjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[netlify]]></category>
            <category><![CDATA[wordpress]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Thu, 07 Mar 2019 02:07:52 GMT</pubDate>
            <atom:updated>2019-03-08T05:15:48.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8pMOXePbk0C70JVAjb9YA.jpeg" /><figcaption>Learn to use the well known Wordpress admin without all the nonsense templating.</figcaption></figure><p>In part 2 we will be setting up our Gatsby configuration, Wordpress backend, and Netlify deploy. Once we finish, we will have our site building on any code or Wordpress content changes! Feel free to checkout the project overview in <a href="https://medium.com/@gavinfoster/react-and-wordpress-static-site-part-one-project-overview-5ad9ebd62e29">Part One</a>.</p><h3>Wordpress</h3><p>Feel free to create any remote Wordpress site, but I’m going to quickly spin up a free site at <a href="https://www.000webhost.com/">https://www.000webhost.com/</a>. The only caveat with the gatsby starter we are going to use is that you need to create a page and a post (with a tag) in order to get rolling 🎢.</p><h3>Gatsby</h3><p>Gatsby’s <a href="https://www.gatsbyjs.org/docs/quick-start">getting started documentation</a> is excellent, but feel free to follow along here.</p><h4>Getting Started</h4><p>Install Gatsby as a global package. Now gatsby will be a cli command.<br>npm install -g gatsby-cli</p><p>We are also going to install a <a href="https://www.gatsbyjs.org/docs/starters/">Gatsby starter project</a>, which will be a Wordpress boilerplate.</p><pre>gatsby new REPOSITORY_NAME https://github.com/GatsbyCentral/gatsby-starter-wordpress</pre><p>Now I can just cd lorenaledezma.com and run gatsby develop to start up my project. It should look something like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAAwj8CdTy1PgQwS5eUKzw.png" /><figcaption>You should see this on <a href="http://localhost:8000/">http://localhost:<strong>8000</strong>/</a></figcaption></figure><h4>Configuration</h4><p>Now we are going to update our gatsby-config.js file in order to add our environment variables (for Wordpress auth).</p><p>You can see we have added process.env.HTACCESS_USER and process.env.HTACCESS_PASSWORD to our auth block. We have also added dotenv package in order to pull in a .env.development file where we define HTACCESS_USER and HTACCESS_PASSWORD for our npm builds.</p><p>Also update the baseURL to the url of your new Wordpress site.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/434a090516b65fc27f7e890b66216395/href">https://medium.com/media/434a090516b65fc27f7e890b66216395/href</a></iframe><p>And this is what our environment variable file looks like. It needs to be in the root directory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55dd74d81ed13b5fb592ec1767d2c269/href">https://medium.com/media/55dd74d81ed13b5fb592ec1767d2c269/href</a></iframe><h3>Netlify</h3><p>Setup an account with <a href="https://app.netlify.com/">Netlify</a> if you haven’t already. Follow <a href="https://www.netlify.com/blog/2016/09/29/a-step-by-step-guide-deploying-on-netlify/">this tutorial</a> to add your github repository and setup a site (create a repo w/ code before hand). If any of the setup options are confusing, please reference the <a href="https://www.gatsbyjs.org/docs/hosting-on-netlify/">Gatsby docs</a> (like npm run build as the build command or that /public is our source directory).</p><p>Once your site is added, you will want to add your environment variables to the project at Settings → Deploys → Build Entironment Variables `settings/deploys#build-environment-variables`. Add both HTACCESS_USER and HTACCESS_PASSWORD .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o6A3vkqaWVJjPfuOaCWcuw.png" /><figcaption>This means that when Netlify runs npm run build it will have access to our credentials</figcaption></figure><h3>Wordpress Next Steps</h3><p>Now we want to add our authorization to our site and also install a plugin to deploy our new static once we create or update our content.</p><p>Install two plugins and follow the instructions in the README.</p><ul><li><a href="https://github.com/WP-API/Basic-Auth">GitHub - WP-API/Basic-Auth: Basic Authentication handler for the JSON API, used for development and debugging purposes</a></li><li><a href="https://github.com/lukethacoder/wp-webhook-deploy-netlify">lukethacoder/wp-webhook-deploy-netlify</a></li></ul><p>Use you admin Wordpress user’s credentials for the environment variables. Also feel free to test out the wp-webhook-deploy-netlify plugin, as you should see it successfully building (from the netlify app dashboard) when you click <strong>deploy </strong>button.</p><p>If you’re adding Advanced Custom Fields to your site, be sure to update your gatsby-config.js with useACF: true .</p><h3>Part Three</h3><p>For Part 3️⃣ we will be diving into Gatsby’s react components! Please comment with any questions or comments! 🔥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf98235e465f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React and Wordpress Static Site: Part One (Project Overview)]]></title>
            <link>https://medium.com/@gavinfoster/react-and-wordpress-static-site-part-one-project-overview-5ad9ebd62e29?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ad9ebd62e29</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 08:33:52 GMT</pubDate>
            <atom:updated>2019-03-08T05:13:33.797Z</atom:updated>
            <content:encoded><![CDATA[<h3>React, Gatsby, &amp; Wordpress Static Site: Part One (Project Overview)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KFisMLWCybHuEeEczU8kGg.jpeg" /><figcaption>One day you will be able to have a friend complaining about not having a website, and without fear, you will be able to proclaim that you can “churn one of those bad boys out” in less than a couple of hours.</figcaption></figure><p>This series will document a project start to finish <a href="http://www.lorenaledezma.com/">www.lorenaledezma.com </a>and provide an overview of web development concepts and along with implementation details. The idea was to get a few friends interested in learning more about coding and provide an outlet for learning new concepts. These walkthroughs will be as introductory as possible.</p><h3>Project</h3><p>A <em>production reel </em>website to display videos, images, basic project information, and contact information.</p><h3>Technology</h3><p><a href="https://wordpress.org/">Wordpress</a>, <a href="https://reactjs.org/">React</a>, <a href="https://www.gatsbyjs.org/">GatsbyJs</a>, <a href="https://www.netlify.com/">Netfliy</a>, <a href="https://github.com/">Git</a>, <a href="http://nodejs.org/">Node</a>, and <a href="https://www.npmjs.com/">NPM</a>.</p><h3>Concepts</h3><p>Version Control, Javascript Framework, Static Site Generators, Server vs. Client, API, and Deployments</p><p><em>Version Control</em></p><p>This is how to keep track of changes. The equivalent of being in photoshop and having image-final.jpg, image-final-1.jpg, image-final-final.jpg (etc.) except it is done in code</p><p><em>Javascript Framework</em></p><p>A Javascript framework is a library that you use like <a href="https://reactjs.org/">react</a> or <a href="https://vuejs.org/">vue</a>. These libraries have conventions that make it easy to create complicated web applications.</p><p><em>Static Site Generators</em></p><p>A static site generator takes files and then builds a website with .html pages to be served. Whenever a file changes, the generator needs to be run in order to rebuild the site and serve the new content. <a href="https://www.gitbook.com/">Gitbook</a> <a href="https://www.gatsbyjs.org/">Gatsby</a> <a href="https://gohugo.io/">Hugo</a> are popular</p><p><em>Server vs. Client</em></p><p>This concept of server vs. client is a fundamental concept in web development. A <strong>Server</strong> is a computer somewhere doing something, often serving a website. A <strong>Client</strong> is a consumer of whatever a server sends, typically a browser (Chrome, Firefox, or Internet Explorer god help you). A server will often send an .html file which is essentially your website. Your .html file might also need some styles (css) images (.jpeg file) or even some flashing text (javascript) which the index.html can ask from the server as well.</p><p><em>API</em> (Application Programming Interface)</p><p>Complicated terminology, but an important concept. A server might store data, like in a database. For example, an e-commerce application or website might rely on a database full of purchases. An application programming interface, API, is just the way that a client, the shop website, can ask the server for the data of all of the purchases. Or maybe all of the purchases for a specific customer. For <strong>RESTful</strong> APIs, that means a set of endpoints like:</p><pre><a href="http://e-commerce.com/purchases/:customer-id">http://e-commerce.com/purchases/:customer-id</a></pre><p>If you made a <strong>GET</strong> request to that endpoint, that is to say, put that url in your browser (with a customer id) it would send you the data of all the purchases for that customer!</p><p><em>Deployments</em></p><p>The code for your website will live on the server so that it can be sent to anyone that requests it (goes to yourwebsite.com). A deployment refers to the process of getting the new code that you’ve written onto the server that runs the code. A very crude way is to <a href="https://www.hostinger.com/tutorials/ssh-tutorial-how-does-ssh-work">ssh</a> (a way to access your server remotely) and change the files directly. A more sophisticated way is to push code to a git repository and then that code is pushed to a server. <a href="https://www.netlify.com/">Netlify</a> is tool for deployment.</p><h3>Paths</h3><p>There are potential areas of concentration for this project.</p><p><em>Frontend</em></p><p>Styles and markup. Write the html and css to create components for the website. Navigation, menu, images, videos etc. Mobile first.</p><p><em>Javascript</em></p><p>Take frontend markup and css to create components. Use state to handle any reactive logic, menu transitions, routing etc. Use Gatsby to pull in <a href="https://www.gatsbyjs.org/packages/gatsby-source-wordpress/">Wordpress</a> posts to generate content.</p><p><em>Wordpress</em></p><p>Create wordpress site for gatsby to use. Create post types and fields.</p><h3>🔥 🤓 🔥</h3><p>There will be more in the series and I’m hoping a few friends or random people show enough interest to help spur along the content of future articles</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ad9ebd62e29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vue Storybook]]></title>
            <link>https://medium.com/@gavinfoster/vue-storybook-e2c7eb43c2c9?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2c7eb43c2c9</guid>
            <category><![CDATA[components]]></category>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Fri, 15 Feb 2019 19:08:07 GMT</pubDate>
            <atom:updated>2020-02-27T19:09:34.850Z</atom:updated>
            <content:encoded><![CDATA[<h3>Storybook</h3><p>At <a href="http://knack.com/">Knack</a> we are building out a component pattern library to create a design system as we iterate on our product’s interface. Knack is a codeless platform where users can create a database, application, or workflows to drive their business.</p><p>As you can imagine, coming up with a cohesive and consistent system can be difficult for an incredibly flexible product. Our team, like many others, has started to use <a href="https://storybook.js.org/">Storybook</a> as a UI development environment in order to rapidly iterate on our pattern library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NyB2iFtgWn_RSPXhsmVFPw.gif" /><figcaption>Storybook Interface showing an &lt;Icon&gt; component</figcaption></figure><p>At Knack, we have begun doing a complete frontend rewrite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVJBAItzroprJab-4oobIQ.gif" /><figcaption>Global and Contextual Loading Component</figcaption></figure><p>Storybook provides addons to extend what comes out of the box. For example the <a href="https://github.com/storybooks/storybook/tree/next/addons/knobs">knobs addon</a> allow you to make dynamic changes like updating a boolean value to true and immediately see the results. This can be powerful for understanding what props a component expects along with the intended visual changes. It also becomes very easy to test isolated changes and see those changes proliferate across the entire library.</p><p>Storybook was developed with UI components in mind, meaning that it’s easy to implement when components are simple and isolated. A &lt;Button&gt;that only expects a label, placeholder, and value prop is very easy to create. What is much more challenging is to display a &lt;Page&gt; component that relies on a store being populated with application data and global UI state. Fortunately we can make this easy by creating an initialization wrapper component.</p><p>First we import our store from our application and pass that in as an argument to our storybook story file. (lines 3 and 13 below)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a64843e3fe7457d21c38797a31aa0a5/href">https://medium.com/media/1a64843e3fe7457d21c38797a31aa0a5/href</a></iframe><p>Now that we have our store available and have also included our Knack API SDK (for making API calls to get our Knack application data) we can populate the store with our simple &lt;DataWrapper&gt; component.</p><p>Our data wrapper component takes an account and application as a prop and uses that to fetch our application data and populate the store. We are also importing our &lt;Loading&gt; component to display while fetching our initial data. Once we get the data back from our api call, we then populate state with this.$store.dispatch(&#39;load&#39;, data) and we are off to the races. We use a v-if to conditionally render our child component once the store has been populated with our data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fde2db36ff691af402805f1f64641a58/href">https://medium.com/media/fde2db36ff691af402805f1f64641a58/href</a></iframe><p>Now our &lt;Login&gt; component has all of its store dependencies and can render accordingly. Also nice to note is that we can even make our API calls from the component in storybook and see the appropriate response and error message! 🔥</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07WvgHBVWz1X6QmsbJ-6NQ.gif" /><figcaption>Page with &lt;Login&gt; component</figcaption></figure><p>We can even create extend our use case to use <a href="https://github.com/gvaldambrini/storybook-router">storybook-router</a> for components that depend on route parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a921cba91d9837839a7cb48832e72d/href">https://medium.com/media/96a921cba91d9837839a7cb48832e72d/href</a></iframe><p>While isolating UI components to their most essential concerns is good in practice, sometimes we need to be able to pull in external data to render complicated layouts. Creating a wrapper component that handles populating store with live data accomplishes that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCkttpvGkC0nMkFRlIfONA.png" /></figure><p>This is a somewhat advanced use case of storybook, but was important for the Knack team. I hope this has been helpful and please hit me up if you have any questions or comments 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2c7eb43c2c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sketch Icon Formatting]]></title>
            <link>https://medium.com/@gavinfoster/sketch-icon-formatting-d1e3080447af?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1e3080447af</guid>
            <category><![CDATA[sketch]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Fri, 15 Feb 2019 17:55:21 GMT</pubDate>
            <atom:updated>2019-02-15T18:01:43.075Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.sketchapp.com/">Sketch</a> is an amazing and popular interface design tool. Unfortunately, sometimes the assets that it exports can be a little wonky. This includes .svgs. Sketch uses masks and &lt;defs&gt; work well to create reusable symbols, but can unfortunately break developer’s components. In my case, this was breaking a vue.js icon component which dynamically imported an .svg file. I decided to create a script to clean up the exported .svgs to be used in my component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0jCbq0tlIs-SOSRCQBcwQ.png" /><figcaption>CLI <a href="https://github.com/fostergn/svg-formatter">SVG Formatter</a></figcaption></figure><p>I ended up using <strong>svgson</strong> to create a node executable script to clean up the svg xml elements. The script parses and extracts the &lt;path&gt; or &lt;polygon&gt; element and wraps it in a &lt;g&gt; tag in order to remove all the unnecessary elements and attributes that break our vue components.</p><p>You can find the current implementation at <a href="https://github.com/fostergn/svg-formatter">SVG Formatter Repository</a>. It takes a --file or --directory argument in order to process the .svgs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NyB2iFtgWn_RSPXhsmVFPw.gif" /><figcaption>Icon component in Storybook UI environment</figcaption></figure><p>I’m not really that familiar with .svg markup, but was happy to keep the design ← → dev pipeline running smoothly 😸. Please let me know if you have any questions, comments, or more info!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1e3080447af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Knack Hack: Native Spanish App]]></title>
            <link>https://medium.com/knackhq/knack-hack-native-spanish-app-d776431a53ed?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/d776431a53ed</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[knack]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Mon, 12 Nov 2018 19:14:55 GMT</pubDate>
            <atom:updated>2020-12-15T15:56:09.063Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building a native application with Knack</h4><p>I wanted to create an easy way to manage my Spanish vocabulary cards and have daily reminders for new words. I ended up building a native Android and iOS application using <a href="https://facebook.github.io/react-native/">React Native</a>, a Javascript framework for building native applications. I used <a href="http://www.knack.com/">Knack</a>, a codeless cloud platform, to store my data and create users. Amazon Web Services ties my native application and Knack database together, using AWS Lambdas to automate push notifications and Knack user authentication / creation.</p><h3>Knack Setup</h3><p>Using Knack, I created a few <a href="https://learn.knack.com/article/4l9f021u5h-working-with-objects">objects</a> to get going that will store the data:</p><ul><li>Vocab — object for flash card style information</li><li>User Vocab — create a connection between vocab cards and users</li><li>Accounts— users to store push notification token, email, and vocab connections.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cE9zc9DWIB0O-oXXk2q7kA.png" /><figcaption>Quickly building out a database with objects and users is easy with Knack (and requires no coding)</figcaption></figure><h3>AWS</h3><p>I used <a href="https://aws.amazon.com/">Amazon Web Services</a> to automate push notifications and connect Knack with my native application.</p><p>I used API Gateway and Lambda in order hit an authentication endpoint and then trigger a lambda that would either create a new Knack account object or fetch the account’s vocab cards using the <a href="https://docs.knack.com/docs/using-the-api">Knack API</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGAQFc2U1Hybpu3Xu_B31w.png" /><figcaption>API Gateway that triggers a Lambda function connecting Knack and React Native App</figcaption></figure><p>I also setup a CloudWatch Event (cron running daily) that would trigger a Lambda that would create a push notification with a vocabulary card.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__y12v3a4o3GA2OMnkPObg.png" /><figcaption>I used <a href="https://expo.io/">https://expo.io</a> for rapid react native development and handling push notifications</figcaption></figure><p>On the react native side, I used <a href="https://nativebase.io/">native base</a> for UI components, <a href="https://reactnavigation.org/">react navigation</a> for routing, and <a href="https://redux.js.org/">redux</a> for state management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJIv8F2Fpnc1TcYt1q1X7Q.png" /><figcaption>Some screenshots from the android version of the native application</figcaption></figure><p>I haven’t used react in a while but was happy with how easily it was to iterate on a simple idea. I’m looking forward to creating some simple UI for creating cards in the native app, adding a social element (sending to friends) and expanding on the vocabulary cards. I want to port the knack signature field to use a standard format, or build a drawing UI component to create images.</p><p>I’ve been happy with how easy it has been to iterate through an idea like this with Knack, AWS, and React Native. I’ll most likely create another article for a drawing UI component or even publishing a native app, which I have never done before. It’d also be nice to automate (maybe scrape 😈) some new vocabulary word and automate that process.</p><p>Thanks for reading and feel free to comment below with any questions or feedback : ^ )</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d776431a53ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/knackhq/knack-hack-native-spanish-app-d776431a53ed">Knack Hack: Native Spanish App</a> was originally published in <a href="https://medium.com/knackhq">Knack</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Knack Hack: Live Connected Equation]]></title>
            <link>https://medium.com/@gavinfoster/knack-hack-live-connected-equation-5570aeca0a3a?source=rss-77f320de6c92------2</link>
            <guid isPermaLink="false">https://medium.com/p/5570aeca0a3a</guid>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[database-development]]></category>
            <dc:creator><![CDATA[Gavin Foster]]></dc:creator>
            <pubDate>Thu, 06 Sep 2018 18:33:53 GMT</pubDate>
            <atom:updated>2018-09-06T18:39:04.620Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a <a href="http://www.knack.com/">Knack</a> tutorial for real time rendering of an equation on a form that depends on a connected object’s field. We will be using a form to create a line item for a customer and we will be calculating the total price, based on the quantity of the line item, and the price of a connected product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*A_llVVzWkiewrajBfy059w.gif" /></figure><h3>Application Setup</h3><p>The example application I’ll be using is an e-commerce site that allows users to add products to their account.</p><h4>Create Objects</h4><p>Create two objects, <strong>Product </strong>and<strong> Line Item. </strong>Create a connection between Line Item &gt; Product.</p><p>The Product object will have fields of:</p><ul><li>Name (text)</li><li>Price (currency)</li><li>Description (paragraph text)</li><li>Monthly (boolean)</li></ul><p>Line Item fields:</p><ul><li>Product (connection to Product object)</li><li>Quantity (number)</li><li>Line Item Price (number)</li><li>Total Price (equation)</li><li>Created (date/time)</li><li>Id (auto increment)</li></ul><h4>Create Page</h4><p>Create a page with a form to <em>insert a new</em> <strong>Line Item. </strong>Make sure that the fields for the connected Product, quantity, and total price exist on the form.</p><p>On the same page add a table that displays <strong>Product</strong> <em>records from your database </em>(this will be hidden in the live app).</p><h4>Custom Code</h4><p>You will need to copy the following <a href="https://gist.github.com/fostergn/9ba4e5f5f5a228c3a622f4296cea0cd9">custom code</a> to your Knack Javascript custom code editor and replace the following variables:</p><pre>var scene_key = &#39;scene_1&#39; <br>var view_key = &#39;view_36&#39; <br>var name_field_key = &#39;field_1&#39; <br>var price_field_key = &#39;field_39&#39; <br>var connected_record_field_key = &#39;field_30&#39; <br>var quantity_field_key = &#39;field_31&#39; <br>var equation_total_field = &#39;field_50&#39;</pre><p>In order to find the variables for your application, go to the page you have created in the builder with your form, and get the scene_key from the url. eg: `<a href="https://builder.knack.com/gavinfoster/web-services#pages/scene_1">https://builder.knack.com/gavinfoster/product-app#pages/scene_1</a>` would mean scene_1 is the value of the variable for scene_key . Similarly, to get the value of the view_key , go to the page in your builder with your form, and click on the form to edit it. You will see view key in the URL. For fields, navigate to the object where the field exists, and click on the field to edit it. You will see the field key in the URL.</p><blockquote>If you are having trouble finding what your field, view, or scene keys are, check out the <a href="https://www.knack.com/developer-documentation/#working-with-fields"><strong>knack documentation</strong></a> for more in-depth help.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5570aeca0a3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>