<?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 Wendell Adriel on Medium]]></title>
        <description><![CDATA[Stories by Wendell Adriel on Medium]]></description>
        <link>https://medium.com/@wendell_adriel?source=rss-7af9a79d81d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TDiesRVh-w72N4Nt-6BXiQ.jpeg</url>
            <title>Stories by Wendell Adriel on Medium</title>
            <link>https://medium.com/@wendell_adriel?source=rss-7af9a79d81d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 13:52:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wendell_adriel/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[PurgeCSS gotchas]]></title>
            <link>https://medium.com/front-end-weekly/purgecss-gotchas-b2067c862dfa?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2067c862dfa</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Wed, 13 May 2020 19:01:01 GMT</pubDate>
            <atom:updated>2020-05-17T14:58:40.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dw-gZw9O8b9vMA_V" /><figcaption>Photo by <a href="https://unsplash.com/@ripato?utm_source=medium&amp;utm_medium=referral">Ricardo Gomez Angel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Some time ago I bought a <a href="https://tailwindui.com/">Tailwind UI</a> license and I wanted to test it alongside Vue.</p><p>Following the example of someone who created a website to sell pixels from the website: <a href="http://milliondollarhomepage.com/">http://milliondollarhomepage.com</a></p><p>And the “I’m Rich” app: <a href="https://en.wikipedia.org/wiki/I_Am_Rich">https://en.wikipedia.org/wiki/I_Am_Rich</a></p><p>I came up with something funny to work on and test it. I created <a href="https://url-list.com/"><strong>URList</strong></a>, a site to archive a limited amount of URLs that can be tagged!!! 🥳🥳🥳</p><p>I used Laravel, Laravel Forge, Vue CLI and Tailwind UI to create it and it was a wonderful experience! If you already worked with <a href="https://tailwindcss.com/">TailwindCSS</a> you know that it offers a wonderful experience to create UIs, so you know what I’m talking about.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Ff%2F788447%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F788447%2F&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/18214d8333adbb5668f31791a3202b60/href">https://medium.com/media/18214d8333adbb5668f31791a3202b60/href</a></iframe><p>The first time I created a build I didn’t set the PurgeCSS so I got a 3MB+ css file. Then I configured PurgeCSS and ran again and it was less than 20Kb, this is amazing!!! But when I took a look on the app, some things were broken and I didn’t understand why, but it was because of the PurgeCSS somehow.</p><p>After some minutes I remembered that I had some classes that were applied dynamically using Vue, so I set these on PurgeCSS whitelist and it was all good.</p><p>I know that this is something really basic and simple, but I thought about writing about this because since I had this issue, maybe it will help someone else.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2067c862dfa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/purgecss-gotchas-b2067c862dfa">PurgeCSS gotchas</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problemas com o PurgeCSS]]></title>
            <link>https://medium.com/@wendell_adriel/problemas-com-o-purgecss-c41f63a19a1c?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c41f63a19a1c</guid>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Wed, 13 May 2020 14:31:22 GMT</pubDate>
            <atom:updated>2020-05-13T14:31:22.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1VErRpE3gP6ufQDE" /><figcaption>Photo by <a href="https://unsplash.com/@adam_whitlock?utm_source=medium&amp;utm_medium=referral">Adam Whitlock</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Essa é uma versão em português desse meu post: <a href="https://dev.to/wendell_adriel/purgecss-gotchas-4ee4">https://dev.to/wendell_adriel/purgecss-gotchas-4ee4</a></blockquote><p>Algum tempo atrás eu comprei uma licença do <a href="https://tailwindui.com/">Tailwind UI</a> e queria criar algo pra testar ele com Vue.</p><p>Seguindo o exemplo de alguém que criou um site para vender pixels do site: <a href="http://milliondollarhomepage.com/">http://milliondollarhomepage.com</a></p><p>E também do aplicativo “I’m Rich”: <a href="https://en.wikipedia.org/wiki/I_Am_Rich">https://en.wikipedia.org/wiki/I_Am_Rich</a></p><p>Eu tive uma ideia de algo engraçado para criar e testar. Eu criei o <a href="https://url-list.com/"><strong>URList</strong></a>, um site com uma lista limitada de URLs que podem ser classificadas por tags!!! 🥳🥳🥳</p><p>Para isso eu utilizei Laravel, Laravel Forge, Vue CLI e o Tailwind UI para o criar e foi uma experiência incrível! Se você já trabalhou com o <a href="https://tailwindcss.com/">TailwindCSS</a> você sabe que ele oferece uma experiência incrível para criar interfaces, então você sabe do que eu estou falando.</p><p>A primeira vez que fiz uma build eu não configurei o PurgeCSS e então o arquivo css final tinha mais que 3MB. Depois disso eu configurei o PurgeCSS e fiz novamente a build e o arquivo final tinha menos que 20Kb, isso é impressionante!!! Mas quando verifiquei o app, algumas coisas estavam quebradas e eu não estava entendendo o motivo, apenas sabia que era relacionado de alguma forma com o PurgeCSS.</p><p>Depois de alguns minutos me lembrei que algumas classes eram aplicadas dinamicamente com o Vue e então coloquei essas classes na whitelist do PurgeCSS e então tudo se resolveu</p><p>Sei que isso é algo bem básico e simples, mas pensei em escrever sobre isso porquê pode ser que como eu tive esse problema, alguma outra pessoa também poderia ter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c41f63a19a1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Modularized Stateless APIs with Laravel 7.x]]></title>
            <link>https://medium.com/@wendell_adriel/creating-modularized-stateless-apis-with-laravel-7-x-1cf4d34c512?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cf4d34c512</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Wed, 25 Mar 2020 19:04:00 GMT</pubDate>
            <atom:updated>2020-03-25T19:04:00.646Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dSBDf2lDAehbPKZQ" /><figcaption>Photo by <a href="https://unsplash.com/@halgatewood?utm_source=medium&amp;utm_medium=referral">Hal Gatewood</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I work with the Laravel framework since it was on version 4.x and I really love the Framework and the things that it provides. But when I started to work with more complex applications and creating APIs with it, I missed some things. So I saw myself doing the same configurations and changing the default Laravel installation structure quite some times. So I decided to create a Skeleton structure for myself and also to use as the base structure for the new API for my company, that’s when I created <strong>LarAPI</strong> and made it as an Open Source project this week:</p><p><a href="https://github.com/WendellAdriel/larapi">WendellAdriel/larapi</a></p><p>This Skeleton has a lot of things already configured out-of-the-box:</p><ul><li>JWT Authentication</li><li>User Roles</li><li>API documentation with Swagger</li><li>Exception Handler configured to return only JSON responses</li><li>Base classes with common features for projects</li><li>Git Hooks to lint the code, run tests and update the API documentation automatically</li></ul><p>I’m still planning to add more things, but you can start using it right now!!! Check out the repository for the complete documentation and to know how to use it.</p><p>If you want to help, give it a star and share with your friends!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cf4d34c512" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Walk on the Svelte Side: Introduction]]></title>
            <link>https://medium.com/front-end-weekly/a-walk-on-the-svelte-side-introduction-f781fb6308f0?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f781fb6308f0</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[svelte]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Mon, 13 May 2019 20:01:00 GMT</pubDate>
            <atom:updated>2019-05-14T11:39:11.536Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zb4LI5J_0DDfS_XcSGCJXA.png" /></figure><h3>CodeShare</h3><p>I have a project called <a href="https://codeshare.com.br/"><strong>CodeShare</strong></a>, to create free and high-quality content in Portuguese, to reach more people in Brazil that didn’t have the opportunity to learn English yet.</p><p>So when I write a post there, I’ll post here as well, but in English (of course), so if you want to check the original version of this article (in Portuguese) you can check it <a href="https://codeshare.com.br/passeio-pelo-svelte-introducao"><strong>here</strong></a>!</p><h3>Introduction</h3><p>You may have entered this article because you heard this name somewhere and don’t know what it is, or you already know, but you want to know more about it or you can be just asking yourself something like <strong>“Why do I need another reactive UI lib if I already have React and Vue?”</strong>. So, whatever reason that brought you here, prepare yourself because we’re going on an adventure: <strong>A Walk on the Svelte Side</strong> is the new series of articles from <strong>CodeShare</strong> where I’ll show what Svelte is, its main features and we will build examples along with this series and in the end you’ll be ready to start using this lib in your projects!</p><p>This first article will be more theoretical, but that’s really important to know how <strong>Svelte</strong> differs from other libs. I suggest that you read with attention so we can dive in the code after.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Ff%2F788447%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F788447%2F&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/18214d8333adbb5668f31791a3202b60/href">https://medium.com/media/18214d8333adbb5668f31791a3202b60/href</a></iframe><h3>What is Svelte</h3><p><strong>Svelte</strong>, like other UI libs, is based in components, but with an essential and very important difference: it doesn’t use the <strong>Virtual DOM differentiation </strong>like <a href="https://reactjs.org/"><strong>React</strong></a> or <a href="https://vuejs.org/"><strong>Vue.js</strong></a> because this libs use declarative structures that are converted into DOM operations that can overload a little the frames of our apps and also the <a href="https://codeshare.com.br/garbage-collector-no-javascript"><strong>Garbage Collector (in Portuguese)</strong></a>.</p><p>But how <strong>Svelte</strong> works then? All the work is done in the build time, that way it converts all of your components to a high-performance imperative code that applies the fewest possible DOM operations, making that <strong>Svelte “</strong>disappears” completely of your final code. You’ll have a pure, high-performance imperative JavaScript code. We can highlight some important aspects of <strong>Svelte</strong>:</p><ul><li>Extraordinary performance</li><li>Small bundles</li><li>Accessibility aspects included in the lib</li><li>Styles encapsulation/isolation by default</li><li>Declarative transitions included in the lib</li><li>Learning curve</li></ul><p>And in the end, the answer to our question: <strong>“What is Svelte?”</strong> can be answered saying that it’s a compiler because its job is to compile the components into an imperative JavaScript code.</p><h3>Reactivity on Svelte</h3><p>Svelte version 3 was released on April 21 and brought huge changes to the lib, making that the written code is cleaner and improving how it works with the reactivity of the components. For example, before this version, to update the state of our components we needed something like:</p><pre>const { clicks } = this.get()<br>this.set({ clicks: clicks + 1 })</pre><p>If you already worked with <strong>React</strong>, you’ll note a huge resemblance on how we handle the state on a class based component (before the launch of the famous <a href="https://reactjs.org/docs/hooks-intro.html"><strong>Hooks</strong></a>):</p><pre>const { clicks } = this.state<br>this.setState({ clicks: clicks + 1 })</pre><p>With the launch of the <strong>Hooks</strong>, the way that <strong>React</strong> works with the state of the components has changed significantly and some other libs started to create their own version of the <strong>Hooks</strong>. <strong>Svelte</strong> didn’t want to follow this path, because behind the curtains they create some overload to the <a href="https://codeshare.com.br/garbage-collector-no-javascript"><strong>Garbage Collector (in Portuguese)</strong></a> and if you need to run this code on an <strong>embedded device</strong> or if your app relies on many animation-based interactions this can lead to some issues.</p><p>So how <strong>Svelte 3</strong> works with reactivity and updating a component state? In a very simple way, without using <strong>proxies</strong> or nothing like that. When we want to change for example a state variable named clicks, we just need to update it:</p><pre>clicks += 1</pre><p>Since <strong>Svelte’s</strong> job is done in the app build time, for being a compiler, it can only do the instrumentation of these updates without any additional complexity. Behind the curtains what he does is:</p><pre>clicks += 1<br>$$invalidate(&#39;count&#39;, count)</pre><h3>Performance on Svelte</h3><p>One of the main diff between <strong>Svelte</strong> and other libs like <strong>React</strong> and <strong>Vue</strong> is that it doesn’t use the <strong>Virtual DOM</strong>, but you must be thinking: how can it be so fast without using the <strong>Virtual DOM</strong>? If you work with <strong>Front-end</strong> (or even with Back-end, but like to read about), probably you already heard about the <strong>Virtual DOM</strong> and that working with it is more performant than with the <strong>Real DOM</strong>.</p><p>But what’s the <strong>Virtual DOM</strong> and how the libs work with it? In a very simple way, the <strong>Virtual DOM</strong> is only a JavaScript object that defines the basic structure of your page. When a change occurs in the state of your application, for example, the value of some property is updated, it’s created a new object and the lib work is to find the diff between the old and the new object and apply the fewest number of updates in the <strong>Real DOM</strong>.</p><p>In practice, there is no way to make any changes to the <strong>Real DOM</strong> without first comparing the two states of the <strong>Virtual DOM</strong>, but this can lead to some unnecessary steps. <strong>Svelte</strong> works as a compiler, in the app build time it already knows how the state of the application can be changed, so it generates the fewest possible steps to manage this possible changes without having any work during application execution.</p><h3>Creating our first Svelte component</h3><p>One of the main features of <strong>Svelte</strong> is to let us build apps in a simple way and writing less code. The longest the code, greater will be the effort to understand it and the chance of having bugs increases, so when we write less code, we have the benefit of being able to understand it faster and introducing fewer bugs.</p><p>Let’s create our first component, it will be something really simple. We will have two text fields where we can provide our first and last name respectively and it will be shown a welcome message on the screen with our full name. <strong>Svelte</strong> components use the .svelte extension where we declare:</p><ul><li>the behaviour of our component with JavaScript inside a &lt;script&gt; tag</li><li>the style of our component with CSS inside a &lt;style&gt; tag, the styles that we declare on a component have a restrict scope to that component, that means that if you create a rule to change the style of the &lt;p&gt; tags of your component, it won&#39;t affect any other &lt;p&gt; tag outside your component</li><li>the structure of our component with HTML, it is not necessary to encapsulate this structure in a &lt;template&gt; tag as we do on <strong>Vue</strong>, and also may have several root elements, other than the <strong>React</strong> that we can return only one element or use the <a href="https://reactjs.org/docs/react-api.html#fragments"><strong>Fragments</strong></a>.</li></ul><p>First, we have the behaviour part of our component that will be a totally normal and basic JavaScript code. We will create two variables and define a function that we will use when we define the structure of our component:</p><pre>&lt;script&gt;<br>    let firstName = &#39;&#39;<br>    let lastName = &#39;&#39;<br><br>    function showGreeting () {<br>        window.alert(`Welcome, ${firstName} ${lastName}`)<br>    }<br>&lt;/script&gt;</pre><p>Below we will also define the style of our component that is also a normal CSS code, the only difference is that the styles declared here will affect only the elements of this component:</p><pre>&lt;style&gt;<br>    * {<br>        font-family: sans-serif;<br>    }<br><br>    p {<br>        font-weight: 700;<br>    }<br><br>    .warning {<br>        color: #ff2b56;<br>    }<br>&lt;/style&gt;</pre><p>The last part of our component is the structure of our component, that&#39;s done with HTML, with only some little details that we will check after:</p><pre>&lt;label for=&quot;first_name&quot;&gt;First name:&lt;/label&gt;<br>&lt;input id=&quot;first_name&quot; type=&quot;text&quot; bind:value={firstName}&gt;<br><br>&lt;label for=&quot;last_name&quot;&gt;Last name:&lt;/label&gt;<br>&lt;input id=&quot;last_name&quot; type=&quot;text&quot; bind:value={lastName}&gt;<br><br>{#if firstName.length &gt; 0 &amp;&amp; lastName.length &gt; 0}<br>    &lt;p&gt;Hello, {`${firstName} ${lastName}`}&lt;/p&gt;<br>    &lt;p&gt;<br>        &lt;button type=&quot;button&quot; on:click={showGreeting}&gt;Show alert greeting!&lt;/button&gt;<br>    &lt;/p&gt;<br>{:else}<br>    &lt;p class=&quot;warning&quot;&gt;Type your first and last name above...&lt;/p&gt;<br>{/if}</pre><p>As you can see we have some details that aren’t an HTML code in our structure, but that is used to connect the structure of our component with its behaviour. In our &lt;input&gt; elements the attribute value is changed to bind:value={variable}, where we link a state variable of our component so that when this variable is changed the change will be reflected in the &lt;input&gt; element and vice versa.</p><p>Just as it is easy to link state variables, invoking functions that we define when an event occurs in the DOM is also very easy, we use on:event={function}. In our code, when the button receives a click it will invoke our showGreeting function defined above.</p><p>Often we need to show or hide some content according to the state of our component, <strong>Svelte</strong> gives us a simple way to do this with the blocks: {#if} {:else if} {:else} {/if}, this way we can control in a simple and clean way what and when to display and hide some content.</p><p>Our example can be seen in the <strong>CodeSandbox</strong> below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F84ljk782w0&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F84ljk782w0&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F84ljk782w0%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccbb907c303a49d9a7544b3fa8bc0887/href">https://medium.com/media/ccbb907c303a49d9a7544b3fa8bc0887/href</a></iframe><p>As you can see in the <strong>CodeSandbox</strong> above, we have a index.js file that imports our component and renders it in the &lt;body&gt;. This file alongside with the files package.json and the config for <a href="https://rollupjs.org/"><strong>Rollup</strong></a>, the default bundler that <strong>Svelte</strong> uses, rollup.config.js are already included in the default template for <strong>Svelte</strong>.</p><p>You can play on the <strong>CodeSandbox</strong> to not need to create the projects locally, but if you want to is really easy as well. We can use <strong>NPX</strong> to create our project in a simple way:</p><pre>npx degit sveltejs/template my-app &amp;&amp; cd my-app &amp;&amp; yarn</pre><p>That way you’ll create a project using a tool called <strong>Degit</strong> that will create a copy of <a href="https://github.com/sveltejs/template"><strong>this repository</strong></a> that’s the minimum default template for an app, with all the needed config. If you prefer or want to make any changes to this default template you can <strong>fork</strong> <a href="https://github.com/sveltejs/template"><strong>this repository</strong></a> and change the command above to use your Github user:</p><pre>npx degit your-github-user/template my-app &amp;&amp; cd my-app &amp;&amp; yarn</pre><p>In the README.md file of this template you&#39;ll find instructions on how to run your project locally and also instructions on how to deploy your app.</p><h3>Conclusion</h3><p>In this first article we saw what <strong>Svelte</strong> is, its main features and we built our first component to see how it works. In the next articles we will go deeper on other features of this lib while we create examples to put in practice the concepts we will learn.</p><p>I hope that you liked this article and if you do, don’t forget about commenting and sharing this article with your friends!!! See ya! 😎</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f781fb6308f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/a-walk-on-the-svelte-side-introduction-f781fb6308f0">A Walk on the Svelte Side: Introduction</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with multiple CSS themes]]></title>
            <link>https://medium.com/front-end-weekly/working-with-multiple-css-themes-1a48b0387a38?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a48b0387a38</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[theming]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Sat, 27 Apr 2019 14:04:41 GMT</pubDate>
            <atom:updated>2019-04-29T00:29:09.344Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kwZilETXVBuwMcL6" /><figcaption>Photo by <a href="https://unsplash.com/@moren?utm_source=medium&amp;utm_medium=referral">moren hsu</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>CodeShare</h3><p>I have a project called <a href="https://codeshare.com.br/"><strong>CodeShare</strong></a>, to create free and high-quality content in Portuguese, to reach more people in Brazil that didn’t have the opportunity to learn English yet.</p><p>So when I write a post there, I’ll post here as well, but in English (of course), so if you want to check the original version of this article (in Portuguese) you can check it <a href="https://codeshare.com.br/trabalhando-com-multiplos-temas-css"><strong>here</strong></a>!</p><h3>Introduction</h3><p>In <a href="https://medium.com/@wendell_adriel/theming-with-css-variables-e4f30343c7c7"><strong>the first article of this series</strong></a> we saw how variables work on CSS and how we can use them to create themes for our projects. In this article, we will put this into practice creating some simple themes and seeing how to change between them.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Ff%2F788447%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F788447%2F&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/18214d8333adbb5668f31791a3202b60/href">https://medium.com/media/18214d8333adbb5668f31791a3202b60/href</a></iframe><h3>Creating the Default Theme</h3><p>As we saw before, the :root selector can be used to store the global variables of our themes. To create a default theme for our app, we will define some variables in this selector that will be used by our elements:</p><pre>:root {<br>    --global-bg-color: #fff;<br>    --global-font-family: Verdana, sans-serif;<br>    --global-text-color: #222;<br>    --global-link-color: blue;<br>    --global-link-hover: lightblue;<br>}</pre><p>In the code above we defined some variables that will be used as the base values for our theme. That way we can use these values to style our elements. Since we’re only working on an example, the number of variables we have are just a few, but in a large project, this list can be much bigger. Now, let’s use our variables:</p><pre>html {<br>    background: var(--global-bg-color);<br>    font-family: var(--global-font-family);<br>    color: var(--global-text-color);<br>}</pre><pre>a {<br>    color: var(--global-link-color);<br>    text-decoration: none;<br>    font-weight: 700;<br>}</pre><pre>a:hover {<br>    color: var(--global-link-hover);<br>}</pre><p>In the code above we used our variables to control the background and text colors, the font and also the color of the links. If in the middle of our project we want to customize any of these values, we just need to change the value of the variable that we want and all the elements that use it will update, pretty simple. Now let’s create some elements to check our theme in action:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>    &lt;head&gt;<br>        &lt;title&gt;Tematização com CSS&lt;/title&gt;<br>        &lt;meta charset=&quot;UTF-8&quot; /&gt;</pre><pre>        &lt;style&gt;<br>            &lt;!-- STYLE HERE --&gt;<br>        &lt;/style&gt;<br>    &lt;/head&gt;</pre><pre>    &lt;body&gt;<br>        &lt;h1&gt;Tematização com variáveis CSS&lt;/h1&gt;<br>        &lt;p&gt;<br>            Exemplo para ser usado em um artigo na<br>            &lt;a href=&quot;https://codeshare.com.br&quot; target=&quot;_blank&quot;&gt;CodeShare&lt;/a&gt;<br>        &lt;/p&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fwyr0q30wzk&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fwyr0q30wzk&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fwyr0q30wzk%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7dc979a1f9c41a94f7219d75ab5d6bb/href">https://medium.com/media/c7dc979a1f9c41a94f7219d75ab5d6bb/href</a></iframe><h3>Creating a Night Mode Theme</h3><p>Now that we already have our default theme, we can work in a new theme for our app. A lot of sites have a <strong>“Night Mode”</strong> to make it easier to read during the night. Let’s create a theme for this.</p><p>There are some ways of working with themes, but my favorite is to use the data- attributes on <strong>HTML</strong>. These data- attributes are a convention used to define custom attributes for tags and to identify which theme we&#39;re using we will create a data-theme attribute. All the elements with this attribute and their children will be modified. Since our new theme will be for our Night Mode we will call it <strong><em>dark</em></strong>.</p><p>Since our elements are already using the variables that we created, to create a new theme we just need to update the values of the ones that we need to modify, that way the values that we change will overwrite the others and the ones we don’t change will be inherited from the :root element. We will use the attribute selector on <strong>CSS</strong> to apply our theme. Since our theme is a <strong>Global Theme</strong>, we will link it to the &lt;html&gt; tag:</p><pre>html[data-theme=&#39;dark&#39;] {<br>  --global-bg-color: #444;<br>  --global-text-color: #ddd;<br>  --global-link-color: yellow;<br>  --global-link-hover: lightyellow;<br>}</pre><p>In the code above we changed the colors for the background, text and links. Now we just need to put the data-theme=&quot;dark&quot; attribute in our &lt;html&gt; tag to see the result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fmp42xzmnp&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fmp42xzmnp&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fmp42xzmnp%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/951d5393cbd529b49f80cc2588a3609c/href">https://medium.com/media/951d5393cbd529b49f80cc2588a3609c/href</a></iframe><h3>Letting the user switch themes</h3><p>Now that we created two themes for our app, it would be interesting if we let the user switch between them right? It’s not something hard to do, let’s create this option. First, let’s remove the data-theme=&quot;dark&quot; attribute from our &lt;html&gt; tag and create the element that will let the user switch themes when clicked.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>    ...<br>    &lt;body&gt;<br>        &lt;span id=&quot;theme-toggle&quot; class=&quot;theme-toggle&quot;&gt;&lt;/span&gt;<br>        ...<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Now let’s style this element, for that we will create two new variables. We will create this element as a fixed element, so the user can switch themes whenever he wants to. We will also assign different values for these variables when our <strong><em>dark</em></strong> theme is enabled, making that this element will also update its appearance:</p><pre>:root {<br>    ...<br>    --global-theme-toggle-bg: #ccc;<br>    --global-theme-toggle-content: &#39;🌞 THEME&#39;;<br>}</pre><pre>html[data-theme=&#39;dark&#39;] {<br>    ...<br>    --global-theme-toggle-bg: #000;<br>    --global-theme-toggle-content: &#39;🌝 THEME&#39;;<br>}</pre><pre>.theme-toggle {<br>    position: fixed;<br>    right: 20px;<br>    top: 20px;<br>    background: var(--global-theme-toggle-bg);<br>    padding: 10px;<br>    border-radius: 5px;<br>    font-size: 0.8rem;<br>    font-weight: 700;<br>    cursor: pointer;<br>}</pre><pre>.theme-toggle::after {<br>    content: var(--global-theme-toggle-content);<br>}</pre><p>Now that we have finished setting up the visual part of our component, let’s add the needed action to make that our theme will switch when the element is clicked:</p><pre>function toggleTheme () {<br>    const htmlTag = document.getElementsByTagName(&quot;html&quot;)[0]<br>    if (htmlTag.hasAttribute(&quot;data-theme&quot;)) {<br>        htmlTag.removeAttribute(&quot;data-theme&quot;)<br>        return<br>    }</pre><pre>    htmlTag.setAttribute(&quot;data-theme&quot;, &quot;dark&quot;)<br>}</pre><pre>document<br>    .getElementById(&quot;theme-toggle&quot;)<br>    .addEventListener(&quot;click&quot;, toggleTheme);</pre><p>In the code above we created a function that will check if the &lt;html&gt; tag has a data-theme attribute and if so, it will remove it and if doesn&#39;t, it will add this attribute with the value <strong><em>dark</em></strong> to activate our Night Mode Theme. After that we create a listener in our element that when it gets clicked it will run the function that we just created:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fm45wj6xz68&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fm45wj6xz68&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fm45wj6xz68%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/62a3e168836f4e9168bc3dc1ae98615f/href">https://medium.com/media/62a3e168836f4e9168bc3dc1ae98615f/href</a></iframe><h3>Improving the Theme Switching</h3><p>Congrats for us! We already let that our users can switch the theme of our app, but we still have some little details that we can improve. For example, when we switch the theme, the update is made in a very sudden way, it would be interesting to make this update in a smoother way and we can do that easily using the transition rule from <strong>CSS</strong>, check how simple it is:</p><pre>html {<br>    ...<br>    transition: all 1s;<br>}</pre><pre>a {<br>    ...<br>    transition: all 1s;<br>}</pre><p>And it’s done!!! See how now the transition between themes is being made much smoother and pleasing to the eye!!! But we can still improve something else. When the user enters in our app and change the theme and leave, we want that when he returns, the site will load the last chosen theme, for that we will use the localStorage to store this info. We will need to make a little change in our toggleTheme function and create one more function to help us:</p><pre>function toggleTheme () {<br>    const htmlTag = document.getElementsByTagName(&#39;html&#39;)[0]<br>    if (htmlTag.hasAttribute(&#39;data-theme&#39;)) {<br>        htmlTag.removeAttribute(&#39;data-theme&#39;)<br>        return window.localStorage.removeItem(&quot;site-theme&quot;)<br>    }</pre><pre>    htmlTag.setAttribute(&#39;data-theme&#39;, &#39;dark&#39;)<br>    window.localStorage.setItem(&quot;site-theme&quot;, &quot;dark&quot;)<br>}</pre><pre>function applyInitialTheme () {<br>    const theme = window.localStorage.getItem(&quot;site-theme&quot;)<br>    if (theme !== null) {<br>        const htmlTag = document.getElementsByTagName(&quot;html&quot;)[0]<br>        htmlTag.setAttribute(&quot;data-theme&quot;, theme)<br>    }<br>}</pre><pre>applyInitialTheme();</pre><pre>document<br>    .getElementById(&quot;theme-toggle&quot;)<br>    .addEventListener(&quot;click&quot;, toggleTheme);</pre><p>That’s it, now we can offer a special experience for our users!!!</p><h3>Applying Themes in Specific Zones</h3><p>We saw above how to create and switch between two <strong>Global Themes</strong>, that means that they’re applied in our application as a whole, but we can also apply themes to specific zones in our app. To show that, let’s create a theme that will change only the font and let’s apply that to some elements:</p><pre>[data-theme=&#39;comic&#39;] {<br>    --global-font-family: &#39;Comic Sans MS&#39;;<br>}</pre><pre>p, span {<br>    font-family: var(--global-font-family);<br>}</pre><pre>&lt;body&gt;<br>    &lt;span data-theme=&quot;comic&quot; id=&quot;theme-toggle&quot; class=&quot;theme-toggle&quot;&gt;&lt;/span&gt;<br>    &lt;h1&gt;Tematização com variáveis CSS&lt;/h1&gt;<br>    &lt;p&gt;<br>        Exemplo para ser usado em um artigo na<br>        &lt;a href=&quot;https://codeshare.com.br&quot; target=&quot;_blank&quot;&gt;CodeShare&lt;/a&gt;<br>    &lt;/p&gt;</pre><pre>    &lt;p data-theme=&quot;comic&quot;&gt;<br>        Exemplo de um tema aplicado em partes específicas da página! Esse texto<br>        tem o tema &quot;comic&quot;!<br>    &lt;/p&gt;<br>&lt;/body&gt;</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fnnqvpvmx1m&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fnnqvpvmx1m&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fnnqvpvmx1m%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/a01ae6c04578c3c71bd7edd69ac14989/href">https://medium.com/media/a01ae6c04578c3c71bd7edd69ac14989/href</a></iframe><h3>Conclusion</h3><p>In our examples above, we worked with three simple themes, but in larger projects, the complexity of the themes can be much bigger. Thinking about that, I created a lib called <strong>CSS Theme Manager</strong> that helps in the management of themes based in CSS variables, check it out and if you find it interesting, use it in your projects!</p><p><a href="https://github.com/WendellAdriel/css-theme-manager">WendellAdriel/css-theme-manager</a></p><p>I hope that you liked this article and if you do, don’t forget about commenting and sharing this article with your friends!!! See ya! 😎</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a48b0387a38" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/working-with-multiple-css-themes-1a48b0387a38">Working with multiple CSS themes</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Theming with CSS variables]]></title>
            <link>https://medium.com/front-end-weekly/theming-with-css-variables-e4f30343c7c7?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4f30343c7c7</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[theming]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Thu, 25 Apr 2019 20:01:01 GMT</pubDate>
            <atom:updated>2019-04-26T20:43:59.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M9i-wIfpWC5bxGru" /><figcaption>Photo by <a href="https://unsplash.com/@zgc1993?utm_source=medium&amp;utm_medium=referral">Z zzz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>CodeShare</h3><p>I have a project called <a href="https://codeshare.com.br/"><strong>CodeShare</strong></a>, to create free and high-quality content in Portuguese, to reach more people in Brazil that didn’t have the opportunity to learn English yet.</p><p>So when I write a post there, I’ll post here as well, but in English (of course), so if you want to check the original version of this article (in Portuguese) you can check it <a href="https://codeshare.com.br/tematizacao-variaveis-css/"><strong>here</strong></a>!</p><h3>Introduction</h3><p>It doesn’t matter if we’re creating a website or an admin page or an app, we need to deliver a solid and consistent design always. We can’t have a software where on each page we use a different font or buttons of all colours and shapes. We need to define a pattern, not only because of the visual aspect but when we create a pattern of colours and layout, the users can learn and get used quickly with our product.</p><p>To make this process easier, some time ago we had to ask for the help of the CSS pre-processors to use features like variables that make our lives easier when it comes to theming. Gladly we don’t need that anymore because of CSS already let us work with variables natively and in this article, we will see how we can use this feature to create a simple, yet efficient design system for our projects.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Ff%2F788447%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2F788447%2F&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/18214d8333adbb5668f31791a3202b60/href">https://medium.com/media/18214d8333adbb5668f31791a3202b60/href</a></iframe><h3>Declaring and using variables</h3><p>To declare a CSS variable it’s super simple. The name of the variables <strong>MUST </strong>start with -- and they are <em>case-sensitive</em>.</p><pre>.my-class {<br>    --font-size: 1rem;<br>}</pre><p>The same way that’s easy to declare a variable, using it is also super simple. We just need to use the var() function. This function takes two parameters: the first one is the name of the variable that we want to get its value and the second one is an optional parameter with a fallback value if the given variable passed as the first parameter isn&#39;t found.</p><pre>.my-class p {<br>    font-size: var(--font-size, 0.8rem);<br>}</pre><p>The variables on CSS inherit values, that means that if a value is not found in a given element, the parent element value will be used.</p><h3>Two layers theming</h3><p>If in our project we group all variables in a single place (Global Variables), we create a single source of truth, but we lose the ability to modularize our theme and always when a dev needs to customize a component he will need to overwrite the CSS rules.</p><p>In the other hand, if we leave the variables scattered all around, we will create a modularized theme, but we lose the consistency between our components and if we need to make a general change, we will have a lot of work.</p><p>To solve this issue we will think about our theme having two layers, we will have the <strong>Global Variables</strong> and the <strong>Modules Variables</strong>. That way we can get the best of the two worlds.</p><h3>Global Variables</h3><p>Global variables are generic variables that will be used to keep the consistency between all our components. Some examples of global variables are font, default font-size and color palette. It’s super simple to define global variables on CSS, we use the :root selector and inside it, we define our variables. It&#39;s not mandatory, but to make it simple to identify that a variable is global or not, I like to use the global- prefix, that way when I&#39;m reading the code I can already know that certain value comes from a global variable.</p><pre>:root {<br>    --global-font-family: Verdana, sans-serif;<br>    --global-font-size: 0.8rem;<br>    --global-text-color: #222;<br>    --global-primary-title-size: 2rem;<br>    --global-color-primary: #88498f;<br>    --global-color-secondary: #779fa1;<br>    --global-color-warning: #e28413;<br>    --global-color-danger: #ff6542;<br>}</pre><p>In the code above, we define some variables that will be used as base values in all our project: font, font size for texts and for main titles, font color for texts and a color palette with four different colors. Now we will use the global variables that we just defined:</p><pre>body {<br>    font-family: var(--global-font-family);<br>    font-size: var(--global-font-size);<br>    color: var(--global-text-color);<br>}<br><br>h1 {<br>    font-size: var(--global-primary-title-size);<br>}</pre><p>In the code above we define the default font, font color and font size for all our product and we also define the font size for the main titles. If we need to change any of these values in the middle of our project, we just need to change the variables declaration with the new values and it’s done! That way we can create some sort of consistency in our product and also create a common reference point for devs and designers to work together in a quick and easy way.</p><h3>Modules Variables</h3><p>These are variables with a restricted scope where it’s defined. Every module variable <strong>MUST</strong> be defined using the value from a global variable and we also need to provide a fallback value for the case that the module will be used in an environment that doesn’t provide global variables, it doesn’t break. It’s not mandatory, but to make it simple to identify that a variable is a module variable, I like to use the module- prefix, that way when I&#39;m reading the code I can already know that certain value comes from a variable of the <strong>X</strong> module. Let&#39;s take as an example a module for a button:</p><pre>:root {<br>    ...<br>    --global-border-radius-sm: 3px;<br>    --global-text-color-light: #fff;<br>}<br><br>.btn {<br>    --btn-border-radius: var(--global-border-radius-sm);<br>    --btn-text-color: var(--global-text-color-light);<br>    border-radius: var(--btn-border-radius, 5px);<br>    color: var(--btn-text-color, #ddd);<br>}<br><br>.btn-primary {<br>    --btn-primary-bg: var(--global-color-primary);<br>    --btn-primary-border: var(--global-color-primary);<br>    background-color: var(--btn-primary-bg, #605770);<br>    border-color: var(--btn-primary-bg, #605770);<br>}<br><br>.btn-secondary {<br>    --btn-secondary-bg: var(--global-color-secondary);<br>    --btn-secondart-border: var(--global-color-secondary);<br>    background-color: var(--btn-secondary-bg, #7fc29b);<br>    border-color: var(--btn-secondary-bg, #7fc29b);<br>}</pre><h3>Understanding the two layers theming</h3><p>Ok, now that we already saw how to structure our theme, we need to understand the reason why this Two Layers Theming works. The way that we built our theme, we make independent modules, because if they are being used on a context where we have the global variables, they will inherit the values from these variables, but if it doesn’t find these variables, we also defined fallback values that will be used.</p><p>We also made that changes can be really easy to be done. For example if we want to change the primary color everywhere in our product, we just need to change the --global-color-primary global variable and all our modules, including the <strong>btn</strong> module will be affected. Now imagine that we want to change the font color of all our buttons, we can change the --global-text-color-light variable, but that will affect all the other modules, so we just need to change the --btn-text-color module variable that will affect only the <strong>btn</strong> module.</p><h3>Conclusion</h3><p>We saw how to create a consistent and adaptable theme for our projects using only CSS. Using this Two Layers Theming approach, we created a better environment and experience for our teams of devs and designers. You can check an example of the code we created in this article in <strong>the Codepen below that I created</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FWendellAdriel%2Fembed%2Fpreview%2FQPxRjN%3Fheight%3D600%26slug-hash%3DQPxRjN%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2FWendellAdriel%2Fpen%2FQPxRjN&amp;image=https%3A%2F%2Fscreenshot.codepen.io%2F408116.QPxRjN.small.cda280ad-5790-42ef-b782-811c8637f83e.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/0eaa0a58ad1c45cf6da973a7ab1e444b/href">https://medium.com/media/0eaa0a58ad1c45cf6da973a7ab1e444b/href</a></iframe><p>I hope that you liked this article and if you do, don’t forget about commenting and sharing this article with your friends!!! See ya! 😎</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4f30343c7c7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/theming-with-css-variables-e4f30343c7c7">Theming with CSS variables</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I’m a dev, believe it, I have a package on NPM]]></title>
            <link>https://medium.com/@wendell_adriel/im-a-dev-believe-it-i-have-a-package-on-npm-68daa4aa97c1?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/68daa4aa97c1</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[community]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Mon, 09 Jul 2018 10:59:12 GMT</pubDate>
            <atom:updated>2018-07-09T10:59:12.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xZ_FBBzP9xsr8HB3vVxBLg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/BVyNlchWqzs?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Amador Loureiro</a> on <a href="https://unsplash.com/search/photos/knowledge?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This title is a little strange, but I’m here to talk about something that all of us, developers and software engineers, think about at least one time in our career.</p><p>I work with software development since 2009, I have some open source projects on my Github, but almost all of them are boilerplates to work with technologies that I work on my job or that I use in personal projects or freelances. I didn’t had any packages published on NPM until today and my first package is a really simple thing that I had a specific need on a project that I’m working on and I thought: “Hmmm, I never published any packages on NPM, even that this is a really specific need for this project, maybe I can help someone with it” and then I published my first package:</p><p><a href="https://www.npmjs.com/package/time-storage">time-storage</a></p><p>I just wanted to write this little introduction to enter on a subject that annoys me. Sometimes I think: “Am I a real developer?”</p><p>When we’re at the beginning of our career we see other developers with more experience and more skills and think: “Wow, that’s a real developer”!!! Maybe this happened with you too…</p><p>Then we start to develop, to study, to get more experience and skills and we always see other developers and think the same thing. Are we never satisfied with our own skills, maybe…</p><p>But things get worst when we start to join communities and groups of developers. We start to see other developers in meetups, conferences and we see these developers as “gods”. They’re the ones that know things, how to create amazing things and projects, etc. Then we see ourselves and think: “Oh man, I’ll never be like that”… but… is that a bad thing?</p><p>You don’t need to create AMAZING open source projects, you don’t need to lead talks in important conferences, you don’t even need to lead talks in local meetups to be a REAL developer/engineer.</p><p>Real developers are the ones that help others!!! That’s a really general answer, but think with me: on my job I help my company to solve its problems thinking in solutions and coding them. I help a colleague to understand or learn something and he/she can help others after that. I can help too with open source projects on Github, NPM. Leading talks in conferences, meetups is another way to help, but that’s NOT THE ONLY WAY!!!</p><p>Small actions like donating a little portion of your time to help others with their questions can change the world around you and create a mass effect. So, stop thinking that only these “famous” developers and engineers are the REAL ones!! You and me can make the difference too!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68daa4aa97c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mercado de TI em Portugal (minha experiência pessoal)]]></title>
            <link>https://medium.com/trainingcenter/mercado-de-ti-em-portugal-minha-experi%C3%AAncia-pessoal-3c01b783e30d?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c01b783e30d</guid>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Fri, 09 Feb 2018 13:41:01 GMT</pubDate>
            <atom:updated>2018-02-09T14:19:05.387Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAGhMziD4d_l96mZqjS52Q.jpeg" /></figure><p>Muitas pessoas já me pediram para escrever um artigo sobre como é o mercado de TI em Portugal e contar um pouco da minha experiência, então nesse artigo de hoje vou compartilhar um pouco sobre esses pontos com vocês com base na minha experiência pessoal.</p><h4>Processo seletivo</h4><p>Eu fiz todo o processo seletivo enquanto estava no Brasil. Um amigo me marcou em uma publicação no Facebook de uma vaga aberta aqui em Lisboa (vaga para Dev Sênior), eu entrei em contato, enviei meu currículo e comecei o processo seletivo.</p><p>A empresa que vim é uma consultora, uma empresa que fornece serviços de consultoria para outras empresas, então meu processo seletivo foi feito por duas empresas: a consultora que é a empresa que ia me contratar e pelo cliente da consultora que era a empresa a qual eu iria prestar serviços. O processo seletivo como um todo foi separado em algumas etapas:</p><ul><li>Conversa com o RH da consultora</li><li>Conversa técnica com a consultora</li><li>Conversa com o RH do cliente</li><li>Teste prático com o cliente</li><li>Conversa técnica com o cliente</li></ul><h4>Visto</h4><p>Depois de estar tudo ok e eu ter sido aprovado para a vaga, a empresa enviou a documentação necessária por correio e eu fui até à embaixada portuguesa (que também é onde fica o consulado em Brasília) e peguei a lista de documentos que tinha de arrumar. Depois de arrumar tudo, voltei à embaixada e dei entrada no visto de residência e para minha sorte em 22 dias o visto estava liberado e no começo de Agosto de 2016 me mudei com minha esposa para Lisboa.</p><h4>Primeiras semanas</h4><p>As primeiras semanas foram complicadas, apesar do idioma ser “o mesmo”, no início para mim era mais fácil conversar em inglês do que em português pois eu não entendia quase nada por causa do sotaque e da velocidade que os portugueses conversavam. Isso foi o mais difícil de se acostumar porque se acostumar com a liberdade que temos de andar na rua de madrugada, com celular na mão sem ter medo de ser assaltado, isso conseguimos acostumar muito rápido.</p><h4>Salário e qualidade de vida</h4><p>Muitas pessoas me perguntam porque eu vim para Portugal sendo que os salários são os mais baixos da Europa. Eu sempre respondo a mesma coisa:</p><p>Portugal nunca tinha sido um local que eu e minha esposa pensávamos em morar, nosso objetivo era o Canadá, mas foi a primeira oportunidade de trabalho fora do Brasil que deu certo. Na semana do nosso vôo para Lisboa fui chamado para uma vaga no Canadá, mas como já tínhamos vendido tudo, estava com passagens na mão, contrato assinado, etc, nós não podíamos mais recusar e voltar atrás e não nos arrependemos disso.</p><p>Dito isso, não saímos do Brasil para ficar rico e todo mundo que me pergunta eu respondo: <strong>PORTUGAL NÃO É UM LUGAR PARA SE FICAR RICO TRABALHANDO COMO DESENVOLVEDOR</strong>. Viemos para cá pela qualidade de vida e isso não tem comparação. Eu vim para ganhar quase o mesmo que ganhava no Brasil, a diferença é que o <strong>PODER DE COMPRA AQUI É BEM MAIOR.</strong></p><p>Pelo que tenho visto os salários de desenvolvedores aqui tem um range entre <strong>800 e 2.5k euros líquido</strong> (não sei salários de arquitetos, designers, etc). Muitas pessoas vão pensar: <strong>NOSSA É MUITO BAIXO.</strong> Sim, eu concordo, mas o custo de vida aqui também é baixo. Tudo depende do estilo de vida das pessoas, mas um casal sem filhos aqui gasta aproximadamente <strong>1.2k para VIVER MUITO BEM</strong>, quando eu digo isso é realmente isso. Ir no mercado e comprar o que quiser comer, algumas saídas para comer fora, contas, etc. Mas como disse, tudo depende do estilo de vida.</p><h4>Dia-a-dia</h4><p>Não sei qual o motivo, mas muitas pessoas me perguntam como é o dia-a-dia no trabalho aqui. Não é muito diferente de como é trabalhar como Dev aí no Brasil, mas posso listar algumas diferenças. Veja que isso é muito relativo, pois cada empresa (seja onde for) tem suas metodologias e particularidades, então o que eu listar aqui pode ser muito bem algo comum para você aí, mas que não foi para mim enquanto trabalhava aí ou vice-versa.</p><p>Vou listar apenas dois pontos em que difere muito das experiências que tive no Brasil:</p><ul><li>Tranquilidade: todas experiências que tive no Brasil, os prazos eram para ontem. Tudo tinha de ser feito de forma muito corrida, não tinha tempo de planejar muito bem, etc. Aqui até o momento o trabalho tem um ritmo mais tranquilo. Tem sim períodos de tensão e que temos que correr e suar para fazer uma entrega, mas no geral o ritmo é bem mais tranquilo e sem tanta pressão como em certas experiências que já tive.</li><li>Contato com outros idiomas: aqui é muito comum se trabalhar em projetos em que outras equipes sejam de outro país, ou que algum cliente seja de outro país, etc. Normalmente quando isso acontece a comunicação passa a ser feita com a língua inglesa. Nos projetos que trabalhei até agora eu tenho contato diariamente com a língua inglesa, seja escrever, ler, ouvir ou falar, estamos diariamente treinando e aperfeiçoando o uso da língua inglesa.</li></ul><h4>Mercado de trabalho</h4><p>O mercado de trabalho de TI está <strong>MUITO AQUECIDO</strong> não só em Portugal, mas em toda Europa. Não por ter milhões de vagas em aberto em todas empresas que existem, mas sim por não encontrarem profissionais qualificados para preencher essas vagas.</p><p>Desde que vim para cá eu recebo convites para participar de processos seletivos diariamente. Geralmente recebo entre 8 e 15 convites desses por semana e de vários países da Europa. Com isso vocês podem ver que o mercado está muito bom. A maioria das vagas que fazem o sponsor do visto são para Devs Sênior, mas também há empresas que fazem sponsor do visto para Devs Pleno e Júnior, talvez seja um pouco mais difícil de encontrar, mas existem.</p><p>Mas como se preparar para essas vagas? Vou dar algumas dicas que aprendi durante minha trajetória profissional:</p><ul><li>Inglês é essencial: antes de sair por aí aprendendo 5 linguagens de programação diferente, a linguagem mais importante será o inglês.</li><li>LinkedIn como porta de oportunidades: como disse anteriormente, recebo muitas propostas de emprego pelo LinkedIn, então manter ele atualizado e ter uma versão do seu perfil em inglês é algo que vai ajudar muito a chamar atenção para novas oportunidades.</li><li>Soft skills: eu já disse isso em um Tweet meu: <a href="https://twitter.com/wendell_adriel/status/946087505312518144">https://twitter.com/wendell_adriel/status/946087505312518144</a>, uma das coisas que difere um Dev Pleno e um Dev Sênior não é apenas o conhecimento técnico, pessoalmente acho que é o menor fator entre ambos. O que realmente faz a diferença são as Soft Skills.</li><li>Marketing pessoal: cuidado com esse ponto, não é sair por aí dizendo que você sabe muito, etc. Mentir é totalmente prejudicial para usa imagem. O que quero dizer aqui é você criar um site pessoal para mostrar seus projetos e suas experiências, participar de eventos, contribuir para projetos, palestrar em algum evento, etc. Tudo isso pode te ajudar, <strong>MAS NÃO FAÇA ISSO PARA “GANHAR PONTOS” EM ENTREVISTAS, etc</strong>. Contribua para projetos, participe e fale em eventos para ajudar as pessoas e o “mérito” vai vir como um “brinde”.</li></ul><h4>Updates</h4><p>Depois de publicar no Twitter o artigo, recebi um comentário que acho importante compartilhar com vocês:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ccLOWNCFtScm6HrDYTtDvw.jpeg" /></figure><h4>Conclusão</h4><p>Espero que tenham gostado e que esse artigo tenha ajudado a esclarecer algumas dúvidas que tinham. Como ele foi escrito com base na minha experiência, outras pessoas podem ter pontos de vista totalmente diferentes do meu, apenas usei minhas experiências como base.</p><p>Se vocês quiserem ver um pouco mais sobre esse assunto, em 2016 dei uma talk na Laraconf Brasil sobre esse tema. Vocês podem ver no vídeo abaixo:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FvYO8adjZ7N0%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DvYO8adjZ7N0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FvYO8adjZ7N0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8a10555de152925b5903e269753f86f/href">https://medium.com/media/c8a10555de152925b5903e269753f86f/href</a></iframe><p>Querem falar sobre tecnologia, desenvolvimento, metodologias de desenvolvimento ou carreira? Cola lá no Twitter: https://twitter.com/wendell_adriel</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c01b783e30d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trainingcenter/mercado-de-ti-em-portugal-minha-experi%C3%AAncia-pessoal-3c01b783e30d">Mercado de TI em Portugal (minha experiência pessoal)</a> was originally published in <a href="https://medium.com/trainingcenter">Training Center</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Path (until now) into React: A learning path]]></title>
            <link>https://medium.com/front-end-weekly/my-path-until-now-into-react-a-learning-path-5d0303b7ffc1?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d0303b7ffc1</guid>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Thu, 28 Dec 2017 12:10:00 GMT</pubDate>
            <atom:updated>2017-12-28T12:10:00.326Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6C4nSvy2Woe0m7bWEn4BA.png" /></figure><h4>A little about me</h4><p>Before talking about <strong>React</strong>, I’ll talk a little how I got there. <strong>I work with web development since 2009</strong> and the first technologies that I worked with were: <strong>HTML, CSS, JavaScript and PHP</strong>. I always worked as a <strong>“Full Stack Developer” </strong>because I started to work as a freelancer, so I had to pick up projects, build them from scratch and put them into production all by myself.</p><p><strong>JavaScript and PHP are my main technologies</strong> (the ones I have more experience and that I’m more comfortable working with).<strong> I’m not an expert in anything, I’m not proud to say that</strong>, but the circumstances led me to be more a <strong>“generalist”</strong> person and that sucks when you have<strong> </strong><a href="https://en.wikipedia.org/wiki/Impostor_syndrome"><strong>Impostor Syndrome</strong></a>.<strong> Nowadays I can work well with any technologies </strong>(currently I’m working with Java and I’m loving to learn Go), <strong>but being a “generalist developer” is hard because a lot of people judge me for that and I don’t blame them for that</strong>. I’m not here to talk about me, so let’s leave that to another time and focus on what’s important.</p><h4>The road into React</h4><p>Some years ago I started to learn about<a href="https://angularjs.org/"> <strong>Angular 1.x</strong></a> and the skills I got with it gave me some really <strong>good opportunities to work on amazing projects with amazing people</strong>. By the way this led me to work with a friend of mine that later would be the “door” for me to <strong>move from Brazil to Portugal</strong>.</p><p>When <a href="https://angular.io/"><strong>Angular 2</strong></a> was in it first steps I was studying it a lot, but I wasn’t liking too much to work with it, so I decided to try something new. Some time ago I already made a PoC with <a href="https://vuejs.org/"><strong>Vue.js</strong></a> and loved it, but I tried something new: <a href="https://reactjs.org/"><strong>React</strong></a>, but at the time that <strong>“HTML on JS stuff”</strong> (yup, now I see how dumb I was) was really strange to me, so I decided to learn more about <strong>Vue.js </strong>and use it in my projects.</p><p><strong>React became very popular</strong>, everyone was talking about it and last year I decided to give it another chance. For my own surprise, the <strong>JSX syntax was not strange to me anymore</strong> and I saw that I could use a lot of concepts that I was already using in <strong>Vue.js </strong>with <strong>React</strong> and I loved it. Since then I started to read, study and talk about it. I still use and love<strong> Vue.js</strong>, but I’m loving to learn and work (on my personal projects and some freelances) with <strong>React</strong>.</p><h4>Learning Path</h4><p>I don’t know if this will be useful, but <strong>I’ll share some resources and tips</strong> with you (maybe someone that’s reading this is lost in how to begin with <strong>React</strong>) that I used on my journey until now and share what are my <strong>“next steps”</strong> in this <strong>endless journey on learning how to solve problems</strong>, because one thing that I say a lot is: <strong>We developers/engineers aren’t paid to code, we’re paid to solve problems</strong>. But to do that we need to know the best tools and technologies available out there and most important: <strong>we need to know what are the right questions to ask and know what to look for</strong>.</p><p><strong>Resources:</strong></p><ul><li><a href="https://reactjs.org/docs"><strong>The official docs</strong></a><strong>:</strong> there’s no better place to learn something, the <strong>docs </strong>can help you learn from basic to advanced topics, so check it out right now!!!</li><li><a href="https://egghead.io/courses/the-beginner-s-guide-to-reactjs"><strong>The Beginner’s Guide to ReactJS</strong></a><strong> by </strong><a href="https://medium.com/u/db72389e89d8"><strong>Kent C. Dodds</strong></a><strong>:</strong> this course is amazing, when I saw it I was already working with <strong>React </strong>for some time, but seeing how <a href="https://medium.com/u/db72389e89d8">Kent</a> explains it’s awesome. I led some workshops before and sometimes I still do and <strong>I wish I had this didactic</strong>. xD</li><li><a href="https://react.holiday/"><strong>React Holiday</strong></a><strong> by </strong><a href="https://medium.com/u/49e1066348ce"><strong>michael chan</strong></a><strong>: </strong>another amazing resource, with this you can learn <strong>React </strong>with small lessons, in each lesson you will learn one or more <strong>React </strong>and <strong>JavaScript </strong>concepts and at the end of it your skills will be on another level. Another example of amazing didactic skill.</li><li><a href="https://www.reactenlightenment.com/"><strong>React Enlightenment</strong></a><strong> by </strong><a href="https://medium.com/u/c54dd6160844"><strong>cody lindley</strong></a><strong>:</strong> one more amazing resource to learn <strong>React </strong>and its concepts. A <strong>Gitbook </strong>with a lot of content that you must know to be a good <strong>React </strong>developer.</li><li><a href="https://egghead.io/courses/advanced-react-component-patterns"><strong>Advanced React Component Patterns</strong></a><strong> by </strong><a href="https://medium.com/u/db72389e89d8"><strong>Kent C. Dodds</strong></a><strong>:</strong> do you want to take your skills to another level? So you <strong>NEED </strong>to take a look at this course. With a simple and clear language, <a href="https://medium.com/u/db72389e89d8">Kent</a> will show you patterns to take your game to another level!!! At the end of this course you’ll have the skills to take a look at that project you started and turn it into an <strong>AWESOME </strong>product!!! ;)</li><li><a href="https://reactpatterns.com/"><strong>React Patterns</strong></a><strong> by </strong><a href="https://medium.com/u/49e1066348ce"><strong>michael chan</strong></a><strong>: </strong>a walkthrough on many common patterns to use in your projects with a simple language and many examples.</li></ul><p><strong>Tips:</strong></p><ul><li>Pick some articles to read daily: <a href="https://medium.com/tag/reactjs">https://medium.com/tag/reactjs</a></li><li>Twitter is a great place for developers and there you can follow a lot of people that can post things related to what you’re learning, so you can take a look at <a href="https://medium.com/@dan_abramov/my-react-list-862227952a8c"><strong>this article</strong></a><strong> by </strong><a href="https://medium.com/u/a3a8af6addc1"><strong>Dan Abramov</strong></a><strong> </strong>to see a list of people that you should follow if you’re interested on <strong>React</strong></li><li>I also use<a href="https://twitter.com/oguzbilgic/lists/react-influencers"><strong> this list</strong></a> to keep up-to-date with React related stuff.</li><li>Read the source code!!! Yes, it’s one of the best things you can do, reading the source code of libraries, frameworks, etc, is a great way to improve your skills. You will learn a lot seeing how other people do things and you can even see something that can be improved and help the project with it!!! xD</li><li>Practice… yes, just reading things isn’t a great way to improve your skills…</li></ul><h4>Conclusion</h4><p>I hope that this article can help you with something!!! I really love to talk about software development, career, games, music, animes and movies. If you want to, just ping me at:</p><ul><li><a href="https://twitter.com/wendell_adriel"><strong>Twitter</strong></a></li><li><a href="https://github.com/WendellAdriel"><strong>Github</strong></a></li><li><a href="https://linkedin.com/in/wendelladrielti/en"><strong>LinkedIn</strong></a></li><li><a href="https://facebook.com/wendell.adriel.7"><strong>Facebook</strong></a></li><li><a href="https://www.instagram.com/wendell_adriel"><strong>Instagram</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d0303b7ffc1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/my-path-until-now-into-react-a-learning-path-5d0303b7ffc1">My Path (until now) into React: A learning path</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microserviços com Spring Cloud: Parte 1]]></title>
            <link>https://medium.com/codeshare/microservi%C3%A7os-com-spring-cloud-parte-1-aeea162e1e33?source=rss-7af9a79d81d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeea162e1e33</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Wendell Adriel]]></dc:creator>
            <pubDate>Thu, 30 Nov 2017 16:26:54 GMT</pubDate>
            <atom:updated>2017-11-30T16:27:21.947Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*XJkI54tkLxXN4QMz1C5hOg.png" /><figcaption>Spring Cloud</figcaption></figure><h4>Introdução</h4><p>Olá galera, quem me acompanha nas redes sociais (<a href="https://facebook.com/wendell.adriel.7">Facebook</a>, <a href="https://instagram.com/wendell_adriel">Instagram</a>, <a href="https://linkedin.com/in/wendelladrielti/en">LinkedIn</a>, etc) deve saber que mudei recentemente de projeto. Anteriormente estava a trabalhar em um projeto na <strong>OLX</strong>, mas há algum tempo atrás mudei de projeto e no momento estou a trabalhar na <strong>Accenture</strong>.</p><p>Na <strong>OLX </strong>estava a trabalhar com <strong>PHP</strong>: uma das primeiras linguagens que aprendi, a que trabalho a mais tempo e tenho mais experiência, e apesar de nesse momento eu estar a focar em <strong>Go</strong>, o projeto que estou atualmente é em <strong>Java </strong>e como tinha um tempo que não trabalhava com <strong>Java</strong>, resolvi estudar um pouco e me atualizar.</p><p>No projeto atual não usamos <strong>Spring</strong>, mas como é um <strong>Ecossistema </strong>(pessoalmente não considero o <strong>Spring </strong>como um <strong>Framework</strong>, pois atualmente ele é realmente um ecossistema completo e cheio de ferramentas para projetos <strong>Java</strong>) que gosto muito de trabalhar com, resolvi aprofundar em alguns assuntos.</p><h4>Arquitetura</h4><p>Nessa pequena série de artigos, iremos ver como construir uma arquitetura minimalista utilizando o <strong>Spring Cloud</strong>. Nossa arquitetura será composta por quatro serviços e será desenvolvida com base em containers <strong>Docker </strong>para facilitar o processo de <strong>“deploy”</strong>:</p><ul><li>Serviço de Descoberta (de outros serviços)</li><li>API Gateway</li><li>Dois microserviços REST bem simples</li></ul><p>Caso queira ver como a nossa arquitetura irá ficar no final da nossa série de artigos, você pode checar o repositório <a href="https://github.com/WendellAdriel/spring-microservices"><strong>aqui</strong></a>!!!</p><p>Para seguir o passo-a-passo da criação da nossa arquitetura continue lendo esse artigo e os outros artigos dessa série. Para continuar você irá precisar de ter instalado as seguintes ferramentas: <strong>JDK 8+</strong>, <strong>Docker </strong>e <strong>Maven</strong>.</p><h4>Serviço de descoberta</h4><p>Nessa primeira parte iremos construir o nosso <strong>Serviço de Descoberta </strong>que tem por finalidade ser um ponto central onde todos os nossos microserviços irão se registrar para dessa forma termos um controle de quais e quantos serviços temos disponíveis ao decorrer do ciclo de vida da nossa aplicação.</p><p>Para iniciar crie um diretório spring-microservices , esse será o diretório onde iremos criar nossa arquitetura. Agora para criar o nosso primeiro serviço, crie um diretório discovery-service que será nosso <strong>Serviço de Descoberta </strong>e entre nele. Como nosso projeto irá utilizar o <strong>Maven</strong>, crie um arquivo pom.xml para adicionarmos as nossas dependências (<a href="https://github.com/WendellAdriel/spring-microservices/blob/master/discovery-service/pom.xml"><strong>veja o código completo aqui</strong></a>).</p><p>Não irei explicar a estrutura de um arquivo pom.xml pois irei supor que quem está lendo já tenha um conhecimento prévio de como o <strong>Maven </strong>funciona. Caso você não tenha, antes de continuar a ler esse artigo tire um tempo para ler um pouco sobre o <strong>Maven</strong>.</p><h4>Spring Boot Actuator</h4><p>Uma das dependências que você irá ver em nosso pom.xml é: spring-boot-starter-actuator . Essa dependência fornece alguns endpoints “out-of-the-box” para aplicações Spring Boot:</p><ul><li>/health: fornece informações sobre o estado do servidor.</li><li>/info: fornece informações diversas. Na configuração da aplicação podemos definir quais informações queremos disponibilizar.</li></ul><p>Além dos endpoints listados acima, o Actuator disponibiliza diversos outros endpoints. Você pode ver uma lista completa <a href="https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-endpoints"><strong>aqui</strong></a>.</p><h4>Spring Cloud Netflix Eureka</h4><p>A dependência mais importante do nosso <strong>Serviço de Descoberta</strong> é: spring-cloud-starter-eureka-server. O <strong>Eureka </strong>é uma biblioteca para criar uma arquitetura de descoberta de serviços desenvolvido e disponibilizado pela <strong>Netflix</strong>.</p><p>Para criarmos a arquitetura de descoberta e registro de serviços da nossa aplicação iremos utilizar o <strong>Eureka</strong>. O nosso <strong>Serviço de Descoberta </strong>será um <strong>Eureka Server</strong> que, como dito anteriormente, tem a função de ser um ponto central onde nossos serviços irão se registrar.</p><h4>Criando nosso serviço</h4><p>Para continuarmos crie a seguinte estrutura de diretórios/arquivos:</p><pre>pom.xml<br>src<br>  main<br>    java<br>      br<br>        com<br>          codeshare<br>            microservices<br>              discovery<br>                Application.java<br>    resources<br>      application.yml<br>      banner.txt<br>  test<br>    java</pre><p>Para criarmos nosso servidor <strong>Eureka </strong>precisamos apenas de uma classe <strong>Java </strong>bem simples como podemos ver abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*moU6sicGBwsU2VEapN3tYw.png" /><figcaption>Application.java</figcaption></figure><p>Criamos nossa classe<strong> Application.java</strong> que tem apenas um método <strong>main </strong>para iniciar nossa aplicação. Para quem já trabalhou com o <strong>Spring Boot</strong> não há nada de especial. A única diferença que temos aqui é que além da anotação @SpringBootApplication para dizermos que nossa aplicação é uma aplicação <strong>Spring Boot</strong>, adicionamos a anotação @EnableEurekaServer para dizermos que nossa aplicação será um servidor <strong>Eureka</strong>. Agora basta configurar o nosso serviço e pronto.</p><p>A configuração do nosso serviço fica no arquivo application.yml e vamos fazer uma configuração bem simples como a abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*7ButeWKG0gCC6_r-PfSjrg.png" /><figcaption>application.yml</figcaption></figure><p>Na nossa configuração definimos a porta que a nosso serviço irá ser executado que será o valor da variável de ambiente <strong>PORT </strong>caso exista e caso não encontre essa variável de ambiente, irá ser a porta <strong>8761 </strong>e definimos o nome da nossa aplicação para <strong>discovery-service</strong>. A configuração do <strong>Eureka </strong>que estamos a fazer é bem simples, colocamos que nossa aplicação irá ser executada no <strong>localhost </strong>e definimos uma configuração de cliente para nosso servidor (isso não é necessário, mas se quisermos ter mais de um <strong>Serviço de Descoberta</strong>, podemos definir se um <strong>Serviço de Descoberta </strong>irá se registrar em outro) apenas como exemplo. Com isso nosso serviço está completo, mas caso queira fazer com que seu serviço seja mais “personalizado” podemos criar dentro do diretório resources um arquivo chamado banner.txt e nele podemos colocar um texto em <strong>ASCII</strong>, para que quando a aplicação for executada, irá imprimir no console o texto definido. Por exemplo a nossa aplicação tem o seguinte conteúdo no arquivo banner.txt :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lSN5sMndnJwWuPGdlJtc-A.png" /><figcaption>banner.txt</figcaption></figure><p>Você pode usar <a href="http://patorjk.com/software/taag/"><strong>esse site</strong></a> para criar o seu texto em ASCII personalizado.</p><h4>Criando nossa imagem Docker</h4><p>Definimos no nosso pom.xml que o artefato final do nosso serviço seria um arquivo .jar (definido em: &lt;packaging&gt;jar&lt;/packaging&gt; ) e também definimos que o nome do arquivo seria<strong> discovery-service</strong> (definido em: &lt;finalName&gt;discovery-service&lt;/finalName&gt; . Então quando fizermos o <strong>build </strong>de nosso serviço o artefato final será o arquivo discovery-service.jar que será criado dentro do diretório target na raiz do nosso serviço. Com nosso serviço é uma aplicação <strong>Spring Boot</strong>, precisamos apenas do nosso arquivo final e do <strong>Java </strong>para conseguirmos executar nossa aplicação e, com isso em mente, vamos criar uma imagem simples e leve apenas com o necessário para que nossa aplicação seja executada. Na raiz do nosso serviço crie um arquivo Dockerfile da seguinte maneira:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*A9k5iGVzz7qD5XOXXeiLhw.png" /><figcaption>Dockerfile</figcaption></figure><p>Nossa imagem é bem simples, estou a usar como base uma imagem <strong>Linux Alpine</strong> que é bem leve e tem um tamanho bem reduzido com o <strong>JDK 8</strong> já instalado. Estou a definir uma variável de ambiente com nome <strong>PORT </strong>(que será usada pela nossa aplicação através do arquivo application.yml). Depois disso eu pego o artefato final da <strong>build </strong>do nosso serviço e adiciono na nossa imagem com o nome app.jar e para executar nosso serviço quando o container for executado eu defino que o <strong>entrypoint </strong>da nossa imagem vai ser executar o arquivo .jar do nosso serviço. Depois disso apenas faço um <strong>expose </strong>na porta utilizada pelo nosso serviço para poder fazer <strong>bind </strong>à essa porta. Vamos agora fazer o build da nossa imagem Docker, na raiz do nosso serviço execute o comando:</p><pre>docker build -t &quot;codeshare/discovery&quot; . </pre><h4>Testando nosso serviço</h4><p>Com nosso serviço e nossa imagem criada, podemos finalmente testar o nosso serviço. Execute o comando:</p><pre>docker run -it -p 8761:8761 codeshare/discovery</pre><p>No console você verá algo parecido com a imagem abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*msOUaR9bLboo-EvoaPuXOA.png" /><figcaption>Serviço de Descoberta com Docker</figcaption></figure><p>Agora vá para <a href="http://localhost:8761/"><strong>http://localhost:8761</strong></a> e você irá ver uma página como a imagem abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F5ESq6gpuEkBQnYrgAZ4pQ.png" /><figcaption>Servidor Eureka</figcaption></figure><p>Como esperado, a lista <strong>“Instances currently registered with Eureka”</strong> está vazia, pois no momento não temos nenhum outro serviço criado. No próximo artigo dessa série iremos criar nossos dois microserviços REST e registrar eles em nosso <strong>Serviço de Descoberta</strong> que acabamos de criar.</p><p>Espero que tenham gostado!!! Continuem ligados na <a href="http://codeshare.com.br/"><strong>CodeShare </strong></a>para mais conteúdos de qualidade e para as novidades que estamos a preparar!!! Um grande abraço para todos e até a próxima!!! xD</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeea162e1e33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeshare/microservi%C3%A7os-com-spring-cloud-parte-1-aeea162e1e33">Microserviços com Spring Cloud: Parte 1</a> was originally published in <a href="https://medium.com/codeshare">CodeShare</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>