diff --git a/client/src/App.tsx b/client/src/App.tsx
index 68faaea..e302c57 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -10,7 +10,7 @@ import { actionCreators, store } from './store';
import { State } from './store/reducers';
// Utils
-import { checkVersion, decodeToken } from './utility';
+import { checkVersion, decodeToken, parsePABToTheme } from './utility';
// Routes
import { Home } from './components/Home/Home';
@@ -31,7 +31,7 @@ export const App = (): JSX.Element => {
const { config, loading } = useSelector((state: State) => state.config);
const dispath = useDispatch();
- const { fetchQueries, setTheme, logout, createNotification } =
+ const { fetchQueries, setTheme, logout, createNotification, fetchThemes } =
bindActionCreators(actionCreators, dispath);
useEffect(() => {
@@ -51,9 +51,12 @@ export const App = (): JSX.Element => {
}
}, 1000);
+ // load themes
+ fetchThemes();
+
// set user theme if present
if (localStorage.theme) {
- setTheme(localStorage.theme);
+ setTheme(parsePABToTheme(localStorage.theme));
}
// check for updated
@@ -68,7 +71,7 @@ export const App = (): JSX.Element => {
// If there is no user theme, set the default one
useEffect(() => {
if (!loading && !localStorage.theme) {
- setTheme(config.defaultTheme, false);
+ setTheme(parsePABToTheme(config.defaultTheme), false);
}
}, [loading]);
diff --git a/client/src/components/Settings/Themer/ThemeGrid/ThemeGrid.tsx b/client/src/components/Settings/Themer/ThemeGrid/ThemeGrid.tsx
index bd88961..fbf5dab 100644
--- a/client/src/components/Settings/Themer/ThemeGrid/ThemeGrid.tsx
+++ b/client/src/components/Settings/Themer/ThemeGrid/ThemeGrid.tsx
@@ -1,8 +1,3 @@
-// Redux
-import { useDispatch } from 'react-redux';
-import { bindActionCreators } from 'redux';
-import { actionCreators } from '../../../../store';
-
// Components
import { ThemePreview } from '../ThemePreview/ThemePreview';
@@ -15,14 +10,11 @@ interface Props {
}
export const ThemeGrid = ({ themes }: Props): JSX.Element => {
- const dispatch = useDispatch();
- const { setTheme } = bindActionCreators(actionCreators, dispatch);
-
return (
{themes.map(
(theme: Theme, idx: number): JSX.Element => (
-
+
)
)}
diff --git a/client/src/components/Settings/Themer/ThemePreview/ThemePreview.tsx b/client/src/components/Settings/Themer/ThemePreview/ThemePreview.tsx
index 81a48fe..ccbb42e 100644
--- a/client/src/components/Settings/Themer/ThemePreview/ThemePreview.tsx
+++ b/client/src/components/Settings/Themer/ThemePreview/ThemePreview.tsx
@@ -1,32 +1,38 @@
+// Redux
+import { useDispatch } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import { actionCreators } from '../../../../store';
+
+// Other
import { Theme } from '../../../../interfaces/Theme';
import classes from './ThemePreview.module.css';
interface Props {
theme: Theme;
- applyTheme: Function;
}
-export const ThemePreview = (props: Props): JSX.Element => {
+export const ThemePreview = ({
+ theme: { colors, name },
+}: Props): JSX.Element => {
+ const { setTheme } = bindActionCreators(actionCreators, useDispatch());
+
return (
- props.applyTheme(props.theme.name)}
- >
+
setTheme(colors)}>
-
{props.theme.name}
+
{name}
);
};
diff --git a/client/src/components/Settings/Themer/Themer.tsx b/client/src/components/Settings/Themer/Themer.tsx
index 4274a34..f8de5ec 100644
--- a/client/src/components/Settings/Themer/Themer.tsx
+++ b/client/src/components/Settings/Themer/Themer.tsx
@@ -9,12 +9,11 @@ import { actionCreators } from '../../../store';
import { Theme, ThemeSettingsForm } from '../../../interfaces';
// Components
-import { Button, InputGroup, SettingsHeadline } from '../../UI';
+import { Button, InputGroup, SettingsHeadline, Spinner } from '../../UI';
import { ThemeBuilder } from './ThemeBuilder/ThemeBuilder';
import { ThemeGrid } from './ThemeGrid/ThemeGrid';
// Other
-import { themes } from './themes.json';
import { State } from '../../../store/reducers';
import { inputHandler, themeSettingsTemplate } from '../../../utility';
@@ -22,6 +21,7 @@ export const Themer = (): JSX.Element => {
const {
auth: { isAuthenticated },
config: { loading, config },
+ theme: { themes },
} = useSelector((state: State) => state);
const dispatch = useDispatch();
@@ -63,10 +63,10 @@ export const Themer = (): JSX.Element => {
return (
-
+ {!themes.length ? : }
-
-
+ {/*
+ */}
{isAuthenticated && (