<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Cleyson Leal Braga</title>
    <description>The latest articles on Forem by Cleyson Leal Braga (@cleysonlb).</description>
    <link>https://forem.com/cleysonlb</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%2F55366%2F874aeaa1-96dc-4193-8fc3-3ecd305a8e44.jpeg</url>
      <title>Forem: Cleyson Leal Braga</title>
      <link>https://forem.com/cleysonlb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cleysonlb"/>
    <language>en</language>
    <item>
      <title>How to maintain software quality with minimal effort</title>
      <dc:creator>Cleyson Leal Braga</dc:creator>
      <pubDate>Wed, 09 Jun 2021 11:47:30 +0000</pubDate>
      <link>https://forem.com/cleysonlb/how-to-maintain-software-quality-with-minimal-effort-104k</link>
      <guid>https://forem.com/cleysonlb/how-to-maintain-software-quality-with-minimal-effort-104k</guid>
      <description>&lt;p&gt;As software scales, one of the greatest challenges is to maintain quality to match. Luckily we have tools and techniques that can help us&lt;/p&gt;

&lt;p&gt;This challenge does not have to be painful, and there are ways to achieve satisfactory results with minimal effort. &lt;/p&gt;

&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;p&gt;Before looking at more complex techniques, we can implement tools that make our software scale consistently; I usually say that quality software development is when all developers are on the same page, working with consistenty and using standardised procedures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linter
&lt;/h3&gt;

&lt;p&gt;Linter is a tool that analyses source code to flag programming errors, bugs, stylistic errors, and suspicious constructs.&lt;br&gt;
For example, when you forget a variable that has never been used.&lt;br&gt;
Linting improves readability, code review discussion level, and it looks like the code was written by one person.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Formatter
&lt;/h3&gt;

&lt;p&gt;Imagine having to remember the style guide standards like indentation, tabs vs. spaces, line breaking before column count, trailing commas vs. no trailing commas, etc.&lt;br&gt;
We would certainly miss something, no matter how many Linters there are to help us.&lt;br&gt;
For that, the code formatter exists, applying rules automatically for your code to follow the code style.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test
&lt;/h3&gt;

&lt;p&gt;Writing tests is the best way to know if your code really works &lt;br&gt;
the way it should and helps to find bugs in advance.&lt;br&gt;
Writing tests also helps to improve the implementation and thought process about the architecture you are implementing...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If it is difficult to test, it is difficult to maintain.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Typecheck
&lt;/h3&gt;

&lt;p&gt;Some languages ​​already have Typecheck natively and if you work or have worked with these languages ​​you already know the power that Typecheck gives you.&lt;br&gt;
Whereas other languages, ​​like Javascript, do not have natively, we can use tools like Flow, type-check or typescript - they all have the same mission for your typed code - to avoid passing incorrect strings. For example, to avoid passing a string where there should be a number or if there is any missing value in the object that was passed.&lt;br&gt;
But Typecheck goes far beyond that, also serving as documentation and helping us to think better about the architecture and building of our applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pre-commit
&lt;/h3&gt;

&lt;p&gt;Pre commits are scripts that run all the previous tools to find out if everything is right with your code before committing to your branch, and if something is wrong it will alert you and prevent you from committing something that is not right.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Review
&lt;/h3&gt;

&lt;p&gt;It is not a tool but a technique, the code review in my opinion is the one that most helps when keeping all developers on the same page, it also helps in sharing knowledge of the code in addition to preventing architecture problems and errors that the tools did not find.&lt;/p&gt;

&lt;p&gt;Maintaining the quality of a software needs to be a priority for every developer who creates and maintains a code base, but using tools to help us should not be painful, I hope these tips help you to keep things in order - that's all folks&lt;/p&gt;

</description>
      <category>pattern</category>
      <category>tools</category>
      <category>software</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Criando temas com custom hook + variáveis CSS 👨‍💻</title>
      <dc:creator>Cleyson Leal Braga</dc:creator>
      <pubDate>Wed, 19 May 2021 12:32:30 +0000</pubDate>
      <link>https://forem.com/cleysonlb/criando-temas-com-custom-hook-variaveis-css-581l</link>
      <guid>https://forem.com/cleysonlb/criando-temas-com-custom-hook-variaveis-css-581l</guid>
      <description>&lt;p&gt;Hoje em dia, uma funcionalidade muito requisitada em sites e apps é a aplicação de temas - normalmente usando o tão aclamado “Dark mode”. Com um clique, podemos mudar toda a cor do app/site para um tema escuro. Seus usuários dizem ser mais agradável aos olhos, e até mesmo trazer mais produtividade.&lt;/p&gt;

&lt;p&gt;A aplicação de um tema pode ser algo ainda maior, se pensarmos no estilo do site como um tema, trazendo mais flexibilidade e padronização. Mesmo que ainda não exista um modo escuro, por exemplo. Também podemos aplicar técnicas que estão muito em alta, como o design token.&lt;/p&gt;

&lt;h3&gt;
  
  
  Iniciando o projeto 🚀
&lt;/h3&gt;

&lt;p&gt;Vamos começar iniciando o projeto instalando e criando nossa aplicação usando o create-react-app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npx create-react-app theme-app
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;theme-app
&lt;span class="nv"&gt;$ &lt;/span&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Com isso, teremos uma estrutura assim:&lt;/p&gt;

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

&lt;p&gt;Podemos excluir os arquivos &lt;code&gt;logo.svg&lt;/code&gt;, &lt;code&gt;App.test.js&lt;/code&gt; e o &lt;code&gt;App.css&lt;/code&gt;. Não precisaremos deles nesse tutorial.&lt;/p&gt;

&lt;h3&gt;
  
  
  Criando nosso tema ✨
&lt;/h3&gt;

&lt;p&gt;Vamos criar nosso CSS com o tema primeiro, pois vamos precisar dele dentro do custom hook.&lt;br&gt;
Vamos criar o arquivo theme.module.css no caminho&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./src/styles/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inicialmente, vamos criar somente duas variáveis que serão usadas para aplicar as cores que desejamos.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.defaultTheme&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* Format: --theme + type + color + variant */&lt;/span&gt;

  &lt;span class="c"&gt;/* Colors */&lt;/span&gt;
  &lt;span class="py"&gt;--theme-background-color-primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--theme-text-color--primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.darkTheme&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* Colors */&lt;/span&gt;
  &lt;span class="py"&gt;--theme-background-color-primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--theme-text-color--primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A lógica aqui, é usar o custom hook para trocar a classe do tema - e com isso, os valores das variáveis, aplicando como um todo na aplicação.&lt;/p&gt;

&lt;h3&gt;
  
  
  Criando nosso custom hook 👨‍💻
&lt;/h3&gt;

&lt;p&gt;Para criar nosso custom hook, vamos usar as API’s de context e useState, arquitetando todas as funcionalidades dentro dele, e exportando somente o que vamos utilizar para controlar a troca de tema.&lt;/p&gt;

&lt;p&gt;Vamos criar o nosso arquivo themeContext.js no caminho&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./src/contexts/themeContext
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nosso themeContext.js será assim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../../styles/theme.module.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;themeContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// exportamos o useTheme com as funções que controlam a troca de tema&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useTheme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;themeContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isDarkmode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsDarkmode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;setDarkmodeOn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setIsDarkmode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;setDarkmodeOff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setIsDarkmode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toggle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setIsDarkmode&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;isDarkmode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setDarkmodeOn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setDarkmodeOff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toggle&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// exportamos o ThemeProvider que aplica a classe do tema na div que vai englobar toda a aplicação&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isDarkmode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsDarkmode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;isDarkmode&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;darkTheme&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defaultTheme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;themeContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isDarkmode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsDarkmode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;themeContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Aplicando nosso tema ✅
&lt;/h3&gt;

&lt;p&gt;Para usar nosso useTheme, vamos criar uma funcionalidade básica só para entender o fluxo de como as coisas funcionam.&lt;/p&gt;

&lt;p&gt;Vamos criar um arquivo chamado &lt;code&gt;Home.js&lt;/code&gt; dentro de &lt;code&gt;./src&lt;/code&gt; e também um arquivo chamado &lt;code&gt;styles.module.css&lt;/code&gt; dentro de &lt;code&gt;./src/styles&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;No &lt;code&gt;Home.js&lt;/code&gt; importamos o &lt;code&gt;useTheme&lt;/code&gt; para poder usar nossa função de toggle que troca os temas e nossa variável isDarkMode para saber se o dark mode está ligado ou não.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Home.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useTheme&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./contexts/themeContext/themeContext&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./styles/styles.module.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;isDarkmode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toggle&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTheme&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

 &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wrapper&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`Dark mode on? &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;isDarkmode&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Trocar tema&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No &lt;code&gt;styles.module.css&lt;/code&gt; aplicamos nossas variáveis (design tokens) que aplicam os valores do tema selecionado.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;styles.module.css&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.wrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--theme-background-color-primary&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--theme-text-color--primary&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Agora podemos usar o provider no nosso App.js e chamar nosso componente Home.js&lt;/p&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./contexts/themeContext/themeContext&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Home&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ThemeProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Home&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ThemeProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Resultado 🤩
&lt;/h3&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/usetheme-context-hzjet"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusão
&lt;/h3&gt;

&lt;p&gt;Usando o context + custom hook fica simples controlar e compartilhar em todo o nosso app os controles de tema, podemos ir além do dark mode e criar outros temas para personalizar nossas aplicações.&lt;br&gt;
Espero que tenham gostado do post e&lt;br&gt;
até a próxima&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>css</category>
      <category>reacthooks</category>
    </item>
    <item>
      <title>Leadershipt in dev teams, how to become a tech leader?</title>
      <dc:creator>Cleyson Leal Braga</dc:creator>
      <pubDate>Tue, 05 May 2020 20:12:55 +0000</pubDate>
      <link>https://forem.com/cleysonlb/leadershipt-in-dev-teams-how-to-become-a-tech-leader-2ob3</link>
      <guid>https://forem.com/cleysonlb/leadershipt-in-dev-teams-how-to-become-a-tech-leader-2ob3</guid>
      <description>&lt;p&gt;Hello, I've been working as a developer for just over 9 years, and I realized for a while that I like the leadership part, even without being a tech leader, I end up taking responsibilities for myself, managing, giving feedbacks, etc., I would like tips on how to specialize in this area, content (video, books, podcasts) and I would also like to hear your experience with this subject! : D&lt;/p&gt;

</description>
      <category>leadership</category>
      <category>techleader</category>
      <category>career</category>
    </item>
    <item>
      <title>Best youtube channels to Devs and Designers</title>
      <dc:creator>Cleyson Leal Braga</dc:creator>
      <pubDate>Sat, 22 Sep 2018 15:38:29 +0000</pubDate>
      <link>https://forem.com/cleysonlb/best-youtube-channels-to-devs-and-designers-4kmk</link>
      <guid>https://forem.com/cleysonlb/best-youtube-channels-to-devs-and-designers-4kmk</guid>
      <description>&lt;p&gt;It's been a while since I've followed youtube channels about the day to day developers and designers, it's very interesting to see what these people's routine is like in their professional lives.&lt;br&gt;
I came to share some of the ones I accompany, and to know which ones you like :D&lt;/p&gt;

&lt;h2&gt;
  
  
  Developers
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/user/hellomayuko"&gt;Mayuko&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/channel/UCO1cgjhGzsSYb1rsB4bFe4Q"&gt;MPJ - Fun fun function&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/user/DevTipsForDesigners"&gt;Dev Tips&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/user/wesbos"&gt;Wes Bos&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/channel/UCgzKCeDYLRzPhQ64R6AKyBQ"&gt;Life of Luba&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Designers
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/user/charlimarieTV"&gt;Charlie Marie&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/channel/UCmypYv02UGldiA8g7j2mCyw"&gt;Hello, I`m Alexa&lt;/a&gt;&lt;/p&gt;

</description>
      <category>developer</category>
      <category>designer</category>
      <category>youtube</category>
      <category>career</category>
    </item>
    <item>
      <title>Hello :D</title>
      <dc:creator>Cleyson Leal Braga</dc:creator>
      <pubDate>Thu, 08 Feb 2018 11:19:33 +0000</pubDate>
      <link>https://forem.com/cleysonlb/my-intro--2mjc</link>
      <guid>https://forem.com/cleysonlb/my-intro--2mjc</guid>
      <description>&lt;p&gt;Hello, my name is Cleyson and I'm a Software developer from Brazil!&lt;br&gt;
my english is not very well.. I'm sorry for that.&lt;br&gt;
I'm work with Ruby on Rails, Javascript and Frontend stuffs, I love Design, UX and Psychology, nice to meet you guys :)&lt;/p&gt;

&lt;p&gt;my blog (portuguese): &lt;a href="http://cleyson.co/"&gt;cleyson.co&lt;/a&gt;&lt;/p&gt;

</description>
      <category>intro</category>
      <category>dev</category>
      <category>firstpost</category>
    </item>
  </channel>
</rss>
