<?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 Art Pai on Medium]]></title>
        <description><![CDATA[Stories by Art Pai on Medium]]></description>
        <link>https://medium.com/@minipai?source=rss-6215f2e30f40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Tb33P6qLA3Aig1By.jpg</url>
            <title>Stories by Art Pai on Medium</title>
            <link>https://medium.com/@minipai?source=rss-6215f2e30f40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:54:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@minipai/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[Simple naming convention that can keep you from CSS uncertainty problem]]></title>
            <link>https://medium.com/@minipai/simple-naming-convention-that-can-keep-you-from-css-uncertainty-problem-7352806e6039?source=rss-6215f2e30f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/7352806e6039</guid>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Art Pai]]></dc:creator>
            <pubDate>Sun, 17 Apr 2016 23:13:33 GMT</pubDate>
            <atom:updated>2016-04-20T16:24:37.050Z</atom:updated>
            <content:encoded><![CDATA[<h3>Easy and hard of CSS</h3><p>CSS is easy. Yes, the point of CSS is let you style HTML with straightforward syntax. The hard part of CSS is hacks. Hacks let you do things that you want do but CSS not yet considered yet. For example, <strong>layout with float</strong> is a hack, that makes it hard and came so many grid frameworks.</p><p>Another real hard part is the naming of CSS selector. Because naming of CSS selector determines the <strong>scope</strong> of HTML elements that will apply to the rule. Also, a naming of CSS selector will effect <strong>specificity</strong> of a rule. If you don’t do it carefully, your stylesheet will end up in <strong>specificity war </strong>and doomed.</p><p>With the evolution of JavaScript tooling, now we have more tools came to solve CSS problems. The latest hotness it <a href="https://github.com/css-modules/css-modules">css-modules</a>. It can guarantee your style will only apply to elements you want. But for those that don’t want to use JavaScript tools yet, I am going to share some simple naming rules to use in your project.</p><h3>Uncertainty Problem</h3><p>The everlasting problem when you write CSS rule is uncertainty problem. You are not sure your rule will affect element you don’t want to. For example, it is quite straightforward to use descendant selectors to limit style in a section.</p><pre>.my-product .price { ... }<br>.my-product .quantity { ... }</pre><p>Especially if you use Sass, it’s so easy to write.</p><pre>.my-product {<br>  .price { ... }<br>  .quantity { ... } <br>}</pre><p>Things work fine, until someone in your team, or even yourself, forget there is a <em>.card .header </em>rule, wrote another <em>.header </em>rule.</p><pre>.price { ... }</pre><pre>/* far away */</pre><pre>.my-product {<br>  .price { ... }<br>  .quantity { ... } <br>}</pre><p>Although <em>.my-product .price </em>have higher specificity, only rules that is duplicated will be overwritten, so you will see unwanted styles.</p><h3>Solve with private class name</h3><p>So lets add a underscore prefix to <em>.price</em>.</p><pre>.price { ... }</pre><pre>/* far away */</pre><pre>.my-product {<br>  ._price { ... }<br>  ._quantity { ... } <br>}</pre><p>The underscore prefix indicates this selector is <strong>private</strong>. You can only use it as a <strong>descendant selector</strong>, so you won’t get unwanted selector by accident anymore. So you may have a bunch of “private selector” that won’t affect each other.</p><pre>.book {<br>  ._price { ... }<br>  ._quantity { ... } <br>}</pre><pre>.pc {<br>  ._price { ... }<br>  ._quantity { ... } <br>}</pre><pre>.mac {<br>  ._price { ... }<br>  ._quantity { ... } <br>}</pre><p>This works quite well until you have complicated structure like this:</p><pre>&lt;div class=&quot;products&quot;&gt;<br>  &lt;div class=&quot;_price&quot;&gt;<br>    &lt;div class=&quot;product&quot;&gt;<br>      &lt;div class=&quot;_price&quot;&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;div&gt;</pre><p>Style of <strong>.product ._price</strong> will be affected by <strong>.products ._price. </strong>Then you will need to use more robust naming methodologies like <a href="http://getbem.com/">BEM</a>, <a href="https://smacss.com/">SMACSS</a> to make sure you style is more robust and explicit. But this never happened to me. Because I only use “private selector” only on styles that are not yet ready to abstract to component yet and the private class names is usually content related.</p><p>Hope this little naming convention helps you have more confident in styling, even when its not a “component” yet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7352806e6039" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AngularJS Tutorial for Designers]]></title>
            <link>https://medium.com/@minipai/angularjs-tutorial-for-designers-8c7dc63ca65f?source=rss-6215f2e30f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c7dc63ca65f</guid>
            <dc:creator><![CDATA[Art Pai]]></dc:creator>
            <pubDate>Sun, 17 Nov 2013 01:09:30 GMT</pubDate>
            <atom:updated>2014-12-02T02:43:59.324Z</atom:updated>
            <content:encoded><![CDATA[<h4>Getting started</h4><p>Although Misko Hevery, creator of AngularJS mentioned that the goal of AngularJS is “<em>to enable web-designers (non-programmers) to build simple app like websites”</em> in various interviews, but the current homepage and documents of AngularJS seems to written only for developers and make designers not only hard to understand but also can’t get interested in it.</p><p>With this alternative tutorial, I will show what web designer cares about and demonstrate what AngularJS can help designers on writing an interaction website, with only very basic JavaScript knowledge is required.</p><p>If you can understand the following code, you are good to go.</p><pre>foo = true<br>foo = !foo<br>foo = { &#39;bar&#39;: false }<br>bar = foo</pre><h3>Setup</h3><p>So lets get started. To setup AngularJS to work is quite simple. Use <strong>&lt;script&gt;</strong> tag to link to angular.js and add an <strong>ng-app </strong>attribute to <strong>&lt;html&gt;</strong>. The <strong>ng-app</strong> attribute, also named “<strong>directive</strong>” in AngularJS, will bootstrap the html document compile to an AngularJS app.</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app</strong>&gt;<br>  &lt;head&gt;<br>    &lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    <br>    I can add: 1 + 2 = <strong>{{</strong> 1+2 <strong>}}<br></strong><br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>AngularJS will process expressions between the double curly brace notation {{ }}.</p><pre>I can add: 1 + 2 = 3</pre><p><a href="http://jsfiddle.net/minipai/7Gwvp/">LIVE DEMO</a></p><p>If the <strong>ng-app</strong> directive were not placed on the html element then the document would not be compiled and the <strong>{{ 1+2 }}</strong> would not be resolved to 3.</p><h3>ng-show</h3><p>The first directive your will love is <strong>ng-show. </strong>With <strong>ng-show </strong>you can set an expectation on when a element will show or not.</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app&gt;</strong><br>  &lt;head&gt;&lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;<br>  &lt;body&gt;<br>  <br>    &lt;p ng-show=&quot;true&quot;&gt;This paragraph is visible.&lt;/p&gt;<br>    &lt;p ng-show=&quot;false&quot;&gt;This paragraph is hidden.&lt;/p&gt; <br>  <br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>The code is quite straight forward. The paragraph that has <strong>ng-show=“true” </strong>will show, the one has <strong>ng-show=“false”</strong> will not.</p><pre>This paragraph is visible.</pre><p><a href="http://jsfiddle.net/minipai/PaR7b/">LIVE DEMO</a></p><h3>ng-click</h3><p>It is useless with only <strong>ng-show</strong>, so you need <strong>ng-click</strong> to add interactions. Add <strong>ng-click </strong>directive to the element (mostly a button) you want to add interaction. The value of <strong>ng-click</strong> will “execute” when the element is clicked.</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app&gt;</strong><br>  &lt;head&gt;&lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;<br>  &lt;body <strong>ng-init=&quot;count=0&quot;</strong>&gt;<br>   <br>    &lt;button <strong>ng-click=&quot;count = count + 1&quot;</strong>&gt;Click Me&lt;/button&gt;<br>    count: {{ count }}<br>  <br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>The value of <em>count</em> will increase by 1 each time the button is clicked. And the initial value <strong>0 </strong>of count is set by <strong>ng-init</strong>.</p><p><a href="http://jsfiddle.net/minipai/5qvHa/">LIVE DEMO</a></p><h3>ng-click + ng-show</h3><p>Combine <strong>ng-click</strong> and <strong>ng-show</strong>, you can now start to do a lot of interactions.</p><p>For example, a toggle button.</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app&gt;</strong><br>  &lt;head&gt;&lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;<br>  &lt;body&gt;<br> <br>    &lt;button <strong>ng-click=&quot;display = !display&quot;&gt;</strong>Toggle&lt;/button&gt;<br>    &lt;p <strong>ng-show=&quot;display&quot;</strong>&gt;Toggle Me!&lt;/p&gt;<br> <br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>When the button is clicked, the value of <strong>display </strong>will change between <em>true</em> and <em>false</em>, and the paragraph will show and hide depend on the value of <strong>display</strong>.</p><p><a href="http://jsfiddle.net/minipai/bAqn7/">LIVE DEMO</a></p><p>Or, control a slide manually.</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app&gt;</strong><br>  &lt;head&gt;&lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;<br>  &lt;body <strong>ng-init=&quot;index=0&quot;</strong>&gt;<br>  &lt;p&gt;<br>     &lt;a href=&quot;#&quot; ng-click=&quot; index=1 &quot;&gt;001&lt;/a&gt; <br>     &lt;a href=&quot;#&quot; ng-click=&quot; index=2 &quot;&gt;002&lt;/a&gt; <br>     &lt;a href=&quot;#&quot; ng-click=&quot; index=3 &quot;&gt;003&lt;/a&gt; <br>     &lt;a href=&quot;#&quot; ng-click=&quot; index=4 &quot;&gt;004&lt;/a&gt; <br>   &lt;/p&gt;<br>   &lt;div ng-show=&quot; index==1 &quot;&gt;&lt;img src=&quot;<a href="http://placehold.it/200&amp;text=1">i</a>mage1.jpg&quot; /&gt;&lt;/div&gt; <br>   &lt;div ng-show=&quot; index==2 &quot;&gt;&lt;img src=&quot;<a href="http://placehold.it/200&amp;text=1">i</a>mage2.jpg&quot; /&gt;&lt;/div&gt; <br>   &lt;div ng-show=&quot; index==3 &quot;&gt;&lt;img src=&quot;<a href="http://placehold.it/200&amp;text=1">i</a>mage3.jpg&quot; /&gt;&lt;/div&gt; <br>   &lt;div ng-show=&quot; index==4 &quot;&gt;&lt;img src=&quot;<a href="http://placehold.it/200&amp;text=1">i</a>mage4.jpg&quot; /&gt;&lt;/div&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>And there is more interactions you can create with <strong>ng-click</strong> and <strong>ng-show</strong>.</p><p><a href="http://jsfiddle.net/minipai/VtFeX/">LIVE DEMO</a></p><h3>ng-class</h3><p>Other then show and hide elements, you will also want elements’ style response to interactions. You can use <strong>ng-class</strong> to dynamically set CSS classes on an HTML element. You have to give <strong>ng-class</strong> a map of class names to boolean values, like this:</p><pre>ng-class=&quot;{&#39;strike&#39;: foo, &#39;bold&#39;: bar}&quot;</pre><p>If the <strong>value</strong> (foo / bar) is <strong>truthy</strong> (true, number other then 0, text thats not empty) , the <strong>key</strong> (strike, bold) will be added as css classes to the element.</p><p>For example:</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app&gt;</strong><br> &lt;head&gt;&lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;<br> &lt;body&gt;<br><br> &lt;p <strong>ng-class</strong>=&quot;{&#39;strike&#39;: true, &#39;bold&#39;: false, &#39;red&#39;: 1, &#39;i&#39;: 0}&quot;&gt;<br>    Map Syntax Example<br> &lt;/p&gt;<br> <br> &lt;/body&gt;<br>&lt;/html&gt;</pre><p>The above code will render as:</p><pre>&lt;p class=&quot;strike red&quot;&gt;Map Syntax Example&lt;/p&gt;</pre><p>However, it’s not practical to use static value in ng-class, see the real world use case in next section.</p><h3>ng-click + ng-class</h3><p>With <strong>ng-class</strong> and <strong>ng-click</strong>, you can create a button that can be “pressed”. (styled with bootstrap.css)</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app&gt;</strong><br> &lt;head&gt;&lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;<br> &lt;body&gt;</pre><pre> &lt;a class=&quot;btn btn-primary&quot; <br>   <strong>ng-click=&quot;show=!show&quot;</strong> <br>   <strong>ng-class=&quot;{&#39;active&#39;: show}&quot;</strong>&gt;<br> Click Me<br> &lt;/a&gt;<br> <br> &lt;/body&gt;<br>&lt;/html&gt;</pre><p><a href="http://jsfiddle.net/minipai/SwLMq/">LIVE DEMO</a></p><p>Or create a tab set. (styled with bootstrap.css)</p><pre>&lt;!doctype html&gt;<br>&lt;html <strong>ng-app&gt;</strong><br>  &lt;head&gt;&lt;script src=&quot;angular.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;<br>  &lt;body&gt;</pre><pre>  &lt;ul class=&quot;nav nav-tabs&quot;&gt;<br>    &lt;li <strong>ng-class=&quot;{active: i==1}&quot; ng-click=&quot;i=1&quot;</strong>&gt;<br>      &lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;<br>    &lt;/li&gt;<br>    &lt;li <strong>ng-class=&quot;{active: i==2}&quot; ng-click=&quot;i=2&quot;</strong>&gt;<br>      &lt;a href=&quot;#&quot;&gt;Profile&lt;/a&gt;<br>    &lt;/li&gt;<br>    &lt;li <strong>ng-class=&quot;{active: i==3}&quot; ng-click=&quot;i=3&quot;</strong>&gt;<br>      &lt;a href=&quot;#&quot;&gt;Messages&lt;/a&gt;<br>    &lt;/li&gt;<br>  &lt;/ul&gt;<br> <br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><a href="http://jsfiddle.net/minipai/K3G5p/">LIVE DEMO</a></p><p>Thats it! We just covered only three directives: <strong>ng-click, ng-show, ng-class</strong>. But now you can start design interactions with AngularJS. Pretty easy, huh?</p><p>If you want to learn more, currently there is no site such as <em>AngularJS for Designer</em> like jQuery has <em>jQuery for Designer</em>. But some video tutorial might help.</p><ol><li><a href="https://www.youtube.com/watch?v=i9MHigUZKEM">AngularJS Fundamentals In 60-ish Minutes</a></li><li><a href="http://egghead.io/">Bite-sized web development training with AngularJS</a>.</li></ol><p>Go a head and check them out, and good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c7dc63ca65f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>