<?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 Adeola Adeyemo J. on Medium]]></title>
        <description><![CDATA[Stories by Adeola Adeyemo J. on Medium]]></description>
        <link>https://medium.com/@DeolaJ?source=rss-c27bdba4579a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NJ4ZMPjuje-jWm2PKb7vZg@2x.jpeg</url>
            <title>Stories by Adeola Adeyemo J. on Medium</title>
            <link>https://medium.com/@DeolaJ?source=rss-c27bdba4579a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 03:22:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@DeolaJ/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[My Global Talent Visa Story]]></title>
            <link>https://medium.com/@DeolaJ/my-global-talent-visa-story-2941665a5279?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2941665a5279</guid>
            <category><![CDATA[global-talent-visa]]></category>
            <category><![CDATA[technation]]></category>
            <category><![CDATA[stories]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[uk]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Mon, 18 Mar 2024 08:01:18 GMT</pubDate>
            <atom:updated>2025-06-24T20:06:02.259Z</atom:updated>
            <content:encoded><![CDATA[<h3>My Global Talent Story</h3><h4>A personal guide to the Global talent visa through Tech Nation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BQ32F1Ot1YVeN-Gbkr4jA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@lanju_fotografie?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Lanju Fotografie</a> on <a href="https://unsplash.com/photos/silhouette-of-man-holding-flashlight-BvAoCypqRXU?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p><em>Originally posted in </em><a href="https://deolaj.com/notes/my-global-talent-visa-story"><em>my portfolio notes</em></a><em> in January, 2024.</em></p><blockquote><strong><em>Update: The requirements change often and some of the tips listed below (January, 2024) are now outdated. I’ll advise that as you read through, compare with the </em></strong><a href="https://technation-globaltalentvisa-guide.notion.site/"><strong><em>official guidelines</em></strong></a><strong><em> also for the latest updates as that’s the ultimate source.</em></strong></blockquote><p>Over the past 2 months, I’ve had conversations about my Global Talent Visa application and felt an article would be the best approach (I love writing articles already) to share my story. Considering how little information is out there, I hope this helps someone with theirs.</p><p>My testimony was getting a Tech Nation endorsement in <strong>2 days</strong>. This article outlines my experience getting the Global Talent Visa, under <strong>Exceptional Promise</strong>, in October 2023 (applying from Lagos, Nigeria) and tips to send in a great application. Bear in mind that the costs listed could change in the future.</p><h3><strong>Global Talent Visa</strong></h3><p>According to the Tech Nation website, “The Global Talent Visa enables the best tech talent from around the world to work in the UK’s digital technology sector, contributing their cutting edge expertise and creative skills”. This is a Tier 1 UK visa that lets you work and live in the UK.</p><p>Benefits include:</p><ul><li>The ability to change your job or start up on your own without needing to update your immigration status.</li><li>Your spouse and any children under 18 can come with you.</li><li>The total cost of application is only £716 per person (+ UK healthcare surcharge).</li><li>Join our network of over 2000 visa alumni members, to share your skills, knowledge and opportunities.</li></ul><p>To read more about eligibility for either Exceptional Promise or Exceptional Talent, visit the <a href="https://stagetechn.wpengine.com/visa-tech-nation-visa-guide/#eligibility-criteria">official website</a>.</p><h3><strong>Background</strong></h3><p>Before going ahead, I am a Senior Frontend Engineer with over 5 years of experience at the time of writing this article, based in Lagos Nigeria. My evidence documents are tailored to <strong>Frontend Development</strong>.</p><p>I got to learn about the Global Talent Visa in 2021 when an announcement was made on Twitter, and decided to read about it. At the time, the requirements felt a bit overwhelming and I wasn’t enthusiastic about relocating to the UK yet. I remember watching a Youtube video by <a href="https://youtu.be/P_QmVVzJz9U">Peace Itimi</a> explaining her experience and kept this opportunity at the back of my mind.</p><p>‍Preparing my application took about 5 weeks. Thankfully I had the support of 3 friends that had gotten the visa to help with reviews and conversations.</p><h3><strong>Application</strong></h3><p>The Global Talent Visa application is divided into 2 stages.</p><h4><strong>Stage 1</strong></h4><p>The first stage involves applying for <strong>endorsement</strong> — this costs <strong>£524</strong>. As a tech professional, I applied under the <a href="https://www.gov.uk/global-talent-digital-technology">digital technology</a> route to <a href="https://technation.io/">Tech Nation</a>. There are other routes available — <a href="https://www.gov.uk/global-talent-arts-culture">Arts &amp; Culture</a> and <a href="https://www.gov.uk/global-talent-researcher-academic">Academia or Research</a></p><p>This stage involves filling the <a href="https://www.gov.uk/global-talent/apply-from-outside-the-uk">online application form</a>. The main documents you need in this state is your International Passport and a valid national identity card (optional). This requires personal information and information about your parents in this step.</p><p>Then you’ll be asked to pay the application fee (£524) which is non-refundable, and asked to submit your documents to the Tech Nation.</p><p>This is the list of the documents I submitted:</p><h4><strong>1. CV</strong></h4><p>This was my regular CV which highlighted my technical skills, work history and volunteer experience.</p><h4><strong>2. Personal Statement</strong></h4><p>This was more like an essay to address my intentions. This is an outline of what I wrote:</p><ul><li>How my love for solving problems started at an early age,</li><li>My academic achievements from Primary school to Secondary school (Best WAEC result in Lagos State), and the University (BGS, Faculty of Engineering, UNILAG)</li><li>My journey into Frontend Engineering and a brief summary of achievements both at work and contributions to the community (articles, mentorship etc.)</li><li>What attracted me to the UK</li><li>Why I wanted the Global Talent Visa specifically and what I planned to achieve with the opportunity</li><li>Finally, where I’d love to work and live in the UK</li></ul><p>Note that this essay must not exceed 1,000 words. Mine was about 996 words (cutting it close). I wrote this when I was done collating all my evidence, it just felt easier to write this last.</p><h4><strong>3. Recommendation Letters</strong></h4><p>Thankfully, I had worked at 3 product-led companies. So I got recommendation letters from the CEOs of each company.</p><p>My letters were written ‍according to the guide and followed a similar outline to this:</p><ul><li>A brief introduction by the author</li><li>How the author and I met and have worked together</li><li>Some achievements the author noticed and comments about my character and work ethic</li><li>Why the author considers me exceptional; and</li><li>What the author thinks about my prospects in the UK and possible contributions to the UK digital economy.</li></ul><p>A few things to note:</p><ul><li>You might need to jog the memory of whoever is writing the letter to ensure that some key details are not missed.</li><li>Feel free to share information about the visa guide. I found and shared <a href="https://www.immigram.io/blog/how-to-write-the-perfect-recommendation-letter">this guide</a> to help each person write their letter too.</li><li>To prove that each document didn’t originate from you, it needs to be signed digitally. In my case, I requested for each letter to be signed with <a href="https://www.docusign.com/">Docusign</a></li></ul><p>Each recommendation letter had a page length of between 5–8 pages. This consisted of the letter’s body (less than 3 pages), the certificate from Docusign proving that I didn’t write it, and the PDF document of their LinkedIn page (instead of a CV). I merged these documents using <a href="https://www.ilovepdf.com/">iLovePDF</a>.</p><h4><strong>4. Evidence Documents</strong></h4><p>I submitted a total of 10 evidence documents.</p><p>I submitted the following documents to fulfill the <strong>Mandatory Criteria:</strong></p><ol><li><strong>High remuneration for services rendered:</strong> In this document, I highlighted my salary at the time and show how this compared to the average Senior Frontend Engineer salary in Lagos. I added my offer letter and invoices of payment received for 4 different months as proof too.</li><li><strong>Publications</strong>: Over my career, I had been writing articles to share knowledge and they came in handy in this application and they had garnered over 100,000 views in total. I had 8 technical articles, all on <strong>Medium</strong>, but the last 2 were also republished on <strong>HackerNoon</strong> for a wider reach. In this document, I showed side by side the articles and their corresponding views (dates included). Thankfully, my last 2 articles were about Supabase, and the official account had posted about it on Twitter, so I included this to show the impact.</li><li><strong>Significant technical contribution (#1 Company)</strong>: In this document, I wrote about my work at my most recent company as a Founding Engineer at Talentdrop (product-led organization) . The focus was majorly on innovation rather than impact because it was a startup. I included a few code snippets showing my Github history, Asana screenshots showing tasks assigned to me over time, progression of the product based on multiple iterations, and finally positive comments and compliments from the CEO and CTO in Slack conversations (with dates included).</li><li><strong>Reference Letter (#1 Company)</strong>: To support my significant technical contribution, I requested a reference letter from the CTO of Talentdrop and she obliged. This was in the same format as the recommendation letters explained above.</li></ol><p>I submitted the following documents to fulfill the <strong>Optional Criteria 2 — Recognition outside work:</strong></p><ol><li><strong>Mentorship</strong>: In this document, I wrote about my track record as a mentor on ADPList from December 2022 because of the structured mentorship requirement. I had written some articles (in 2021 published in my online notes) about my experience as a Frontend Engineer, one of which serves as some sort of guide and included this. Finally, I had been mentoring informally since 2019 and included this to show track record — WhatsApp conversations (dates included) with 3 different mentees where we discussed concerns, shared wins and so on.</li><li><strong>Volunteering and Talks:</strong> In 2019, I had built the website for Nielle’s Cookout (a Millenial/Gen Z event) whose theme was “How to rule your finances”. The website helped with ticket registration, vendor registration and information dissemination. I wrote about my experience as a volunteer — Software Engineer and also helped with sponsorship conversations with Flutterwave and PiggyVest. Fortunately, there were email threads, the website source code was live on Github, and there was a public directory of pictures from the event too with 500 attendees. I was also invited to speak virtually to a digital community group in 2021, where I gave a presentation about how to build an online portfolio. In 2022, I was invited to a Career day event at a secondary school (my alma mater). I shared the invitation letters, banners and media from both events</li></ol><p>I submitted the following documents to fulfill the <strong>Optional Criteria 3 — Impact:</strong></p><ol><li><strong>Significant technical contribution (#2 Company)</strong>: In this document, I wrote about my work at my first place of work, Formplus (product-led organization), as a Frontend Engineer. The focus was majorly on impact and how my work was instrumental to the business. I broke down my impact into about 5 different pieces of work, screenshots of the product’s progression over time and media mention of the company, and finally product announcements and positive comments from teammates and the CEO in Slack conversations (dates included).</li><li><strong>Reference Letter (#2 Company)</strong>: To support my significant technical contribution above, I requested a reference letter from the Engineering Lead at Formplus (he had also moved on to another company) and he obliged. This was in the same format as the recommendation letters explained above.</li><li><strong>Significant technical contribution (#3 Company)</strong>: In this document, I wrote about my work at Kora (product-led organization) as a Senior Frontend Engineer. The focus was majorly on impact also. I included media announcements of the work I had done that got launched after I had left and showed evidence to prove I made a significant impact. I included screenshots of certain product screens I worked on, iterations, and finally positive comments and compliments from teammates and the CTO in Slack conversations (dates included).</li><li><strong>Reference Letter (#3 Company)</strong>: To support my significant technical contribution, I requested a reference letter from the CTO of Kora and he obliged. This was in the same format as the recommendation letters explained above.</li></ol><p>A few things to note about these documents:</p><ul><li>Create an evidence list when you start, this will help guide you while updating the documents. I created a folder on google drive with subfolders to arrange my documents.</li><li>Do not to forge evidence because it’s wrong and can harm your chances.</li><li>Don’t be ashamed to reach out to former colleagues to help get evidence of work you have done.</li><li>Lean more towards storytelling, but be direct and concise.</li><li>Try to include as much as you can in the 3 pages limit and favor clear images (screenshots). I had to reduce margins in my document to fit copy and images.</li><li>Include links to external resources as a secondary option. For example, if you need to share a folder of additional videos/photos, publications, github repositories etc. They might not check these, but it’s good to have them.</li><li>Format your document to look presentable and to emphasize certain information.</li><li>I created a sample folder for some samples to have an idea of how mine was structured and formatted: <a href="https://drive.google.com/drive/folders/15caq-Y07P8lyf9F5x-GxFjRPTnbS1D4Q?usp=drive_link">Global Talent Samples</a></li></ul><p>These are all the documents I submitted in my application. I submitted in the evening on October 4th and got endorsed on October 6th (2 days later) in the evening. The endorsement came in the form of an email.</p><p>Then I moved to the next stage.</p><h4><strong>Stage 2</strong></h4><p>This stage involves filling another <a href="https://www.gov.uk/global-talent/apply-from-outside-the-uk">online application form</a>. You might be required to fill in similar information as the application form in Stage 1. Ensure that you select ‘Initial application’ too if it’s your first time.</p><p>You’ll be required to pay the <strong>visa fee</strong> — this costs <strong>£192</strong>. You’ll also have to pay the <a href="https://www.gov.uk/healthcare-immigration-application/pay">healthcare surcharge</a> as part of your application — this is usually <strong>£624 per year</strong> for each person applying (now £1,035 from March 2024). For a 5 years visa, you have to pay — £624 * 5 = £3,120. Note that you do not need to pay for the 5 years at once. I was advised to pay for 5 years at once by everyone that had gotten the visa though.</p><p>Afterwards, you’ll need to book an appointment for biometrics. I selected the Ikeja center in Isaac John, Lagos. I selected the “Self Upload” option instead of Assisted service and didn’t upgrade my selection when selecting a time slot. So this process was completely free.</p><p>I uploaded my Passport data page, Endorsement letter (print the endorsement email) and my Tuberculosis test results. To upload my documents, I ensured that the documents were clearly visible and I named them appropriately. E.g “Adeola Adeyemo — Passport”.</p><p>I took my Tuberculosis test at St. Nicolas hospital and it cost <strong>₦60,000</strong>. It was one of the recommended hospitals by <a href="https://www.gov.uk/government/publications/tuberculosis-test-for-a-uk-visa-clinics-in-nigeria/tuberculosis-testing-in-nigeria">UK Immigration</a>. You can book an appointment <a href="https://intranet.saintnicholashospital.com/uk-tb-screening">here</a>.</p><p>My experience at the Visa center was seamless. I got there 1 hour before the appointed time of 9:15am, and left by 9:30am. I didn’t need to take anything other than my International Passport, its photocopy, and a printout of the appointment email. I had to pay about <strong>₦9,800</strong> (now ₦12,250) for home delivery of my International Passport. I got my Passport after 6 days.</p><p>Here are a few more things to note:</p><ul><li>All payments were made with a USD Card</li><li>If you are applying for a dependent, you need to pay the application fee (endorsement), visa fee and healthcare surcharge for each person.</li><li>Pick early appointment slots for the Tuberculosis test and Visa biometrics</li></ul><h3><strong>Final Thoughts</strong></h3><p>If you feel like you don’t have enough evidence, please give yourself time and don’t rush the process or fake anything. It’s always good to evaluate your chances early by creating a checklist and noting areas you haven’t done enough.</p><p>These might seem like a lot, but trust me that if you are consistent in your career about doing great work and also giving back to the community, it will be easier to put together an application.</p><p>I got a lot of help and support from friends while putting my application together, so I hope this helps anyone that’s considering applying or trying to decide whether to.</p><p>For further reading, check out <a href="https://stagetechn.wpengine.com/visa-tech-nation-visa-guide/">the official guide</a>, <a href="https://www.sebiomo.com/post/my-technation-global-talent-endorsement">Anuoluwapo Sebiomo’s story</a>, <a href="https://digitalmarketwoman.com/global-talent-visa/">Oyinlola Akindele’s story</a>, <a href="https://medium.com/@ooade/my-experience-applying-for-a-global-talent-visa-95d906e06925">Ademola Adegbuyi’s story</a>, and an article on <a href="https://techcabal.com/2022/07/22/digital-nomads-how-creatives-can-japa-with-the-uk-global-talent-visa/">TechCabal</a>.</p><p>Feel free to send a DM or connect on LinkedIn if you have questions. Wishing you the best.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2941665a5279" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to trigger email notifications on a contact form with Supabase]]></title>
            <link>https://medium.com/@DeolaJ/how-to-trigger-email-notifications-on-a-contact-form-with-supabase-210cf245e57e?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/210cf245e57e</guid>
            <category><![CDATA[email-notifications]]></category>
            <category><![CDATA[contact-form]]></category>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[triggers-in-sql]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Mon, 13 Nov 2023 13:16:49 GMT</pubDate>
            <atom:updated>2023-11-13T13:16:49.672Z</atom:updated>
            <content:encoded><![CDATA[<p>A simple tutorial on Database Functions and Triggers — Part 3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovJSNXS_8ncYaNN7OpQIpA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@billjelen?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Bill Jelen</a> on <a href="https://unsplash.com/photos/m010U75wdxE?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Originally posted in </em><a href="https://deolaj.com/notes/how-to-trigger-email-notifications-on-a-contact-form-with-supabase"><em>my portfolio notes</em></a><em> in November, 2023.</em></p><p>This marks the conclusion of my Supabase tutorial series. If you haven’t done so already, please take a moment to check out the preceding articles, “<a href="https://medium.com/@DeolaJ/how-to-create-a-contact-form-with-supabase-next-js-b8c729cb7b3d">How to create a contact form with Supabase &amp; Next JS</a> (Part 1)” and “<a href="https://medium.com/@DeolaJ/how-to-send-emails-with-edge-functions-on-supabase-3653389c07c4">How to send emails with Edge Functions on Supabase</a> (Part 2)”. For this article, we will continue using the same Supabase project and API keys.</p><p>In Part 1, we established a connection between our contact form and the Supabase table (contacts). In Part 2, we developed an edge function to send emails (email). However, our contact form and edge function remain unconnected.</p><p>In this tutorial, we tie everything we have learned so far. We delve into creating a database function on Supabase which interacts with our edge function (email from Part 2). Additionally, we’ll explore the creation of a database trigger to invoke this database function whenever a new row is added to the contacts table. This establishes a direct link between the contact form and email notifications.</p><p>To follow along, a basic understanding of SQL is recommended, but no worries — I’ll provide some explanations as we progress.</p><h3>Database functions</h3><p>Within Supabase, <a href="https://supabase.com/docs/guides/database/functions">Database functions</a> are essentially <a href="https://www.postgresql.org/docs/current/sql-createfunction.html">SQL functions</a> supported in Postgres. These functions can be created either in the SQL Editor (as illustrated below) or directly on the Dashboard. For the sake of this tutorial, we’ll opt to use the Dashboard rather than the SQL Editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hBRKG8yjDXU_IzrymyXL9w.png" /><figcaption>SQL Editor</figcaption></figure><h4>Create a Database function</h4><p>Navigate to the Database Functions page on your project’s dashboard, it should be identical to the screen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RuEZs_DzO8opuOa_e5d8tA.png" /></figure><p>Next, click on create a new function button to follow create a database function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLMKe32k1bzV0bhPWTOFhw.png" /><figcaption>Creating a new database function</figcaption></figure><p>We call this function send_contact_email . Feel free to call it whatever you like.</p><p>We set the return type to trigger here because we need this function to be triggered by an update to our contacts table — this is called a <strong>Trigger function</strong>. The return type of a database function can be set to any return type from the dropdown though.</p><p>This function doesn’t need any arguments, so that section is empty.</p><pre>begin<br>  select<br>    http(<br>      (<br>        &#39;POST&#39;,<br>        &#39;EMAIL_EDGE_FUNCTION_URL&#39;,<br>        ARRAY [http_header(&#39;Authorization&#39;,&#39;Bearer API_KEY&#39;)],<br>        &#39;application/json&#39;,<br>        concat(<br>          &#39;{&quot;name&quot;:&quot;&#39;,<br>          new.name,<br>          &#39;&quot;, &quot;email&quot;: &quot;&#39;,<br>          new.email,<br>          &#39;&quot;, &quot;body&quot;: &quot;&#39;,<br>          new.body,<br>          &#39;&quot;}&#39;<br>        )<br>      ) :: http_request<br>    );<br><br>return new;<br><br>end;</pre><p>As seen above, we use the http extension (more on this later) to send the values of the new table row: name, email and body, to our email edge function. Replace EMAIL_EDGE_FUNCTION_URL with the actual URL from your edge function dashboard and API_KEY with yours.</p><p>Switch on the advanced settings toggle to set the type of security you need, if applicable. I selected SECURITY DEFINER for the sake of this tutorial, but this depends on your use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4QAEDtht3mUL69bsYCMxNA.png" /><figcaption>Advanced settings</figcaption></figure><p>Once you make a selection, submit to create your function. The function should be visible on the list, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZ72jrKS8yhkANrKbYQMTg.png" /><figcaption>Database function created</figcaption></figure><h4>Enable HTTP Extension</h4><p>To make API calls from our database function, <strong>enable the </strong><strong>http extension</strong> in the Extensions Tab of your Database. Read more about the <a href="https://supabase.com/docs/guides/database/extensions/http?database-method=dashboard">http extension</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y_Uix6ShoBnUy7aIZ0qR6A.png" /><figcaption>Extensions tab</figcaption></figure><p>Next, we call our trigger function.</p><h3>Database Trigger</h3><p>According to the Supabase documentation,</p><blockquote>In Postgres, a trigger executes a set of actions automatically on table events such as INSERTs, UPDATEs, DELETEs, or TRUNCATE operations.</blockquote><p>To call our trigger function, we need to create a trigger object that determines when the function is called. You can read more about this <a href="https://supabase.com/docs/guides/database/postgres/triggers">here</a>.</p><p>Thankfully, this can be done from the Dashboard on Supabase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jD5xc1XxjN133NL1Wg47zw.png" /><figcaption>Triggers Tab</figcaption></figure><h4>Create Trigger</h4><p>Creating a trigger is easy, click on the create a new trigger button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x30SLDTwHQ_wn5jNSvVOMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66U5BntSnqdIIThROgWY0w.png" /><figcaption>Creating a trigger</figcaption></figure><p>First, we name the trigger send_contact_email , same as the database function. Feel free to choose a name that suits your preferences.</p><p>In our case, we want the trigger to monitor the contacts table, and specifically aim to trigger email sending when a new row is added. Therefore, we select the Insert event. The trigger type is set to After the event , reflecting a personal preference, the alternative option is before the event.</p><p>Next, we configure this trigger to run on each Row in an operation — this choice explains why we reference new.name , new.email, new.body in our database function earlier. This ensures that even in cases of a bulk insert operations, emails are sent for each entry in the table.</p><p>Finally, we select the function to trigger. You should see the send_contact_email function in the list of database functions. Submit the form to create your trigger, and you are done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qDdSe0aEIMDvR6SHK95swA.png" /><figcaption>Trigger created</figcaption></figure><h3>Complete workflow</h3><p>To understand the end to end flow,</p><ul><li>An entry is submitted on the Contacts form (Next JS)</li><li>This creates a new row in the contacts table on Supabase (<strong>from</strong> <strong>Part 1</strong>)</li><li>The insert operation calls the send_contact_email trigger</li><li>The send_contact_email trigger calls its corresponding database function — send_contact_email .</li><li>The send_contact_email function makes an API call to the email Edge function with the values of the new row.</li><li>The email edge function (<strong>from</strong> <strong>Part 2</strong>) sends an email to the provided email address.</li></ul><p>To test whether it works, submit an entry to the contact form or directly on the contacts table, and the email submitted should receive an email notification. Alternatively, you can test this on the <a href="https://supabase-tutorials.vercel.app/">demo page</a>.</p><h3>Conclusion</h3><p>It’s worth noting that there are shorter alternatives to this approach. We have the option to directly call edge functions and database functions from the client, as demonstrated in the NextJS application in Part 1, without the need for a trigger.</p><p>Nevertheless, in the interest of introducing some of Supabase’s products, I chose to present this approach in a 3-part series.</p><p>Feel free to share your suggestions in the comments too for others to learn.</p><p>Thank you for following along.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=210cf245e57e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to send emails with Edge Functions on Supabase]]></title>
            <link>https://medium.com/@DeolaJ/how-to-send-emails-with-edge-functions-on-supabase-3653389c07c4?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3653389c07c4</guid>
            <category><![CDATA[email]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[edge-function]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 11:49:49 GMT</pubDate>
            <atom:updated>2023-11-15T13:42:25.275Z</atom:updated>
            <content:encoded><![CDATA[<p>A simple tutorial on Edge Functions — Part 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3PuRZLBCgVuuYSETvWRUw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@archduk3?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Carl Nenzen Loven</a> on <a href="https://unsplash.com/photos/v01fum9ZgJw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This is Part 2 of my Supabase tutorial series. If you haven’t, please check out the previous article, H<a href="https://medium.com/@DeolaJ/how-to-create-a-contact-form-with-supabase-next-js-b8c729cb7b3d">ow to create a contact form with Supabase &amp; Next JS</a>. We will use the same Supabase project and API keys.</p><p>In this tutorial, we learn how to create an edge function to send emails. We will walk through how to trigger email notifications when the contacts table has a new entry in the next article.</p><p>To follow along, you need basic knowledge of JavaScript. You can also check it out on <a href="https://github.com/DeolaJ/supabase-tutorials">Github</a>.</p><h3>Edge functions</h3><p>“<a href="https://supabase.com/docs/guides/functions">Edge Functions</a> are server-side TypeScript functions, distributed globally at the edge — close to your users. They can be used for listening to webhooks or integrating your Supabase project with third-parties <a href="https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/stripe-webhooks">like Stripe</a>.”</p><p>We can deploy server-side code that works as API endpoints. If you have worked with Firebase or Netlify, this is similar to how Cloud functions and Netlify functions work.</p><h4>Initialize supabase locally</h4><p>To create an edge function in our project, we need the supabase CLI. If you don’t have this installed, follow the instructions <a href="https://github.com/supabase/cli">here</a> . <strong>Check that you have the latest version installed too </strong>to avoid spending 2 days debugging like me.</p><pre>brew install supabase/tap/supabase</pre><p>Next, initialize a supabase project and follow the instructions.</p><pre>supabase init</pre><p>Next, link your supabase database to your local project. Replace [reference_id] with the project reference, you can check yours in the General tab of the project settings page. The database password is in the Database tab also.</p><pre>supabase link --project-ref [reference_id]</pre><p>Once this is done, we should have a supabase folder at the root of our local project with the config.toml file.</p><h4>Create function</h4><p>Next, we create an edge function named email.</p><pre>supabase functions new email</pre><p>This creates an email function. This function is situated in supabase/functions folder. All our functions will be added to this folder.</p><p>The default email function should look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sEISpmLsrwhLEiRYezPf2w.png" /></figure><p>Next, modify the email function to be functional. Feel free to use any email service you like. For the sake of this example, we will use <a href="https://resend.com/">resend</a>. Thankfully, there is a guide <a href="https://supabase.com/docs/guides/functions/examples/send-emails">here</a>.</p><pre>import { serve } from &quot;https://deno.land/std@0.131.0/http/server.ts&quot;;<br><br>console.log(`Function &quot;email&quot; up and running!`);<br><br>const RESEND_API_KEY = Deno.env.get(&quot;RESEND_API_KEY&quot;);<br><br>serve(async (request: Request): Promise&lt;Response&gt; =&gt; {<br>    const { email, body, name }: { email: string; body: string; name: string } =<br>        await request.json();<br><br>    if (!email?.length) {<br>        return new Response(JSON.stringify({ error: &quot;No email provided&quot; }), { status: 400 });<br>    }<br><br>    try {<br>        const res = await fetch(&quot;https://api.resend.com/emails&quot;, {<br>            method: &quot;POST&quot;,<br>            headers: {<br>                &quot;Content-Type&quot;: &quot;application/json&quot;,<br>                Authorization: `Bearer ${RESEND_API_KEY}`,<br>            },<br>            body: JSON.stringify({<br>                from: &quot;hello@deolaj.com&quot;,<br>                to: email,<br>                subject: &quot;You have a new message!&quot;,<br>                html: `<br>                    &lt;div&gt;<br>                        &lt;p&gt;Hi Deola,&lt;/p&gt;<br>                        &lt;p&gt;${body}&lt;/p&gt;<br>                        &lt;p&gt;From: ${name}&lt;/p&gt;<br>                    &lt;/div&gt;<br>                `,<br>            }),<br>        });<br><br>        if (!res.ok) {<br>            return new Response(JSON.stringify({ error: &quot;An error occurred&quot; }), { status: 500 });<br>        }<br><br>        const data = await res.json();<br><br>        return new Response(JSON.stringify(data), {<br>            status: 200,<br>            headers: {<br>                &quot;Content-Type&quot;: &quot;application/json&quot;,<br>            },<br>        });<br>    } catch (error: any) {<br>        return new Response(JSON.stringify({ error: error?.message }), { status: 500 });<br>    }<br>});</pre><p>A few things to note here. First, notice the email, body, and name values from our contacts table in Part 1 of this series. We also use RESEND_API_KEY from our environment variables (more on this in the next section).</p><h4>Environment variables</h4><p>We need to set the RESEND_API_KEY variable to use. There are two ways to do this.</p><p>The first involves creating an .env file in the root supabase folder. Remember to add .env to your .gitignore file. This will add all the variables in the .env file.</p><pre>supabase secrets set --env-file ./supabase/.env</pre><p>Alternatively, you can set the variables individually</p><pre>supabase secrets set RESEND_API_KEY=value</pre><p>Note that some environment variables have been set by default. To view all environment variables, run</p><pre>supabase secrets list</pre><p>For a more comprehensive explanation, check the <a href="https://supabase.com/docs/guides/functions/secrets">functions guide</a> or <a href="https://supabase.com/docs/reference/cli/supabase-secrets">CLI documentation</a>.</p><h4>Deployment</h4><p>To deploy the email function, simply run</p><pre>supabase functions deploy email</pre><p>Feel free to invoke your function in your terminal to test. Replace the FUNCTION_URL , API_KEY , and email with yours.</p><pre>curl --request POST &#39;FUNCTION_URL&#39; \<br>  --header &#39;Authorization: Bearer API_KEY&#39; \<br>  --header &#39;Content-Type: application/json&#39; \<br>  --data &#39;{&quot;email&quot;:&quot;hello@deolaj.com&quot;, &quot;name&quot;:&quot;Test person&quot;, &quot;body&quot;:&quot;This is a test email&quot;}&#39;</pre><p>To invoke your function locally, check this <a href="https://supabase.com/docs/guides/functions/local-development">guide</a></p><h3>Conclusion</h3><p>I hope this tutorial helps to get started with edge functions on supabase.</p><p>Next, we learn how to trigger email notifications when our contact form (from Part 1) gets a new submission.</p><p>Follow along to Part 3, <a href="https://medium.com/@DeolaJ/how-to-trigger-email-notifications-on-a-contact-form-with-supabase-210cf245e57e">How to trigger email notifications on a contact form with Supabase</a></p><p><em>Originally posted in </em><a href="https://deolaj.com/notes/how-to-send-emails-with-edge-functions-on-supabase"><em>my portfolio notes</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3653389c07c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a contact form with Supabase & Next JS]]></title>
            <link>https://medium.com/@DeolaJ/how-to-create-a-contact-form-with-supabase-next-js-b8c729cb7b3d?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8c729cb7b3d</guid>
            <category><![CDATA[contact-form]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 07:48:32 GMT</pubDate>
            <atom:updated>2023-11-10T15:06:24.495Z</atom:updated>
            <content:encoded><![CDATA[<p>An introduction to Supabase — Part 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oj2uFR0BHVG3jyi9ah6euQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@anniespratt?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Annie Spratt</a> on <a href="https://unsplash.com/photos/goholCAVTRs?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Originally posted in </em><a href="https://deolaj.com/notes/how-to-create-a-contact-form-with-supabase-and-next-js"><em>my portfolio notes</em></a> i<em>n April, 2023.</em></p><p><a href="https://supabase.com">Supabase</a> is an open source Firebase alternative and helps you to build faster and focus on your products. As someone that likes to test out ideas once in a while, Firebase and Supabase have been interesting to work with.</p><p>In this tutorial, I will walk you through an introduction to Supabase, setting up a Database table, creating a simple contact form in Next JS, and putting it all together.</p><p>I assume you have basic knowledge of Next JS to follow along.</p><p>To follow along with the Next JS project, check it out on <a href="https://github.com/DeolaJ/supabase-tutorials">Github</a>. The contact form demo is also <a href="https://supabase-tutorials.vercel.app/">live</a>.</p><h3>Supabase</h3><p>Creating a Supabase account is pretty simple. Visit <a href="https://supabase.com">Supabase</a> and click on the “Start your project” button.</p><p>First, create an organization</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*zWUtjQCgyyfAR0vvdVJIXA.png" /></figure><p>Next, create a project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*UJqRpch7kjzygn03eFxsvA.png" /></figure><p>On the next screen, your project API keys will be displayed. Copy the public key and keep it aside. We will use it later in this tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*8ii3Sp1CW3Vq18FGfNdkeQ.png" /></figure><p>Copy the URL under the Project Configuration section too. This will be your base URL for the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*sNZpkPXCYupl6i0wnUDWPw.jpeg" /></figure><p>Next, we will create a table for the contact form.</p><h3>Create a Database table</h3><p>In the section below, click on Database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFR_l8fwR8e6eWUrv_A5iQ.png" /></figure><p>A blank page will be displayed. Click on the button to create a new table and follow the steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c9rF7Vkm1Y3gONPcl4yINw.png" /></figure><p>Add as many columns as you’d like. For the sake of this tutorial, we will create a table named “contacts” with the following columns.</p><p>Note that the column types are important and the RLS policies section is checked. This controls access to our table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*EoQFtyTihmipKaY6PR4G9g.png" /></figure><p>Next, we write a simple policy for our table. Without a row level policy, we will not be able to read, update or delete rows on our table.</p><p>On our blank table, click on “No active RLS policies” on the extreme right of the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUeoA-OeuOU3gaL2zyQagQ.png" /></figure><p>Create a new policy and select “For full customization”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*1ubTu-NNn6ktgFsAOBcUvw.png" /></figure><p>For the sake of this tutorial, we will enable access to all operations on our table. To read more about Row level security, visit this page in the <a href="https://supabase.com/docs/guides/auth/row-level-security">documentation</a>.</p><p>Follow the steps below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLrjDa0vBtBpky0Az-h_AQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RF1tDhFhLlqL-_JDBOxH2g.png" /></figure><p>We are all set to create our contact form now.</p><h3>Contact form</h3><p>To follow along with the Next JS project, check it out on [Github](<a href="https://github.com/DeolaJ/supabase-tutorials">https://github.com/DeolaJ/supabase-tutorials</a>).</p><p>Create a simple Next JS project:</p><pre>npx create-next-app contact-form<br>npm install formik yup @supabase/supabase-js</pre><p>We install a few dependencies to help create the contact form and to interact with our supabase table.</p><p>To start, we create the supabase client in our next JS application using the <a href="https://www.npmjs.com/package/@supabase/supabase-js">supabase-js</a> library. I added the Supabase base URL and our project’s public key to the .env file to be used here. There is an example .env file in the github project.</p><pre>import { createClient } from &quot;@supabase/supabase-js&quot;;<br>const supabase = createClient(<br>   process.env.NEXT_PUBLIC_SUPABASE_URL,<br>   process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY<br>);<br>export default supabase;</pre><p>Next, we create a simple contact form with the following schema</p><pre>...<br><br>const ContactSchema = Yup.object().shape({<br>   name: Yup.string().max(140, &quot;Too long!&quot;).required(&quot;Required.&quot;),<br>   email: Yup.string().email(&quot;Invalid email.&quot;).max(140, &quot;Too long!&quot;).required(&quot;Required.&quot;),<br>   body: Yup.string().max(280, &quot;Too long!&quot;).required(&quot;Required.&quot;),<br>});<br><br>...</pre><p>Any kind of form works here. I chose formik for convenience. Check the github project for a complete picture.</p><pre>...<br><br>&lt;Formik   <br>    enableReinitialize<br>    initialValues={defaultContact}<br>    validationSchema={ContactSchema}<br>    onSubmit={handleSubmit}<br>&gt;<br>    &lt;Form&gt;<br>        &lt;Field name=&quot;name&quot;&gt;<br>            {({ field, meta }) =&gt; (<br>                &lt;div className=&quot;form-control&quot;&gt;<br>                    &lt;label mb=&quot;1.5&quot; fontSize=&quot;sm&quot; htmlFor=&quot;contact-name&quot;&gt;<br>                        Name<br>                    &lt;/label&gt;<br>                    &lt;input {...field} placeholder=&quot;Enter name&quot; id=&quot;contact-name&quot; /&gt;<br>                    {meta.error &amp;&amp; meta.touched &amp;&amp; &lt;p&gt;{meta.error}&lt;/p&gt;}<br>                &lt;/div&gt;<br>            )}<br>        &lt;/Field&gt;<br>        &lt;Field name=&quot;email&quot;&gt;<br>            {({ field, meta }) =&gt; (<br>                &lt;div className=&quot;form-control&quot;&gt;<br>                    &lt;label mb=&quot;1.5&quot; fontSize=&quot;sm&quot; htmlFor=&quot;contact-email&quot;&gt;<br>                        Email<br>                    &lt;/label&gt;<br>                    &lt;input {...field} placeholder=&quot;Enter email&quot; id=&quot;contact-email&quot; /&gt;<br>                    {meta.error &amp;&amp; meta.touched &amp;&amp; &lt;p&gt;{meta.error}&lt;/p&gt;}<br>                &lt;/div&gt;<br>            )}<br>        &lt;/Field&gt;<br>        &lt;Field name=&quot;body&quot;&gt;<br>            {({ field, meta }) =&gt; (<br>                &lt;div className=&quot;form-control&quot;&gt;<br>                    &lt;label mb=&quot;1.5&quot; fontSize=&quot;sm&quot; htmlFor=&quot;contact-body&quot;&gt;<br>                        Body<br>                    &lt;/label&gt;<br>                    &lt;textarea<br>                        {...field}<br>                        id=&quot;contact-body&quot;<br>                        placeholder=&quot;Describe what you are reaching out for.&quot;<br>                    /&gt;<br>                    {meta.error &amp;&amp; meta.touched &amp;&amp; &lt;p&gt;{meta.error}&lt;/p&gt;}<br>                &lt;/div&gt;<br>            )}<br>        &lt;/Field&gt;<br><br>        &lt;div className=&quot;button-container&quot;&gt;<br>            &lt;button type=&quot;submit&quot; className=&quot;submit-button&quot;&gt;<br>                {isSubmittingForm ? &quot;Submitting...&quot; : &quot;Submit&quot;}<br>            &lt;/button&gt;<br>        &lt;/div&gt;<br>    &lt;/Form&gt;<br>&lt;/Formik&gt;<br><br>...</pre><p>Next, we create the handleSubmit function to interact with our supabase table.</p><pre>async function handleSubmit(values, { resetForm }) {<br>    const { name, email, body } = values;<br>    try {<br>        const { error } = await supabase.from(&quot;contacts&quot;).insert({ name, email, body });<br>        if (error) {<br>            throw error;<br>        }<br>        setFeedback(&quot;Form submitted successfully&quot;);<br>        resetForm();<br>    } catch (error) {<br>        console.log(&quot;Error occurred&quot;, { error });<br>        setFeedback(&quot;An error occurred&quot;);<br>    }<br>}</pre><p>The supabase client is used to insert a new row into the exact table we created (contacts). If this works well, you should see the new row on your table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iexp8Cec56jiPq7EjLAr1w.png" /></figure><h4>Using React Query</h4><p>Alternatively, you can use this with React Query.</p><p>First, create a hook</p><pre>import { useMutation } from &quot;@tanstack/react-query&quot;;<br><br>import supabase from &quot;../lib/supabase&quot;;<br><br>const updateContacts = async (contact) =&gt; {<br>    const { data, error } = await supabase.from(&quot;contacts&quot;).insert(contact);<br>    if (error) {<br>        throw error;<br>    }<br>    return data;<br>};<br><br>export default function useUpdateContacts() {<br>    return useMutation((contact) =&gt; updateContacts(contact));<br>}</pre><p>Then call the hook inside your contact form,</p><pre>...<br><br>const { mutateAsync: submitFormAsync, isLoading: isSubmittingForm } = useUpdateContacts();<br><br>...</pre><p>Then use this in your handleSubmit function instead</p><pre>async function handleSubmit(values, { resetForm }) {<br>    const { name, email, body } = values;<br>    try {<br>        await submitFormAsync({ name, email, body });<br>        setFeedback(&quot;Form submitted successfully&quot;);<br>        resetForm();<br>    } catch (error) {<br>        console.log(&quot;Error occurred&quot;, { error });<br>        setFeedback(&quot;An error occurred&quot;);<br>    }<br>}</pre><h3>Conclusion</h3><p>Note that for free accounts on Supabase, the project is paused after 7 days of inactivity.</p><p>I hope this tutorial helps to get started with supabase. This is the first article of my Supabase and Next JS series.</p><p>Follow along to Part 2, <a href="https://medium.com/@DeolaJ/how-to-send-emails-with-edge-functions-on-supabase-3653389c07c4">How to send emails using Edge functions on Supabase</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8c729cb7b3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to generate a dynamic sitemap for your Next JS website]]></title>
            <link>https://frontend-digest.com/how-to-generate-a-dynamic-sitemap-for-your-next-js-website-7dd4f5ef667?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dd4f5ef667</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[contentful]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[sitemap]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Thu, 15 Dec 2022 12:26:26 GMT</pubDate>
            <atom:updated>2022-12-16T14:10:37.192Z</atom:updated>
            <content:encoded><![CDATA[<p>A short tutorial to create a dynamic sitemap (Headless CMS)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*paLaGGK5ZMqLXc8UzLEi9w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dariuszsankowski?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dariusz Sankowski</a> on <a href="https://unsplash.com/s/visual/6789b5c7-0f1d-46d1-9446-957aeb8df587?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Originally posted in </em><a href="https://deolaj.com/notes/how-to-generate-a-dynamic-sitemap-for-your-next-js-website"><em>my portfolio notes</em></a><em> on July, 2021.</em></p><p>A sitemap will give your website pages more visibility on Google Search by defining the relationship between pages.</p><p>In this tutorial, I will walk you through how to create a static and dynamic sitemap for your Next JS website.</p><h3>Static Sitemap</h3><p>If you just need a simple sitemap, you can simply create a sitemap.xml.js in your pages folder and structure it in the following way:</p><pre>&lt;urset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;<br>  &lt;url&gt;<br>     &lt;loc&gt;https://deolaj.com&lt;/loc&gt;<br>     &lt;changefreq&gt;monthly&lt;/changefreq&gt;<br>     &lt;priority&gt;1.0&lt;/priority&gt;<br>   &lt;/url&gt;<br>   &lt;url&gt;<br>     &lt;loc&gt;https://deolaj.com/notes&lt;/loc&gt;<br>     &lt;changefreq&gt;monthly&lt;/changefreq&gt;<br>     &lt;priority&gt;1.0&lt;/priority&gt;<br>   &lt;/url&gt;<br>&lt;urlset&gt;</pre><h3>Dynamic Sitemap with local pages</h3><p>To create a dynamic sitemap, first create a sitemap.js file anywhere in the root of your project or in the src folder.<br>Then add the globby library to your project to get the list of routes:</p><pre>yarn add globby — dev</pre><p>First, to get the page routes, we will use the globby package to extract the routes first. We exclude the Next JS default pages (_app.tsx, _document.tsx etc.), [slug].tsx, and api pages since they are not important.</p><pre>const globby = require(‘globby’);<br><br>const pages = await globby([<br> ‘pages/**/*.tsx’,<br> ‘!pages/_*.tsx’,<br> ‘!pages/**/[slug].tsx’,<br> ‘!pages/api’,<br> ]);</pre><p>Next, we get the current Date:</p><pre>const currentDate = new Date().toISOString();</pre><p>Next, we create the complete sitemap string</p><pre>const sitemap = `<br>  &lt;?xml version=”1.0&quot; encoding=”UTF-8&quot;?&gt;<br>    &lt;urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;<br>     ${pages.map((page) =&gt; {<br>       const path = page<br>         .replace(‘pages’, ‘’)<br>         .replace(‘.js’, ‘’)<br>         .replace(‘.tsx’, ‘’)<br>         .replace(‘.md’, ‘’);<br>       const route = path === ‘/index’ ? ‘’ : path;<br>       return `<br>         &lt;url&gt;<br>           &lt;loc&gt;${`https://deolaj.com${route}`}&lt;/loc&gt;<br>           &lt;lastmod&gt;${currentDate}&lt;/lastmod&gt;<br>           &lt;changefreq&gt;monthly&lt;/changefreq&gt;<br>           &lt;priority&gt;1.0&lt;/priority&gt;<br>         &lt;/url&gt;<br>       `;<br>     })<br>   .join(‘’)}<br>  &lt;/urlset&gt;<br>`;</pre><p>Next, write this file to your public folder:</p><pre>const fs = require(‘fs’);<br> fs.writeFileSync(‘public/sitemap.xml’, sitemap);</pre><p>Finally, put everything together</p><pre>const fs = require(‘fs’);<br>const globby = require(‘globby’);<br><br>async function generateSiteMap() {<br> const pages = await globby([<br>   ‘pages/**/*.tsx’,<br>   ‘!pages/_*.tsx’,<br>   ‘!pages/**/[slug].tsx’,<br>   ‘!pages/api’,<br> ]);<br><br> const currentDate = new Date().toISOString();<br><br>  const sitemap = `<br>    &lt;?xml version=”1.0&quot; encoding=”UTF-8&quot;?&gt;<br>     &lt;urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;<br>       ${pages.map((page) =&gt; {<br>         const path = page<br>         .replace(‘pages’, ‘’)<br>         .replace(‘.js’, ‘’)<br>         .replace(‘.tsx’, ‘’)<br>         .replace(‘.md’, ‘’);<br>         const route = path === ‘/index’ ? ‘’ : path;<br>         return `<br>           &lt;url&gt;<br>             &lt;loc&gt;${`https://deolaj.com${route}`}&lt;/loc&gt;<br>             &lt;lastmod&gt;${currentDate}&lt;/lastmod&gt;<br>             &lt;changefreq&gt;monthly&lt;/changefreq&gt;<br>             &lt;priority&gt;1.0&lt;/priority&gt;<br>           &lt;/url&gt;<br>         `;<br>       })<br>     .join(&#39;&#39;)}<br>   &lt;/urlset&gt;<br>  `;<br><br>  fs.writeFileSync(‘public/sitemap.xml’, sitemap);<br>}<br><br>generateSiteMap();</pre><h3>Dynamic Sitemap with remote content</h3><p>In this example, I will use contentful to illustrate how to generate dynamic pages using remote content. E.g blog posts.</p><p>First, initialize the contentful client with your space id and access token</p><pre>const { createClient } = require(‘contentful’);<br><br>const client = createClient({<br> space: process.env.CONTENTFUL_SPACE_ID,<br> accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,<br>});</pre><p>Get the posts from contentful and their paths (slug)</p><pre>const notePosts = await client<br> .getEntries({ content_type: ‘notes’, order: ‘sys.createdAt’ })<br> .then((response) =&gt; {<br>   // this is a custom utility function I created to extract the posts<br>   const posts = generateNotePosts(response.items);<br>   return posts;<br> });<br><br> const notePaths = notePosts.map(({ fields: { slug } }) =&gt; slug);</pre><p>Next, modify the sitemap string with a new section for remote pages</p><pre>…<br> ${notePaths.map((route) =&gt; {<br>   return `<br>     &lt;url&gt;<br>       &lt;loc&gt;${`https://deolaj.com/notes/${route}`}&lt;/loc&gt;<br>       &lt;lastmod&gt;${currentDate}&lt;/lastmod&gt;<br>       &lt;changefreq&gt;monthly&lt;/changefreq&gt;<br>       &lt;priority&gt;1.0&lt;/priority&gt;<br>     &lt;/url&gt;<br>   `;<br> })<br> .join(‘’)}<br>…</pre><p>Finally, put everything together</p><pre>const fs = require(‘fs’);<br>const globby = require(‘globby’);<br>const { createClient } = require(‘contentful’);<br><br>async function generateSiteMap() {<br>  const pages = await globby([<br>   ‘pages/**/*.tsx’,<br>   ‘!pages/_*.tsx’,<br>   ‘!pages/**/[slug].tsx’,<br>   ‘!pages/api’,<br>  ]);<br><br>  const client = createClient({<br>   space: process.env.CONTENTFUL_SPACE_ID,<br>   accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,<br>  });<br><br>  const currentDate = new Date().toISOString();<br><br>  const notePosts = await client<br>   .getEntries({ content_type: ‘notes’, order: ‘sys.createdAt’ })<br>   .then((response) =&gt; {<br>     // this is a custom utility function I created to extract the posts<br>     const posts = generateNotePosts(response.items);<br>     return posts;<br>   });<br><br>  const notePaths = notePosts.map(({ fields: { slug } }) =&gt; slug);<br><br>  const sitemap = `<br>    &lt;?xml version=”1.0&quot; encoding=”UTF-8&quot;?&gt;<br>      &lt;urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;<br>       ${pages.map((page) =&gt; {<br>         const path = page<br>           .replace(‘pages’, ‘’)<br>           .replace(‘.js’, ‘’)<br>           .replace(‘.tsx’, ‘’)<br>           .replace(‘.md’, ‘’);<br>         const route = path === ‘/index’ ? ‘’ : path;<br>         return `<br>           &lt;url&gt;<br>             &lt;loc&gt;${`https://deolaj.com${route}`}&lt;/loc&gt;<br>             &lt;lastmod&gt;${currentDate}&lt;/lastmod&gt;<br>             &lt;changefreq&gt;monthly&lt;/changefreq&gt;<br>             &lt;priority&gt;1.0&lt;/priority&gt;<br>           &lt;/url&gt;<br>         `;<br>       })<br>     .join(‘’)}<br><br>      ${notepaths.map((route) =&gt; {<br>        return `<br>          &lt;url&gt;<br>            &lt;loc&gt;${`https://deolaj.com/notes/${route}`}&lt;/loc&gt;<br>            &lt;lastmod&gt;${currentDate}&lt;/lastmod&gt;<br>            &lt;changefre&gt;monthly&lt;/changefreq&gt;<br>            &lt;priority&gt;1.0&lt;/priority&gt;<br>          &lt;/url&gt;<br>        `;<br>      })<br>      .join(&#39;&#39;)}<br>   &lt;/urlset&gt;<br>  `;<br><br>  fs.writeFileSync(‘public/sitemap.xml’, sitemap);<br>}<br><br>generateSiteMap();</pre><h3>Putting it together</h3><p>To ensure that your page is built, add the following to your next.config.js</p><pre>module.exports = {<br>  webpack: (config, { isServer }) =&gt; {<br>    if (isServer) {<br>    // Replace the path below with the `sitemap.js` file location<br>    require(‘./src/utils/sitemap’);<br>  }<br>  return config;<br>};</pre><p>Run your local server and the sitemap.xml should appear in your /public folder</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dd4f5ef667" width="1" height="1" alt=""><hr><p><a href="https://frontend-digest.com/how-to-generate-a-dynamic-sitemap-for-your-next-js-website-7dd4f5ef667">How to generate a dynamic sitemap for your Next JS website</a> was originally published in <a href="https://frontend-digest.com">Frontend Digest</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a Custom Route Blocking Modal in React]]></title>
            <link>https://medium.com/@DeolaJ/how-to-create-a-custom-route-blocking-modal-in-react-9306139ee3c7?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9306139ee3c7</guid>
            <category><![CDATA[react-router]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[modal]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Fri, 19 Mar 2021 10:46:02 GMT</pubDate>
            <atom:updated>2021-04-11T08:16:43.253Z</atom:updated>
            <content:encoded><![CDATA[<h4>A short tutorial on how to block navigation using both the beforeunload event and React Router Prompt in a hybrid solution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXWQvWBtRQqP5jZ2GGz13Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@florianrieder?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Florian Rieder</a> on <a href="/s/photos/gate?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Recently, I faced a problem where I needed to show a message to block a user from navigating away from the page after performing some action in a React application. So I did some research on solutions that could give some control. While searching for this solution, I stumbled on <a href="https://javascript.plainenglish.io/creating-a-custom-userconfirmation-modal-with-the-react-router-prompt-dc1faa5a65a0">this</a> article that also helped in drafting a solution by taking advantage of the React-Router library.</p><p>To extend that solution, I will walk you through some basic steps to create a hybrid solution. This solution involves:</p><ul><li>A custom modal to block routing to other React pages using react-router,</li><li>and the default browser dialog which blocks other forms of navigation using thebeforeunload event to catch other corner cases.</li></ul><p>This hybrid solution can be extended to fit other use cases. The Custom Modal created in this tutorial is in this <a href="https://codesandbox.io/s/custom-route-blocking-modal-r5dpu">Sandbox</a> if you want to skip the explanation.</p><p>You need a basic understanding of JavaScript, React JS, and some knowledge of the React-Router to follow along.</p><h4>The Beforeunload event</h4><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event">According to MDN</a>,</p><blockquote>The <strong>beforeunload</strong> event is fired when the window, the document and its resources are about to be unloaded. The document is still visible and the event is still cancelable at this point.</blockquote><p>With this event, we can stop users from navigating by triggering a dialog that asks if the user wants to leave the page or not.</p><h4>React Router</h4><p>React-router helps with routing in React applications, and it provides a component, Prompt, which helps with route blocking logic. We will use this component in this solution.</p><p>Next, we will create a custom modal in React.</p><h3>Creating the Base Modal</h3><p>To create a modal in React, we use portals. According to the <a href="https://reactjs.org/docs/portals.html">official documentation</a>,</p><blockquote>Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51fef9a550d4ce5c08cc69e8c6993ec7/href">https://medium.com/media/51fef9a550d4ce5c08cc69e8c6993ec7/href</a></iframe><p>In this snippet, we create an element that represents the modal (div) and we store it in a ref. Then we append this modal (div) to an element (with the id of ‘modal’) already present in the DOM.</p><p>The modal is styled using styled-components . Then we use this modal element to wrap our modal body in a new component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cf66a14f287b03917ce6577af2c5ecd/href">https://medium.com/media/6cf66a14f287b03917ce6577af2c5ecd/href</a></iframe><p>In this component, we basically cover the cases when the modal is closed by either clicking the close button or clicking on the outer area of the modal. The scrolling container helps to catch cases where the Modal content overflows the viewport.</p><p>This is a very simple modal and does not cover making the modal accessible to keyboard users. To make your modal more accessible, check out <a href="https://bitsofco.de/accessible-modal-dialog/">this article</a>.</p><p>Next, we will use this component to create our confirmation modal</p><h3>Creating the Confirmation Modal</h3><p>In this section, we will separate the React and non-react route blocking implementations. Then merge both in one file.</p><h4>Blocking React routes</h4><p>First, as we mentioned earlier, we will use the Prompt component from React Router. According to the <a href="https://reactrouter.com/core/api/Prompt">documentation</a>, Prompt has a message prop, a function which:</p><blockquote><em>Will be called with the next </em><em>location and </em><em>action the user is attempting to navigate to. Return a string to show a prompt to the user or </em><em>true to allow the transition.</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/661e436d969b39c781557e4caf5d9c72/href">https://medium.com/media/661e436d969b39c781557e4caf5d9c72/href</a></iframe><p>The Prompt gets the handleBlockedRoute function as its message prop. Note the following:</p><ul><li>handleBlockedRoute gets the next location like mentioned in the documentation as a parameter. It also determines whether the prompt is shown or not</li><li>The state variable, confirmedNavigation tracks whether the user has decided to leave the page through the modal</li><li>A prop isBlocked , which we will use later, helps us to signal to the Modal whether the navigation should be stopped or not</li><li>lastLocation holds the last location that was blocked as its name suggests</li><li>showModal opens the Confirmation Modal and sets the next location that was initial blocked into lastLocation .</li></ul><p>So the handleBlockedRoute first determines whether the route should be blocked based on the isBlocked prop and the confirmedNavigation state variable. If the route should be blocked, it triggers the confirmation modal and also sets the lastLocation state variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36759db3a8ba132c3b6cbb199d762834/href">https://medium.com/media/36759db3a8ba132c3b6cbb199d762834/href</a></iframe><p>So if a user decides to leave the page after the modal has been triggered, we trigger the handleConfirmNavigationClick function. Note the following:</p><ul><li>The handleConfirmNavigationClick function closes the modal, then sets the confirmNavigation state variable to true</li><li>The useEffect hook watches for changes in confirmNavigation . If the navigation routing has been confirmed ( confirmNavigation is true) and there exists a lastLocation (the location that was blocked earlier), we trigger the route change using the useHistory hook.</li></ul><h4>Blocking Non-React routes</h4><p>As mentioned earlier, we will use the beforeunload event to block non-react routing</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6496da1780142d3a2029b65a300e98d9/href">https://medium.com/media/6496da1780142d3a2029b65a300e98d9/href</a></iframe><p>Note the following:</p><ul><li>isModalOpen determines whether the modal is open or not. It is changed by two functions: openModal and closeModal</li><li>shouldUnload determines whether the Browser dialog should show when the beforeunload event is triggered</li></ul><p>First, we add the setShouldUnload function to the useEffect hook that allows navigation routing in react. Then we create a useEffect hook that blocks non-react routing.</p><h4>Putting it all together</h4><p>Merging everything with some styling for the Custom Modal, we get this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/daf05b525d5ea36880b310bee810ee82/href">https://medium.com/media/daf05b525d5ea36880b310bee810ee82/href</a></iframe><p>The content and title are passed to the modal in practice.</p><h3>In Practice</h3><p>To view the modal and dialog in action, we have created two pages to illustrate the blocked navigation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee3603597e895b3e76c82231b6ddbac3/href">https://medium.com/media/ee3603597e895b3e76c82231b6ddbac3/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48ff7b1ba2e20481d97e0b60fc37d35b/href">https://medium.com/media/48ff7b1ba2e20481d97e0b60fc37d35b/href</a></iframe><p>Finally, note that the Prompt component should be used within a Router.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c20204bbd8a70bc6a3cffd6ec71c6311/href">https://medium.com/media/c20204bbd8a70bc6a3cffd6ec71c6311/href</a></iframe><p>Thank you for following along. This is the end of the tutorial. Please leave a comment or feedback below if you have any. I hope you found this useful. Once again, to view the modal in action, check out this <a href="https://codesandbox.io/s/custom-route-blocking-modal-r5dpu">Sandbox</a>.</p><p>You can also share your feedback with me on <a href="https://twitter.com/Deo_Joe">Twitter</a>, follow me here on Medium, or <a href="https://github.com/DeolaJ">Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9306139ee3c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Twin.macro Tutorial for Beginners: Styling with Tailwind CSS and Emotion in React]]></title>
            <link>https://medium.com/@DeolaJ/twin-macro-tutorial-for-beginners-styling-with-tailwind-css-and-emotion-in-react-5228c819d713?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5228c819d713</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Mon, 08 Feb 2021 12:42:48 GMT</pubDate>
            <atom:updated>2021-03-30T10:52:08.492Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How to set up your React project to use Tailwind CSS and Emotion using Twin.macro</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2tTVlZLqzJlBfpX4NOn4Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@saracervera?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sara Cervera</a> on <a href="https://unsplash.com/photos/6zAxhF--deQ?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>First a little overview of each library based on their documentation:</p><blockquote>Emotion is a library designed for writing css styles with JavaScript. It provides powerful and predictable style composition in addition to a great developer experience with features such as source maps, labels, and testing utilities. Both string and object styles are supported.</blockquote><blockquote>Tailwind is a utility-first CSS framework packed with classes like that can be composed to build any design, directly in your markup.</blockquote><blockquote>Twin blends the magic of Tailwind with the flexibility of css-in-js</blockquote><p>I never felt I could need a styling solution that involved merging two libraries. However, as a good saying goes:</p><blockquote>I can’t say I wasn’t hoping for it, but I didn’t see it coming.”<br>― <strong>Jessi Kirby, </strong><a href="https://www.goodreads.com/work/quotes/17589097"><strong>Golden</strong></a></blockquote><p><strong>Tailwind</strong> gives the advantage of a utility first CSS approach, which can be tailored to build unique interfaces. Tailwind also ensures that your stylesheet does not grow exponentially with your project size. Also, Tailwind’s classes pose less cognitive load with intuitive class names (you get used to it after a short while).</p><p><strong>Emotion</strong> helps to solve the cascading problem since styles are scoped. It also generates class names out of the box which can have the component names as an attached label to aid readability. It helps to manage specificity with our selectors.</p><p>Each can stand alone and be sufficient. However, I was faced with a unique problem that involved letting the end-users overwrite styles (add Custom CSS). I also needed to use JavaScript variables to generate classes conditionally, but avoid the use of inline styles which can be a headache to overwrite.</p><p>After some research, I stumbled on <strong>Twin.macro </strong>which solves this unique problem by merging the usability of CSS-in-JS libraries like Emotion with the Utility approach given by Tailwind. Tailwind’s classes are composed of style declarations. This is useful for teams that are already familiar with Tailwind.</p><p>One of Tailwind’s weaknesses is creating complex animations. Working with Twin.macro also helps to attach custom animation to classes through the CSS-in-JS declaration.</p><p>In this tutorial, I will walk you through the steps to set up a React project to use Twin.macro. Then, we will look at a few examples of how to use this library for different use cases.</p><p>To follow along, you need a basic understanding of how JSX works.</p><h3>Installation</h3><ol><li>First, install Emotion as a dependency</li></ol><pre>yarn add @emotion/styled @emotion/react</pre><p>Emotion requires you to do the following to use the css prop. Without this, your classes appear like <strong>[object object].</strong></p><pre>/** @jsx jsx */<br>import { jsx } from &#39;@emotion/react&#39;</pre><p>To avoid importing jsx in all files, other methods can be found in the <a href="https://emotion.sh/docs/css-prop">official documentation</a>. I use the @emotion/babel-preset-css-prop preset mostly.</p><p>2. Install tailwind CSS as a dependency or dev dependency (this depends on whether you want to extend some functionalities).</p><pre>yarn add tailwindcss</pre><p>Generate tailwind.config.js to extend as you see fit. We’ll discuss this in a bit more detail later.</p><pre>npx tailwindcss init --full</pre><p>3. Next, install Twin.macro as a dependency:</p><pre>yarn add twin.macro</pre><p>Then install a plugin for babel macros:</p><pre>yarn add --dev babel-plugin-macros @babel/core</pre><p>Add a new babelMacros key to yourpackage.json to configure Twin.</p><pre>&quot;babelMacros&quot;: {<br>    &quot;twin&quot;: {<br>      &quot;preset&quot;: &quot;emotion&quot;<br>    }<br>  },</pre><p>This selects Emotion as the CSS-in-JS library to use with Twin.macro.</p><p>Create a .babelrc file at the root of your project. Add the babel-plugin-macros to your babel configuration file.</p><pre>{<br>  &quot;plugins&quot;: [<br>    &quot;babel-plugin-macros&quot;,<br>  ],<br>}</pre><p>We are all done. Next, we will make use of twin.macro to create and style components.</p><blockquote>Note, to set up VSCode to give auto-complete options for twin.macro, check <a href="https://github.com/ben-rogerson/twin.macro/discussions/227">this</a> out</blockquote><h3>Usage Examples</h3><p>I picked and modified some examples from the <a href="https://github.com/ben-rogerson/twin.macro">Github documentation</a>.</p><ol><li>Using the tw prop directly with jsx elements:</li></ol><pre>import &#39;twin.macro&#39;;</pre><pre>const One = () =&gt; &lt;div tw=&quot;text-blue-300&quot;&gt;One&lt;/div&gt;;</pre><p>2. Nesting the tw prop to add conditional styles:</p><pre>import tw from &#39;twin.macro&#39;;</pre><pre>const Two = ({ hasHover }) =&gt; (<br>  &lt;div css={[tw`border border-solid border-black`, hasHover &amp;&amp; tw`hover:border-blue-300`]}&gt;Two&lt;/div&gt;<br>);</pre><p>3. Using Emotion’s css prop to add conditional styles:</p><pre>import tw, { css } from &#39;twin.macro&#39;;</pre><pre>// Notice that Emotion&#39;s css prop is imported directly from twin.macro</pre><pre>const hoverStyles = css`<br>  &amp;:hover {<br>    border-color: black;<br>    ${tw`text-black border-solid`}<br>  }<br>`;</pre><pre>const Three = ({ hasHover, text = &quot;Three&quot; }) =&gt; (<br>  &lt;div css={[tw`border`, hasHover &amp;&amp; hoverStyles]}&gt;{text}&lt;/div&gt;<br>);</pre><p>4. Using tw prop to create styled components:</p><pre>import tw from &#39;twin.macro&#39;;</pre><pre>const Four = tw.div`border border-solid border-blue-300 hover:border-black`;</pre><p>5. Clone existing styled components with extra styling:</p><pre>import tw from &#39;twin.macro&#39;;</pre><pre>const Four = tw.div`border border-solid border-blue-300 hover:border-black`;</pre><pre>const Five = tw(Four)`border-purple-500`;</pre><p>6. Using Emotion’s styled import for conditional styling:</p><pre>import tw, { styled } from &#39;twin.macro&#39;;</pre><pre>const StyledSix = styled.div(({ hasBorder }) =&gt; [<br>  `color: black;`,<br>  hasBorder &amp;&amp; tw`border-purple-500 border-solid border rounded-sm`<br>]);</pre><pre>const Six = () =&gt; &lt;StyledSix hasBorder&gt;Six&lt;/StyledSix&gt;;</pre><p>7. Using the backticks to add custom styling to styled components:</p><pre>import tw, { styled } from &#39;twin.macro&#39;;</pre><pre>const StyledSeven = styled.div`<br>  color: black;<br>  ${({ hasBorder }) =&gt; hasBorder &amp;&amp; tw`border border-solid border-purple-500`}<br>`;</pre><pre>const Seven = () =&gt; &lt;StyledSeven hasBorder&gt;Seven&lt;/StyledSeven&gt;;</pre><p>8. Merging multiple styling formats in styled components:</p><pre>import tw, { styled } from &#39;twin.macro&#39;;</pre><pre>const StyledEight = styled.div`<br>  ${tw`text-sm`};<br>  ${({ hasBorder }) =&gt; hasBorder &amp;&amp; tw`border-purple-500`};<br>  ${({ color }) =&gt; color &amp;&amp; `<br>    color: ${color};<br>  `};<br>  font-weight: 500;<br>`;</pre><pre>const Eight = () =&gt; (<br>  &lt;StyledEight<br>    hasBorder<br>    color=&quot;blue&quot;<br>   &gt;<br>    Eight<br>  &lt;/StyledEight&gt;<br>);</pre><p>9. Nesting the tw prop in a styled component:</p><pre>import tw, { styled } from &#39;twin.macro&#39;;</pre><pre>export const StyledNine = styled.div`<br>  span {<br>    ${tw`text-blue-800`};<br>  }<br>`;</pre><pre>export const Nine = () =&gt; (<br>  &lt;StyledNine&gt;<br>    &lt;span&gt;Nine&lt;/span&gt;<br>  &lt;/StyledNine&gt;<br>);</pre><p>All examples are also in this <a href="https://codesandbox.io/s/twin-macro-example-9py0t">Sandbox</a>.</p><p>More usage patterns and features are up to your imagination and knowledge of JavaScript, Emotion, and Twin.macro&#39;s features.</p><p>Next, we will extend our tailwind configuration to use custom classes with Twin.macro.</p><h4>Tailwind Config Extension</h4><p>Twin.macro works directly with tailwind.config.js .</p><p>For example, if you want to add a specific border-radius of 1px (which is not available by default), you can directly edit the tailwind.config.js the following way:</p><pre>module.exports = {<br>  theme: {<br>    extend: {<br>      borderRadius: {<br>        xs: &quot;1px&quot;,<br>      }<br>    }<br>  }<br>};</pre><p>The new border-radius property becomes available in the form of rounded-xs which we will add as a class.</p><pre>import tw, { styled } from &quot;twin.macro&quot;;</pre><pre>const Wrapper = styled.div`<br>  ${tw`rounded-xs p-4`};</pre><pre>  font-size: 26px;<br>  font-family: sans-serif;</pre><pre>  &gt; * {<br>    ${tw`my-3 p-3`};<br>  }<br>`;</pre><p>This shows the power of theming that Tailwind provides by default. To read more about extending the tailwind configuration, check out the <a href="https://tailwindcss.com/docs/">official documentation</a>.</p><h3>Support</h3><p><em>Twin.macro</em> is also available for JavaScript frameworks like Gatsby, and Next.js. Vue.js is only an experimental version at the moment. Twin.macro can also be used with <a href="https://styled-components.com/docs">Styled Components</a>.</p><p>This the end of the tutorial; I hope you found this useful to get started with Twin.macro. Once again, to view all examples in this tutorial, check out this <a href="https://codesandbox.io/s/twin-macro-example-9py0t">Sandbox</a>.</p><p>You can share your feedback with me on <a href="https://twitter.com/Deo_Joe">Twitter</a>, in a tweet, or below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5228c819d713" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create an Image Uploader using React and Cloudinary]]></title>
            <link>https://frontend-digest.com/how-to-create-an-image-uploader-using-react-and-cloudinary-5f07959723c4?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f07959723c4</guid>
            <category><![CDATA[cloudinary]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Thu, 02 Jul 2020 18:30:50 GMT</pubDate>
            <atom:updated>2020-07-02T18:30:50.910Z</atom:updated>
            <content:encoded><![CDATA[<h4>Short tutorial using Google Firebase Cloud functions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6XNFfL6x2dY-mwfuHR_ujw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@daiga_ellaby?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Daiga Ellaby</a> on <a href="/s/photos/build?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Image uploaders have a variety of use cases ranging from file uploads on forms to updating your social media profile.</p><p>Since there are different ways to solve this problem, we first had to answer a few questions.</p><p>The first question was: Where do you store the images? I chose <a href="https://www.cloudinary.com">Cloudinary</a>.</p><p>The second question was: How do you upload the images to Cloudinary? The solution required some server-side solutions I figured. I had some experience using <a href="https://firebase.google.com/docs/functions">Google Firebase’s Cloud functions</a>, so I decided to go through that route.</p><p>Cloud Functions offers a scalable solution for running the back-end code in the cloud. This allows you to create web applications and focus mainly on the client-side without maintaining your server.</p><p>The project repo is live on Github <a href="https://github.com/DeolaJ/react-firebase">here</a> in case you want to skip ahead to look at the source code.</p><p>In this tutorial, I’ll walk you through the steps to set up a simple React and Firebase project. Then, we’ll create a cloud function to handle image uploads using the base64 image link. Then we’ll also deploy our React application through Firebase Hosting.</p><p>There will be little focus on user experience improvements for the image uploader.</p><p>To follow along, you’ll need a basic understanding of Javascript and React JS. This is not a complete beginner’s tutorial.</p><h3>Create a Cloudinary account</h3><p><a href="https://www.cloudinary.com">Cloudinary</a> is a powerful tool used to create, optimize, and deliver images, videos, and other media across every device and channel. It also provides a media storage bucket that is generous for their free plan. We’ll take advantage of their ease of storing images in this tutorial.</p><p>If you don’t have an account, go ahead and register <a href="https://cloudinary.com/signup">here</a>.</p><p>For your Cloud function, you need a Cloud name, API Key, and API Secret which are available on your Dashboard.</p><p>Let’s move on to setting up our React Application.</p><h3>Set up a simple React Application</h3><p>The React application will be bootstrapped using <a href="https://github.com/facebook/create-react-app">Create React App</a>. We can get started by running the following command in the terminal, if create-react-app isn’t installed.</p><pre>npm install -g create-react-app</pre><p>Move into the directory where you want your project to be and create the react application with any name you desire. I chose “react-firebase” for the sake of this tutorial.</p><pre>create-react-app react-firebase</pre><p>When the process is complete, your folder structure should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*nNedLZTZ3HQCkvqRZ80T5g.png" /><figcaption>Create-React-App folder structure</figcaption></figure><p>Next, we’ll set up our Firebase project.</p><h3>Set up Firebase</h3><p>In your terminal, move into the folder directory and install the Firebase tools, which will allow you to use Firebase locally. To install the tools, run the following command:</p><pre>npm install -g firebase-tools</pre><p>You need to login to your Firebase account to proceed. Run the following command in the terminal. If you don’t have a Firebase account, you’ll have to create one.</p><pre>firebase login</pre><p>When you are logged in, the next step involves initializing Firebase in the React application. To do that, run the following command in your terminal</p><pre>firebase init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEuEdUFs_nSkZj4iKVCqEQ.png" /><figcaption>Firebase initialization</figcaption></figure><p>You will need to specify the Firebase tools you need for the project. For this tutorial, we only need Cloud functions and hosting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*NaasZ2lgIloBg-t6rklggQ.png" /><figcaption>Firebase folder which is deployed</figcaption></figure><p>You need to also choose the folder which Firebase will deploy, which we will cover later in this tutorial. I chose the build folder for this because Create React App generates a build folder. This folder contains production assets when you run yarn build.</p><p>Select that you also want this project to be a Single Page Application.</p><p>When the initialisation is complete, your project should contain a functions folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*EhWfYEFepSPWOg3RDyYb_Q.png" /><figcaption>Sample functions folder structure</figcaption></figure><p>Your firebase.json file should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3dca52635e94a2ccedfc487c4eddeaa5/href">https://medium.com/media/3dca52635e94a2ccedfc487c4eddeaa5/href</a></iframe><p>Next, we’ll set up our Image Uploader form</p><h3>Create a simple form</h3><p>Uploading files is simple using the HTML input element with a type of “file”, however, we need to handle the file as it is chosen from any device.</p><p>We can create a component ImageUploader in src/components/imageuploader.js to serve as our form. I used a react hook, useState to handle the filename, which we show as feedback that the file was successfully received by the input elements.</p><p>We have two input elements in the form to handle two forms of image upload based on two methods to use Cloud functions:</p><ul><li><a href="https://firebase.google.com/docs/functions/callable">Call functions from your app</a>, and</li><li><a href="https://firebase.google.com/docs/functions/http-events">Call functions via HTTP requests</a></li></ul><p>doUploadImage and doUploadFormImage will be created later when we have set up our Cloud Functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a961ad12f71fffe4f8b27d50723e6eee/href">https://medium.com/media/a961ad12f71fffe4f8b27d50723e6eee/href</a></iframe><p>If you are interested in compressing the image, check the next section. If not, you can skip the next section</p><h4>Image processing TL;DR</h4><p>To restrict the size of images uploaded, you can add a library to handle image compression before the upload to Cloudinary. For this, I chose <a href="https://www.npmjs.com/package/browser-image-compression">Browser-image-compression</a>.</p><pre>yarn add browser-image-compression</pre><p>Edit the ImageUploader component to include image compression. The image size is restricted to 1MB for the sake of this tutorial.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2df70a62bf88b195fb709f67131e5bcc/href">https://medium.com/media/2df70a62bf88b195fb709f67131e5bcc/href</a></iframe><p>Next, we’ll create our Cloud Functions.</p><h3>Cloud Functions</h3><p>From the root of your project directory, move to the functions directory in the terminal</p><pre>cd functions</pre><p>Next, install cloudinary</p><pre>npm install cloudinary</pre><p>Next, set some environment variables for your Cloud functions. The main environment variables you need are your Cloudinary account’s cloudname, API key, and API secret which you should have gotten from your Dashboard earlier.</p><p>Run the following command in your terminal to set your Cloudinary environment variables</p><pre>firebase functions:config:set cloudinary.apikey=&quot;// your API key&quot; cloudinary.cloudname=&quot;// your Cloudname&quot; cloudinary.apisecret=&quot;// your API secret&quot;</pre><p>To view environment variables, run the following command:</p><pre>firebase functions:config:get</pre><p>Note this: To make a call to an external API endpoint (Cloudinary), you need to upgrade your Firebase account to the Blaze plan.</p><p>Next, set up your Cloud Functions to handle the upload to Cloudinary.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78ae6917891e325702f14f151bfd11e7/href">https://medium.com/media/78ae6917891e325702f14f151bfd11e7/href</a></iframe><p>Here, a Firebase application is initialized using the Firebase config environment variable and firebase-admin.</p><p>Create your first cloud function using functions.https.onCall, then the second with functions.https.onRequest .</p><p>You can read more about Firebase Cloud Functions <a href="https://firebase.google.com/docs/functions">here</a>.</p><p>Notice that the environment variables are gotten using the functions.config() object.</p><p>The upload function will use onCall function invocation while uploadForm will handle the onRequest function invocation.</p><p>In both Cloud Functions, we set the Cloudinary instance using the Cloud name, API key, and API secret variables. Then, we use the Cloudinary Node.js SDK to upload the image — public_id (set the image filename) and tags (to group images) are part of the list of options for uploading an image to Cloudinary. Finally, we send a response to the client-side once the upload is done.</p><p>Next, let’s set up the doUploadImage and doUploadFormImage to send the image from the client-side.</p><h3>Cloud function on Client Side</h3><p>First, install firebase in your project directory root</p><pre>npm install firebase</pre><p>To proceed, we need a Firebase application config. To get this, log in to our Firebase account, click on the react-firebase project or whatever your Firebase project name is.</p><p>When you have opened your project, you should see the + Add app button below your project name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*H4k_ray3IW7E_apth6gpYg.png" /></figure><p>Follow the steps to create your app. When you are done, click the project settings icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*Kw_QNOB1SwTs3EmQWg1FTQ.png" /></figure><p>Scroll to the button to copy your app config.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHaOZEUsqnGSsL-0p7MtPg.png" /><figcaption>Firebase config</figcaption></figure><p>Return to your project src folder and create a firebase.js file to initialize a Firebase application on the client side.</p><p>Import only the Firebase tools you need. In this tutorial, we only use Firebase functions. Your file should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ffb8c0d8163ad8b9f0cf297ec60c6f2/href">https://medium.com/media/0ffb8c0d8163ad8b9f0cf297ec60c6f2/href</a></iframe><p>Then, create a utils/upload.js file in the src folder of your project</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e2f0a84edb5188fec5fdc4d81f21c37/href">https://medium.com/media/3e2f0a84edb5188fec5fdc4d81f21c37/href</a></iframe><p>This file contains two functions doUploadImage and doUploadFormImage which handle image uploads using the two types of Cloud Function invocation.</p><p>First, import your Firebase app from firebase.js.</p><p>For doUploadImage , we call our function using firebase.functions().httpsCallable().</p><p>For doUploadFormImage , we call our functions using a regular HTTP request (fetch). Our function URL redirects using a method covered in a later section. We created our uploadForm function using https.onRequest() .</p><p>The Cloudinary response has a secure_url, which we attach to the links.</p><p>Note this: Firebase functions have a timeout of 60 seconds. Remember to also secure your Firebase config from being public.</p><h4>Function Redirects</h4><p>To ensure that all links redirect to your Firebase application, add these extra rewrite options to firebase.json. This also handles the uploadForm HTTP request.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02d90661bf446144037b89b382fa3ef1/href">https://medium.com/media/02d90661bf446144037b89b382fa3ef1/href</a></iframe><p>Next, we’ll deploy our application to Firebase hosting.</p><h3>Deploy</h3><p>Now that everything is set up, you can go ahead and deploy your app! Run the following command in your terminal:</p><pre>yarn build</pre><p>When your production assets are ready, run the following:</p><pre>firebase deploy</pre><p>Firebase provides a unique URL where your deployed app is.</p><p>This tutorial is live on:</p><p><a href="https://react-firebase-19.web.app">https://react-firebase-19.firebaseapp.com</a></p><p>That’s the end of the tutorial; I hope you found this useful to create an image uploader and get started with Google Firebase Cloud functions.</p><p>You can share your feedback with me on <a href="https://twitter.com/Deo_Joe">Twitter</a> in a tweet or below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f07959723c4" width="1" height="1" alt=""><hr><p><a href="https://frontend-digest.com/how-to-create-an-image-uploader-using-react-and-cloudinary-5f07959723c4">How to create an Image Uploader using React and Cloudinary</a> was originally published in <a href="https://frontend-digest.com">Frontend Digest</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wondering how to start drawing digitally?]]></title>
            <link>https://medium.com/@DeolaJ/wondering-how-to-start-drawing-digitally-debd6fd6ad9d?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/debd6fd6ad9d</guid>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[art]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[artist]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Sat, 11 Jan 2020 12:34:15 GMT</pubDate>
            <atom:updated>2020-01-13T08:20:48.145Z</atom:updated>
            <content:encoded><![CDATA[<h4>Story of how I got started with Digital art in 2019 — 100 Days of Digital Art (#100daysofdrawing)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rw9l_CnpYSn2WytvkZyjKQ.png" /><figcaption>Final drawing in 2019</figcaption></figure><p>On some days it still feels like a dream. This all started as a random interest I picked up towards the end of 2018. Instagram became my very own customized Disney channel, as everyday I’d search through my feed to explore art for inspiration and humor, then I got a bright idea — I could actually do this if too if I tried.</p><blockquote>I had never done fine art in school or had a talent for it</blockquote><p>The desire to get intentional about art had been lit inside me. This made me add it to the list of goals for 2019 — <strong>Learn character design and create at least 5 characters by the end of January</strong>. As resolutions and goals go, this was minimal for me. I had taken screenshots of digital artwork and web comics for amusement, so I had enough references to use.</p><p>Apparently, things didn’t go as I planned. I had the Adobe Illustrator software on my laptop, and got tutorials on character design. After watching a few tutorials and trying it out myself, it felt fun but frustrating. I quickly realized that using a mouse on a laptop wouldn’t cut it for me. I also figured out that:</p><ul><li>I needed to use my hands freely to sketch and draw</li><li>Using my laptop would mean I’d need access to constant power supply</li><li>A phone was handy for quickly trying out ideas I had.</li></ul><p>Alas! I made up my mind to get a mobile app instead. I quickly ran to our good friend “Google”; I searched for “Best mobile apps for drawing”. After reading multiple articles, I chose 3: <strong>Artflow</strong>, <strong>Adobe draw</strong> and <strong>Autodesk Sketchbook pro</strong>. I decided to test out the options and pick one that I’d stick with. <strong>Artflow</strong> won it for me because of its user interface (the Software developer in me leaped for joy).</p><p>The next challenge was getting a stylus pen to use. Most of the options online were expensive, so I stuck with a pen that had a rubber tip to get started. I just wanted to start learning and didn’t mind how. Artflow had some hidden features which I had to pay for and I did. Thereafter, I was ready to start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6wly1weK_y_rcpUsHHSb6A.jpeg" /><figcaption><a href="https://www.google.com/url?sa=i&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwin0N64_frmAhXIT98KHeprDusQjhx6BAgBEAI&amp;url=https%3A%2F%2Fwww.allbranded.ie%2FThe-Classics%2FPens-Pencils%2FBall-Pen-With-Black-Rubber-Grip-Stylus.html&amp;psig=AOvVaw3Vu5bKWMhauXj7u4FS53_j&amp;ust=1578812567593887">Rubber tip pen I used</a></figcaption></figure><h4>Drawing began</h4><p>I tried out the features on Artflow and got familiar with a few things. One major advantage I loved about drawing digitally was this duo of friends — “the undo and redo buttons”. Only God knows how frequently I used them. Soon, I realized the pen I had gotten had a larger surface area in relation to my phone screen (Samsung Galaxy S6). This made it difficult to draw accurately at first, but after a short while, I just went with it. I checked YouTube for tutorials on how to draw with Artflow and watched a couple.</p><blockquote>Early on while drawing, I zoomed in a lot on my mobile phone to be precise. Later, I found out this affected my drawing posture and eyesight, so I don’t recommend this.</blockquote><p>At this point, I had started drawing but wasn’t comfortable with the end product. The lines were wiggly and it was hard to connect because of the large surface area of the rubber tip. The pen I started with wasn’t mine, so I had to return it after a few days. I decided to put my drawing on hold for a while when I had to leave for the NYSC Orientation camp. Fortunately, I was able to get mine for free at the NYSC camp — Cowbell distributed them to Youth Corpers as souvenirs. I collected an extra piece from my roommate also. I got really excited about this and couldn’t wait to get home to start.</p><h4><strong>Leveling up</strong></h4><p>When I got back from NYSC camp, I searched my photo gallery for references to try out and made up my mind to start a 100 days of digital art challenge to push myself to get better. I read an article earlier in the year and felt I needed to. I got started on a Monday, then tweeted about it that evening to make myself accountable.</p><h3>Deola on Twitter</h3><p>So I&#39;m committing to 100 days of character design. Leggo!</p><p>At first, I’d place the reference picture on the artboard in Artflow, then start drawing lines that were exactly like what I saw to produce the same result. I had to zoom in on my phone to be accurate but I didn’t mind doing that. On the 1st day, I wasn’t proud of what I drew so I didn’t share it. I wasn’t going to give up so I continued. The results got better and I started seeing improvements in my drawing by day 3. This encouraged me to keep sharing my drawings on Whatsapp with friends. I got great feedback and some supporters which motivated me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15Ow3OH7KYfXfqMTtKmLcQ.png" /><figcaption>First drawing of my 100 days of drawing challenge</figcaption></figure><p>By day 4, I asked my friends to send ideas on what I should draw next. Esther, my friend, sent her picture. Three other friends sent their pictures for me to try out and in case you’re wondering, I was excited. Day 6 was a Saturday, so I took some time out to draw Esther’s picture. I also shared the results with friends on Whatsapp, and they loved it. The following day, I opened an Instagram account to document my drawings during this challenge period.</p><iframe src="https://www.instagram.com/p/Bxx7CHBF7nM/embed/?cr=1&amp;amp;rd=https%3A%2F%2Fwww.instagram.com" width="658" height="882" frameborder="0" scrolling="no"><a href="https://medium.com/media/cead2318f93ed9c8ea6e7bc7ce32649d/href">https://medium.com/media/cead2318f93ed9c8ea6e7bc7ce32649d/href</a></iframe><p>Over the next couple of days, I kept drawing different faces. More requests kept coming in, and I didn’t stop accepting till it became apparent that I couldn’t draw all. I also didn’t stop following artists, taking screenshots for drawing references and watching tutorials videos on Instagram and YouTube. After drawing about 8 faces, I noticed it started getting frustrating to draw, because I spent a lot of time trying to perfect the lines and ensure the drawings looked like the actual people.</p><p>The next step was searching for more tutorials on drawing human faces (proportions) and also checking out tutorials on other drawing applications like Procreate, Medibang, Photoshop etc. Artflow tutorials were scarce online; I had to find others that complimented my drawing process in general. I’m still reaping the benefits of this till now.</p><p><strong><em>Fundamentals and consistency are so important when learning a new skill, and I made sure I didn’t miss out.</em></strong></p><h4>Motivation</h4><p>Everyday had been a new learning curve:</p><ul><li>Learning to draw eyes</li><li>Learning to draw noses</li><li>Learning how to use layers and clipping masks</li><li>Drawing lips,</li><li>Learning about colors and blending</li><li>Learning about blend modes</li><li>Learning to draw female hairstyles</li><li>Learning to draw legs</li></ul><p>And the list goes on. It was hard to keep all the lessons in my head but consistent practice helped some stick.</p><iframe src="https://www.instagram.com/p/B051LFWlvSG/embed/?cr=1&amp;amp;rd=https%3A%2F%2Fwww.instagram.com" width="658" height="989" frameborder="0" scrolling="no"><a href="https://medium.com/media/36523b747822c55a49c9992e0952d551/href">https://medium.com/media/36523b747822c55a49c9992e0952d551/href</a></iframe><p>I had noticed art challenges on Instagram (#drawinyourownstyle, #drawinyourstylechallenge) and I participated in a few too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-SyNaOehvAqBvP-ScFfzQ.png" /><figcaption>Day 90: This shows how I used references to help my drawing process</figcaption></figure><p>I also kept posting my art on Instagram, Whatsapp and Twitter to get feedback. My art account on Instagram started growing too. By day 50, I was comfortable with a lot of human features but my eyes had been hurting from the strain. I also had a health issue with my chest at that time. This made me take a break from drawing for a while but I kept learning everyday, sometimes during long hospital trips.</p><p>Feedback, likes and comments kept me going on the bad days. I almost gave up at one point too, but spacing out my drawings relieved me of the mental stress of posting regularly. I also kept searching for new artists to follow and learn from on Instagram everyday, and never stopped taking screenshots.</p><p>I kept pushing myself everyday because I noticed that a lot of people loved my determination. I had started on May 13th, and was able to finish the 100 days of digital art challenge on August 22nd. I did a short challenge to decide how to round off and my friend, Maryam won the challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X71GYXee-t4FedkwEOgEJA.png" /><figcaption>Final drawing of #100daysofdrawing — Birthday gift to my friend, Maryam</figcaption></figure><p>I used my story to motivate others too. Since someone with almost no talent in drawing was able to learn a lot by being intentional, consistent and being self-driven for growth in that aspect. Afterwards, I took a short break to rest my eyes and started saving up to get an actual stylus pen and IPad.</p><h4>Next steps</h4><p>I have drawn a lot more characters and faces since the end of the challenge. I also got a <strong>Sketchbook</strong> and moved to paper drawings in August to improve my knowledge of art. It has helped to improve my knowledge of art in general and I recommend this.</p><p>In October, I started drawing comics for my friend’s <a href="http://banterrepublic.blog">blog</a> — 2 comic strips every week on average. Comic illustration had been on my mind the whole time, so it felt good to try out too. I named my comics: <a href="https://instagram.com/balloon_comics">Balloon comics</a>. I also participated in #Inktober2019 too with a few entries. I did all these at my pace and under less pressure.</p><p>I was able to get my dad’s old Ipad in September, but had to wait till November when I bought my stylus pen to start using it. This resulted in a move from Artflow to Procreate as my drawing software.</p><p>I have decided to keep drawing and improving in both character design and web comics. I have so many ideas for 2020, and I’m grateful to God that 2019 was a fruitful year in this respect. There were a lot times when I fell sick or needed strength. So it’s fine take breaks in-between and learn at your pace.</p><p>Thank you for reading till the end. If you have questions or comments, you can drop them below. If you want to reach out, you can find me on <a href="https://twitter.com/Deo_Joe">Twitter</a> or <a href="https://instagram.com/dejoe_art">Instagram</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=debd6fd6ad9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating A Simple Collapsible Sidebar with JavaScript (No Framework Required)]]></title>
            <link>https://medium.com/@DeolaJ/creating-a-simple-collapsible-sidebar-with-javascript-no-framework-required-af9f8265d156?source=rss-c27bdba4579a------2</link>
            <guid isPermaLink="false">https://medium.com/p/af9f8265d156</guid>
            <category><![CDATA[web-design-tutorial]]></category>
            <category><![CDATA[sidebar]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Adeola Adeyemo J.]]></dc:creator>
            <pubDate>Thu, 12 Dec 2019 16:28:43 GMT</pubDate>
            <atom:updated>2021-02-03T09:08:37.884Z</atom:updated>
            <content:encoded><![CDATA[<h4>A short and simple tutorial on how to create a collapsible sidebar for your website</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-5INVv_9lw32zaI33S-vQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jjying?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">JJ Ying</a> on <a href="https://unsplash.com/s/photos/compress?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>While working on a recent project, I discovered that I needed to create a sidebar that collapses when it’s not needed. As usual, I went online to seek help but I still had some difficulties while working on it. But as they say,</p><blockquote>“Difficulties mastered are opportunities won”</blockquote><p>The opportunity, in this case, is the fact that I found a method that’s a lot easier than most and is even simple to implement.</p><h4>What is the Purpose of a Collapsible Sidebar?</h4><p>If you have ever observed a well-designed website, you would have noticed that not all information is presented at once. In fact, most of these websites use collapsible sidebars to optimize pages and improved overall user experience. A collapsible sidebar helps to expand or collapse the available sidebar space when necessary.</p><p>I’ll explain the method I used while working on the project. First, we’ll create an HTML template, then apply CSS styling to it. We’ll then go on to use JavaScript to add functionality to our collapse button which carries out the collapse action.</p><h4>HTML Template</h4><pre>&lt;div class=&quot;grid-container&quot;&gt;<br>    &lt;div class=&quot;sidebar&quot;&gt;<br>        &lt;button&gt;<br>            M<br>        &lt;/button&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;main-content&quot;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><p>First, create a simple container (“div”) with two sections: sidebar and main-content. Add a button to the sidebar which will execute the collapse effect; this will be discussed later. Then, add class names to the sections for appropriate styling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*x5YPOv9Oh3PprZ66x6lxDg.png" /><figcaption>Your view should look this way</figcaption></figure><h4>CSS</h4><pre>.grid-container {<br>    width: 90vw;<br>    margin: 0 auto;<br>    height: 90vh;<br>    display: flex;<br>    border: 2px solid rgba(0, 0, 0, .4);<br>    transition: 1s ease;<br>}</pre><p>First, we style the grid-container and make it a flex container. Child elements will automatically be arranged in a horizontal row. To show the effects and make the container stand out, add a border.</p><pre>.sidebar {<br>  width: 30%;<br>  height: 100%;<br>  background-color: #54a;<br>  transition: 1s ease;<br>  position: relative;<br>}</pre><pre>.main-content {<br>  width: 70%;<br>  height: 100%;<br>  background-color: #ccc;<br>  transition: 1s ease;<br>}</pre><p>The sidebar and main-content elements were given a collective width of 100% to ensure that the page width is always maximized. I added background colors to give a visual effect for the sake of this tutorial. You can style your sections as desired.</p><p>The CSS transition property controls how the collapse effect is applied to the elements also. You can read more about the CSS transition property <a href="https://www.w3schools.com/cssref/css3_pr_transition.asp">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*TeTfx6ybCY4shSRoDjBUTg.png" /></figure><pre>.main-content_large {<br>  width: 90%;<br>}</pre><pre>.sidebar_small {<br>  width: 10%;<br>}</pre><p>We will add these classes to the sidebar in the JavaScript section to apply the collapse effect. The collapsed width of the sidebar and the expanded width of our main-content elements are set. Next, we style our collapse button.</p><pre>button {<br>  position: absolute;<br>  border: none;<br>  height: 40px;<br>  width: 40px;<br>  border-radius: 50%;<br>  box-shadow: 0px 1px 4px 1px rgba(0 ,0, 0, .3);<br>  left: 100%;<br>  top: 2rem;<br>  transform: translateX(-50%);<br>  cursor: pointer;<br>}</pre><p>The button is styled to be separate from the sidebar content; it controls the collapse effect. The button appears to be attached to the right end of the sidebar. This is done using the CSS <a href="https://www.w3schools.com/cssref/css3_pr_transform.asp">transform</a> property.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*pcjfqC3x96ZKcHSQFi9EQw.png" /></figure><h4>JavaScript</h4><pre>const sidebar = document.querySelector(&#39;.sidebar&#39;);<br>const mainContent = document.querySelector(&#39;.main-content&#39;);</pre><pre>document.querySelector(&#39;button&#39;).onclick = function () {<br>  sidebar.classList.toggle(&#39;sidebar_small&#39;);<br>  mainContent.classList.toggle(&#39;main-content_large&#39;)<br>}</pre><p>Using JavaScript, apply a click event to the button. When the button is clicked, the ‘sidebar_small’ class is added to the sidebar and the ‘main-content_large’ class is added to the main-content element. This toggle effect adds and removed both classes when the button is clicked</p><p>The full tutorial is available in this <a href="https://codepen.io/DeolaJ/pen/xvjbKY">pen</a>.</p><p>We’ve come to the end of this tutorial on creating a collapsible sidebar with Javascript. I hope you found it useful. If you did, share a few claps and follow me on <a href="https://twitter.com/Deo_Joe">Twitter</a> or <a href="https://medium.com/@DeolaJ">Medium</a>. You can also leave your feedback as comments in the comment section.</p><p>Till next time, keep creating.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af9f8265d156" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>