-
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
[POC] Emotion Theming #382
Changes from all commits
ab6f7ec
dea7c1d
9f06fb0
effe460
bc85a62
f316d78
b358d77
cdbe9d1
e8af052
d478afa
c6ab095
0984474
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,9 +128,10 @@ | |
"yarn-run-all": "^3.1.1" | ||
}, | ||
"dependencies": { | ||
"@emotion/core": "^10.0.35", | ||
"@emotion/styled": "^10.0.27", | ||
"@emotion/core": "10.0.35", | ||
"@emotion/styled": "10.0.27", | ||
"@react-aria/focus": "^3.0.2", | ||
"emotion-theming": "10.0.27", | ||
"lodash.round": "^4.0.4", | ||
"lodash.throttle": "^4.1.1", | ||
"lodash.uniqueid": "^4.0.1", | ||
|
@@ -146,6 +147,7 @@ | |
"peerDependencies": { | ||
"@emotion/core": "10.0.35", | ||
"@emotion/styled": "10.0.27", | ||
"emotion-theming": "10.0.27", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've run into compatibility issues in the past in applications that use our library if there's an It's higher maintenance to handle it this way but I think it is worth the small cost. |
||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
}, | ||
|
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; |
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: null, | ||
primaryTint1: '#000000', | ||
primaryTint2: null, | ||
primaryTint3: '#cccccc', | ||
secondary: '#414a4c', | ||
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; |
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, | ||
); | ||
}); | ||
}); |
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'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import PRIMARY_COLORS from '../colors/primary'; | ||
|
||
export default { | ||
__type: 'primary', | ||
BOX_SHADOW: {}, | ||
COLORS: PRIMARY_COLORS, | ||
} as const; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SECONDARY_COLORS from '../colors/secondary'; | ||
|
||
export default { | ||
__type: 'secondary', | ||
BOX_SHADOW: {}, | ||
COLORS: SECONDARY_COLORS, | ||
} as const; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import primaryTheme from './primary'; | ||
import secondaryTheme from './secondary'; | ||
|
||
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; | ||
}; |
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.
We will have to update our Usage documentation to note that all applications using
radiance-ui
need to set up aThemeProvider
at the top level of their App--or at least at the highest-level that makes use ofradiance-ui
components: https://emotion.sh/docs/theming