<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Luis Perez</title>
    <description>The latest articles on DEV Community by Luis Perez (@xilenomg).</description>
    <link>https://dev.to/xilenomg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F584969%2F18d7f58c-a408-480a-8b16-3590ddc67707.jpeg</url>
      <title>DEV Community: Luis Perez</title>
      <link>https://dev.to/xilenomg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xilenomg"/>
    <language>en</language>
    <item>
      <title>How to clear commit history using GIT</title>
      <dc:creator>Luis Perez</dc:creator>
      <pubDate>Sun, 28 Mar 2021 12:51:01 +0000</pubDate>
      <link>https://dev.to/xilenomg/how-to-clear-commit-history-using-git-2jmj</link>
      <guid>https://dev.to/xilenomg/how-to-clear-commit-history-using-git-2jmj</guid>
      <description>&lt;p&gt;I am working in a presentation to Hotmart Dev team and it will basically have a hands on during this presentation and I will be sharing the final code on Github.&lt;/p&gt;

&lt;p&gt;But I don't want them to follow each step I made so I decided to clear the whole commit history. &lt;/p&gt;

&lt;p&gt;I obviously had to search because I never had a need to clear the whole commit history and I found this on Stack Overflow from 2014 and edited in 2020:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The answer is pretty clear how I had to do it, so I am sharing here.&lt;/p&gt;

&lt;p&gt;Let's see how it was done!&lt;/p&gt;

&lt;p&gt;Checkout&lt;br&gt;
&lt;code&gt;git checkout --orphan latest_branch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add all the files&lt;br&gt;
&lt;code&gt;git add -A&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Commit the changes&lt;br&gt;
&lt;code&gt;git commit -am "commit message"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Delete the branch&lt;br&gt;
&lt;code&gt;git branch -D main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Rename the current branch to main&lt;br&gt;
&lt;code&gt;git branch -m main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Finally, force update your repository&lt;br&gt;
&lt;code&gt;git push -f origin main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's all folks!&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>development</category>
      <category>code</category>
    </item>
    <item>
      <title>How do I organize my CSS code for components?</title>
      <dc:creator>Luis Perez</dc:creator>
      <pubDate>Tue, 23 Feb 2021 18:15:50 +0000</pubDate>
      <link>https://dev.to/xilenomg/how-do-i-organize-my-css-code-for-components-1552</link>
      <guid>https://dev.to/xilenomg/how-do-i-organize-my-css-code-for-components-1552</guid>
      <description>&lt;p&gt;I usually do my best to make my CSS code a lot simpler. It's really boring when you open an CSS file and you have no idea what's going on there, right?&lt;/p&gt;

&lt;p&gt;It's really important, at least for me, to improve the way you write your code everyday. There is always a way to improve it. If you can't find it, share your code with us so we can understand your strategy. That would be amazing!&lt;/p&gt;

&lt;p&gt;The code bellow would be used on my React Components and I achieved this template by writing many components for my project. I would be really happy if you tell me the pros and cons of the structure bellow, so I can improve myself.&lt;/p&gt;

&lt;p&gt;If you have no idea about how CSS works please comment at the bottom and I will create a new article about it. This one, requires a little bit more of knowledge about CSS as I am not going through all the rules.&lt;/p&gt;

&lt;p&gt;So, let's start!&lt;/p&gt;

&lt;p&gt;First thing I would like to say is I don't use either id or tag references for my components. It will avoid elements from a component to be impacted by another component's CSS. Like, ".element h3" can impact ".element .inner-element h3" style.&lt;br&gt;
For this article, let's consider this HTML structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7oFHYqgd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5j8jdf13yahm2kf05w1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7oFHYqgd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5j8jdf13yahm2kf05w1.png" alt="HTML Code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's how I expect it to looks like in four different states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selected&lt;/li&gt;
&lt;li&gt;Regular&lt;/li&gt;
&lt;li&gt;Regular with mouse hover over&lt;/li&gt;
&lt;li&gt;Button Disabled&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QmwgI5hF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apedvrksj2cu9xeabvpw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QmwgI5hF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apedvrksj2cu9xeabvpw.png" alt="Layout"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will be using SCSS (Sassy CSS) to make it easier to see the set of rules I will be creating. I won't talk about naming classes or standards but I have been using BEM in my projects.&lt;/p&gt;

&lt;p&gt;First thing I will create in this CSS is the component wrapper. It will help me to isolate all the styles for this component as the main class for it won't be repeated anywhere else. That's why I don't like to use tag names in my CSS: A rule created for another component could impact my current one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.element{
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this component I will be splitting my code in few parts and some of these parts can be repeated through each part.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It will be my CSS code for the element wrapper or main class&lt;/li&gt;
&lt;li&gt;It will be my inner elements and others components classes if they exists&lt;/li&gt;
&lt;li&gt;It will be my list of selectors, like :hover, :active and so on.&lt;/li&gt;
&lt;li&gt;It will be my modifier classes.&lt;/li&gt;
&lt;li&gt;It will be my media queries which is the only one I don't want to repeat inside the inner classes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's see how it looks like!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.element {
  // element css

  // inner elements and components
  &amp;amp;__inner-element {
  }

  // selectors
  &amp;amp;:hover {
  }

  // modifiers
  &amp;amp;--selected {
  }

  // media queries
  @media (min-width: 767px) {
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code splitting can be repeated inside any of inner elements, selectors, modifiers and media queries. In the case bellow, I repeated this structure inside media query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
@media (min-width: 767px) {
  // wrapper element css
  border: 1px solid #CECECE;

  // inner element css
  &amp;amp;__inner-element {
    padding: 16px;

    // another inner element css
    &amp;amp;__action {

      // inner element selector
      &amp;amp;:hover {
        background: #FF9900;
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After sharing all this, i would like to invite you to see the full code for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;link
      href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200;0,300;0,400;0,600;0,700;0,800;0,900;1,200;1,300;1,400;1,600;1,700;1,800;1,900&amp;amp;display=swap"
      rel="stylesheet"
    /&amp;gt;
    &amp;lt;link href="./css/index.css" rel="stylesheet" type="text/css" /&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div class="element element--selected"&amp;gt;
      &amp;lt;div class="element__inner-element"&amp;gt;
        &amp;lt;div class="element__inner-element__text"&amp;gt;
          &amp;lt;h2 class="element__inner-element__text__header"&amp;gt;SELECTED&amp;lt;/h2&amp;gt;
          &amp;lt;p class="element__inner-element__text__paragraph"&amp;gt;
            ipsum dolor sit amet, consectetur adipiscing elit. Nunc non congue
            tortor.
          &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="element__inner-element__action"&amp;gt;
          &amp;lt;button class="element__inner-element__action__button"&amp;gt;
            View now
          &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class="element element"&amp;gt;
      &amp;lt;div class="element__inner-element"&amp;gt;
        &amp;lt;div class="element__inner-element__text"&amp;gt;
          &amp;lt;h2 class="element__inner-element__text__header"&amp;gt;REGULAR&amp;lt;/h2&amp;gt;
          &amp;lt;p class="element__inner-element__text__paragraph"&amp;gt;
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non
            congue tortor.
          &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="element__inner-element__action"&amp;gt;
          &amp;lt;button class="element__inner-element__action__button"&amp;gt;
            View now
          &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class="element element"&amp;gt;
      &amp;lt;div class="element__inner-element"&amp;gt;
        &amp;lt;div class="element__inner-element__text"&amp;gt;
          &amp;lt;h2 class="element__inner-element__text__header"&amp;gt;MOUSE HOVER&amp;lt;/h2&amp;gt;
          &amp;lt;p class="element__inner-element__text__paragraph"&amp;gt;
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non
            congue tortor.
          &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="element__inner-element__action"&amp;gt;
          &amp;lt;button class="element__inner-element__action__button"&amp;gt;
            View now
          &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class="element element--disabled"&amp;gt;
      &amp;lt;div class="element__inner-element"&amp;gt;
        &amp;lt;div class="element__inner-element__text"&amp;gt;
          &amp;lt;h2 class="element__inner-element__text__header"&amp;gt;BUTTON DISABLED&amp;lt;/h2&amp;gt;
          &amp;lt;p class="element__inner-element__text__paragraph"&amp;gt;
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non
            congue tortor.
          &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="element__inner-element__action"&amp;gt;
          &amp;lt;button class="element__inner-element__action__button" disabled&amp;gt;
            View now
          &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.element {
  $element: &amp;amp;;
  background: #ffffff;
  font-family: 'Nunito', sans-serif;

  &amp;amp;__inner-element {
    border: 1px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    &amp;amp;__text {
      &amp;amp;__header {
        margin: 0 0 8px 0;
      }

      &amp;amp;__paragraph {
        margin: 0 0 8px 0;
        &amp;amp;:last-child {
          margin-bottom: 0px;
        }
      }
    }

    &amp;amp;__action {
      text-align: center;
      &amp;amp;__button {
        background: #cecece;
        border: 1px solid #999999;
        border-radius: 3px;
        white-space: nowrap;
        padding: 4px 8px;

        &amp;amp;:hover {
          transform: scale(1.2);
        }

        &amp;amp;:disabled {
          opacity: 0.5;
        }
      }
    }
  }

  &amp;amp;:hover {
    background: #aadaad;
    #{$element}__inner-element {
      &amp;amp;__action {
        &amp;amp;__button {
          border: 0px;
          background: #f04e23;
          color: #ffffff;
        }
      }
    }
  }

  &amp;amp;--selected {
    background: #aaffad;
    #{$element}__inner-element {
      &amp;amp;__action {
        &amp;amp;__button {
          background: #cece00;
        }
      }
    }
  }

  &amp;amp;--disabled {
    opacity: 0.5;

    &amp;amp;:hover {
      background: #ffaaaa;
    }
  }

  @media (min-width: 767px) {
    border: 1px;

    &amp;amp;__inner-element {
      padding: 16px;
    }

    &amp;amp;--selected {
      background: #eeeeee;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; We use interpolation #{$element} to avoid rewrite the wrapper class name. &lt;a href="https://sass-lang.com/documentation/interpolation"&gt;https://sass-lang.com/documentation/interpolation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What do you think? Please comment bellow if you have a better idea or if you liked the way I wrote this code.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>css</category>
      <category>bem</category>
    </item>
  </channel>
</rss>
