Skip to content

Commit

Permalink
Update readme, remove color === false check
Browse files Browse the repository at this point in the history
  • Loading branch information
colepeters committed Mar 25, 2024
1 parent 7279059 commit 9d4fb67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ Theme scales are intended to give you enough colors for all use cases including
--primary-900: hsl(212, 74.7%, 8%);
```

### Opting out of theme styles

The classes and custom properties generated by the `theme` configuration are optional, and can be excluded by setting the `theme` property in your styleguide to `false`:

```json
{
"theme": false
}
```

### `color`
`color` is for one off spot colors. Colors must be specified as hexidecimal and can be named however you like. For example:

Expand Down
10 changes: 2 additions & 8 deletions test/themeColor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@ import test from 'tape'

import themeColor from '../theme-color.mjs'

const noThemeColor = {
theme: false,
color: false,
}

const noTheme = {
theme: false
}

const noColor = {
color: false
color: {}
}

test('themeColor', t => {
t.equal(themeColor({ config: noThemeColor }), '', 'should emit an empty string when `config.theme` and `config.color` are both `false`')
t.notOk(themeColor({ config: noTheme }).includes('/*** Theme Colors ***/'), 'should not include theme colors when `config.theme` is `false`')
t.notOk(themeColor({ config: noColor }).includes('/*** Spot Colors ***/'), 'should not include spot colors when `config.color` is `false`')
t.notOk(themeColor({ config: noColor }).includes('/*** Spot Colors ***/'), 'should not include spot colors when `config.color` is empty')
t.end()
})
4 changes: 2 additions & 2 deletions theme-color.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import hextohsl from './hex-to-hsl.mjs'
export default function themeColor({ config }) {
const { color = {}, theme = {} } = config

if (color === false && theme === false) {
if (theme === false) {
return ''
}

Expand Down Expand Up @@ -137,7 +137,7 @@ ${grayScale}

let result = ``
if (theme !== false) result += themeStyles
if (color !== false && Object.keys(color).length) result += colorStyles
if (Object.keys(color).length) result += colorStyles

return result
}
Expand Down

0 comments on commit 9d4fb67

Please sign in to comment.