2016-05-18 81 views
2

我正在使用sass調色板,我想知道如何使此功能可用於多個調色板。Sass函數調用多個調色板

現在我可以用這個功能1調色板,如何使這個功能適用於多個調色板?

@function palette($palette, $shade: 'base') { 
    @return map-get(map-get($color-palettes, $palette), $shade); 
} 



$primary-palette: (
    grey: (
     xx-light : lighten($grey, 43%), 
     x-light : lighten($grey, 35%), 
     light : lighten($grey, 6%), 
     base  : $grey, 
     dark  : darken($grey, 8%), 
     x-dark : darken($grey, 16%) 
    ), 
); 

//將是我的中學paletter在CSS

body { 
    background-color: palette(grey,dark); 
} 

有人能幫助應用

$secondary-palette: (
      black: (
       light : lighten($grey, 6%), 
       base  : $grey, 
       dark  : darken($grey, 8%), 
       x-dark : darken($grey, 16%) 
      ), 
     ); 

?謝謝

回答

0

我以前沒有做過這樣的事情,但它看起來非常強大。我做了一些搜索和this article seems to suggest you'd put the black palette within $primary-palette as well,只有一組主調色板。

從帖子:

$colors: (
    blue: (
    0: hsl(198, 74%, 49%), 
    1: hsl(200, 72%, 61%), 
    2: hsl(200, 71%, 73%), 
    [...] 
), 
    red: (
    0: hsl(3, 72%, 62%), 
    1: hsl(4, 85%, 66%), 
    2: hsl(4, 84%, 78%), 
    [...] 
) 
) 


@function get-color($color, $value: 0) { 
    @return map-get(map-get($colors, $color), $value); 
} 


.button--blue{ 
    color: get-color(blue, 0); 
    background: get-color(blue, 4); 
    &:hover{ 
    background: get-color(blue, 3); 
    } 
} 
+0

順便說一句,我真的需要嘗試了這一點。我想我在文檔中看到過它,但最初被嚇倒了。電力用戶的東西。 – alexbea