Skip to content

Commit

Permalink
feat(🎨 Themes): Added success and warning colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
artalat committed Apr 22, 2019
1 parent 9364013 commit 82473d9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/getComponent.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`getComponent should render a button component 1`] = `
"paddingTop": 8,
},
Object {
"backgroundColor": "#fafafa",
"backgroundColor": "#f5f5f5",
},
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`Button should render Button with custom children 1`] = `
"paddingTop": 8,
},
Object {
"backgroundColor": "#fafafa",
"backgroundColor": "#f5f5f5",
},
Object {
"alignSelf": "stretch",
Expand Down Expand Up @@ -76,7 +76,7 @@ exports[`Button should render Button with default color styles 1`] = `
"paddingTop": 8,
},
Object {
"backgroundColor": "#fafafa",
"backgroundColor": "#f5f5f5",
},
]
}
Expand Down Expand Up @@ -132,7 +132,7 @@ exports[`Button should render Button with full width 1`] = `
"paddingTop": 8,
},
Object {
"backgroundColor": "#fafafa",
"backgroundColor": "#f5f5f5",
},
Object {
"alignSelf": "stretch",
Expand Down Expand Up @@ -337,7 +337,7 @@ exports[`Button should use TouchableNativeFeedback on android platform 1`] = `
styles={
Object {
"default": Object {
"backgroundColor": "#fafafa",
"backgroundColor": "#f5f5f5",
},
"defaultText": Object {},
"fullWidth": Object {
Expand Down
6 changes: 3 additions & 3 deletions src/themes/__tests__/ThemeContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('ThemeContext', () => {
setTimeout(() => {
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
expect((tree as any).props.style.backgroundColor).toBe('#fafafa');
expect((tree as any).props.style.backgroundColor).toBe('#f5f5f5');
done();
});
});
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('ThemeContext', () => {

// Check theme
let view = wrapper.find('ThemeDemo').childAt(0).first();
expect((view.prop('style') as any).backgroundColor).toBe('#fafafa');
expect((view.prop('style') as any).backgroundColor).toBe('#f5f5f5');
expect(wrapper.find('ThemeDemo').find('Text').last().text()).toBe('BlueBase Light');

// Change theme
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('ThemeContext', () => {

// Check theme
const view = wrapper.find('ThemeDemo').childAt(0).first();
expect((view.prop('style') as any).backgroundColor).toBe('#fafafa');
expect((view.prop('style') as any).backgroundColor).toBe('#f5f5f5');
expect(wrapper.find('ThemeDemo').find('Text').last().text()).toBe('BlueBase Light');

// Check Subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`ThemeContext should render a ThemeDemo component with themed background
<View
style={
Object {
"backgroundColor": "#fafafa",
"backgroundColor": "#f5f5f5",
"padding": 8,
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/themes/helpers/createPalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export const light = {
*/
background: {
card: '#ffffff',
default: '#fafafa',
default: '#f5f5f5',
light: '#fafafa',
dark: '#eeeeee',
},

/** The colors used to style the action elements. */
Expand Down Expand Up @@ -55,6 +57,8 @@ export const dark = {
background: {
card: '#424242',
default: '#303030',
light: '#404040',
dark: '#202020',
},
action: {
active: '#ffffff',
Expand Down Expand Up @@ -85,6 +89,18 @@ const common = {
light: '#ff4081',
main: '#f50057',
},
success: {
contrastText: '#fff',
dark: '#388e3c',
light: '#81c784',
main: '#4caf50',
},
warning: {
contrastText: '#fff',
dark: '#ffa000',
light: '#ffd54f',
main: '#ffc107',
},
};

export function createPalette(mode: 'light' | 'dark') {
Expand Down
11 changes: 11 additions & 0 deletions src/themes/structure/Palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export interface TypeAction {

export interface TypeBackground {
default: string;

/** Lighter shade of background */
light: string;

/** Darker share of background */
dark: string;

card: string;
}

Expand All @@ -32,6 +39,8 @@ export type TypeDivider = string;
export interface Palette {
primary: PaletteColor;
secondary: PaletteColor;
success: PaletteColor;
warning: PaletteColor;
error: PaletteColor;
action: TypeAction;
divider: TypeDivider;
Expand All @@ -42,6 +51,8 @@ export interface Palette {
export interface PaletteInput {
primary?: Partial<PaletteColor>;
secondary?: Partial<PaletteColor>;
success?: Partial<PaletteColor>;
warning?: Partial<PaletteColor>;
error?: Partial<PaletteColor>;
action?: Partial<TypeAction>;
divider?: TypeDivider;
Expand Down

0 comments on commit 82473d9

Please sign in to comment.