<?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 Gian Ramirez on Medium]]></title>
        <description><![CDATA[Stories by Gian Ramirez on Medium]]></description>
        <link>https://medium.com/@gece.ramirez?source=rss-4690b29f6681------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*elPuwjcPAZpdf7SW34nBiQ.jpeg</url>
            <title>Stories by Gian Ramirez on Medium</title>
            <link>https://medium.com/@gece.ramirez?source=rss-4690b29f6681------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 12:13:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gece.ramirez/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[[Serie] Proyecto React.js de alta calidad (1)]]></title>
            <link>https://medium.com/@gece.ramirez/serie-proyecto-react-js-de-alta-calidad-1-ed282ae4a6d3?source=rss-4690b29f6681------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed282ae4a6d3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Gian Ramirez]]></dc:creator>
            <pubDate>Tue, 25 Feb 2020 13:14:53 GMT</pubDate>
            <atom:updated>2020-02-25T14:36:48.391Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Serie] Proyecto React.js en la vida real (1)</h3><h4>Episodio 1: Next JS, Standard JS, Commitlint, Commitizen, Husky</h4><h4>Índice</h4><ol><li><a href="#8db1">Instalación</a></li><li><a href="#e26e">Estructura de archivos</a></li><li><a href="#5860">Arrancando Next.js</a></li><li><a href="#b93f">Estilo del código</a></li><li><a href="#7ec8">Estándares de commits</a></li><li><a href="#edcb">Corregir automáticamente los estilos antes de cada commit</a></li></ol><h4>Instalación</h4><p>Creamos una carpeta para nuestro proyecto, nos colocamos dentro e iniciamos npm.</p><pre>npm init --yes</pre><p>Las primeras librerías que necesitaremos son:</p><pre>npm i next@9.2.1 react@16.12.0 react-dom@16.12.0</pre><p><strong><em>¿Por qué Next.js?</em></strong> Es una excelente opción para el server side rendering, code splitting y mejor SEO.</p><p>Agreguemos los scripts necesario dentro de package.json :</p><pre>&quot;scripts&quot;: {</pre><pre>  &quot;dev&quot;: &quot;next&quot;,</pre><pre>  &quot;build&quot;: &quot;next build&quot;,</pre><pre>  &quot;start&quot;: &quot;next start&quot;,</pre><pre>  &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;</pre><pre>}</pre><h4>Estructura del archivos</h4><p>Next.js usa una estructura de archivos simple. Un directorio para las páginas (es importante saber que el nombre de estas también las serán para nuestras rutas) y un directorio para nuestros componentes UI.</p><pre>my-project/<br>  src/<br>    pages<br>    components</pre><h4>Arrancando Next.js</h4><p>Crearemos nuestra primera pagina para probar que todo funciona hasta ahora.</p><pre>// pages/index.js</pre><pre>function HomePage() {</pre><pre>  return &lt;div&gt;Bienvenidos&lt;/div&gt;</pre><pre>}</pre><pre>export default HomePage</pre><p>Ejecutamos npm run dev para levantar nuestro proyecto. Next.js levanta un servidor node por defecto que se encarga de resolver peticiones HTTP y retornar solo las partes del aplicación que son requeridas en esa petición, por eso se dice que Next.js realiza <strong>code splitting</strong> de manera automática.</p><p>También tienes la opción de configurar ese servidor, pero eso lo explicaremos más adelante, cuando haga falta.</p><h4>Estilo del código</h4><p>Ahora que ya probamos que nuestra aplicación funciona, debemos alinear nuestro estilo del código a uno estandarizado internacionalmente. Depende completamente de gustos personales, si te gusta que al final de cada línea tenga un punto y coma, usar comillas simples o dobles, entre otras.</p><p>Sin embargo, en esta ocasión usaremos el estilo de código <a href="https://standardjs.com/"><strong>Standard</strong></a> por una sencilla razón, no necesita archivos de configuración, Standard esta hecho para ser como su nombre lo dice, un estándar y no preocuparse por cada detalle del estilo del código.</p><p>Puedes instalar Standard de manera global o localmente.</p><pre># global<br>npm install standard --global</pre><pre># local<br>npm install standard --save-dev</pre><p>Y ahora agregaremos dos scripts a nuestro package.json :</p><pre>&quot;scripts&quot;: {</pre><pre>  ...,</pre><pre>  &quot;lint:fix&quot;: &quot;standard --fix&quot;,</pre><pre>  &quot;lint:check&quot;: &quot;standard&quot;</pre><pre>}</pre><p>Corremos npm run lint:check para conocer cuales fueron los errores de linting.</p><p>Si realmente no te interesa cuales fueron y solo quieres que se corrijan automáticamente corremos npm run lint:fix .</p><p><strong>OJO: </strong>En algunas ocasiones el auto fix no será capaz de corregir todos los errores, por lo que tendrás que hacerlo manualmente.</p><p>Ahora somos capaces de estandarizar nuestro código antes de hacer subirlo al repositorio. Y que pasa si me olvido de hacer npm run lint:fix? Buena pregunta. Para resolver esto, usaremos una librería llamada <a href="https://www.npmjs.com/package/husky"><strong>Husky</strong></a><strong> </strong>te la presentare en la <a href="#edcb">siguiente sección</a>.</p><h4>Estándares de commits</h4><p>Primero debemos iniciar GIT con el comando git init, y luego crear un archivo .gitignore para que GIT ignore nuestro directorio node_modules y .next .</p><pre># .gitignore<em><br></em>node_modules<br>.next</pre><p>Necesitamos que nuestros commits obedezcan a un estándar para lograr una mejor lectura y orden de los commits. Para asegurar esto necesitamos las siguientes librerías.</p><pre>npm install --save-dev husky @commitlint/cli @commitlint/config-conventional</pre><p>Ahora necesitamos un archivo de configuración para commitlint (<em>commitlint.config.js</em>)</p><pre><em>// commitlint.config.js</em><br>module.exports = {extends: [&#39;@commitlint/config-conventional&#39;]}</pre><p>Usaremos Husky para interceptar los git-hooks, en específico el . Necesitamos actualizar nuestro package.json y agregar una llave para husky.</p><pre>{<br>  &quot;husky&quot;: {<br>    &quot;hooks&quot;: {<br>      &quot;commit-msg&quot;: &quot;commitlint -E HUSKY_GIT_PARAMS&quot;<br>    }<br>  }<br>}</pre><p>Para terminar esta sección, nos hace falta que una herramienta nos prepare el diseño de nuestros commits, y aquella herramienta es <strong>commitizen</strong>.</p><pre>npm install --global commitizen</pre><pre># Dentro de nuestro proyecto<br>commitizen init cz-conventional-changelog --save-dev --save-exact</pre><p>Si revisan su package.son, este se actualizó agregando automáticamente un config para commitizen.</p><pre>{<br>  &quot;config&quot;: {<br>    &quot;commitizen&quot;: {<br>      &quot;path&quot;: &quot;./node_modules/cz-conventional-changelog&quot;<br>    }<br>  }<br>}</pre><p>Ahora estamos listos para hacer commits seguros. Abrimos un terminal en la raíz de nuestro proyecto y probamos.</p><pre># Agregamos todos nuestros cambios<br>git add .</pre><pre># Commiteamos<br>git cz</pre><p>Luego de ejecutar git cz debemos llenar un formulario como el siguiente:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*okKfYeCue_qEaY1IS76Ecg.png" /><figcaption>Commitizen commit form</figcaption></figure><p>Y ya tenemos nuestro commit listo 🙌</p><h4>Corregir automáticamente los estilos antes de cada commit</h4><p>Ahora que ya tenemos Husky lo usaremos para que valide y corrija nuestro código antes de cada commit. Así aseguramos que el código que suba a nuestro repositorio cumpla con Standard.</p><p>Para lograr esto primero necesitamos instalar la librería lint-staged que nos ayudará a manipular el stage del commit.</p><pre>npm install lint-staged --save-dev</pre><p>Agregamos un nuevo hook de husky dentro de package.json y una configuración para lint-staged .</p><pre>...,<br>&quot;lint-staged&quot;: {<br>  &quot;src/**/*.{js,jsx}&quot;: [<br>    &quot;npm run lint:fix&quot;,<br>    &quot;git add&quot;<br>  ]<br>},<br>&quot;husky&quot;: {<br>   &quot;hooks&quot;: {<br>     &quot;pre-commit&quot;: &quot;lint-staged&quot;,<br>     &quot;commit-msg&quot;: &quot;commitlint -E HUSKY_GIT_PARAMS&quot;<br>  }<br>},<br>...</pre><p>Y listo! Si olvidas de hacer lint:fix a tu código, Husky lo hará por ti y tu commit está a salvo.</p><p>Full repo: <a href="https://github.com/zendostrike/neon-sky-web">https://github.com/zendostrike/neon-sky-web</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed282ae4a6d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Super Mario’s memory game with ReactJS]]></title>
            <link>https://medium.com/analytics-vidhya/making-super-marios-memory-game-with-reactjs-efffeb7249f?source=rss-4690b29f6681------2</link>
            <guid isPermaLink="false">https://medium.com/p/efffeb7249f</guid>
            <category><![CDATA[videogames]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mario-bros]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Gian Ramirez]]></dc:creator>
            <pubDate>Thu, 21 Nov 2019 16:19:29 GMT</pubDate>
            <atom:updated>2019-11-27T08:59:33.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*8PGpfUHbxUuCg-BIP1K0Ag.jpeg" /><figcaption>Super Mario Bros 3 Card Memory Mini-Game</figcaption></figure><p>Welcome! Do you like games and programming? This is for you.</p><p>In this article we will develop the famous Super Mario’s card memory game using the popular facebook library <a href="https://reactjs.org/">ReactJS</a>.</p><p>Game consists in make all cards in the board meet their pair.</p><p>Let’s start!</p><h4>Part 1: Create react app</h4><p>Since this a single page application I recommend to use the <a href="https://github.com/facebook/create-react-app">create-react-app</a> CLI to generate a new project, no other configuration is necessary and let us focus on coding. Open a terminal and type:</p><pre>npx create-react-app my-game</pre><p>Use your favorite IDE and open the project.</p><p>Delete index.css, remove everything from App.js and App.css. In App.js let’s write an initial class component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/206e3643dda205c446b2d47ba40b3d7f/href">https://medium.com/media/206e3643dda205c446b2d47ba40b3d7f/href</a></iframe><h4>Part 2: The UI</h4><p>So, what’s the plan? What components should we create?</p><p>As we see in the image above, game consists on Cards on a Grid, so, those are our components: <strong>Card</strong>, <strong>Grid</strong>.</p><p><strong>Card</strong></p><p>Our card component will receive 3 props:</p><ul><li>Item: An object abstraction of a card. It contains fields like <em>type</em>, <em>revealed</em>, <em>solved</em> and <em>bgImage</em>.</li><li>Index: A number that indicates the card index in the array.</li><li>onClick: A function that handles the logic when a card is clicked.</li></ul><p>This component has not logic itself and there is not need to manage component lifecycles, that’s why we made it a functional component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af4da014a30ab70c37543a3f66cfe79d/href">https://medium.com/media/af4da014a30ab70c37543a3f66cfe79d/href</a></iframe><p><strong>Card styles</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bc5bbcc40742cfadb5aa1a073bcea0d/href">https://medium.com/media/4bc5bbcc40742cfadb5aa1a073bcea0d/href</a></iframe><p><strong>Board</strong></p><p>The board component has the unique responsibility to render a grid with 6 columns.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5451b09e1c48743024f8bbafa36926b/href">https://medium.com/media/d5451b09e1c48743024f8bbafa36926b/href</a></iframe><p><strong>Board styles</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4482138ef71ded2427ea737e88785cd/href">https://medium.com/media/f4482138ef71ded2427ea737e88785cd/href</a></iframe><h4>Part 3: Game resources</h4><p>Our components are ready but we need to generate the board first.</p><p>Let’s create a new folder inside <em>src</em> called <em>entities</em>. In <em>entities</em> folder create a <em>js</em> file called <strong>Card.js</strong>. We will export a Card class that will help us to populate or board.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fff86ffa0b13fdcd69efc999cf996cb6/href">https://medium.com/media/fff86ffa0b13fdcd69efc999cf996cb6/href</a></iframe><p>Card attributes:</p><ul><li><strong>revealed</strong>: Boolean. Indicates if card is facing front.</li><li><strong>type</strong>: String. Indicates the card type, i.e.<em> “goomba”</em> card.</li><li><strong>bgImage</strong>: String. Card background.</li><li><strong>solved</strong>: Boolean. Indicates if the card was correctly solved (met his pair).</li></ul><p>Now, we have to generate the game resources (cards). To make that, let’s create a <em>js</em> file called <em>GameResources</em> inside <em>src</em> folder:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9cadab530b25aa933030e15b435b723/href">https://medium.com/media/a9cadab530b25aa933030e15b435b723/href</a></iframe><p>A card array is generated in memory and exported by this class.</p><p>So, we need a board with random cards and their pairs. To achieve this let’s create a new file called <em>BoardGenerator</em> in the <em>src</em> folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36552d6430190deebf75852f799bcfec/href">https://medium.com/media/36552d6430190deebf75852f799bcfec/href</a></iframe><p><strong><em>generateBoard</em></strong> is a function that walks cards lenght multiplied by 2 and assign each position a random card. To not repeat a card with same type more than 2 times, it verifies with a <em>do while</em> structure and generates a new one.</p><h4>Part 4: Logic</h4><p>Let’s import the components we did and the <em>generateBoard</em> function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/173698eb25696f980bf81b70ce520b1a/href">https://medium.com/media/173698eb25696f980bf81b70ce520b1a/href</a></iframe><p>And add the following state:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba30b76975362660eab9f8510ad15bf5/href">https://medium.com/media/ba30b76975362660eab9f8510ad15bf5/href</a></iframe><p>Our new render function will be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6675de8dd302d37393a2686a86ea1d07/href">https://medium.com/media/6675de8dd302d37393a2686a86ea1d07/href</a></iframe><p>App styles</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16998007010ec2e0041eba5e748ccf75/href">https://medium.com/media/16998007010ec2e0041eba5e748ccf75/href</a></iframe><p>At this point we will be able to see a board with cards:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*-b7tU5rhUh_r56zHCWwfsA.png" /></figure><p>Now, let’s make the logic of the game.</p><p>We need to handle clicks on cards and validate if two cards match.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a04aad3b4833a9243ad330b2704f990/href">https://medium.com/media/7a04aad3b4833a9243ad330b2704f990/href</a></iframe><p>Match cards</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34b59275c268e3ee2c27469a04ad6c0c/href">https://medium.com/media/34b59275c268e3ee2c27469a04ad6c0c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*JIgPJJrbZbZm81y0oX6VfQ.png" /></figure><p>reset a turn and flip cards</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6a594f2ef80a6dcbc2e496f9cbedaa1/href">https://medium.com/media/e6a594f2ef80a6dcbc2e496f9cbedaa1/href</a></iframe><p>Full App.js component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4737d46d1b71beb934358eee16456b9d/href">https://medium.com/media/4737d46d1b71beb934358eee16456b9d/href</a></iframe><p>Link of the repo: <a href="https://github.com/zendostrike/match-the-cards">https://github.com/zendostrike/match-the-cards</a></p><p>And that’s it, thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efffeb7249f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/making-super-marios-memory-game-with-reactjs-efffeb7249f">Making Super Mario’s memory game with ReactJS</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>