1- // ================================================================================
21//
32// Name: Material Shadows
43// Description: Paper shadows of material design.
5- // Version: 1 .0.1
4+ // Version: 2 .0.0
65//
76// Author: Denis Malinochkin
87// Git: https://github.com/mrmlnc/material-shadows
98//
109// twitter: @mrmlnc
1110//
12- // ================================================================================
13-
14- // Settings
15- // --------------------------------------------------------------------------------
16-
17- @md-z-depth-css : false;
18- @md-z-depth-animation : true ;
19- @md-z-depth-animation-time : .28s ;
20- @md-z-depth-animation-function : cubic-bezier (.4 , 0 , .2 , 1 );
21-
22-
23-
24- // Shadows
25- // --------------------------------------------------------------------------------
26-
27- // md-z-depth-1
28- @md-z-depth-1-top : 0 2px 10px 0 rgba (0 , 0 , 0 , 0.16 );
29- @md-z-depth-1-bottom : 0 2px 5px 0 rgba (0 , 0 , 0 , 0.26 );
30-
31- // md-z-depth-2
32- @md-z-depth-2-top : 0 6px 20px 0 rgba (0 , 0 , 0 , 0.19 );
33- @md-z-depth-2-bottom : 0 8px 17px 0 rgba (0 , 0 , 0 , 0.2 );
34-
35- // md-z-depth-3
36- @md-z-depth-3-top : 0 17px 50px 0 rgba (0 , 0 , 0 , 0.19 );
37- @md-z-depth-3-bottom : 0 12px 15px 0 rgba (0 , 0 , 0 , 0.24 );
38-
39- // md-z-depth-4
40- @md-z-depth-4-top : 0 25px 55px 0 rgba (0 , 0 , 0 , 0.21 );
41- @md-z-depth-4-bottom : 0 16px 28px 0 rgba (0 , 0 , 0 , 0.22 );
42-
43- // md-z-depth-5
44- @md-z-depth-5-top : 0 40px 77px 0 rgba (0 , 0 , 0 , 0.22 );
45- @md-z-depth-5-bottom : 0 27px 24px 0 rgba (0 , 0 , 0 , 0.2 );
46-
11+ // ------------------------------------
4712
4813
4914// Mixins
50- // --------------------------------------------------------------------------------
51-
52- // Top & Bottom
53- .md-z-depth (@depth : 1 ) {
54- box-shadow : ~ " @{md-z-depth-@{depth} -bottom}, @{md-z-depth-@{depth} -top}" ;
55- }
15+ // ------------------------------------
5616
57- // Top
17+ // Generator for top shadow
5818.md-z-depth-top (@depth : 1 ) {
59- box-shadow : ~ " @{md-z-depth-@{depth} -top}" ;
19+ @color : .12 , .19 , .19 , .21 , .22 ;
20+ @offset-y : 2px , 6px , 17px , 25px , 40px ;
21+ @blur : 10px , 20px , 50px , 55px , 77px ;
22+
23+ box-shadow + : 0 extract (@offset-y , @depth ) extract (@blur , @depth ) rgba (0 , 0 , 0 , extract(@color , @depth));
6024}
6125
62- // Bottom
26+ // Generator for bottom shadow
6327.md-z-depth-bottom (@depth : 1 ) {
64- box-shadow : ~ " @{md-z-depth-@{depth} -bottom}" ;
28+ @color : .16 , .2 , .24 , .22 , .2 ;
29+ @offset-y : 2px , 8px , 12px , 16px , 27px ;
30+ @blur : 5px , 17px , 15px , 28px , 24px ;
31+
32+ box-shadow + : 0 extract (@offset-y , @depth ) extract (@blur , @depth ) rgba (0 , 0 , 0 , extract(@color , @depth));
6533}
6634
67- // Animation
68- .md-z-depth-animation (@depth-after , @depth-orientation : full) {
35+ // Generator for top and bottom shadow
36+ .md-z-depth (@depth : 1 ) {
37+ .md-z-depth-bottom (@depth );
38+ .md-z-depth-top (@depth );
39+ }
40+
41+ // Generator animation hover and focus effect
42+ .md-z-depth-animation (@depth , @orientation : full) {
6943 & :hover ,
7044 & :focus {
71- & when (@depth- orientation = full) {
72- .md-z-depth (@depth-after );
45+ & when (@orientation = full) {
46+ .md-z-depth (@depth );
7347 }
7448
75- & when (@depth- orientation = top ) {
76- .md-z-depth-top (@depth-after );
49+ & when (@orientation = top ) {
50+ .md-z-depth-top (@depth );
7751 }
7852
79- & when (@depth- orientation = bottom ) {
80- .md-z-depth-bottom (@depth-after );
53+ & when (@orientation = bottom ) {
54+ .md-z-depth-bottom (@depth );
8155 }
8256 }
8357}
8458
85- // Class generator - .md-z-depth-*
86- .md-generate-depth (@i : 1 , @count ) when (@i =< @count ) {
87- &-z @{i} {
88- .md-z-depth (@i );
8959
90- &-top {
91- .md-z-depth-top ( @i );
92- }
60+ // Classes
61+ // ------------------------------------
62+ .md-z-depth-class ( @animation : true , @time : .28 s , @function : cubic-bezier ( .4 , 0 , .2 , 1 )) {
9363
94- &-bottom {
95- .md-z- depth-bottom (@i );
96- }
97- }
64+ // Generator for shadow classes
65+ .generate- depth-class (@i : 1 , @count ) when ( @i =< @count ) {
66+ &- @{i} {
67+ .md-z-depth ( @i );
9868
99- .md-generate-depth (@i + 1 , @count );
100- }
69+ &-top {
70+ .md-z-depth-top (@i );
71+ }
72+
73+ &-bottom {
74+ .md-z-depth-bottom (@i );
75+ }
76+ }
10177
78+ .generate-depth-class (@i + 1 , @count );
79+ }
10280
81+ .generate-depth-class (1 , 5 );
10382
104- // Classes
105- // --------------------------------------------------------------------------------
106-
107- .md-z-depth when (@md-z-depth-css = true ) {
108- .md-generate-depth (1 , 5 );
109-
110- // md-z-depth-animation
111- &-animation when (@md-z-depth-animation = true ) {
112- & :hover {
113- .md-z-depth-z1 ,
114- .md-z-depth-z2 ,
115- .md-z-depth-z3 ,
116- .md-z-depth-z4 ,
117- .md-z-depth-z5 {
118- transition : box- shadow @md-z-depth-animation-time @md-z-depth-animation-function ;
119- }
83+ // z-depth-animation
84+ &-animation when (@animation = true ) {
85+ .z-depth-1 ,
86+ .z-depth-2 ,
87+ .z-depth-3 ,
88+ .z-depth-4 ,
89+ .z-depth-5 {
90+ transition : box- shadow @time @function ;
12091 }
12192 }
122- }
93+ }
0 commit comments