Skip to content

Commit ed7dfe0

Browse files
authored
Merge pull request #33 from CodeDead/feature/theme-reset
Feature/theme reset
2 parents a04df05 + 3024a7e commit ed7dfe0

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ DeadHash is a free and open-source utility to calculate file and text hashes. Th
1919

2020
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and built using [Electron](https://electronjs.org/).
2121

22+
## Building
23+
24+
In order to produce binary distributable files or to start a development build, you must first issue the following command,
25+
in order to ensure that the React build is up-to-date:
26+
```
27+
yarn react-build
28+
```
29+
30+
After running `yarn react-build`, you can issue the following command in order to produce the binary distributable files:
31+
```
32+
yarn build
33+
```
34+
35+
If you want to start the development version, you can issue the following command, after running `yarn react-build`:
36+
```
37+
yarn start
38+
```
39+
2240
## Learn More
2341

2442
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

src/components/App/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles';
55
import Home from '../../routes/Home';
66
import Settings from '../../routes/Settings';
77
import ThemeSelector from '../../utils/ThemeSelector';
8-
import Topbar from '../Topbar';
8+
import TopBar from '../TopBar';
99
import About from '../../routes/About';
1010
import File from '../../routes/File';
1111
import Text from '../../routes/Text';
@@ -71,7 +71,7 @@ const App = () => {
7171
<ThemeProvider theme={theme}>
7272
<BrowserRouter>
7373
<DropZone enabled={enabled} onDrop={onDrop} reRoute="/file">
74-
<Topbar />
74+
<TopBar />
7575
<CssBaseline />
7676
<Switch>
7777
<Route path="/settings">
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const useStyles = makeStyles((theme) => ({
3737

3838
const { ipcRenderer } = window.require('electron');
3939

40-
const Drawerbar = ({ open, onClose }) => {
40+
const DrawerBar = ({ open, onClose }) => {
4141
const [state] = useContext(MainContext);
4242
const language = state.languages[state.languageIndex];
4343
const selectedItem = state.selectedListItem;
@@ -145,4 +145,4 @@ const Drawerbar = ({ open, onClose }) => {
145145
);
146146
};
147147

148-
export default Drawerbar;
148+
export default DrawerBar;
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import MenuIcon from '@material-ui/icons/Menu';
99
import Menu from '@material-ui/core/Menu';
1010
import MenuItem from '@material-ui/core/MenuItem';
1111
import CloseIcon from '@material-ui/icons/Close';
12+
import Brightness5Icon from '@material-ui/icons/Brightness5';
13+
import Brightness7Icon from '@material-ui/icons/Brightness7';
1214
import MinimizeIcon from '@material-ui/icons/Minimize';
1315
import FullScreenIcon from '@material-ui/icons/Fullscreen';
1416
import FullscreenExitIcon from '@material-ui/icons/FullscreenExit';
15-
import Drawerbar from '../Drawerbar';
16-
import { setLanguageIndex } from '../../reducers/MainReducer/Actions';
17+
import DrawerBar from '../DrawerBar';
18+
import { setLanguageIndex, setThemeStyle } from '../../reducers/MainReducer/Actions';
1719
import { MainContext } from '../../contexts/MainContextProvider';
1820

1921
const drawerWidth = 220;
@@ -45,11 +47,11 @@ const useStyles = makeStyles((theme) => ({
4547

4648
const { ipcRenderer } = window.require('electron');
4749

48-
const Topbar = () => {
50+
const TopBar = () => {
4951
const [state, d1] = useContext(MainContext);
5052

5153
const {
52-
languageIndex, minimizeEnabled, maximizeEnabled, languageEnabled,
54+
languageIndex, minimizeEnabled, maximizeEnabled, languageEnabled, themeStyle,
5355
} = state;
5456
const language = state.languages[languageIndex];
5557

@@ -124,6 +126,13 @@ const Topbar = () => {
124126
ipcRenderer.send('handle-maximize');
125127
};
126128

129+
/**
130+
* Change the theme style
131+
*/
132+
const changeThemeStyle = () => {
133+
d1(setThemeStyle(themeStyle === 'dark' ? 'light' : 'dark'));
134+
};
135+
127136
return (
128137
<div className={classes.root}>
129138
<AppBar
@@ -145,6 +154,10 @@ const Topbar = () => {
145154
{language.appName}
146155
</Typography>
147156

157+
<IconButton color="inherit" onClick={changeThemeStyle}>
158+
{themeStyle === 'dark' ? <Brightness5Icon /> : <Brightness7Icon />}
159+
</IconButton>
160+
148161
{languageEnabled
149162
? (
150163
<div>
@@ -264,10 +277,10 @@ const Topbar = () => {
264277
</IconButton>
265278
</Toolbar>
266279
</AppBar>
267-
<Drawerbar open={drawerOpen} onClose={() => setDrawerOpen(false)} />
280+
<DrawerBar open={drawerOpen} onClose={() => setDrawerOpen(false)} />
268281
<Toolbar />
269282
</div>
270283
);
271284
};
272285

273-
export default Topbar;
286+
export default TopBar;

src/reducers/MainReducer/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const MainReducer = (state, action) => {
5252
};
5353
case RESET_MAIN_REDUCER:
5454
localStorage.languageIndex = 1;
55+
localStorage.themeStyle = 'light';
5556
localStorage.themeIndex = 0;
5657
localStorage.autoUpdate = true;
5758
localStorage.minimizeEnabled = true;
@@ -62,6 +63,7 @@ const MainReducer = (state, action) => {
6263
return {
6364
...state,
6465
languageIndex: 1,
66+
themeStyle: 'light',
6567
themeIndex: 0,
6668
autoUpdate: true,
6769
minimizeEnabled: true,

0 commit comments

Comments
 (0)