Skip to content

Commit 2309549

Browse files
committed
feat: added theme toggle button, dependency upgrades, added ability to export to html
1 parent eba80c3 commit 2309549

17 files changed

Lines changed: 96 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Advanced PortChecker
22

3-
![Advanced PortChecker](https://i.imgur.com/yoWDImn.png)
3+
![Advanced PortChecker](https://i.imgur.com/vdt1sXZ.png)
44

55
![GitHub](https://img.shields.io/badge/language-JavaScript+Rust-green)
66
![GitHub](https://img.shields.io/github/license/CodeDead/Advanced-PortChecker)

src-tauri/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/TopBar/index.jsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ import ListItem from '@mui/material/ListItem';
1414
import ListItemButton from '@mui/material/ListItemButton';
1515
import ListItemIcon from '@mui/material/ListItemIcon';
1616
import ListItemText from '@mui/material/ListItemText';
17+
import Brightness5Icon from '@mui/icons-material/Brightness5';
18+
import Brightness7Icon from '@mui/icons-material/Brightness7';
1719
import TravelExploreIcon from '@mui/icons-material/TravelExplore';
1820
import SettingsIcon from '@mui/icons-material/Settings';
1921
import AttachMoneyIcon from '@mui/icons-material/AttachMoney';
2022
import InfoIcon from '@mui/icons-material/Info';
2123
import { useNavigate } from 'react-router-dom';
2224
import DrawerHeader from '../DrawerHeader';
2325
import { MainContext } from '../../contexts/MainContextProvider';
24-
import { openWebSite } from '../../reducers/MainReducer/Actions';
26+
import { openWebSite, setThemeType } from '../../reducers/MainReducer/Actions';
2527

2628
const drawerWidth = 240;
2729

@@ -82,7 +84,8 @@ const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open'
8284
);
8385

8486
const TopBar = () => {
85-
const [state] = useContext(MainContext);
87+
const [state, d1] = useContext(MainContext);
88+
const { themeType, themeToggle } = state;
8689

8790
const [open, setOpen] = useState(false);
8891

@@ -132,6 +135,13 @@ const TopBar = () => {
132135
handleDrawerClose();
133136
};
134137

138+
/**
139+
* Change the theme style
140+
*/
141+
const changeThemeStyle = () => {
142+
d1(setThemeType(themeType === 'dark' ? 'light' : 'dark'));
143+
};
144+
135145
return (
136146
<>
137147
<AppBar
@@ -161,6 +171,16 @@ const TopBar = () => {
161171
>
162172
{language.applicationName}
163173
</Typography>
174+
<div style={{ flexGrow: 1 }} />
175+
{themeToggle ? (
176+
<IconButton
177+
aria-label={language.theme}
178+
color="inherit"
179+
onClick={changeThemeStyle}
180+
>
181+
{themeType === 'dark' ? <Brightness5Icon /> : <Brightness7Icon />}
182+
</IconButton>
183+
) : null}
164184
</Toolbar>
165185
</AppBar>
166186
<Drawer variant="permanent" open={open}>

src/contexts/MainContextProvider/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const threads = localStorage.threads ? parseFloat(localStorage.threads) : 1;
1616
const timeout = localStorage.timeout ? parseFloat(localStorage.timeout) : 250;
1717
const noClosed = localStorage.noClosed ? (localStorage.noClosed === 'true') : false;
1818
const sort = localStorage.sort ? (localStorage.sort === 'true') : true;
19+
const themeToggle = localStorage.themeToggle ? (localStorage.themeToggle === 'true') : true;
1920

2021
const initState = {
2122
autoUpdate,
@@ -44,6 +45,7 @@ const initState = {
4445
noClosed,
4546
sort,
4647
scanResults: null,
48+
themeToggle,
4749
};
4850

4951
export const MainContext = createContext(initState);

src/languages/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@
8080
"exportType": "Export type",
8181
"export": "Export",
8282
"exportSuccessful": "Export successful",
83-
"runningLatestVersion": "You are running the latest version."
83+
"runningLatestVersion": "You are running the latest version.",
84+
"themeToggleInTopBar": "Toggle theme in top bar"
8485
}

src/languages/es_es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@
8080
"exportType": "Tipo de exportación",
8181
"export": "Exportar",
8282
"exportSuccessful": "Exportación exitosa",
83-
"runningLatestVersion": "Estás ejecutando la última versión."
83+
"runningLatestVersion": "Estás ejecutando la última versión.",
84+
"themeToggleInTopBar": "Alternar tema en la barra superior"
8485
}

src/languages/fr_fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@
8080
"exportType": "Type d'exportation",
8181
"export": "Exporter",
8282
"exportSuccessful": "Exportation réussie",
83-
"runningLatestVersion": "Vous utilisez la dernière version."
83+
"runningLatestVersion": "Vous utilisez la dernière version.",
84+
"themeToggleInTopBar": "Basculer le thème dans la barre supérieure"
8485
}

src/languages/nl_nl.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@
8080
"exportType": "Export type",
8181
"export": "Exporteren",
8282
"exportSuccessful": "Exporteren succesvol",
83-
"runningLatestVersion": "U gebruikt de laatste versie."
83+
"runningLatestVersion": "U gebruikt de laatste versie.",
84+
"themeToggleInTopBar": "Thema toggle in de bovenste balk"
8485
}

src/languages/zh_cn.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@
8080
"exportType": "导出类型",
8181
"export": "出口",
8282
"exportSuccessful": "导出成功",
83-
"runningLatestVersion": "您正在运行最新版本。"
83+
"runningLatestVersion": "您正在运行最新版本。",
84+
"themeToggleInTopBar": "在顶部栏中切换主题"
8485
}

src/main.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
body {
2+
margin: 0;
3+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5+
sans-serif;
6+
-webkit-font-smoothing: antialiased;
7+
-moz-osx-font-smoothing: grayscale;
8+
}
9+
10+
code {
11+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12+
monospace;
13+
}

0 commit comments

Comments
 (0)