Skip to content

Commit c2cc692

Browse files
committed
refact: Restructure theme implementation
1 parent d765d9f commit c2cc692

File tree

6 files changed

+64
-44
lines changed

6 files changed

+64
-44
lines changed

config-overrides.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const {override, fixBabelImports, addLessLoader} = require('customize-cra');
2+
const Theme = require('./src/styles/theme');
23

34
module.exports = override(
45
fixBabelImports('import', {
@@ -9,22 +10,23 @@ module.exports = override(
910
addLessLoader({
1011
javascriptEnabled: true,
1112
modifyVars: {
12-
'@primary-color': '#6D15A1',
13-
'@link-color': '#30ADED',
14-
'@info-color': '#d9d9d9',
15-
'@success-color': '#B6F537',
16-
'@warning-color': '#faad14',
17-
'@heading-color': 'rgba(0, 0, 0, .85)',
18-
'@text-color': 'rgba(0, 0, 0, .65)',
19-
'@text-color-secondary': 'rgba(0, 0, 0, .45)',
20-
'@disabled-color': 'rgba(0, 0, 0, .25)',
21-
'@border-color-base': '#d9d9d9',
13+
'@primary-color': Theme.primary,
14+
'@link-color': Theme.link,
15+
'@info-color': Theme.info,
16+
'@success-color': Theme.success,
17+
'@warning-color': Theme.warning,
18+
'@error-color': Theme.error,
19+
'@heading-color': Theme.heading,
20+
'@text-color': Theme.text,
21+
'@text-color-secondary': Theme.textSecondary,
22+
'@disabled-color': Theme.disabled,
23+
'@border-color-base': Theme.borderBase,
2224

2325
// Layout
24-
'@layout-header-background': '#F0F2F5',
26+
'@layout-header-background': Theme.layoutHeaderBg,
2527

2628
// Menu
27-
'@menu-bg': '#F0F2F5'
28-
},
29+
'@menu-bg': Theme.menuBg,
30+
}
2931
}),
3032
);

src/styles/colors.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/styles/core/common.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import styled from 'styled-components';
2-
import color from '../colors';
2+
import Theme from '../theme';
33

44
export const H1 = styled.h1`
5-
color: ${color.textColor};
5+
color: ${Theme.textColor};
66
font-size: 48px;
77
`;
88

99
export const H2 = styled.h2`
10-
color: ${color.textColor};
10+
color: ${Theme.textColor};
1111
font-size: 42px;
1212
`;
1313

1414
export const H3 = styled.h3`
15-
color: ${color.textColor};
15+
color: ${Theme.textColor};
1616
font-size: 28px;
1717
`;
1818

1919
export const H4 = styled.h4`
20-
color: ${color.textColor};
20+
color: ${Theme.textColor};
2121
font-size: 16px;
22-
`;
22+
`;

src/styles/home/banner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import styled from 'styled-components';
22
import imgBanner from '../../assets/images/banner.jpg';
3-
import color from '../../styles/colors';
3+
import Theme from '../theme';
44

55
export const Banner = styled.div`
66
height: 400px;
77
width: 100%;
88
padding-top: 100px;
9-
background-image: linear-gradient(${color.primaryGradient}, ${color.secondaryGradient}), url(${imgBanner});
9+
background-image: linear-gradient(${Theme.gradientPrimary}, ${Theme.gradientSecondary}), url(${imgBanner});
1010
background-position: center center;
11-
`;
11+
`;

src/styles/home/featuredArtists.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import styled from 'styled-components';
2-
import color from '../../styles/colors';
2+
import Theme from '../theme';
33

44
export const FeaturedArtist = styled.div`
55
height: 400px;
66
width: 100%;
77
margin-top: 8px;
88
margin-bottom: 8px;
99
padding: 25px;
10-
background-image: linear-gradient(${color.primaryGradient}, ${color.secondaryGradient}), url(${require('../../assets/images/featured/1.jpg')});
10+
background-image: linear-gradient(${Theme.gradientPrimary}, ${Theme.gradientSecondary}), url(${require('../../assets/images/featured/1.jpg')});
1111
background-position: center center;
12-
`;
12+
`;

src/styles/theme.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
NOTE:
3+
Changes to *SOME* of these values will not take effect until you bootstrap webpack.
4+
Example when using yarn start, you must kill the process and run yarn start again!
5+
6+
This is due to the fact that this file is being used to modify Ant Design LESS variables
7+
via `modifyVars`.
8+
9+
See config-overrides.js
10+
Ref: https://ant.design/docs/react/use-with-create-react-app#Customize-Theme
11+
*/
12+
module.exports = {
13+
black: '#000',
14+
white: '#FFF',
15+
accentPrimary: '#FF0AD2',
16+
accentSecondary: '#1cedea',
17+
dark: '#060028',
18+
light: '#CCCCCC',
19+
text: '#131313',
20+
textSecondary: '#323232',
21+
primary: '#6C16A1',
22+
secondary: '#AB29A1',
23+
link: '#30ADED',
24+
info: '#d9d9d9',
25+
success: '#B6F537',
26+
warning: '#faad14',
27+
error: '#f5222d',
28+
heading: '#101010',
29+
disabled: '#575757',
30+
borderBase: '#d9d9d9',
31+
layoutHeaderBg: '#EDEAF5',
32+
menuBg: '#EDEAF5',
33+
34+
/* Gradients */
35+
gradientPrimary: 'rgba(230, 100, 101, 0.5)',
36+
gradientSecondary: 'rgba(145, 152, 229, 0.5)',
37+
};

0 commit comments

Comments
 (0)