<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adjoa Wadee</title>
    <description>The latest articles on DEV Community by Adjoa Wadee (@adjoawadee).</description>
    <link>https://dev.to/adjoawadee</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F589247%2F020d2249-8dc0-4d80-ae0f-124512415665.jpg</url>
      <title>DEV Community: Adjoa Wadee</title>
      <link>https://dev.to/adjoawadee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adjoawadee"/>
    <language>en</language>
    <item>
      <title>Anchor tags with scroll effect in Nuxt 3</title>
      <dc:creator>Adjoa Wadee</dc:creator>
      <pubDate>Wed, 15 Feb 2023 16:40:59 +0000</pubDate>
      <link>https://dev.to/adjoawadee/anchor-tags-with-scroll-effect-in-nuxt-3-285n</link>
      <guid>https://dev.to/adjoawadee/anchor-tags-with-scroll-effect-in-nuxt-3-285n</guid>
      <description>&lt;p&gt;Building a Single Page Application in Nuxt 3 is quite simple. Every SPA requires links with anchor tags to navigate to sections of the page. That's easy to achieve with an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag with an &lt;code&gt;href='#anchor'&lt;/code&gt; attribute that specifies where your link should navigate to.&lt;/p&gt;

&lt;p&gt;In Nuxt, I set this up by using &lt;code&gt;NuxtLink&lt;/code&gt; with a &lt;code&gt;path&lt;/code&gt; and a &lt;code&gt;hash&lt;/code&gt;. For instance, this is written in a &lt;code&gt;Navigation.vue&lt;/code&gt; file.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8cs0paduv8h0boea3ek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8cs0paduv8h0boea3ek.png" alt="NuxtLink with a hash" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following that, I have a different file probably named &lt;code&gt;WhateverSection.vue&lt;/code&gt;. In this section, add an &lt;code&gt;id&lt;/code&gt; that is the same name as the one given in our &lt;code&gt;hash&lt;/code&gt;. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jn07xoxa1l5jjql9np6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jn07xoxa1l5jjql9np6.png" alt="Template with section" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This should already work. However, it just navigates to a section without any scrolling effect. A nice and smooth scroll effect is important for a pleasant user experience. That is what we would like to accomplish here. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://nuxtjs.org/docs/components-glossary/scrolltotop/" rel="noopener noreferrer"&gt;Nuxt 2&lt;/a&gt; has a &lt;code&gt;scrollToTop&lt;/code&gt; &amp;amp; &lt;code&gt;scrollBehavior&lt;/code&gt; option which isn't available (&lt;em&gt;yet&lt;/em&gt;) in Nuxt 3. At least, none of the documentation I read mentioned it. &lt;/p&gt;

&lt;p&gt;Another option would be to make use of the &lt;code&gt;scrollIntoView()&lt;/code&gt; HTML function, but that doesn't help achieve my goal of adding a scroll effect. &lt;/p&gt;

&lt;p&gt;With a little research, I figured I wasn't the only one that encountered this little issue in Nuxt 3. &lt;/p&gt;

&lt;p&gt;Here are the steps I followed to achieve this.&lt;/p&gt;

&lt;p&gt;First, we have to create a &lt;code&gt;/plugin&lt;/code&gt; folder for our application and a &lt;code&gt;router.ts&lt;/code&gt; file to contain our code. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxo16heu9bi69vro5irwx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxo16heu9bi69vro5irwx.png" alt="Folder structure" width="480" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Nuxt or Vue, &lt;a href="https://vuejs.org/guide/reusability/plugins.html" rel="noopener noreferrer"&gt;plugins&lt;/a&gt; contain code that should run before a Vue app is created.&lt;br&gt;
Nuxt automatically reads files in the &lt;a href="https://nuxt.com/docs/guide/directory-structure/plugins" rel="noopener noreferrer"&gt;plugin directory&lt;/a&gt; so you don't have to worry about loading them directly into your app.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;router.ts&lt;/code&gt;, we would set it up with &lt;code&gt;defineNuxtPlugin&lt;/code&gt; which basically informs your Nuxt app to create a new plugin. You then want to pass the &lt;code&gt;$router&lt;/code&gt; which is an object from your Nuxt app, to give us access to the Vue router options on which we're about to expand. &lt;code&gt;ScrollBehavior&lt;/code&gt; is part of &lt;a href="https://router.vuejs.org/api/interfaces/RouterOptions.html#Properties-scrollBehavior" rel="noopener noreferrer"&gt;Vue's router options&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9z2y8ikh76yx4rr69tkb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9z2y8ikh76yx4rr69tkb.png" alt="scroll behavior" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can set the hash you want to scroll to, where on the screen this section should be placed, and the type of behavior you expect when scrolling. &lt;/p&gt;

&lt;p&gt;With this, you can also expand on the plugin adding all sorts of fancy things you want to achieve when scrolling.&lt;/p&gt;

&lt;p&gt;I wouldn't have been able to make this post without taking a good peak at the following links:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://github.com/lukaszflorczak/nuxt3-demo/tree/test/scroll-behavior/plugins" rel="noopener noreferrer"&gt;this&lt;/a&gt; solution with the plugin folder structure&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/nuxt/nuxt/issues/12732" rel="noopener noreferrer"&gt;this&lt;/a&gt; issue that looked just like mine&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/nuxt/nuxt/issues/12732#issuecomment-1397227098" rel="noopener noreferrer"&gt;this&lt;/a&gt; response by Daniel Roe. In case you missed it, he gave a talk at &lt;a href="https://vuejs.amsterdam/" rel="noopener noreferrer"&gt;VueJs Amsterdam&lt;/a&gt; about rapid development with Nuxt 3!&lt;/li&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@bagelsncoffee_?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Ryan Harper&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/S8nT0awuFEU?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ux</category>
      <category>ui</category>
      <category>portfolio</category>
      <category>career</category>
    </item>
    <item>
      <title>Using Tailwind's @apply in Vue3 + Nuxt3</title>
      <dc:creator>Adjoa Wadee</dc:creator>
      <pubDate>Tue, 14 Feb 2023 13:26:07 +0000</pubDate>
      <link>https://dev.to/adjoawadee/using-tailwinds-apply-in-vue3-nuxt3-5aih</link>
      <guid>https://dev.to/adjoawadee/using-tailwinds-apply-in-vue3-nuxt3-5aih</guid>
      <description>&lt;p&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind&lt;/a&gt; is great because it offers utility first styling. &lt;br&gt;
Providing low-level styling, it can sometimes feel like writing inline styling. &lt;br&gt;
I can already see the benefits of Tailwind including rapid development and it's performance advantages. &lt;br&gt;
I noticed how long these stylings go to achieve the look I am going for. &lt;br&gt;
Repeated lines of code that can be a quite annoying and it's not very readable. &lt;/p&gt;

&lt;p&gt;That is until I discovered the &lt;code&gt;@apply&lt;/code&gt; directive.&lt;/p&gt;

&lt;p&gt;Consider this section&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmkk8x2ynccwxhnmszkr.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmkk8x2ynccwxhnmszkr.jpeg" alt="Consider this line here:" width="800" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;simplified to this..&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsgrf9pwg9405f85lp940.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsgrf9pwg9405f85lp940.jpeg" alt="simplified to:" width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Vue, you can add styles to a Single File Component (SFC) in the &lt;code&gt;&amp;lt;styles&amp;gt;&lt;/code&gt; tag. Here we can encapsulate the styling of this file. It's also a good practice to &lt;code&gt;scope&lt;/code&gt; the style to this component.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F406dt3pyahua32amvcbm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F406dt3pyahua32amvcbm.jpeg" alt="section styling" width="800" height="698"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This helps keeping code clean and readable. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>career</category>
      <category>ai</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
