This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Checkbox color updates & Extending theme based styling to varia…
…nts (#46) * Allow for color props for CheckboxGroup * Modify to support better nested styling * Update to support another style syntax, Address feedback * Major version bump * Revert "Major version bump" This reverts commit fba7a2b. * Remove extra pattern * Add toplevel styles instead of components * Add util tests
- Loading branch information
1 parent
fada878
commit 6f3569f
Showing
5 changed files
with
118 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`#utils #getComponentStyle should return top-level component style from theme 1`] = ` | ||
" | ||
background-color: tomato; | ||
" | ||
`; | ||
|
||
exports[`#utils #getComponentVariant should return primary variant from theme 1`] = ` | ||
Object { | ||
"style": " | ||
background-color: blue; | ||
", | ||
} | ||
`; | ||
|
||
exports[`#utils #getComponentVariant should throw error if variant not found 1`] = `[Error: Molekule: "foobar" variant not found in theme...]`; | ||
|
||
exports[`#utils #getVariantStyles should return variant style for component from theme 1`] = ` | ||
" | ||
background-color: blue; | ||
" | ||
`; | ||
|
||
exports[`#utils #themeGet should fallback when theme config not found 1`] = ` | ||
Object { | ||
"primary": Object { | ||
"style": "background-color: green", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`#utils #themeGet should return theme config 1`] = ` | ||
Object { | ||
"primary": Object { | ||
"style": " | ||
background-color: blue; | ||
", | ||
}, | ||
} | ||
`; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { getComponentStyle, getVariantStyles, getComponentVariant, themeGet } from './utils'; | ||
|
||
const MOCK_THEME = { | ||
variants: { | ||
Element: { | ||
primary: { | ||
style: ` | ||
background-color: blue; | ||
`, | ||
}, | ||
}, | ||
}, | ||
styles: { | ||
Element: ` | ||
background-color: tomato; | ||
`, | ||
}, | ||
}; | ||
|
||
describe('#utils', () => { | ||
describe('#themeGet', () => { | ||
it('should return theme config', () => { | ||
expect(themeGet('variants.Element')({ theme: MOCK_THEME })).toMatchSnapshot(); | ||
}); | ||
|
||
it('should fallback when theme config not found', () => { | ||
expect( | ||
themeGet('variants.foobar', { primary: { style: `background-color: green` } })({ theme: MOCK_THEME }) | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('#getComponentVariant', () => { | ||
it('should return primary variant from theme', () => { | ||
expect(getComponentVariant(MOCK_THEME, 'Element', 'primary')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should throw error if variant not found', () => { | ||
try { | ||
getComponentVariant(MOCK_THEME, 'Element', 'foobar'); | ||
} catch (error) { | ||
expect(error).toMatchSnapshot(); | ||
} | ||
}); | ||
}); | ||
|
||
describe('#getComponentStyle', () => { | ||
it('should return top-level component style from theme', () => { | ||
expect(getComponentStyle('Element')({ theme: MOCK_THEME })).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('#getVariantStyles', () => { | ||
it('should return variant style for component from theme', () => { | ||
expect(getVariantStyles('Element', 'primary')({ theme: MOCK_THEME })).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |