<?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 Luky Vj on Medium]]></title>
        <description><![CDATA[Stories by Luky Vj on Medium]]></description>
        <link>https://medium.com/@lukyvj?source=rss-a5d0f8f8e874------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pEs7_w2VLRveNKT3.png</url>
            <title>Stories by Luky Vj on Medium</title>
            <link>https://medium.com/@lukyvj?source=rss-a5d0f8f8e874------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 21:51:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lukyvj/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[The new Pandicons]]></title>
            <link>https://medium.com/@lukyvj/the-new-pandicons-6ced6a512d03?source=rss-a5d0f8f8e874------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ced6a512d03</guid>
            <dc:creator><![CDATA[Luky Vj]]></dc:creator>
            <pubDate>Sun, 18 Jan 2015 13:15:10 GMT</pubDate>
            <atom:updated>2015-01-20T13:51:03.959Z</atom:updated>
            <content:encoded><![CDATA[<p>A story about icons, Sketchs and why you need to save &amp; test your work.</p><p>Hi there, today, we will talk about the new services &amp; brands icons used in <a href="http://usepanda.com/">Panda</a>, we like to call them “<a href="https://github.com/panda-network/pandicons">The Pandicons</a>”.</p><p>But first, let me introduce you to Panda :</p><blockquote>Panda is newsfeed dashboard for designers, developers<br>and entrepreneurs. Panda aggregates content from sources<br>like Hacker News, Product Hunt and Dribbble, making<br>it easier for you to stay informed and inspired.</blockquote><p><a href="https://usepanda.com/">Panda - The homepage for your favorite websites</a></p><p>A week ago, an online-friend of mine &amp; Panda co-founder <a href="http://twitter.com/AhmetSulek">@AhmetSulek</a> , sent me a message over Facebook messenger, asking if I could do a small freelance work for them.</p><p>First, I said I wasn’t able to do so, because I already had some work to achieve before starting a new one, and I had some issues with my computer, that won’t let me work peacefully.</p><p>So I assumed that Panda asked someone else, and I said to Ahmet that I keeped him informed if I was able to work for them in less than a week.</p><p>I finally got my computer back, fixed, and I was done with my work, so I was able to attack the project.<br>Plus, in the mission summary Ahmet sent me, I saw that the requirement was to use <a href="http://bohemiancoding.com/sketch/"><strong>Sketch</strong></a>, and honestly, my last impression with sketch was chaotic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*u28WhBjO0Xa9odXnz3uovQ.png" /><figcaption>Sketch logo</figcaption></figure><p>So I thought it could have been a good way to get into Sketch again, and maybe, change my point of view about the product.</p><p>And after a small reflexion, I finally decided that I will work for them.</p><p>I had 28 icons to vectorize, from their <strong>30x30 PNG</strong> version, to scalables vectorized graphics (<strong>SVG</strong>). Initially, I told the Panda team that I would be able to finish it over two days. So I started on the monday morning, with the thought that I’ll be done with the day after.</p><p>I spent the whole day to vectorize the icons on Sketch, learning how this beautiful product was working, I started to loving it, and sometimes, I was sending the whole file to Ahmet, just to be sure that what I did was fitting to the team’s expectations. And Ahmet told me many times : “<em>It’s good, keep going, it’ll be perfect</em>”.</p><p>I did so, and I kept designing them, one after an other.</p><p>At the same time, I was chatting with my developers crew ( <a href="http://twitter.com/bullgit">@bullgit</a> | <a href="http://bullg.it/">http://bullg.it</a> ), showing them what I was doing, just to know if they had a thought or any feedbacks to share.</p><p>At the evening, I had 5 remaining icons to do, and I hesitated between keep going and finish it, or stop and getting back to it the next morning.. I decided to finish it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*v2ewa5tvAu6-BnwKbgndZQ.png" /></figure><p>So I started to design the “<a href="http://www.swiss-miss.com/"><em>SwissMiss</em></a>” icon, when I realized that the letters would be to thin for an image trace, so I decided to try a function of sketch that I didn’t knew yet, the “<em>Create symbols</em>”.. Don’t ask the context, I don’t recall at which level I was, to decide to turn the letters into symbols, but I did so. And it was a huge mistake.</p><p>Sketch starting to freeze, my icons weren’t display on the page anymore.. So I took the decision to restart the software, I closed it, opened it, and double click on my “<em>pandicon.sketch</em>” archive… Nothing happened..I thought, maybe dragging and dropping it ? I did so, and … Nothing happened.</p><p>Was I really losing all my work, had I really working all day long for nothing ? It was incredible, I asked my developer friends of <a href="http://bullg.it/">bullgit</a> to open it, unsuccessfully.. I asked Ahmet to open it, unsuccessfully.. We all looked into the sketchfile, opening it with a text editor, and surprise ( or not ).. It was encrypted in Binary..</p><p>My last chance, was to tweet to @sketchapp, and they never responded..</p><h3>Luky Vj on Twitter</h3><p>I can&#39;t open a sketchfile of 991ko I asked friends to try, same result. What hpn ? Howto solve it ? It&#39;s an entire day of work. @sketchapp</p><p>I finally took my last option : Re vectorize them, one by one, using dropbox to save all the versions of my file.</p><p>I wasn’t proud of what just happened, but you know, sometimes a fresh restarts worth way much than continue to work on a buggy file.</p><p>The tuesday morning, Ahmet sent me the last “<em>working</em>” draft of the icons, and I had to re-start the vectorization, with only 8 icons, already present in the file.</p><p>But it wasn’t that painfull, I took the occasion to know sketch a little bit better. I had the feeling to be faster than the previous day, so I get all my stength and I finished this iconset in time, the tuesday evening, Panda got its new icons, and I had fullfilled my mission.</p><h4>About the icons</h4><p>The icons are destined to be view at a <strong>30x30</strong> size, but because of the vectorization, they’d look the same no matter the dimensions, to illustrate it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nuDc17yhMFvEhuytXzMOWw.png" /><figcaption><a href="https://github.com/panda-network/pandicons">https://github.com/panda-network/pandicons</a></figcaption></figure><p>It was a fun work tho, I learned a lot from my mistakes, and I think this is what is important, not doing mistakes, but learning from them.</p><p>Now, when I’m working on sketch, I can’t stop thinking about my misaventure, and I constantly check if my work is working, or not.</p><p>You can see the “<em>Pandicons</em>” github repo :<br><a href="https://github.com/panda-network/pandicons">https://github.com/panda-network/pandicons</a></p><p>Or directly live, on codepen :<br><a href="http://codepen.io/LukyVj/pen/LEWWwq/">http://codepen.io/LukyVj/pen/LEWWwq/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ced6a512d03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An introduction to Gulp.js]]></title>
            <link>https://medium.com/@lukyvj/an-introduction-to-gulp-js-295ee489e2c9?source=rss-a5d0f8f8e874------2</link>
            <guid isPermaLink="false">https://medium.com/p/295ee489e2c9</guid>
            <dc:creator><![CDATA[Luky Vj]]></dc:creator>
            <pubDate>Tue, 06 Jan 2015 12:19:25 GMT</pubDate>
            <atom:updated>2015-01-08T19:59:51.945Z</atom:updated>
            <content:encoded><![CDATA[<p>introduction to Gulp.js, and how to start using it.</p><p>I recently had some requests from people asking if I could share my workflow with Gulp, and I finally decided to do so.</p><p>You will find a link to a github repository containing a demo of all the topics pictured in the article.</p><p><em>Note that the code examples, if copy pasted, will not display the comas (‘) correctly, you’ll have to replace them by hand.</em></p><h3>What is gulp ?</h3><p>Gulp is what internet call a “Javascript Tasks Runner”, so it’s not so difficult to guess what it does.. It runs Javascript Tasks, and it works with <a href="http://nodejs.org/">Node.js</a>.</p><p>The advantages of using JS Tasks runner, is that your workflow will be enhanced and effortless. The output (if gulp is properly setup) will be an improved project in terms of performances, and the page weight will be reduced.</p><p>It’s also a good way to automate your workflow, and trust me, once you’ll start using Gulp, you’ll never be able to stop using it.</p><h4>Is gulp the only JS Task runner ?</h4><p>No , it’s not. There are actually some really good JS Task runners, such as <a href="http://gruntjs.com/">Grunt</a>, <a href="https://github.com/broccolijs/broccoli">Broccoli</a>, <a href="http://brunch.io/">Brunch </a>or even <a href="http://coffeescript.org/documentation/docs/cake.html">Cake</a>.</p><p>Before trying (and loving) Gulp, I was working with Grunt, which is also a really good tool, but for obvious reasons (Speed, syntax, etc) I finally decided to go with Gulp.</p><p><em>(At the end of the article, in the resources links, you’ll find a great comparison blogpost about all of them.)</em></p><h3>Let’s start</h3><p><em>Make sure you have Node.js installed before starting the installation.</em></p><h4>Regular Install :</h4><p>In order to start the tutorial, you’ll need to go to the Gulp.js project page, to install it.</p><p>Go to <a href="http://gulpjs.com/">http://gulpjs.com/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2Dg0-LJ3EAKbj4_v72cGw.png" /><figcaption><a href="http://gulpjs.com/">http://gulpjs.com/</a></figcaption></figure><p>Click on “Try it now”, and follow the few steps of installation.</p><h4>Here is a short version</h4><p>(From the Github project page)</p><p>Install gulp globally :</p><pre>$ npm install --global gulp</pre><p>You may have to run is as root</p><pre>$ sudo npm install --global gulp</pre><p>The<strong> —global</strong> flag will install Gulp globally, then you will be able to run $ gulp from any directory on your computer.</p><p>Install gulp in your project devDependencies:</p><pre>$ npm install --save-dev gulp</pre><p>The —<strong>save-dev</strong> flag when installing, will add gulp to the project’s <strong>package.json</strong>. This allows anyone who might develop on or use the project to install the dependencies, with a simple <strong>npm install</strong> command. By contrast, the<strong> -g </strong>flag is global only to your local machine.</p><p>Create a <strong>gulpfile.js</strong> at the root of your project:</p><pre>var gulp = require(&#39;gulp&#39;);<br><br>gulp.task(&#39;default&#39;, function() {<br> // place code for your default task here<br>});</pre><p><em>(Note that this gulpfile will do nothing.)</em></p><p>Run Gulp:</p><pre>$ gulp</pre><p>Thats it, you just run your first Gulp.js script, was it difficult ? I bet it wasn’t.</p><h4>Alternative install:</h4><p>Well, personally, I use <a href="http://yeoman.io/">Yeoman</a>, a webapp generator, to start my projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LJ7FRpCXBUodgIlEwCURw.png" /><figcaption><a href="http://yeoman.io/">http://yeoman.io/</a></figcaption></figure><p>If you decide to use Yeoman, follow their installation instructions, and come back later.</p><p>So, I assume you now have Yeoman installed, it’s time to start a <strong>Gulp.js </strong>project with Yeoman.</p><ul><li>First step, open your command line editor (I use the Terminal) and type :</li></ul><pre>yo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*1Vg7FwvvyqxEfJydodtezA.png" /></figure><p>You’ll get the following message.</p><p>Select “<strong>Gulp Webapp</strong>” and press <strong>Return.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*svIeThMlTZnsnaGRX9Kn-g.png" /></figure><p>Once you selected the “<strong>Gulp Webapp</strong>” option, they will ask you which tool you’d like to use with your webapp, my natural choice is <strong>SASS</strong>.</p><p>Select one, and press <strong>Return.</strong></p><p>our Yeoman project will be created and Yeoman will try to run:</p><pre>bower install &amp; npm install</pre><p>To install your required dependencies.</p><p>If Yeoman failed the previous command, you will have to run <strong>npm install </strong>yourself. Don’t forget to use <strong>sudo</strong> to enforce the right access.</p><pre>bower install &amp; sudo npm install</pre><p>Once everything is installed, you will see the cute Yeoman message, informing you that your installation is done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*FW8MC9rtUzzkOYvCL6oAUA.png" /></figure><h4>Now, we can focus on Gulp !</h4><h2>Your First Gulpfile.js</h2><h3>Folder organisation</h3><p>I assume that you have a folder structure similar to the following :</p><pre>Project/<br>      |<br>      gulpfile.js<br>      app/<br>        |<br>        index.html<br>        |<br>        scripts/<br>        styles /<br>        images /<br>        fonts /</pre><p>We will only focus on the gulpfile.js, no matter what is inside, remove everything, and start from an empty file, it will be easier for you to understand how Gulp works then.</p><h3>Let’s do it</h3><p>So, we will start by requesting Gulp, with a require(); Not sure if this function is herited because Gulp.js is a Node program, but I think it’s not difficult to guess what a Require do.</p><pre>var gulp = require(‘gulp’);</pre><p>It means that we will use Gulp.</p><p>Then, define all the node package that will be used into your gulpfile. To know which package we will need, we have to define what we want to do.</p><p>Today, we want to :</p><ul><li>Compile our SASS files to CSS</li><li>Prefix our CSS</li><li>Minify our CSS / Javascript</li></ul><p>This will be our exercice today.</p><h4>Get the packages :</h4><p>These commands should be run in the root of your project. I.e. the same folder as <strong>gulpfile.js</strong></p><ul><li><a href="https://github.com/sindresorhus/gulp-ruby-sass">Gulp-ruby-sass</a> : <strong><em>$ npm install gulp-ruby-sass</em></strong></li><li><a href="https://github.com/sindresorhus/gulp-autoprefixer">Gulp-autoprefixer</a> : <strong><em>$ npm install gulp-autoprefixer</em></strong></li><li><a href="https://github.com/jonathanepollack/gulp-minify-css">Gulp-minify-css</a> : <strong><em>$ npm install gulp-minify-css</em></strong></li><li><a href="https://github.com/craigjennings11/gulp-uglifyjs">Gulp-uglifyjs</a> : <strong><em>$ npm install gulp-uglifyjs</em></strong></li></ul><p>So, now we have all the desired packages, it’s time to load them into our Gulpfile.js.</p><pre>var gulp = require(‘gulp’);</pre><pre>// Load the packages<br>var sass = require(‘gulp-ruby-sass’);<br>var autoprefixer = require(‘gulp-autoprefixer’);<br>var minifycss = require(‘gulp-minify-css’);<br>var uglify = require(‘gulp-uglifyjs’);</pre><p>Now, let’s create our first task, the <strong>style compiler</strong> ! But first, let’s look at an empty task :</p><pre>gulp.task(‘task-name’, function () {<br> // All the gulp awesomeness here<br>});</pre><h4>Styles task:</h4><p>We will define a name to our task, then we will be able to call it via the command-line tool, let’s say our task will be called <strong>styles</strong>, since it’s a task to compile, prefix and minify our CSS.</p><pre>gulp.task(‘styles’, function () { </pre><pre>// The scss file location<br> return gulp.src(‘app/styles/main.scss’) </pre><pre>// Will compile the SASS, The sourcemap=none is a fix                        // to A problem that have Autoprefixer<br> .pipe(sass({ <br> style: ‘expanded’, <br> “sourcemap=none”: true <br> })) </pre><pre>// Will autoprefix the css                      .pipe(autoprefixer({ <br> browser: [‘last 2 version’]<br> })) </pre><pre><br>// The final destination             .pipe(gulp.dest(‘app/styles’)); <br>});</pre><p><a href="https://github.com/sindresorhus/gulp-ruby-sass/issues/156"><em>here is the link to the sourcemap=none issue on github</em></a></p><p>Let’s look deeper into this task.</p><p>So the first line, the Return, tells gulp where to find the desired file to work on.</p><p>The second line, will tell Gulp, how to compile the SASS. You can use one of these arguments: <strong>nested</strong>, <strong>compact</strong>, <strong>compressed </strong>or<strong> expanded.</strong></p><p>The third line defines how autoprefixer will prefix the CSS. Here I use ‘last 2 versions’, but I encourage you to take a look at the <a href="https://github.com/postcss/autoprefixer#browsers">different browser you can target</a>.</p><p>And finally, the last line define the destination of the compiled file.</p><p>Then, you just have to run</p><pre>$ gulp styles</pre><p>to launch the task, and some milliseconds later, your SASS file will be compiled, prefixed and minified.</p><h4>Scripts task:</h4><p>Now we have defined our first task, it’s time for us to handle the Javascript file.</p><p>You have to know that there are tons of gulp packages that works with javascript files, I like to use the <a href="https://www.npmjs.com/package/gulp-jshint">JSHint package</a> to see if my code contains some errors, but on this article, I will only focus on the Javascript minification.</p><pre>gulp.task(‘scripts’, function () {<br> return gulp.src(‘app/scripts/main.js’) // The js files location<br> .pipe(uglify())                        // Will minify the JS<br> .pipe(gulp.dest(‘app/dist/scripts/’)); // The final destination<br>});</pre><p>Because we already cover the Return &amp; Dest lines, I will only explain what the uglify() line do.</p><p>Uglify is self defined as a :</p><blockquote>JavaScript parser / mangler / compressor / beautifier library for NodeJS</blockquote><p>But to keep things simple, I like to see it as a Javascript improver. It will not make your code better if you did mistakes, but it will compress it and minify it, to make it run faster.</p><p>To launch the scripts task, simply run :</p><pre>$ gulp scripts</pre><p>And now, you have defined 2 tasks in your gulpfile.js, and with these two tasks, you’ve got a great base to start to play with Gulp.</p><h2>Tips, Tricks and plugins</h2><p>Now, you know how to use Gulp, you have played with it, and get how it works.</p><p>It’s time to discover some more things you can do with Gulp, let’s discover some plugins, tips and tricks, that will make you save some time !</p><ul><li>Watch files for change &amp; live-reload</li><li>Get the size of your project files</li><li>Remove the extra css from your stylesheet</li><li>Resize a bunch of images, one shot style.</li><li>Gzip scripts and styles.</li></ul><h4>Watch files for change &amp; live-reload</h4><p>Sometimes, you need to save some time, and the goal of Gulp is to automate everything.<br>What if you want to be able to watch your files, and reload the page when one of them is edited, saved or deleted?</p><p>Gulp can do that !</p><p>You have to use some cool plugins, I will not explain you how they work, too keep this article reasonable, but I will tell you how to use it.</p><p>So here are the plugins :</p><p><a href="https://www.npmjs.com/package/gulp-load-plugins"><strong>gulp-load-plugins</strong></a>, <a href="https://www.npmjs.com/package/connect"><strong>connect</strong></a><strong> </strong><a href="https://www.npmjs.com/package/connect-livereload"><strong>connect-livereload</strong></a>, <a href="https://www.npmjs.com/package/gulp-livereload"><strong>gulp-livereload</strong></a><strong> </strong>&amp; <a href="https://www.npmjs.com/package/opn"><strong>opn</strong></a></p><p>First, add this package to your list :</p><pre>var $ = require(‘gulp-load-plugins’)();</pre><p>Then define the connect task, which will run a web server :</p><pre>// Connect task<br>gulp.task(‘connect’, function () {</pre><pre>// Here, require the connect plugin<br> var connect = require(‘connect’); <br> var app = connect()<br> .use(require(‘connect-livereload’)({ port: 35729 }))<br> .use(connect.static(‘app’))<br> .use(connect.static(‘.tmp’))<br> .use(connect.directory(‘app’));</pre><pre>require(‘http’).createServer(app)<br> .listen(9000)<br> .on(‘listening’, function () {<br> console.log(‘Started connect web server on <a href="http://localhost:9000&#39;/">http://localhost:9000&#39;</a>);<br> });<br>});</pre><p>Note that the connect-livereload package is a connect middleware for adding the livereload script to the response, so, no browser plugin is needed. As it’s declared on the Github project of the package :</p><blockquote><em>if you are happy with a browser plugin, then you don’t need this middleware.</em></blockquote><p>Now we have to open our webserver on localhost:9000, note that you have to match the listened port on the connect task over, so the port 9000 :</p><pre>// Serve task<br>gulp.task(‘serve’, [‘connect’, ‘styles’, ‘scripts’], function () {<br> require(‘opn’)(‘<a href="http://localhost:9000&#39;/">http://localhost:9000&#39;</a>);<br>});</pre><p>Now, create the watch task :</p><pre>// Watch task <br>gulp.task(‘watch’, [‘connect’, ‘serve’], function () {<br> var server = $.livereload();</pre><pre>// watch for changes<br> gulp.watch([<br> ‘app/*.html’,<br> ‘app/scripts/**/*.js’,<br> ‘app/styles/**/*.css’,<br> ‘app/images/**/*’<br> ]).on(‘change’, function (file) {<br> server.changed(file.path);<br> });</pre><pre>gulp.watch(‘app/styles/**/*.scss’, [‘styles’]);<br> gulp.watch(‘app/scripts/**/*.js’, [‘scripts’]);<br>});</pre><p>So, now everything is ready. When you change something on your sass file, it will be recompiled, and the .css file will be updated, and your browser will reload instantly, that’s just <a href="https://github.com/bullgit/wiki/wiki/Osome">OSOME</a> !</p><h4>Get the size of your project files</h4><p>Sometimes, you have to keep an eye on your files size, making sure that you doesn’t go further than a certain weight, or for any other reasons.</p><p>There is a cool task that keeps you informed about your files size, and it requires only one common plugin: <a href="https://www.npmjs.com/package/gulp-size"><strong>gulp-size</strong></a><strong>.</strong></p><p>Once loaded on your project with a require :</p><pre>var size = require(‘gulp-size’);</pre><p>you just have to write the following piece of code :</p><pre>gulp.task(‘infos’, function(){<br> // You can pass as many relative urls as you want<br> return gulp.src([<br> ‘app/scripts/**/*’,<br> ‘app/styles/**/*’<br> ]) <br> .pipe(size());<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*INTlNK1Diax02ZMOlPGx3w.png" /></figure><p>This task will return an addition of all the files you indicates.</p><h4>Remove the extra css from your stylesheet</h4><p>This is a cool plugin to use, the <a href="https://www.npmjs.com/package/uncss"><strong>uncss</strong></a><strong> </strong>plugin, as described on their <a href="https://github.com/giakki/uncss">Github rep</a>o :</p><blockquote><em>UnCSS is a tool that removes unused CSS from your stylesheets. It works across multiple files and supports Javascript-injected CSS.</em></blockquote><p>So you see how it could be useful when you’re done with one of your project .</p><p>The following example shows you how to remove the unused css from the index page.</p><pre>gulp.task(‘uncss’, function() {<br> gulp.src(‘app/styles/main.css’)<br>  .pipe(uncss({<br> html: [‘app/index.html’]<br> }))<br>  .pipe(gulp.dest(‘app/dist/styles’));<br>});</pre><p>As you may figure, this task will check if there is unused css in your <strong><em>index.html</em></strong>, and if there is, it will output a new <strong><em>main.css</em></strong><em> </em>file, into the <strong>app/dist/styles </strong>folder.</p><p>And with a bit of creativity, and to ensure you to never have extra css, you can add this task to your watch loop.</p><p>First, modify your serve task and add the uncss task, and then, each time you will run the <strong>gulp serve </strong>command, it will run the <strong>uncss </strong>task.</p><pre>// Serve task<br>gulp.task(‘serve’, [‘connect’, ‘styles’, ‘scripts’, ‘uncss’], function () {<br> require(‘opn’)(‘<a href="http://localhost:9000&#39;/">http://localhost:9000&#39;</a>);<br>});</pre><p>Now, we want this to happen automatically each time we save our <strong>style.scss</strong>. Therefore, modify your watch task and add a line that triggers the <strong>uncss </strong>task to run when a css file changes.</p><pre>// Watch task <br>gulp.task(‘watch’, [‘connect’, ‘serve’], function () {<br>  var server = $.livereload();</pre><pre>// watch for changes<br> gulp.watch([<br>   ‘app/*.html’,<br>   ‘app/scripts/**/*.js’,<br>   ‘app/styles/**/*.css’,<br>   ‘app/dist/styles/**/*.css’,<br>   ‘app/images/**/*’<br> ]).on(‘change’, function (file) {<br>   server.changed(file.path);<br> });</pre><pre>  gulp.watch(‘app/styles/**/*.scss’, [‘styles’]);<br>  gulp.watch(‘app/styles/**/*.css’, [‘uncss’]);<br>  gulp.watch(‘app/scripts/**/*.js’, [‘scripts’]);</pre><pre>  // Watch some files, to reload the page if changed.<br>  gulp.watch(&#39;app/styles/**/*.scss&#39;, [&#39;styles&#39;]);<br>  gulp.watch(&#39;app/styles/**/*.css&#39;, [&#39;uncss&#39;]);<br>});</pre><p>That’s it ! Easy and useful.</p><h4>Resize a bunch of images, one shot style.</h4><p>Now let’s see what we can do for images, I bet every one here already worked on a project with images that have to be in a gallery for example, or in a slideshow, and the images ARE NOT at the same dimensions at all !</p><p>You can always open photoshop to re-dimension them, but wait, there is a package for that too !<br>The <a href="https://www.npmjs.com/package/gulp-image-resize">gulp-image-resize</a> package !</p><p>Start by downloading the plugin into your project</p><pre>npm install gulp-image-resize</pre><p>Then require the task at the top of your gulpfile.js</p><pre>var imageResize = require(‘gulp-image-resize’);</pre><p>Now, let’s say that we have some images with dimensions of 600px*600px inside our app/images folder, and we want them to be resized to 200px*200px. Add these few lines of Javascript:</p><pre>gulp.task(‘image-resize’, function(){<br>  return gulp.src(‘app/images/*.png’)<br>  .pipe(imageResize({ <br>    width : 200<br>  }))<br>  .pipe(gulp.dest(‘app/images/min’))<br>})</pre><p>Now :</p><pre>gulp image-resize </pre><p>And it’ll process all your images in less effort.</p><p><strong><em>Note : You have to get GraphicsMagick or ImageMagick installed on your computer, according to : </em></strong><a href="https://www.npmjs.com/package/gulp-image-resize"><strong><em>https://www.npmjs.com/package/gulp-image-resize</em></strong></a></p><h4>Gzip scripts and styles</h4><p>When you talk about website optimization, there is always someone that talks about <a href="http://www.gnu.org/software/gzip/">Gzip</a>, gzipping this, gzipping that.</p><p>It could be a pain to gzip files by hand, one after an other.. And now, there is a gulp package for it, <a href="https://www.npmjs.com/package/gulp-pako"><strong>gulp-pako</strong></a> plugin !</p><p>So, as usual :</p><pre>npm install gulp-image-resize</pre><p>Then :</p><pre>var pako = require(‘gulp-pako’);</pre><p>And the tasks :</p><pre>gulp.task(‘css-gzip’, function(){<br>  return gulp.src(‘app/styles/main.css’)<br>   .pipe(pako.gzip())<br>   .pipe(gulp.dest(‘app/dist/styles/’))<br>});</pre><pre>gulp.task(‘js-gzip’, function(){<br>  return gulp.src(‘app/scripts/**/*.js’)<br>   .pipe(pako.gzip())<br>   .pipe(gulp.dest(‘app/dist/scripts/’))<br>});</pre><pre>gulp.task(‘gzip’, [‘css-gzip’, ‘js-gzip’]);</pre><p>So running gulp css-gzip will gzip your css, running js-gzip will gzip your scripts, and the gulp gzip will compress both.</p><p>And we’re done, I hope you will try Gulp.js and you will love it as I do. Hopefully it will change your workflow for ever ☺</p><h3>Links and resources</h3><h4>Tools :</h4><ul><li><a href="http://gulpjs.com/">Gulp.js</a></li><li><a href="http://nodejs.org/">Node.js</a></li><li><a href="http://yeoman.io/">Yeoman.io</a></li><li><a href="https://www.npmjs.com/">npm.js</a></li><li><a href="http://gulpfiction.divshot.io/">Gulp Fiction</a>.</li></ul><h4>Articles :</h4><ul><li><a href="http://blog.cozycloud.cc/technic/2014/06/18/task-runners-comparison/">JS Task Runners Comparison: Grunt vs Cake vs Gulp vs Broccoli</a></li><li><a href="http://blog.npmjs.org/post/101775448305/npm-and-front-end-packaging">npm and frontend packaging</a></li></ul><h3>Want more ? Here is a demo !</h3><p>I created a github repo to better illustrate the article, and give it more strenght.<br>It’s also a good way for you to grab it and use it as a starting base on your Gulp.js adventure.</p><p><a href="https://github.com/LukyVj/Introduction-to-Gulp.js/tree/gh-pages">Github Repository</a><br><a href="http://lukyvj.github.io/Introduction-to-Gulp.js/app/">Demo Page</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_KqCaGHcE_tE6cp5dF0Jyg.png" /></figure><p><em>If you have any feedbacks or impressions, feel free to drop me an email, a tweet or a comment.</em></p><p>A big thank yo to <a href="http://twitter.com/haraldandertun"><strong>Harald Sigh Andertun (@Haraldandertun)</strong></a><strong> </strong>, for his help on this article ☺</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=295ee489e2c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Metro Style Accordion]]></title>
            <link>https://medium.com/@lukyvj/how-to-create-a-metro-style-accordion-5eb3e1afe780?source=rss-a5d0f8f8e874------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eb3e1afe780</guid>
            <dc:creator><![CDATA[Luky Vj]]></dc:creator>
            <pubDate>Tue, 16 Dec 2014 12:16:14 GMT</pubDate>
            <atom:updated>2014-12-16T12:16:14.457Z</atom:updated>
            <content:encoded><![CDATA[<p>This post was written 2 years ago, it’s a repost from <a href="http://www.republicof3.com/tutorial-how-to-create-a-metro-style-accordion/">http://www.republicof3.com/tutorial-how-to-create-a-metro-style-accordion/</a></p><p>Hello readers!<br>Today I’ve got a treat for you. We will be learning how to code a Metro Style Accordion menu in just a few steps. This menu uses jQuery and jQueryUI, it can be done in a few other ways but I will show you the way I do it, it’s just something I feel comfortable with. You can download the files (HTML / CSS / PSD) for this tutorial at the end of the article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*CG37NG8EyZCOmFT1VL69Iw.png" /></figure><h4>Summary:</h4><ul><li><a href="http://web.archive.org/web/20130217133023/http://www.republicof3.com/tutorial-how-to-create-a-metro-style-accordion/#html">The Markup</a></li><li><a href="http://web.archive.org/web/20130217133023/http://www.republicof3.com/tutorial-how-to-create-a-metro-style-accordion/#css">The CSS</a></li><li><a href="http://web.archive.org/web/20130217133023/http://www.republicof3.com/tutorial-how-to-create-a-metro-style-accordion/#js">The Magic / JavaScript</a></li><li><a href="http://web.archive.org/web/20130217133023/http://www.republicof3.com/tutorial-how-to-create-a-metro-style-accordion/#demo">Demo / Download</a></li></ul><h4>The Markup</h4><p>Let’s start by looking at the HTML for this menu. As you can see, the HTML is really simple and I’m sure you can understand it easily. We only have to use the ul and the li in the mark-up for the structure of the accordion followed by the insertion of thea tag into <strong>every </strong>li of the <strong>first </strong>level. This will make it into a link.</p><p>Now you might have noticed that we have set a class .close to each ul of the <strong>first </strong>level too, and we use the i tag to set an icon for each category. We then import the latest minified version of the jQuery code and the jQueryUI code. Using the minified version as much as possible will be great to keeping the size of the markup less and increase the load time on the page.</p><p>Let’s have a look at the HTML</p><pre>&lt;ul&gt;<br>	&lt;li&gt;<br>		&lt;a href=”#”&gt;&lt;i&gt;&lt;/i&gt;Friends&lt;/a&gt;<br>		&lt;ul class=”closed”&gt;<br>			&lt;li&gt;Jason Brody&lt;/li&gt;<br>			&lt;li&gt;Gordon Freeman&lt;/li&gt;<br>			&lt;li&gt;Master Chief&lt;/li&gt;<br>			&lt;li&gt;Lara Croft&lt;/li&gt;<br>			&lt;li&gt;Dirk the Daringk&lt;/li&gt;<br>			&lt;li&gt;Mario&lt;/li&gt;<br>		&lt;/ul&gt;<br>	&lt;/li&gt;<br>	&lt;li&gt;<br>		&lt;a href=”#”&gt;&lt;i&gt;&lt;/i&gt;Videos&lt;/a&gt;<br>		&lt;ul class=”closed”&gt;<br>			&lt;li&gt;Paradise&lt;/li&gt;<br>			&lt;li&gt;It’s Time&lt;/li&gt;<br>			&lt;li&gt;Sixteen Saltines&lt;/li&gt;<br>			&lt;li&gt;Burn it Down&lt;/li&gt;<br>			&lt;li&gt;First Of The YearYear&lt;/li&gt;<br>			&lt;li&gt;Feel So Close&lt;/li&gt;<br>			&lt;li&gt;Ballad Of Hollis Brown&lt;/li&gt;<br>			&lt;li&gt;We Are Young&lt;/li&gt;<br>		&lt;/ul&gt;<br>	&lt;/li&gt;<br>	&lt;li&gt;<br>		&lt;a href=”#”&gt;&lt;i&gt;&lt;/i&gt;Galleries&lt;/a&gt;<br>		&lt;ul class=”closed”&gt;<br>			&lt;li&gt;Manga Artworks&lt;/li&gt;<br>			&lt;li&gt;Anime Cosplay&lt;/li&gt;<br>			&lt;li&gt;Skyrim Cosplay&lt;/li&gt;<br>		&lt;/ul&gt;<br>	&lt;/li&gt;<br>	&lt;li&gt;<br>		&lt;a href=”#”&gt;&lt;i&gt;&lt;/i&gt;Podcasts&lt;/a&gt;<br>		&lt;ul class=”closed”&gt;<br>			&lt;li&gt;Stuff You Should Know&lt;/li&gt;<br>			&lt;li&gt;Outside the Lines&lt;/li&gt;<br>			&lt;li&gt;The Nerdist&lt;/li&gt;<br>			&lt;li&gt;Tekzilla&lt;/li&gt;<br>			&lt;li&gt;The Ricky Gervais Podcast&lt;/li&gt;<br>			&lt;li&gt;FormulaPod&lt;/li&gt;<br>			&lt;li&gt;ESPN: Football Today&lt;/li&gt;<br>			&lt;li&gt;Wired’s The Monitor&lt;/li&gt;</pre><pre>		&lt;/ul&gt;<br>	&lt;/li&gt;<br>	&lt;li&gt;<br>		&lt;a href=”#”&gt;&lt;i&gt;&lt;/i&gt;Bolts&lt;/a&gt;<br>		&lt;ul class=”closed”&gt;<br>			&lt;li&gt;TheChive&lt;/li&gt;<br>			&lt;li&gt;9Gag&lt;/li&gt;<br>			&lt;li&gt;BroMyGod&lt;/li&gt;<br>		&lt;/ul&gt;<br>	&lt;/li&gt;<br>&lt;/ul&gt;</pre><pre>&lt;script src=”http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=”http://code.jquery.com/ui/1.9.2/jquery-ui.js&quot;&gt;&lt;/script&gt;</pre><h4>The CSS</h4><p>Now for the CSS. As you can see that most of the lines uses a &gt; operator. For example, when I write body &gt; ul &gt; li it says that the li is the child of the ul which is the child of the body . You can surely use another method of doing this, I just stumbled upon this method and wanted to share it with you.</p><p>You see the font-face{…} bit that I’ve used to import the <strong>Lato </strong>font. We’ve also used the <a href="http://web.archive.org/web/20130217133023/http://www.republicof3.com/tutorial-how-nth-childn-can-make-your-life-easier/">nth-child(*</a>) method to target each of the categories and set the related icons body &gt; ul &gt; li:nth-child(*) &gt; a &gt; i</p><p>As for the counter, we used the <strong>CSS Counters </strong>technic which helps you implement an automated numbered count in CSS. We have added two classes .active and .closed. These classes will basically used to add functionality to the accordion. The.active class will color the background of categories when they will be targeted and the .closed will help us make the accordion’s categories expand and close. You can see that the height is set to 0<strong>px </strong>which is the value the pane will collapse back to once closed.</p><pre>@import url(http://fonts.googleapis.com/css?family=Lato);</pre><pre>body{<br>max-width: 240px;<br>	margin: 100px auto 50px auto;<br>	background: #1f1f1f;<br>	text-align: center;<br>}<br>ul{<br>list-style:none;<br>margin:0;<br>padding:0;<br>text-align:left;<br>font-family: Helvetica;<br>}<br>body &gt; ul{<br>margin-bottom:200px;<br>border:1px solid #222;<br>}<br>body &gt; ul &gt; li{<br>position:relative;<br>}<br>body &gt; ul &gt; li &gt; a{<br>display:block;<br>outline:0;<br>height:20px;<br>padding:10px;<br>text-decoration:none;<br>color:#fff;<br>background:#ea2d49;<br>border-bottom:1px solid #222;<br>font-family:Lato;<br>font-weight:300;<br>-webkit-font-smoothing:antialiased;<br>text-transform:uppercase;<br>font-size:14px;<br>}<br>body &gt; ul &gt; li &gt; a &gt; i{<br>display:block;<br>width:45px;<br>height:30px;<br>float:left;<br>}<br>body &gt; ul &gt; li:nth-child(1) &gt; a &gt; i{<br>background:url(http://web-gate.fr/images/republicof3/icon_friend.png)no-repeat top left;<br>/*background-size*/<br>-webkit-background-size:40%;<br> -moz-background-size:40%;<br> -o-background-size:40%;<br> background-size:40%;<br>background-position:5px 3px;<br>}<br>body &gt; ul &gt; li:nth-child(2) &gt; a &gt; i{<br>background:url(http://web-gate.fr/images/republicof3/icon_video.png)no-repeat top left;<br>/*background-size*/<br>-webkit-background-size:40%;<br> -moz-background-size:40%;<br> -o-background-size:40%;<br> background-size:40%;<br>background-position:5px 3px;<br>}<br>body &gt; ul &gt; li:nth-child(3) &gt; a &gt; i{<br>background:url(http://web-gate.fr/images/republicof3/icon_gallery.png)no-repeat top left;<br>/*background-size*/<br>-webkit-background-size:40%;<br> -moz-background-size:40%;<br> -o-background-size:40%;<br> background-size:40%;<br>background-position:5px 3px;<br>}<br>body &gt; ul &gt; li:nth-child(4) &gt; a &gt; i{<br>background:url(http://web-gate.fr/images/republicof3/icon_podcast.png)no-repeat top left;<br>/*background-size*/<br>-webkit-background-size:40%;<br> -moz-background-size:40%;<br> -o-background-size:40%;<br> background-size:40%;<br>background-position:5px 3px;<br>}<br>body &gt; ul &gt; li:nth-child(5) &gt; a &gt; i{<br>background:url(http://web-gate.fr/images/republicof3/icon_bolt.png)no-repeat top left;<br>/*background-size*/<br>-webkit-background-size:20%;<br> -moz-background-size:20%;<br> -o-background-size:20%;<br> background-size:20%;<br>background-position:10px 3px;<br>}<br>body &gt; ul &gt; li &gt; ul{<br>counter-reset:items;<br>height:auto;<br>overflow:hidden;<br>background:#fff;<br>color:#ec2b48;<br>width:100%;<br>}<br>body &gt; ul &gt; li &gt; ul &gt; li{<br>counter-increment:items;<br>padding:1em 1.3em;<br>border-bottom:1px solid #DDD;<br>font-size:12px;<br>cursor:pointer;<br>}<br>body &gt; ul &gt; li &gt; ul &gt; li:hover{<br>background:#f4F4F4;<br>}<br>body &gt; ul &gt; li:after{<br>content:counter(items);<br>font-size:14px;<br>position:absolute;<br>right:10px;<br>top:15px;<br>background:#c0273c;<br>height:30px;<br>padding:5px 20px;<br>margin:-15px -10px;<br>color:white;<br>text-indent:0;<br>text-align:center;<br>line-height:2;<br>/*box-shadow*/<br>-webkit-box-shadow:inset 4px 0 8px rgba();<br> -moz-box-shadow:inset 4px 0 8px rgba();<br> box-shadow:inset 4px 0 8px rgba();<br>}<br>body &gt; ul &gt; li &gt; ul &gt; li:after{<br>content:counter(items);<br>font-size:0.857em;<br>background:#f4f5f4;<br>height:100%;<br>margin:-27px 174px;<br>display:block;<br>float:left;<br>color:#c0273c;<br>text-indent:0;<br>text-align:center;<br>font-size:14px;<br>line-height:2.5;<br>border-top:1px solid #DDD;<br>height:38px;<br>width:48px;<br>}<br>.active{<br>background:#c0273c;<br>}<br>.closed{<br>height:0;<br>}</pre><h4>The Magic / JavaScript</h4><p>Finally, we’re at the best part of it all. This is where the magic happens. What will follow are a few lines of jQuery. I’ll go on a explain what it means and will do before we get to the code.In our example, the $(this) is the equivalent to HTML’s a, so in this scenario the $(this) = a.</p><p>We will now write a function for when you click on the a tag, the function will simply add the .active class to the a tag along with the .toggleClass() class followed by setting a delay of 5 to the background color of the selected category_this.toggleClass(‘active’, 5);.</p><p>We then remove the .close class to open the pane by targeting the .next() element once the a is active. It’s the ul, so the result will be that it opens it with a delay too, but a bit longer this time, to make this a smoother transition$(this).next().addClass(‘closed’, 500);. And we collapse the open pane with these last lines of code. To do so, we need to target all a tags if they are not the clicked one and we will do this by writing .not(_this) and remove the desired class.</p><pre>$(function() {<br>	$(“a”).bind(‘click’,function() {<br>		var _this = $(this);</pre><pre>		// Expand the current link<br>		_this.toggleClass(‘active’, 5);<br>		_this.next().toggleClass(‘closed’, 500);<br>		// Contract the others and set off the ‘active’ state.<br>		$(“a”).not(_this).each(function() {<br>			$(this).next().addClass(‘closed’, 500);<br>			$(this).removeClass(‘active’, 5);<br>		});<br>	});<br>});</pre><h4>That’s it!</h4><p>I hope you enjoyed this little tutorial and I would like to thanks <a href="http://web.archive.org/web/20130217133023/http://www.republicof3.com/author/labib/">Labib Jaffar</a> who did an excellent work by designing this awesome Metro Style Accordion!</p><p>You can download the HTML files as well as the PSD. This is a freebie and you can use it however you like and we’d love to see how and where you’ve used it. Do post in the links in the comments section below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eb3e1afe780" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I animated Color-Template]]></title>
            <link>https://medium.com/@lukyvj/how-i-animated-color-template-4f45dc4e9410?source=rss-a5d0f8f8e874------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f45dc4e9410</guid>
            <dc:creator><![CDATA[Luky Vj]]></dc:creator>
            <pubDate>Mon, 15 Dec 2014 19:13:45 GMT</pubDate>
            <atom:updated>2014-12-15T19:13:45.361Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi guys, today, I want to cover a chapter about <a href="http://rocket-design.fr/color-template">Color-Template</a>! Color-Template is a sweet color tool and guide that we created with <a href="http://rocket-design.fr/">Rocket-Design</a>.</p><p>And the topic of the day is essencially about how I created an animation for the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N1Ly0FUlKGCU-lDu.png" /></figure><p>On this post, I will only focus on the last animation, which is, in my own opinion the most interesting. And I kinda use the same animation process on all the animations of the page.</p><p>So, today, I will dissect the animation of the 8<strong>th section </strong>for you. This animation, uses<strong>HTML/CSS/JAVASCRIPT</strong>, but because I’m a warrior shitty JS developer, I will use <strong>Jquery</strong>to work.. As usual.</p><h3>Description</h3><p>This animation is quite simple, when the user is on the good section, the animation is triggered, and the magic happen !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/0*CY8flYv2A4OCfnBo.gif" /></figure><p>As you can see, the animation will only affect the <strong>width </strong>of 3 elements. Each width get bigger right after the previous one. I’m sure you can already imagine how its made. A simple hover event fired by Jquery, and its done.</p><h3>Looking deeeper</h3><h4>About the HTML structure</h4><pre>&lt;div class=”bar”&gt;<br> &lt;span class=”cat6&quot;&gt;&lt;/span&gt;<br> &lt;span class=”cat1&quot;&gt;&lt;/span&gt;<br> &lt;span class=”cat3&quot;&gt;&lt;/span&gt;<br>&lt;/div&gt;</pre><p>As you can see, the html structure isn’t that complicated ! Just 3 spans surrounded by a.bar div. Each span, will be a part of the graph, and the classes can helps you to understand the value of each span.</p><h4>About the CSS</h4><pre><strong>.bar </strong>{<br> <strong>width: 570</strong>px;<br> <strong>height: 20</strong>px;<br> <strong>padding: .25</strong>em;<br> <strong>background: </strong>rgba(255<strong>,255,255,0.35)</strong>;<br> <strong>margin: 1</strong>em <strong>auto</strong>;<br> -webkit-<strong>border-</strong>radius<strong>: 5</strong>px;<br> -moz-<strong>border-</strong>radius<strong>: 5</strong>px;<br> <strong>border-</strong>radius<strong>: 5</strong>px;<br> <strong>overflow: hidden</strong>;<br>}</pre><pre>.<strong>bar </strong>span {<br> <strong>display: block</strong>;<br> <strong>height: 100%</strong>;<br> <strong>float: left</strong>;<br> <strong>position: relative</strong>;<br> -webkit-transition<strong>: width .4</strong>s ease;<br> -moz-transition<strong>: width .4</strong>s ease;<br> -o-transition<strong>: width .4</strong>s ease;<br> transition<strong>: width .4</strong>s ease;<br>}</pre><pre>.<strong>bar </strong>span.<strong>cat6 </strong>{<br> <strong>width: 0</strong>;<br> <strong>background: </strong>#e53c8d;<br> -webkit-<strong>border-</strong>radius<strong>: 3</strong>px;<br> -moz-<strong>border-</strong>radius<strong>: 3</strong>px;<br> <strong>border-</strong>radius<strong>: 3</strong>px;<br> <strong>z-index: 4</strong>;<br>}</pre><pre>.<strong>bar </strong>span.<strong>cat1 </strong>{<br> <strong>width: 0</strong>;<br> <strong>background: </strong>#f8b100;<br> <strong>border-top-right-</strong>radius<strong>: 3</strong>px;<br> <strong>border-bottom-right-</strong>radius<strong>: 3</strong>px;<br> <strong>z-index: 3</strong>;<br> -webkit-box-shadow<strong>: -1</strong>em 0 0 0 #f8b100;<br> -moz-box-shadow<strong>: -1</strong>em 0 0 0 #f8b100;<br> box-shadow<strong>: -1</strong>em 0 0 0 #f8b100;<br> -webkit-transition<strong>: width .4</strong>s ease .4s;<br> -moz-transition<strong>: width .4</strong>s ease .4s;<br> -o-transition<strong>: width .4</strong>s ease .4s;<br> transition<strong>: width .4</strong>s ease .4s;<br>}</pre><pre>.<strong>bar </strong>span.<strong>cat3 </strong>{<br> <strong>width: 0</strong>;<br> <strong>background: </strong>#7db928;<br> <strong>border-top-right-</strong>radius<strong>: 3</strong>px;<br> <strong>border-bottom-right-</strong>radius<strong>: 3</strong>px;<br> <strong>z-index: 2</strong>;<br> -webkit-box-shadow<strong>: -1</strong>em 0 0 0 #7db928;<br> -moz-box-shadow<strong>: -1</strong>em 0 0 0 #7db928;<br> box-shadow<strong>: -1</strong>em 0 0 0 #7db928;<br> -webkit-transition<strong>: width .4</strong>s ease .8s;<br> -moz-transition<strong>: width .4</strong>s ease .8s;<br> -o-transition<strong>: width .4</strong>s ease .8s;<br> transition<strong>: width .4</strong>s ease .8s;<br>}</pre><pre>.<strong>bar.active </strong>span.<strong>cat6 </strong>{<br> <strong>width: 60%</strong>;<br>}</pre><pre>.<strong>bar.active </strong>span.<strong>cat1 </strong>{<br> <strong>width: 10%</strong>;<br>}</pre><pre>.<strong>bar.active </strong>span.<strong>cat3 </strong>{<br> <strong>width: 30%</strong>;<br>}</pre><p>On this part, you can see that I style the look of the bar and its inner spans, and I create a class .active that will make them grow, and will make them visible.</p><p>You can see that the width of each span is equal to 0, and they become wider only when the.active class is applied to the parent container.</p><p>Now, the only problem is to find a simple way to add this class to the .bar container, and only few lines of javascript will do the trick.</p><h3>The Jquery</h3><pre>$(document).ready(<strong>function () </strong>{<br><em>// Declare Vars</em><br> <strong>var </strong>blockLast <strong>= </strong>$(‘#section8&#39;);<br> <br> <em>//Create an event, here its on “mouseover”</em><br> blockLast.on(‘mouseover’, <strong>function (</strong>e) {<br> e.preventDefault();<br> <strong>var </strong>elm <strong>= </strong>$(‘#section8 .bar’);</pre><pre> <em>//And add the class</em><br> elm.addClass(‘active’);<br> });<br>});</pre><p>Let’s look deeper into these javascript lines, so, you start by creating a variable of the zone you want to make reactive to your mouse, mine is blockLast. Then you have to add an event that will “trigger” your desired action. Here we want to add a class to the .bar div, so you have to create a variable that will correspond to the parent container of your spans, Here its elm. so right after creating your variable, you have to .addClass() to your elm, Here I simply write elm.addClass(‘active’).</p><p>That’s all ! It wasn’t so hard ;)</p><h3>Demo</h3><p>So after understanding this code, its time to see it in action ! Just take a look at this pen :</p><p><a href="http://codepen.io/LukyVj/pen/euLDK">http://codepen.io/LukyVj/pen/euLDK</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f45dc4e9410" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responsive images with CSS]]></title>
            <link>https://medium.com/@lukyvj/responsive-images-with-css-f76093bd8719?source=rss-a5d0f8f8e874------2</link>
            <guid isPermaLink="false">https://medium.com/p/f76093bd8719</guid>
            <dc:creator><![CDATA[Luky Vj]]></dc:creator>
            <pubDate>Sun, 14 Dec 2014 20:40:05 GMT</pubDate>
            <atom:updated>2015-04-15T10:20:48.154Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi guys ! Today I want to talk about a specific topic, which is <strong>The Responsives images </strong>or at least, “How to change images relatively to the screen size” , we will make an overview, from the concept to the realisation ! Ready ? Go !</p><h3>Responsive images ? What does it mean ?</h3><p>Its simple, responsive images, are not images that will be adapted to a screen size, but its more about the technic used to switch from a big image, to a smaller one.</p><p>I always smile when I listen people saying :”Yeah look at this responsive images ! Thats so cool !” .. No, its not cool, and its certainely not responsive images, let me explain it to you, with my words, and my vision.</p><h3>How and when do we need to implement them ?</h3><p>First of all, responsive images aren’t an obligation, it can be used to decrease the page speed, and make your webpages faster. I’m not gonna explain why and how it improve the page speed, but I’ll give you a bunch of links at the end of the article, to help you understand that.</p><p>Anyway, you “have” to use them as often as you can, on articles, services pages (landing pages or IDK), in a way, its better to use it everywhere. But it can be a hard work sometimes, because you’ll need at least 2 different images format, and more if you want to make a super responsive images system.</p><h3>The logic</h3><p>The logic is pretty simple, on a large screen, use the “biggest” image, (if I may say so) and on a smaller screen, use a smaller image. You admit this isn’t so complicated right ?</p><p>So we will use 2 different screen sizes, the first of 1200<strong>px </strong>and the second of 640<strong>px </strong>for the smaller screens (ipad/smartphones). Also to be more comfortable, we will translate those values in <a href="http://display-blog.com/em-vs-px/"><strong>EM</strong></a><strong>.</strong></p><p>So our base values will be 75<strong>em (1200px) </strong>and 40<strong>em (640px)</strong>, of course you can add all media queries you want, but to get the “logic” of the system, we will need only two.</p><h3>Step 2</h3><h4>Prepare your images.</h4><p>For a test-case, you’ll have to do some images modifications in photoshop (or any software, its not important), choose any images, its better if the quality is high. proceed like the following : * Open your image on photoshop, and save your images as “image-1&quot;. * Reduce the size of your images, and why not modify the image to make it lighter (in terms on quality of course..), and save it as “image-2&quot;. * Done.</p><p>Now, you have your 2 different pictures, we can start to work.</p><h3>Step 2</h3><h4>Define a html structure.</h4><p>The structure will be simple, a div will contain a p (Just to add content) tag and a fake image, representated by a &lt;div class=”image”&gt;&lt;/div&gt;, can’t be easier.</p><pre>&lt;div class=”block”&gt;<br> &lt;div class=”image”&gt;&lt;/div&gt;<br> &lt;p&gt;Church-key Williamsburg fixie, hashtag keffiyeh retro twee lomo beard Helvetica fingerstache sriracha ethnic meggings. &lt;/p&gt;<br>&lt;/div&gt;</pre><p>Ok, so take some time to understand the code above, ok ? Sweet, let’s go further.</p><h3>Step 3</h3><h4>Add CSS</h4><p>Now, its time to style our poor HTML document, in order to be able to create the responsive images system with css. We will create a “basic” page, with also poor css.</p><pre>html<strong>,</strong>body{<br> <strong>width:100%</strong>;<br> <strong>height:100%</strong>;<br>}<br>.<strong>block</strong>{<br> <strong>width:60%</strong>;<br> <strong>margin:2</strong>em 20<strong>%</strong>;<br>}</pre><pre>.<strong>image</strong>{<br> <strong>width:100%</strong>;<br> <strong>height:20</strong>em;<br> <strong>display:block</strong>;<br> <strong>background:</strong>url(https://medium.com/%E2%80%98path/to/your/image-1&#39;)<strong>no-repeat center center</strong>;<br> <em>/* Here, you have to add a basic/normal version of your image, which will be loaded by default, so for the background, set the path to your image-1*/</em><br> <strong>background-size:</strong>cover; <br> <strong>border:4</strong>px <strong>solid transparent</strong>;<br>}</pre><p>If you reproduce everything properly, you could view something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3G7z7IJtYxUBKr9j.png" /></figure><h3>Step 4</h3><h4>Add media queries, and let the magic happen.</h4><p>Now, its time to make it adaptative, so, I bet you get how we will do this. We simply ask to the browser via CSS, to load image-1 if the screen size is big (or normal), and load the image-2 if the screen size is small (like a mobile view).</p><pre><strong>@media </strong>all and (max-width:75em){<br> <em>/* Our first breakpoint */</em><br>}</pre><pre><strong>@media </strong>all and (max-width:40em){<br> <em>/* The second breakpoint */</em><br>}</pre><p>Remember, we only set 2 different sizes, its not important because its only a test-case and honnestly, we don’t need more breakpoints to make the system works. So, now we have everything, from the images, to the media-queries, its time to make it functionnal, don’t panic, its easy as ABC.</p><p>Note that we added different border colors, to let you know which media-query is active</p><pre><em>/* Our first breakpoint, will show the image-1, because its higher in terms of quality, and so better for the user */</em><br><strong>@media </strong>all and (max-width:75em){<br>.<strong>image</strong>{<br> <strong>background:</strong>url(https://medium.com/%E2%80%98path/to/your/image-1.png%E2%80%99)<strong>no-repeat center center</strong>;<br> <strong>background-size:</strong>cover; <br> <strong>border:4</strong>px <strong>solid </strong>red;<br> }<br>}</pre><pre><em>/* And here, we will ask to load the second image, which is more adapted to small screen, because we make it with a less quality, and so, it’ll take less time to load on a user’s small device. */</em><br><strong>@media </strong>all and (max-width:40em){<br> .<strong>image</strong>{<br> <strong>background:</strong>url(https://medium.com/%E2%80%98path/to/your/image-2.png%E2%80%99)<strong>no-repeat center center</strong>;<br> <strong>background-size:</strong>cover; <br> <strong>border:4</strong>px <strong>solid </strong>blue;<br> } <br> }</pre><h3>Proof of concept</h3><p>You can go to see this code live by following this link : <a href="http://lucasbonomi.com/demos/responsive-images">Proof of concept / Demo</a></p><h3>Links &amp; Resources :</h3><ul><li><a href="http://t.co/9JtykpOPui">A little Solution for responsive images | Hugo Darby Brown</a></li><li><a href="http://mobile.smashingmagazine.com/2013/07/22/simple-responsive-images-with-css-backgrounds/">Simple Responsive Images With CSS Background Images (smashingmagazine.com</a>)</li><li><a href="http://pxtoem.com/">PXtoEM</a></li></ul><p><strong>Lucas Bonomi</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f76093bd8719" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>