-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Theme setup] Initial setup and Accordion example #436
Merged
michaeljaltamirano
merged 9 commits into
epic/add-theming-functionality
from
theme-setup-1
Oct 27, 2020
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
74c7b6c
initial setup
daigof fa6e987
convert Acoordion,add theme suport to stories
daigof 90394d5
complete accordion example
daigof 55d8d58
shouldShowForEnvironment refactor
daigof 1325877
commit snapshot size
daigof 94a3429
Merge branch 'master' into theme-setup-1
michaeljaltamirano 303f3af
v13.0.0-alpha.1
michaeljaltamirano 75fa067
Merge branch 'master' into theme-setup-1
michaeljaltamirano f6e6a91
Replace swap button with addon-toolbars to fix visual regression
michaeljaltamirano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,60 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
import COLORS from '.'; | ||
|
||
const PRIMARY_COLORS = { | ||
// brand colors | ||
primary: COLORS.purple100, | ||
primaryTint1: COLORS.purple85, | ||
primaryTint2: COLORS.purple70, | ||
primaryTint3: COLORS.purple30, | ||
secondary: COLORS.lavender100, | ||
tertiary: COLORS.purple4, | ||
|
||
// general colors | ||
success: COLORS.statusGreen, | ||
successBackground: COLORS.statusGreenBackground, | ||
successBorder: COLORS.statusGreenBorder, | ||
info: COLORS.statusPurple, | ||
infoBackground: COLORS.statusPurpleBackground, | ||
infoBorder: COLORS.statusPurpleBorder, | ||
error: COLORS.statusRed, | ||
errorBackground: COLORS.statusRedBackground, | ||
errorBorder: COLORS.statusRedBorder, | ||
default: COLORS.purple70, | ||
defaultBackground: COLORS.purple10, | ||
defaultBorder: COLORS.purple15, | ||
accent: COLORS.red, | ||
disabled: COLORS.purple10, | ||
failure: COLORS.red, | ||
hover: COLORS.purple4, | ||
warning: COLORS.yellowLight, | ||
|
||
// ui colors | ||
background: COLORS.purple4, | ||
backgroundDark: COLORS.purple4, | ||
border: COLORS.purple10, | ||
divider: COLORS.purple10, | ||
|
||
// form colors | ||
radioBorder: COLORS.purple30, | ||
radioBorderSelected: COLORS.lavender100, | ||
|
||
// typography | ||
textMuted: COLORS.purple70, | ||
textGhost: COLORS.purple30, | ||
textDisabled: COLORS.purple30, | ||
|
||
// overlay | ||
overlay: 'rgba(45, 45, 48, 0.7)', | ||
overlaySolid: 'rgba(45, 45, 48, 1)', | ||
|
||
black: COLORS.black, | ||
white: COLORS.white, | ||
}; | ||
|
||
export const PRIMARY_COLORS_PROP_TYPES = PropTypes.oneOf( | ||
Object.values(PRIMARY_COLORS), | ||
); | ||
|
||
export default PRIMARY_COLORS; |
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,60 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
import COLORS from '.'; | ||
|
||
const SECONDARY_COLORS = { | ||
// brand colors | ||
primary: '#4c0000', | ||
primaryTint1: '#b20000', | ||
primaryTint2: null, | ||
primaryTint3: '#ff0000', | ||
secondary: '#ff8000', | ||
tertiary: null, | ||
|
||
// general colors | ||
success: null, | ||
successBackground: null, | ||
successBorder: null, | ||
info: null, | ||
infoBackground: null, | ||
infoBorder: null, | ||
error: null, | ||
errorBackground: null, | ||
errorBorder: null, | ||
default: null, | ||
defaultBackground: null, | ||
defaultBorder: null, | ||
accent: null, | ||
disabled: null, | ||
failure: null, | ||
hover: null, | ||
warning: null, | ||
|
||
// ui colors | ||
background: null, | ||
backgroundDark: null, | ||
border: null, | ||
divider: null, | ||
|
||
// form colors | ||
radioBorder: null, | ||
radioBorderSelected: null, | ||
|
||
// typography | ||
textMuted: null, | ||
textGhost: null, | ||
textDisabled: null, | ||
|
||
// overlay | ||
overlay: null, | ||
overlaySolid: null, | ||
|
||
black: COLORS.black, | ||
white: COLORS.white, | ||
}; | ||
|
||
export const SECONDARY_COLORS_PROP_TYPES = PropTypes.oneOf( | ||
Object.values(SECONDARY_COLORS), | ||
); | ||
|
||
export default SECONDARY_COLORS; |
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,10 @@ | ||
import PRIMARY_COLORS from './primary'; | ||
import SECONDARY_COLORS from './secondary'; | ||
|
||
describe('theme colors', () => { | ||
it('primary and secondary colors have the same number of properties', () => { | ||
expect(Object.keys(PRIMARY_COLORS).length).toEqual( | ||
Object.keys(SECONDARY_COLORS).length, | ||
); | ||
}); | ||
}); |
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,2 @@ | ||
export { default as primaryTheme } from './primary'; | ||
export { default as secondaryTheme } from './secondary'; |
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,9 @@ | ||
import PRIMARY_COLORS from '../colors/primary'; | ||
|
||
const primaryTheme = { | ||
__type: 'primary', | ||
BOX_SHADOW: {}, | ||
COLORS: PRIMARY_COLORS, | ||
} as const; | ||
|
||
export default primaryTheme; |
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,9 @@ | ||
import SECONDARY_COLORS from '../colors/secondary'; | ||
|
||
const secondaryTheme = { | ||
__type: 'secondary', | ||
BOX_SHADOW: {}, | ||
COLORS: SECONDARY_COLORS, | ||
} as const; | ||
|
||
export default secondaryTheme; |
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,13 @@ | ||
import { primaryTheme, secondaryTheme } from '.'; | ||
|
||
type BoxShadow = | ||
| typeof primaryTheme['BOX_SHADOW'] | ||
| typeof secondaryTheme['BOX_SHADOW']; | ||
|
||
type Colors = typeof primaryTheme['COLORS'] | typeof secondaryTheme['COLORS']; | ||
|
||
export type ThemeType = { | ||
__type: 'primary' | 'secondary'; | ||
BOX_SHADOW: BoxShadow; | ||
COLORS: Colors; | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daigof I removed the
swap theme
button because updating the global styles caused all of the stories are render with additional padding: https://www.chromatic.com/snapshot?appId=5f6e46f1e7081000221523cf&id=5f9857317557760022517a76Decided to use
@storybook/addon-toolbars
for a more built-in solution.