web development - technologies and tools

21
Web development Technologies and tools

Upload: yoann-gotthilf

Post on 01-Jul-2015

326 views

Category:

Education


3 download

DESCRIPTION

Support de cours pour le développement Web

TRANSCRIPT

Page 1: Web development - technologies and tools

Web developmentTechnologies and tools

Page 2: Web development - technologies and tools

Web technologies overview

AND MORE....

Page 3: Web development - technologies and tools

Studied Web technologies

AND MORE....

Page 4: Web development - technologies and tools

Bower

« A package manager for the web » http://bower.io/

Bower is a central repository for browser libraries or frameworks (Jquery, Boostrap, AngularJS, ...)

Page 5: Web development - technologies and tools

Bower why

• Improve development speed• Track and maintain easily your dependencies• Separate dependencies from your project’s source repository

(Git, CVS, ...)

Page 6: Web development - technologies and tools

Bower files

• bower.json : Project informations • Name• Version• Dependencies• Licence, Main file, Private, Etc...

• .bowerrc : Project Bower configuration (optional)• Dependencies directory• Remote repository url• Etc...

Page 7: Web development - technologies and tools

Bower commands

• Install Bowernpm install -g bower

• Create bower.jsonbower init

• Install a new Web packagebower install jquerybower install jquery --save (save it in bower.json)

• Update dependencies from bower.json : bower installbower update

Page 8: Web development - technologies and tools

Bower exemple

1. Install package :bower install bootstrap --save

2. Add in your index.html : <link rel="stylesheet" href="bower_components/dist/css/bootstrap.css" ><script src="bower_components/dist/js/bootstrap.js"></script>

3. Done !

Page 9: Web development - technologies and tools

Grunt

« The JavaScript Task Runner » http://gruntjs.com

Manage all your Web development tasks.(preprocessing, linting, testing, minifying, ...)

Page 10: Web development - technologies and tools

Grunt vs Gulp

Grunt• Configuration over code• More mature system• Over 3500 plugins

Gulp• Code over configuration• Steam-based build system• Small and elegant API• Over 700 plugins

Page 11: Web development - technologies and tools

Grunt commands

• Install Gruntnpm install –g grunt-cli

• Install pluginnpm install grunt-contrib-uglifynpm install grunt-contrib-uglify --save-dev (save it in package.json)

• Create taskin Gruntfile.js

• Run taskgrunt build

• Run default taskgrunt

Page 12: Web development - technologies and tools

Grunt Gruntfile.jsmodule.exports = function(grunt) {

// Project configuration.grunt.initConfig({

pkg: grunt.file.readJSON('package.json'),uglify: {options: {banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'

},build: {src: 'src/<%= pkg.name %>.js',dest: 'build/<%= pkg.name %>.min.js'

}}

});

// Load the plugin that provides the "uglify" task.grunt.loadNpmTasks('grunt-contrib-uglify');

// Default task(s).grunt.registerTask('default', ['uglify']);

};

Page 13: Web development - technologies and tools

Grunt file format exemples

// Files Object Formatfiles: {

'dest/a.js': ['src/aa.js', 'src/aaa.js'],'dest/a1.js': ['src/aa1.js', 'src/aaa1.js'],

},

// File Compact Formatfiles: {

src: ['src/aa.js', 'src/aaa.js'],dest: 'dest/a.js'

},

// File paternsfiles: {

src: ['src1/*.js', 'src2/**/*.js', 'src3/{,*/}*.js'],dest: 'dest/scripts.js'

},

// File optionsfiles: {

cwd: 'lib/',src: ['**/*.js'],dest: 'build/',ext: '.min.js',

},

Page 14: Web development - technologies and tools

LESS

« Less is a CSS pre-processor, meaning that it extends the CSS language, [...] that allow you to make CSS that is more maintainable, themable and extendable. » http://lesscss.org

Page 15: Web development - technologies and tools

LESS variables

// Variables@link-color: #428bca; @link-color-hover: darken(@link-color, 10%);

// Usagea.link {

color: @link-color;}

a:hover {color: @link-color-hover;

}

.widget {color: #fff;background: @link-color;

}

Page 16: Web development - technologies and tools

LESS mixins

.border-radius (@radius: 5px) {-webkit-border-radius: @radius;

-moz-border-radius: @radius;border-radius: @radius;

}

#header {.border-radius(4px);color: black;

}

.button {.border-radius(6px);

}

Page 17: Web development - technologies and tools

LESS nested 1/2

.btn {color: black;.navigation {

font-size: 12px;}.logo {

width: 300px;}&:hover {

color: red;}

}

.btn {color: black;

}.btn .navigation {

font-size: 12px;}.btn .logo {

width: 300px;}

.btn:hover {color:red;

}

Page 18: Web development - technologies and tools

LESS nested 2/2

.screencolor {@media screen {

color: green;@media (min-width:768px) {

color: red;}

}@media tv {

color: black;}

}

@media screen {.screencolor {

color: green;}

}@media screen and (min-width: 768px) {

.screencolor {color: red;

}}@media tv {

.screencolor {color: black;

}}

Page 19: Web development - technologies and tools

LESS operations

@base: 5%;@filler: @base * 2;@other: @base + @filler;@font-size-base: 12em;

color: #888 / 4;background-color: @base-color + #111;height: 100% / 2 + @filler;font-size: @font-size-base+2;

Page 20: Web development - technologies and tools

LESS functions

http://lesscss.org/functions/

• ceil• svg-gradient• rgba• saturate• ...

Page 21: Web development - technologies and tools

LESS guards

.mixin (@a) when (lightness(@a) >= 50%) {background-color: black;

}.mixin (@a) when (lightness(@a) < 50%) {

background-color: white;}.mixin (@a) {

color: @a;}

.class1 { .mixin(#ddd) }

.class2 { .mixin(#555) }

.class1 {background-color: black;color: #ddd;

}.class2 {

background-color: white;color: #555;

}