Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit efcdda3

Browse files
committed
Merge branch 'pages' into dev
2 parents d24ba67 + 8ad34b0 commit efcdda3

File tree

17 files changed

+62
-43
lines changed

17 files changed

+62
-43
lines changed

components/ThemeSelector/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import React from 'react'
88
import PropTypes from 'prop-types'
9+
import R from 'ramda'
910

1011
import { ICON_CMD } from '../../config'
1112

@@ -22,14 +23,15 @@ import {
2223
AuthorName,
2324
} from './style'
2425

25-
import { makeDebugger, themeKeys, themeMeta, uid } from '../../utils'
26+
import { makeDebugger, themeMeta, uid } from '../../utils'
27+
2628
/* eslint-disable no-unused-vars */
2729
const debug = makeDebugger('c:ThemeSelector:index')
2830
/* eslint-enable no-unused-vars */
2931

3032
const DotStyle = ({ curTheme, changeTheme }) => (
3133
<FlexWrapper>
32-
{themeKeys.map(name => (
34+
{R.keys(themeMeta).map(name => (
3335
<ThemeDot
3436
key={uid.gen()}
3537
active={curTheme === name}
@@ -42,7 +44,7 @@ const DotStyle = ({ curTheme, changeTheme }) => (
4244

4345
const DetailStyle = ({ curTheme, changeTheme }) => (
4446
<DetailWrapper>
45-
{themeKeys.map(name => (
47+
{R.keys(themeMeta).map(name => (
4648
<IntroBox key={uid.gen()} active={curTheme === name}>
4749
<ThemeDot
4850
large

config/general.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
general behavior of the site
33
*/
44

5+
export const DEFAULT_THEME = 'cyan'
6+
57
export const PAGE_SIZE = {
68
S: 10,
79
D: 20,

config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { PAGE_SIZE, WORD_LIMIT, TAG_COLORS } from './general'
1+
export { DEFAULT_THEME, PAGE_SIZE, WORD_LIMIT, TAG_COLORS } from './general'
22
export {
33
GRAPHQL_ENDPOINT,
44
ISSUE_ADDR,

stores/RootStore/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
markStates,
1212
toast,
1313
toastBarColor,
14-
themeDict,
14+
themeSkins,
1515
} from '../../utils'
1616

1717
import {
@@ -229,7 +229,7 @@ const rootStore = t
229229
self.footer.sponsorHepler()
230230
},
231231
toast(type, options = {}) {
232-
const themeData = themeDict[self.theme.curTheme]
232+
const themeData = themeSkins[self.theme.curTheme]
233233
const progressBarColor = toastBarColor(type, themeData)
234234

235235
const toastOpt = R.merge(options, { progressBarColor })

stores/ThemeStore/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,33 @@
66
import { types as t, getParent } from 'mobx-state-tree'
77
import R from 'ramda'
88

9-
import { makeDebugger, markStates, themeDict, defaultTheme } from '../../utils'
9+
import { DEFAULT_THEME } from '../../config'
10+
import { makeDebugger, markStates, themeSkins } from '../../utils'
1011

1112
/* eslint-disable no-unused-vars */
1213
const debug = makeDebugger('S:ThemeStore')
1314
/* eslint-enable no-unused-vars */
1415

1516
export const ThemeDefaults = {
16-
curTheme: defaultTheme,
17+
curTheme: DEFAULT_THEME,
1718
}
1819

1920
export const ThemeStore = t
2021
.model('ThemeStore', {
2122
curTheme: t.optional(
22-
t.enumeration('theme', R.keys(themeDict)),
23-
defaultTheme
23+
t.enumeration('theme', R.keys(themeSkins)),
24+
DEFAULT_THEME
2425
),
2526
})
2627
.views(self => ({
2728
get root() {
2829
return getParent(self)
2930
},
3031
get themeData() {
31-
return themeDict[self.curTheme]
32+
return themeSkins[self.curTheme]
3233
},
3334
get themeKeys() {
34-
return R.keys(themeDict)
35+
return R.keys(themeSkins)
3536
},
3637
}))
3738
.actions(self => ({

utils/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ export {
8989
*/
9090
export {
9191
theme,
92-
defaultTheme,
9392
themeMeta,
94-
themeDict,
95-
themeKeys,
93+
themeSkins,
9694
themeCoverMap,
9795
themeCoverIndexMap,
9896
} from './themes'

utils/themes/index.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,16 @@
1212
*/
1313

1414
import R from 'ramda'
15+
import skinsData from './skins'
1516

16-
import Cyan from './Cyan'
17-
import Purple from './Purple'
18-
import SolarizedDark from './SolarizedDark'
19-
import Github from './Github'
20-
import Blue from './Blue'
21-
import Yellow from './Yellow'
22-
import Green from './Green'
23-
import IronGreen from './IronGreen'
17+
export const themeSkins = { ...skinsData }
2418

25-
export const defaultTheme = 'cyan'
26-
export const themeDict = {
27-
cyan: { ...Cyan },
28-
solarized: { ...SolarizedDark },
29-
purple: { ...Purple },
30-
yellow: { ...Yellow },
31-
github: { ...Github },
32-
blue: { ...Blue },
33-
green: { ...Green },
34-
ironGreen: { ...IronGreen },
35-
}
19+
// cover color of a theme
20+
export const themeCoverMap = R.map(R.path(['cover']), themeSkins)
21+
// the "T" color in themeSelector
22+
export const themeCoverIndexMap = R.map(R.path(['coverIndex']), themeSkins)
3623

37-
export const themeKeys = R.keys(themeDict)
38-
39-
export const themeCoverMap = R.map(R.path(['cover']), themeDict)
40-
export const themeCoverIndexMap = R.map(R.path(['coverIndex']), themeDict)
41-
42-
// shorthand for style-components
24+
// curried shorthand for style-components
4325
export const theme = themepath =>
4426
R.path(['theme', ...R.split('.', themepath)]) || 'wheat'
4527

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)