Top Banner
Hello, JSS! NetEase Mail FETC. 孙孙
47

孙极-Hello, JSS! - 一种新样式语言的诞生

Dec 18, 2014

Download

Technology

Webrebuild

网易邮箱资深页面架构工程师孙极,男,86年出生,4年前端经验,参与了网易邮箱极速4、iPad和iPhone版开发。主题《Hello, JSS! - 一种新样式语言的诞生》
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 孙极-Hello, JSS! - 一种新样式语言的诞生

Hello, JSS!

NetEase Mail FETC.

孙极

Page 2: 孙极-Hello, JSS! - 一种新样式语言的诞生

十多年前⋯⋯

Page 3: 孙极-Hello, JSS! - 一种新样式语言的诞生

四年前⋯⋯

Page 4: 孙极-Hello, JSS! - 一种新样式语言的诞生

今天

Page 5: 孙极-Hello, JSS! - 一种新样式语言的诞生

什么是 JSS?

Page 6: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS解析

Page 7: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS解析

JavascriptActionscriptPHP⋯⋯

Page 8: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS的特性

Page 9: 孙极-Hello, JSS! - 一种新样式语言的诞生

常量

Page 10: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

.mod1 { …color:#CC3300;… }

.mod2 { …background:#CC3300;… }

.mod3 { …border-color:#CC3300;… }

.mod4 { …outline:#CC3300;… }…

Page 11: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

$color = “ #CC3300 ” ;

.mod1 { …color:$color;… }

.mod2 { …background:$color;… }

.mod3 { …border-color:$color;… }

.mod4 { …outline:$color;… }…

Page 12: 孙极-Hello, JSS! - 一种新样式语言的诞生

常量

定义常量:$string1 = ”#CCC”;$string2 = ”10px”;$number1 = 10;$number2 = 10px;

Page 13: 孙极-Hello, JSS! - 一种新样式语言的诞生

常量

使用常量:div{

color:$string1;width:$number2;

}

Page 14: 孙极-Hello, JSS! - 一种新样式语言的诞生

常量

常量运算:$string1 = ”#CCC”;$string2 = ”10px”;

$string1+ $string2 #CCC10px

Page 15: 孙极-Hello, JSS! - 一种新样式语言的诞生

常量

常量运算:$num1 = 10px;$num2 = 20;

$num1+ $num2 30px

Page 16: 孙极-Hello, JSS! - 一种新样式语言的诞生

常量

常量运算:$string = “10px”;$num = 20;

$string+ $num 10px20

Page 17: 孙极-Hello, JSS! - 一种新样式语言的诞生

函数

Page 18: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

.mod1 {...

-webkit-box-shadow:0 0 5px #999;-moz-box-shadow:0 0 5px #999;box-shadow:0 0 5px #999;...

}.mod2 {

...

-webkit-box-shadow:0 0 6px #CCC;-moz-box-shadow:0 0 6px #CCC;box-shadow:0 0 6px #CCC;...

}...

Page 19: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

$shadow($x,$y,$s,$c){-webkit-box-shadow:$x $y $s $c;-moz-box-shadow:$x $y $s $c;box-shadow:$x $y $s $c;

}

Page 20: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

$shadow($x,$y,$s,$c){-webkit-box-shadow:$x $y $s $c;-moz-box-shadow:$x $y $s $c;box-shadow:$x $y $s $c;

}

.mod1 {…

$shadow(0,0,5px,”#999”);…

}.mod2 {

$shadow(0,0,8px,”#ccc”);…

}

Page 21: 孙极-Hello, JSS! - 一种新样式语言的诞生

函数

定义函数:$func(){

color:#ccc;}

Page 22: 孙极-Hello, JSS! - 一种新样式语言的诞生

函数

定义函数:$func($a,$b,$c){

color:$a;background:$b;font-size:$c;

}

Page 23: 孙极-Hello, JSS! - 一种新样式语言的诞生

函数

定义函数:$func($a=“#ccc”,$b=“#000”,$c=12px){

color:$a;background:$b;font-size:$c;

}

Page 24: 孙极-Hello, JSS! - 一种新样式语言的诞生

函数

使用函数:div{

$func();}

Page 25: 孙极-Hello, JSS! - 一种新样式语言的诞生

函数

使用函数:div{

$func(“#000”,$string1)}

Page 26: 孙极-Hello, JSS! - 一种新样式语言的诞生

分组

Page 27: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

table th,table td{...}

Page 28: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

.parent>.child1,

.parent>.child2{...}

Page 29: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

.link1:hover,

.link1:active,

.link2:hover,

.link2:active{...}

Page 30: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

table (th,td) {...}

Page 31: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

.parent>(.child1,.child2) {...}

Page 32: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

(.link1,.link2):(hover,active) {...}

Page 33: 孙极-Hello, JSS! - 一种新样式语言的诞生

封装

Page 34: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

.mod .hd{...}

.mod .bd{...}

.mod .bd p{...}

.mod .bd table{...}

.mod .ft{...}

Page 35: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

.mod_hd{...}

.mod_bd{...}

.mod_bd p{...}

.mod_bd table{...}

.mod_ft{...}

Page 36: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

.mod[[.hd{...}.bd[[

p{...}table{...}

]].ft{...}

]]

Page 37: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

.mod[[_hd{...}_bd[[

p{...}table{...}

]]_ft{...}

]]

Page 38: 孙极-Hello, JSS! - 一种新样式语言的诞生

Hack

Page 39: 孙极-Hello, JSS! - 一种新样式语言的诞生

CSS

div{+width:10px;-width:12px;?

}

Page 40: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

div{-ie7-width:10px;-wk-width:15px;-!ie-width:18px;-?sunji-width:20px;...

}

Page 41: 孙极-Hello, JSS! - 一种新样式语言的诞生

继承

Page 42: 孙极-Hello, JSS! - 一种新样式语言的诞生

.mod

.newMod

class=“mod newMod”

CSS

Page 43: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

.newMod,

.mod[[...

]]

Page 44: 孙极-Hello, JSS! - 一种新样式语言的诞生

JSS

$mod($s){$s{...}($s) p{...}

}

$mod (“.mod,.newMod”);

Page 45: 孙极-Hello, JSS! - 一种新样式语言的诞生

vs. SassLess

Page 46: 孙极-Hello, JSS! - 一种新样式语言的诞生

举个栗子

Page 47: 孙极-Hello, JSS! - 一种新样式语言的诞生

谢谢 !classtyle.com/jss