fix(theme): fix getInitialTheme helper

This commit is contained in:
George Lima 2019-02-20 11:59:57 -03:00
parent aeb44d62b8
commit 29dfa3988c
2 changed files with 10 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import { configureStore, history } from './redux/create';
import { Router } from './router/container';
import { appTheme as theme, GlobalStyle } from './theme';
import electronStore from '../config/electron-store';
import { DARK, THEME_MODE } from './constants/themes';
import { DARK, LIGHT, THEME_MODE } from './constants/themes';
const store = configureStore({});
@ -18,15 +18,19 @@ type State = {
themeMode: string,
};
const getInitialTheme = () => {
const themeInStore = String(electronStore.get(THEME_MODE));
if (themeInStore === DARK || themeInStore === LIGHT) return themeInStore;
return DARK;
};
export class App extends Component<Props, State> {
state = {
themeMode: electronStore.get(THEME_MODE) || DARK,
themeMode: getInitialTheme(),
};
componentDidMount() {
if (!electronStore.has(THEME_MODE)) {
electronStore.set(THEME_MODE, DARK);
}
electronStore.set(THEME_MODE, getInitialTheme());
electronStore.onDidChange(THEME_MODE, newValue => this.setState({ themeMode: newValue }));
}

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="125" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="125" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h91v20H0z"/><path fill="#4C1" d="M91 0h34v20H91z"/><path fill="url(#b)" d="M0 0h125v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,DejaVu Sans,Geneva,sans-serif" font-size="11"><text x="45.5" y="15" fill="#010101" fill-opacity=".3">flow-coverage</text><text x="45.5" y="14">flow-coverage</text><text x="107" y="15" fill="#010101" fill-opacity=".3">88%</text><text x="107" y="14">88%</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="125" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="125" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h91v20H0z"/><path fill="#4C1" d="M91 0h34v20H91z"/><path fill="url(#b)" d="M0 0h125v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,DejaVu Sans,Geneva,sans-serif" font-size="11"><text x="45.5" y="15" fill="#010101" fill-opacity=".3">flow-coverage</text><text x="45.5" y="14">flow-coverage</text><text x="107" y="15" fill="#010101" fill-opacity=".3">89%</text><text x="107" y="14">89%</text></g></svg>

Before

Width:  |  Height:  |  Size: 745 B

After

Width:  |  Height:  |  Size: 745 B