<?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 Lam PHAN on Medium]]></title>
        <description><![CDATA[Stories by Lam PHAN on Medium]]></description>
        <link>https://medium.com/@lampt2509?source=rss-1aab790e163c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sNz0QzBKB43v-6kUIYuOAg.jpeg</url>
            <title>Stories by Lam PHAN on Medium</title>
            <link>https://medium.com/@lampt2509?source=rss-1aab790e163c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 12:53:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lampt2509/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[Css starter kit that works for all of my projects (part 1)]]></title>
            <link>https://medium.com/@lampt2509/css-starter-kit-that-works-for-all-of-my-projects-part-1-587c08629e58?source=rss-1aab790e163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/587c08629e58</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[kit]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Lam PHAN]]></dc:creator>
            <pubDate>Sat, 28 Apr 2018 11:33:52 GMT</pubDate>
            <atom:updated>2018-04-28T11:37:16.203Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRvdV5fWrwJzBkSRmHeOWg.jpeg" /><figcaption>Clean and simple architecture is gold</figcaption></figure><p>When I create a new project from scratch, it’s always hard to know where to begin. But starting from scratch is no longer practical. I think it is only good to start from scratch if you are in the learning curve. But in the modern world, development’s speed is important. Sometimes you need to go fast and make less mistakes.</p><p>While making a new project from scratch, it takes time to config it(and you notice that you did the same thing for the last project you created ?). What if you make mistakes (even the copy-paste one) and put two hours to figure out how to solve them? But it doesn’t have to be this way !</p><h3>You Need a Starter Kit</h3><p>Why is this so important ? Because in reality, all of your projects may have the same basic configuration.</p><blockquote>A starter kit is nothing different than a set of configurations that are standardized because they apply to most projects.</blockquote><p>It allows us to develop new project “out-of-the-box” which is faster than setting up everything from scratch.</p><p>A starter kit serves a variety of purposes:</p><ol><li>It codifies a long list of decisions, best practices, and lessons learned.</li><li>It protects from forgetting important details.</li><li>It encourages consistency.</li><li>It avoids repeating work.</li><li>It increases quality because doing the right thing becomes automatic.</li></ol><h3>The css architecture is always forgotten by most developers</h3><p>Someone told me that css is complicated. I think css itself is not, it is even simpler than other languages ! But it is really hard to keep your project <strong>clean</strong> with css. When the project becomes bigger, it is very easy to make a mess with css. That’s why I think we need a clean architecture for not only javascript, python, php, etc. but also <strong>css.</strong></p><p>Over more than 30 professional and personal projects I have done, I understand the importance of good css architecture for front-end developers and designers. That why I’d like to share with you the starter kit that we usually use in our projects. It keeps the project simple, it even allows us do something more complicated like theming.</p><p>Here is its repository: <a href="https://github.com/davenlin19/scss-starter-kit">https://github.com/davenlin19/scss-starter-kit</a>. Feel free to clone it and apply it into your next project (or your current ones)</p><p>I’ll go into details in the part 2 of this article (coming soon).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=587c08629e58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set up persistence scss from Chrome DevTools for Angular]]></title>
            <link>https://medium.com/@lampt2509/set-up-persistence-scss-from-chrome-devtools-for-angular-220ce0818568?source=rss-1aab790e163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/220ce0818568</guid>
            <category><![CDATA[chrome-dev-tools]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[sass]]></category>
            <dc:creator><![CDATA[Lam PHAN]]></dc:creator>
            <pubDate>Sat, 28 Oct 2017 22:18:07 GMT</pubDate>
            <atom:updated>2017-10-29T20:46:08.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*-kYlyIpR9BF8JtGEnrag9g.jpeg" /><figcaption>Good configuration allows us to go straight to the goal</figcaption></figure><p>As front-end developers who use sass preprocessor, we all know how annoying it is to create some css rules with Google Chrome devtools and then go back to our IDE, re-apply them into our scss files.</p><p>This is the demo of this tutorial:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMREDM6t0a1M%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMREDM6t0a1M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMREDM6t0a1M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d79302cd0797f51f990ab5df2e7ce46/href">https://medium.com/media/4d79302cd0797f51f990ab5df2e7ce46/href</a></iframe><h3>The problem</h3><p>This is what I did when I design something in an Angular project:</p><ul><li>Go to Chrome devtools, in the Elements tab, inspect the element that I want to change.</li><li>Make some changes like background-color, color, border.</li><li>Go back to my editor, looking for the scss file that contains the element’s selector above.</li><li>Looking for the right place where I should put the new style rules.</li><li>Re-type the new rules that I wrote in Chrome devtools.</li></ul><p>That is annoying but the following scenarios are even worse:</p><ul><li>Have you ever added a lot of css rules on your Chrome devtools to have a beautiful design that makes you happy, then you tried to copy all of that to your IDE and accidentally, <strong>Ctrl + S (oh no !</strong>,<strong> </strong>old habit<strong>) </strong>(some editor like PyCharm even saves automatically, in this case this really is a dev killer), your browser reloads and you lost all of your codes :(</li><li>Have you ever failed to find all of your new code from your Chrome devtools when you finish, because you don’t remember exactly where you put them ? Maybe new code is easy for remember, but if we tried to change some existing style rules, like font-size, that is really difficult to find it again. It took me a lot of time !!!</li><li>Or each time you write a (or a few) new style rule(s) on Chrome devtools, you have to copy and paste it into your editor, save and wait for the browser reloads itself and so on. If your app is big, that takes time, a lot !</li></ul><p>Luckily, our best friend Chrome devtools has a new experimental feature: <strong>Live Sass</strong>. That allows us to <strong>modify scss files directly from Chrome Devtools with a little effort</strong>.</p><h3>The solution</h3><p>Why we have that problem that make us slow to make the design that we love ? Because with angular cli, webpack compiles our scss to css, bundles them in one big js file. So we lost all references back to our scss files !</p><p>What we need to do here, basically is try to remove the style of the component that we want to change from the js bundle file and put them into a separate file.</p><h3>Demo</h3><p>Now, let’s see the demo in a new angular project.</p><pre>ng <strong>new </strong>angular-live-sass --style=scss<br>cd angular-live-sass</pre><p>Let’s create a new component <strong>“House”</strong>:</p><pre>ng generate component house</pre><p>Now we have two components, the main <strong>AppComponent</strong> and the new component <strong>HouseComponent</strong>.</p><p>In the template of <strong>AppComponent</strong>, we will replace the default content by this:</p><pre>&lt;h1&gt;This is my new app&lt;/h1&gt;<br><br>&lt;app-house&gt;&lt;/app-house&gt;</pre><p>and its style:</p><pre>h1 {<br>    color: indigo;<br>}</pre><p>In the <strong>HouseComponent</strong>’s template:</p><pre>&lt;p&gt;This is my new house&lt;/p&gt;</pre><p>and in house.component.scss:</p><pre>p {<br>    font-size: 20px;<br>    color: coral;<br>}</pre><p>Now let’s build our application and starts a web server with</p><pre>ng serve -o</pre><p>Our application will look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FnXVEaa7eAGHOvhsqo0C2A.png" /><figcaption>Capture before using live sass feature</figcaption></figure><p>You can notice that on the right, next to the <strong>h1[_ngcontent-c0]</strong>, the “<strong>&lt;style&gt;&lt;/style&gt;</strong>” means that this style rule is actually in the &lt;head&gt; tag.</p><p>To make the live-edit work, we will go to my github <a href="https://github.com/davenlin19/angular-live-sass">repository</a> and get the folder “<strong>livesass” </strong>that contains two files:</p><ul><li>gulpfile.js</li><li>livesass.js</li></ul><p>Put this folder at the root of your angular application, you’ll have the following tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*dPm0gf7wVZ3qZYrmDSnOpw.png" /></figure><p>Add this script into package.json:</p><pre>&quot;livesass&quot;: &quot;gulp --gulpfile livesass/gulpfile.js&quot;</pre><p>In index.html, add <strong>inject:css</strong> and <strong>inject:js</strong> to let gulp know where it should inject our custom css and script:</p><pre>&lt;!doctype html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot;&gt;<br>    &lt;title&gt;AngularLiveSass&lt;/title&gt;<br>    &lt;base href=&quot;/&quot;&gt;<br><br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>    &lt;link rel=&quot;icon&quot; type=&quot;image/x-icon&quot; href=&quot;favicon.ico&quot;&gt;<br>    <strong>&lt;!-- inject:css --&gt;<br>    &lt;!-- endinject --&gt;</strong><br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;app-root&gt;&lt;/app-root&gt;<br>    <strong>&lt;!-- inject:js --&gt; <br>    &lt;!-- endinject --&gt;</strong><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Install some gulp package:</p><pre>npm install -g gulp<br>npm install --save-dev gulp gulp-inject gulp-inject-string gulp-sass gulp-sourcemaps map-stream</pre><p>Now, if we want to live edit style of our two components, we need to run this command:</p><pre>npm run livesass -- --dirPaths=src/app/house/ --dirPaths=src/app/</pre><p><strong>dirPaths </strong>is the path of the components we want to live edit.</p><p>The last thing to do now is activate the <strong><em>developer tools experiments</em></strong> of Chrome devtools, to do that, we have to go to: <strong>chrome://flags </strong>and enable the option “<strong><em>developer tools experiments” </em></strong>and restart your browser. Then, open your Chrome devtools, go to <strong>Settings, </strong>you will see a new tab “<strong>Experiments”, </strong>make sure that you tick the “<strong>Live Sass” </strong>option.</p><p>Now let’s see how our site look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A9Azkd-NX9iPoyKzckrLTg.png" /><figcaption>Capture after using live sass</figcaption></figure><p>Wow, as you can see, now at the right side, we have “<strong>app.component.scss</strong>”<strong> </strong>instead of “<strong>&lt;style&gt;&lt;/style&gt;</strong>” because the style of AppComponent now is no longer in the head but in the app.component.scss file.</p><p>One last thing we have to do, is map this file with the app.component.scss on your disk. To do that, we need to go to <strong>Sources</strong> tab and add our “angular-live-sass” folder in the workspace</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKkqH_Pa9WVjCCiXT3pZwQ.png" /><figcaption>Add folder to Chrome devtools workspace</figcaption></figure><p>Once our folder is in the workspace, right click on the app.component.scss and choose “<strong>map to file system resource</strong>”. If you do it right, Chrome will suggest the file you need to choose at the first place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzu0GkMfPFnqUUtEg4Q_aQ.png" /><figcaption>Map your file in the server with the local file</figcaption></figure><p>Now let’s make some changes in the <strong>h1 </strong>of AppComponent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pucP0svVvWwW6wLcR6kwWw.png" /><figcaption>The result</figcaption></figure><p>Click on <strong>app.component.scss </strong>to go to the <strong>Sources </strong>tab, save this file, the browser will reload but your design stays with us 😋. Check your IDE to make sure that the new style rules have been well saved.</p><p>Limitations: this method still has some problems with css specificity or angular special selectors like <strong>:host.</strong></p><p>This is my repository: <a href="https://github.com/davenlin19/angular-live-sass">https://github.com/davenlin19/angular-live-sass</a>, feel free to fork or share. If you have any questions, just let me know, i will try my best to answer you asap !</p><p>If you think that is useful, please hit the clap button, to make this method reach more people. That means a lot to me ! Thanks for reading !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=220ce0818568" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>