Created
November 9, 2014 06:25
-
-
Save visioncan/d39f1d31f923754f14e1 to your computer and use it in GitHub Desktop.
模組裡 map merge 寫法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////// 版的css設定 | |
$list: ( | |
li:( | |
background-color: #fff | |
) | |
); | |
//////////////////////////////////// 模組scss ----------------------- | |
$list: () !default; | |
$list-defaults: ( | |
li: ( | |
color: red, | |
border: 1px solid #ccc | |
), | |
a: ( | |
display: block | |
) | |
); | |
//////////////////////////////////// 模組功能: | |
@function get($map, $select) { | |
@if map-has-key($map, $select) { | |
@return map-get($map, $select); | |
} @else { | |
@return (); | |
} | |
} | |
@mixin merge ($select, $defaults, $custom) { | |
$maps: map-merge(get($defaults, $select), get($custom, $select)); | |
@each $key, $val in $maps { | |
#{$key}: #{$val}; | |
} | |
} | |
@mixin product-list ($select) { | |
@include merge($select, $list-defaults, $list); | |
} | |
// 模組功能的css | |
ul.product-list li { | |
@include product-list(li); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment