Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from lee-chase/alpha-colors
Browse files Browse the repository at this point in the history
Alpha colors
  • Loading branch information
mbarlock committed Dec 16, 2015
2 parents 8be81cd + 56720b0 commit 7f54b50
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ With the color palette imported you will now have access to two functions:

Returns the specified color from the specified color palette

#### `color($palette, [$tone: 'core'])`
#### `color($palette, [$tone: 'core'], $alpha)`

```scss
//////////////////////////////////////////////////
Expand All @@ -34,13 +34,18 @@ Returns the specified color from the specified color palette
// |---------------|---------------|----------| //
// | Color Palette | String | Yes | //
// | Color Tone | String/Number | Optional | //
// | Color Alpha | Number | Optional | //
// ------------------------------------------ //
//////////////////////////////////////////////////

background: color('blue', 80); // #1d3649
background: color('blue', 8); // #1d3649
background: color('blue', 'core'); // #4178be
background: color('blue'); // #4178be
-- with an alpha
background: color('blue', 80, $alpha: 0.5); // rgba(29, 54, 73, 0.5)
background: color('blue', $alpha: 0.5); // rgba(65, 120, 190, 0.5)

```

### Color Tint
Expand Down
8 changes: 6 additions & 2 deletions _ibm-colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
//
// background: color('blue', 80); // #1d3649
// background: color('blue'); // #4178be
//
// background: color('blue', 80, $alpha: 0.5); // rgba(29, 54, 73, 0.5)
// background: color('blue', $alpha: 0.5); // rgba(65, 120, 190, 0.5)
//
//////////////////////////////
@function color($palette, $tone: 'core') {
@function color($palette, $tone: 'core', $alpha: 1) {
// Add a little helper so tone can be passed as single digit number
@if type-of($tone) == 'number' {
@if $tone % 10 == $tone {
Expand Down Expand Up @@ -43,7 +47,7 @@
$palette: 'warm-white';
}

@return map-get(map-get($__ibm-color-palettes, $palette), $tone);
@return rgba(map-get(map-get($__ibm-color-palettes, $palette), $tone), $alpha);
}

//////////////////////////////
Expand Down

0 comments on commit 7f54b50

Please sign in to comment.