<?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: Uduakabaci Udofe</title>
    <description>The latest articles on DEV Community by Uduakabaci Udofe (@uduakabaci).</description>
    <link>https://dev.to/uduakabaci</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%2F287383%2F8c82123e-bd14-499d-9693-8e4ee2f93f1f.jpg</url>
      <title>DEV Community: Uduakabaci Udofe</title>
      <link>https://dev.to/uduakabaci</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uduakabaci"/>
    <language>en</language>
    <item>
      <title>How to set up TailwindCSS in Angular.</title>
      <dc:creator>Uduakabaci Udofe</dc:creator>
      <pubDate>Mon, 27 Dec 2021 11:47:15 +0000</pubDate>
      <link>https://dev.to/uduakabaci/how-to-set-up-tailwindcss-in-angular-1ehi</link>
      <guid>https://dev.to/uduakabaci/how-to-set-up-tailwindcss-in-angular-1ehi</guid>
      <description>&lt;p&gt;TailwindCSS is one of the most loved CSS frameworks on the block and one of the reasons many people prefer TailwindCSS to the existing solutions is because, unlike other CSS frameworks, TailwindCSS is easy to pick up and allows for great customization. You can change just about anything in Tailwind by adding some configurations to the config file. This means that you don’t need to force changes to a class with &lt;code&gt;important&lt;/code&gt;. If you don’t like something, you can replace it. &lt;/p&gt;

&lt;p&gt;In this tutorial, I’ll show you how to add TailwindCSS to your Angular project, but before we get into that, let’s explore a bit about tailwind CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is TailwindCSS
&lt;/h2&gt;

&lt;p&gt;The TailwindCSS team defines it as “a utility-first CSS framework packed with classes like &lt;code&gt;flex&lt;/code&gt;, &lt;code&gt;pt-4&lt;/code&gt;, &lt;code&gt;text-center&lt;/code&gt;, and &lt;code&gt;rotate-90&lt;/code&gt; that can be composed to build any design, directly in your markup”. What this means is that TailwindCSS provides us with classes that we can use to produce any design imaginable. Each class does exactly one thing and this makes it easy to see what the page will look like in the browser from the code. &lt;/p&gt;

&lt;p&gt;Composing independent classes to produce a design means applying a lot of classes to an element and this means having a bloated HTML file,  but in tailwind CSS, this can be fixed with the @apply derivative. You can read more &lt;a href="https://tailwindcss.com/docs/reusing-styles#extracting-classes-with-apply"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unlike bootstrap, with tailwind CSS, you don’t need to hold on to styles you don’t need. Tailwind provides a purge feature that will remove unused style while from your production build. This means that you can shave off many megabytes of unused styles. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to set up tailwind in angular
&lt;/h2&gt;

&lt;p&gt;To add TailwindCSS to your project, you have two choices:  using the CDN link or CLI.&lt;br&gt;
Whereas the CDN link helps you get started with Tailwind CSS quickly, the CLI is much more complex to set up, but it allows you the kind of freedom that is not possible with the CDN link. With the CLI, you can add or override the existing configurations with ease and this makes it the preferred choice for large projects. &lt;/p&gt;

&lt;p&gt;If CDN is what you want, simply add &lt;code&gt;&amp;lt;link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"&amp;gt;&lt;/code&gt; to the head portion of your project’s index.html and you are set. But if you need customization, then there are two methods of adding Tailwind using the CLI.&lt;/p&gt;
&lt;h3&gt;
  
  
  Method 1: Angular CLI
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Run &lt;code&gt;ng add @ngneat/tailwind&lt;/code&gt; on your command line. This will ask you a bunch of questions.&lt;/li&gt;
&lt;li&gt;When asked if you want to enable JIT mode type yes. The JIT comes with lightning-fast build time and allows us to generate arbitrary styles without writing custom CSS. with this feature, you can add our custom style like bg-[#348feb] to our template and Tailwind will generate a class for us. The CSS generated in JIT mode is the same as in production, so this means lean CSS during development and a responsive dev tool as a result. You can read more about the JIT mode &lt;a href="https://v2.tailwindcss.com/docs/just-in-time-mode"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;When asked if you want to enable dark mode select class&lt;/li&gt;
&lt;li&gt;When asked what TailwindCSS plugins you want to enable, pick the ones you like or press enter to continue.
Tailwind should now be installed in your project. After the installation, you will notice that a new tailwind.config.js file has been added to your project and both the style.css and index.html have been modified. These are just the required bit for Tailwind in your project. Go ahead and use tailwind, everything should work.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Method 2: Manual installation
&lt;/h3&gt;

&lt;p&gt;Step 1 =&amp;gt; Run  &lt;code&gt;npm install -D tailwindcss@latest&lt;/code&gt;  to install tailwindCSS&lt;br&gt;
Step 2 =&amp;gt; Run &lt;code&gt;npx tailwindCSS init&lt;/code&gt; to initialize TailwindCSS in your project.&lt;br&gt;
Step 3 =&amp;gt; Update the newly create tailwind.config.js file to this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  prefix: "",
  purge: {
    enabled: true,
    content: ["./src/**/*.{html,ts}"],
  },
  darkMode: "class", // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {},
  },
  plugins: [],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4 =&amp;gt; Add this to the beginning of your styles.scss file&lt;br&gt;
 &lt;code&gt;@import 'tailwindcss/base';&lt;br&gt;
@import 'tailwindcss/components';&lt;br&gt;
@import 'tailwindcss/utilities';&lt;/code&gt;&lt;br&gt;
Everything should now work. &lt;/p&gt;

&lt;p&gt;How To Build Tailwind For Production.&lt;br&gt;
For angular, simply running &lt;code&gt;npm run build&lt;/code&gt; should build angular for your project. But the size will be large. You can reduce the size of the production build by simply adding the &lt;code&gt;enabled: true&lt;/code&gt; to the purge field of the tailwind.config.js file and Tailwind will go ahead and purge the used styles. &lt;/p&gt;

&lt;p&gt;One thing to keep in mind when purging for production with TailwindCSS is that dynamically creating class strings in your HTML with string concatenation will break your production build. This is because TailwindCSS uses PurgeCSS internally and it doesn’t try to parse your HTML or do anything special. It simply looks for any strings in the entire file that match this regular expression &lt;code&gt;/[^&amp;lt;&amp;gt;"'`\s]*[^&amp;lt;&amp;gt;"'`\s:]/g&lt;/code&gt;.  So things like&lt;code&gt;&amp;lt;div class="text-{{  error  ?  'red'  :  'green'  }}-600"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;  might break because Tailwind won’t catch that. &lt;/p&gt;

&lt;p&gt;It may still work if the class is used correctly somewhere else. What you want to do is to always include the full class no matter what like &lt;code&gt;&amp;lt;div class=”{{error? ‘text-red-600’: ‘text-green-600’'}}”&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;. Another way to do this is to add the needed class as a comment and continue dynamically creating a class string and PurgeCSS will pick it up. &lt;/p&gt;

&lt;p&gt;That’s it for this tutorial, thanks for reading. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Document Your Next Open-source Project</title>
      <dc:creator>Uduakabaci Udofe</dc:creator>
      <pubDate>Thu, 16 Dec 2021 08:34:38 +0000</pubDate>
      <link>https://dev.to/uduakabaci/how-document-your-next-open-source-project-124i</link>
      <guid>https://dev.to/uduakabaci/how-document-your-next-open-source-project-124i</guid>
      <description>&lt;p&gt;I find myself looking at many open-source projects in a given week because I love reading people’s code. Reading another person’s code is one of the best ways to learn new things about your favorite technology and I have not been disappointed in that area. I’ve also been prompted to question some of my logic, but occasionally, I catch myself swearing over a project’s documentation, and according to &lt;a href="https://opensourcesurvey.org/2017/"&gt;this&lt;/a&gt; survey performed in 2017, the numbers are pretty bad.&lt;/p&gt;

&lt;p&gt;While some people omit documentation for their projects because they feel it’s not important, others include half-baked documentation without a demo whatsoever, leaving the reader overwhelmed. You want to provide enough information to the reader in the most detailed way possible, while still being concise. This might sound hard, but it’s worth it. &lt;/p&gt;

&lt;p&gt;The essence of this guide is to provide you with actionable tips on how to write a well-structured, and rich in details documentation that will help people make the most of your, existing or new, pet open-source project. &lt;/p&gt;

&lt;p&gt;Keep in mind that this guide is for people who want to fill out their pet project’s README.md file but do not know how to begin. It is not aimed at big projects, although what you will be doing won’t differ much. &lt;/p&gt;

&lt;h2&gt;
  
  
  How To Structure Your Project Documentation
&lt;/h2&gt;

&lt;p&gt;One of the most overlooked aspects of documentation is its structure. It’s not enough to write about your project in gory details without structure because the required details, at that point, might be lost in useless information. The best way to do this is to split your documentation into separate sections and provide the details where needed.&lt;/p&gt;

&lt;p&gt;You want to start with a “getting started guide” where you showcase your project’s power and slowly move towards the architectural design where you explain exactly how your project does what it does. Also, the API section comes in handy for projects that expose API so you want to include it. &lt;/p&gt;

&lt;p&gt;Now, let’s go through each section and explain what they do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started Guide
&lt;/h3&gt;

&lt;p&gt;This section is where you walk users through your project by performing a task. A good way to do this is to start with a finished result and walk through how to achieve the result with a step-by-step guide. Each step should do one thing and build on top of the last step. Bonus point if you catch some errors the user might run into while setting up the project, it shows you battle-tested the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  API  Documentation
&lt;/h3&gt;

&lt;p&gt;The API documentation is where you write in-depth about the APIs the project exposes. Projects with multiple components are good candidates for this. You want to go through each component and highlight what options they expect and the type of options they expect if that matters. &lt;/p&gt;

&lt;p&gt;You can immediately follow through with the architectural design or the “In the production guide”. Keep in mind that the ultimate is goal is to not provide extraneous details. Keep everything as concise as possible.&lt;br&gt;
Architectural Design&lt;br&gt;
The architectural design section is where you write about how your project does what it does. Explain a design decision and why that makes sense for the projects. You can also go through the inspiration for that the said design decision, this helps familiarize the readers with your mental model of the project. &lt;/p&gt;

&lt;p&gt;You can also go into what potential contributors should look out for in the project should they decide to contribute. The best place for this is the CONTRIBUTING.md file, but I find it very helpful to have information like this in the main documentation.&lt;/p&gt;

&lt;h3&gt;
  
  
  License
&lt;/h3&gt;

&lt;p&gt;This is a very important part of a project’s documentation because it dictates how people will interact with the project. It’s advisable to choose the one you are comfortable with as some licenses require modified copies of your work to be also open-source. This might not be what you want.&lt;/p&gt;

&lt;p&gt;Also, if your project uses another project, be sure to check out that project’s license because some licenses require you to use the same license as the project your project is built upon. Below is a list of some commonly used licenses. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apache License, Version 2.0&lt;/li&gt;
&lt;li&gt;GNU General Public License v3.0&lt;/li&gt;
&lt;li&gt;MIT License
You can find details for these licenses here.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure you choose the one that fits both you (the author) and your project well.&lt;/p&gt;

&lt;p&gt;That’s pretty much it. If you have suggestions or questions, drop a comment below.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to achieve dark/light mode with CSS.</title>
      <dc:creator>Uduakabaci Udofe</dc:creator>
      <pubDate>Wed, 08 Dec 2021 12:10:02 +0000</pubDate>
      <link>https://dev.to/uduakabaci/how-to-achieve-darklight-mode-with-css-3p07</link>
      <guid>https://dev.to/uduakabaci/how-to-achieve-darklight-mode-with-css-3p07</guid>
      <description>&lt;p&gt;If you have ever written CSS for a large web app then you know how hard it is to manage CSS. Add that to the increasing need to support dark and light modes in your app and you’ll have an overwhelming app starring you in the face.  It helps to have methodologies and pre-processors handy but even with these tools, CSS can easily balloon into a monster code-base that's very hard to manage if not properly structured from the get-go.&lt;/p&gt;

&lt;p&gt;In this guide, I'll introduce you to a simple system i use to manage my CSS and how you can absorb it into your current front-end workflow. We'll start with a brief introduction to methodologies and preprocessors and why you should pick up one if you haven’t already.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do We Need CSS Methodologies?
&lt;/h2&gt;

&lt;p&gt;When it comes to writing CSS, I think it’s better to avoid selecting tags or even an element’s descendant because the HTML structure can change in the future. A better option is to split the HTML into independent components, style them with classes, and then compose them to achieve the desired interface, and here is where CSS methodologies come in. CSS methodologies are formal, documented systems for writing CSS in a way that allows us to develop, maintain and scale the front-end as a set of small, isolated modules.&lt;/p&gt;

&lt;p&gt;CSS methodologies provide us with structures and mental models to manage CSS efficiently. With CSS methodologies, we can embrace the whole DRY (don’t repeat yourself) ideology easily because our CSS will be divided into isolated modules which makes styling a breeze and repetition kind of  hard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do We Need CSS Preprocessors?
&lt;/h2&gt;

&lt;p&gt;Whereas methodologies provide us with systems to manage our CSS, preprocessors such as SASS, LESS, and stylus provide tools to implement these in a way that is easy to understand and maintain. There are a few methodologies and preprocessors to choose from, but for this guide, I'll be using the BEM methodology because it is relatively easy to pick up and it is very intuitive. I’ll also be using SASS as my preprocessor of choice because of its mass appeal.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Better Way To Structure CSS
&lt;/h2&gt;

&lt;p&gt;The first step towards building a scalable and maintainable system is to group the primary values. Primary values are values that multiple parts of the system depend on, for example, colors, font families, and font sizes. If multiple components of the system rely on a value, it makes sense to isolate the value and store it somewhere and then reference that value from the dependent components instead of hard-coding the value into these components. So that in an event of a change, we will only update one part of our system and have the change reflected in all dependent components.&lt;/p&gt;

&lt;p&gt;When grouping the primary values, we will store these values in CSS variables and reference these variables in our component. What we want to do is to pick out the primary colors and fonts and store them in CSS variables with explainable names. It’s easier if we have a UI to look at but if we don’t, then we’ll need to make these hard design decisions ourselves. &lt;/p&gt;

&lt;p&gt;Some designs use different fonts for different hierarchies and different colors for different messages/text, so it makes sense to understand what we are working with. When naming our font variables, it’s best to name them in terms of their use-case instead of some generic name, the same thing with colors.  We want to abandon names like --font-ubuntu, --color-red for names like --headline-font,  --main-accent-color as these names explain the roles of each font and color in our system. This way, we understand what each color and font does at glance.&lt;/p&gt;

&lt;p&gt;With everything we’ve said so far, our codebase should look more like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
  --main-accent0: hsl(165, 100%, 50%);
   /* lighter version for hovers */
  --main-accent1: hsl(165, 100%, 90%); 
  --headline-font: Ubuntu;
}

/* then in our call to action we can do like this*/
.button {
   background-color: var(--main-accent0);
   font-family: var(--headline-font);
   &amp;amp;:hover {
    background-color: var(--main-accent-1);
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How To Structure CSS For Theme Switching
&lt;/h2&gt;

&lt;p&gt;When it comes to themes (dark mode/light mode), there are a couple of ideas I know of: one way is to put the dark and light theme variables in their separate stylesheets and load them when the user needs them. I do not like this approach because the browser will have to fetch the themes from the server, and for servers with high latency, users with bad network speed, or even users using our app offline, our web app might not work smoothly.&lt;/p&gt;

&lt;p&gt;My preferred approach is to have all the variables in one stylesheet, split them up into classes, and then toggle these classes depending on what mode we want to achieve. Here is what I mean.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*main.scss*/


.theme {
  &amp;amp;__light {
    --high-contrast-bg: hsl(194, 2%, 93%);
    --high-contrast-text: hsl(194, 2%, 28%);
  }
  &amp;amp;__dark {
    --high-contrast-bg: hsl(194, 2%, 48%);
    --high-contrast-text: hsl(194, 2%, 98%);
  }
}

.card {
  padding: 20px;
  background-color: var(--high-contrast-bg);
  color: var(--high-contrast-text);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- index.html --&amp;gt;
 &amp;lt;body class="theme theme__light"&amp;gt;
    &amp;lt;div class="card"&amp;gt;
    &amp;lt;div class="card__header"&amp;gt;
      header
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="card__body"&amp;gt;
      body
    &amp;lt;/div&amp;gt;
    &amp;lt;button class="theme-switcher"&amp;gt;switch to &amp;lt;span class="theme-switcher__current-mode"&amp;gt;dark&amp;lt;/span&amp;gt; mode&amp;lt;/button&amp;gt;
  &amp;lt;/div&amp;gt;
 &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a Javascript snippet to help us achieve that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.addEventListener("DOMContentLoaded", () =&amp;gt; {
  const theme = document.querySelector(".theme");
  const button = document.querySelector(".theme-switcher");
  const mode = document.querySelector(".theme-switcher__current-mode");
  button.addEventListener("click", () =&amp;gt; {
    theme.classList.remove("theme__dark", "theme__light");
    if (mode.innerText == "dark") {
      theme.classList.add("theme__dark");
      mode.innerText = "light";
    } else {
      theme.classList.add("theme__light");
      mode.innerText = "dark";
    }
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you for reading this guide, I hope you’ve learned a thing or two. If you have a question or a suggestion for this guide, please don’t hesitate to send ‘em in. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
