Merge branch 'master' into master

This commit is contained in:
Bastian Meissner 2020-05-21 09:49:50 +02:00 committed by GitHub
commit 8a39463caa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 376 additions and 447 deletions

View file

@ -2,7 +2,7 @@
![screenshot](screenshot.png 'screenshot') ![screenshot](screenshot.png 'screenshot')
Dashboard is just that - a dashboard. It's inspired by [SUI](https://github.com/jeroenpardon/sui) and has all the same features as SUI. Dashboard is just that - a dashboard. It's inspired by [SUI](https://github.com/jeroenpardon/sui) and has all the same features as SUI, such as simple customization through JSON-files and a handy search bar to search the internet more efficiently.
## Features ## Features

View file

@ -1,13 +1,13 @@
import React from 'react'; import React from "react";
import styled, { createGlobalStyle } from 'styled-components'; import styled, { createGlobalStyle } from "styled-components";
import SearchBar from './components/searchBar'; import SearchBar from "./components/searchBar";
import Greeter from './components/greeter'; import Greeter from "./components/greeter";
import AppList from './components/appList'; import AppList from "./components/appList";
import BookmarkList from './components/bookmarkList'; import BookmarkList from "./components/bookmarkList";
import SettingsModal from './components/settingsModal'; import SettingsModal from "./components/settingsModal";
import { selectedTheme } from './selectedTheme'; import selectedTheme from "./components/themeManager";
const GlobalStyle = createGlobalStyle` const GlobalStyle = createGlobalStyle`
body { body {

View file

@ -1,70 +1,46 @@
import React, { useCallback, useEffect, useState } from 'react'; import React from "react";
import MaterialIcon from 'material-icons-react'; import MaterialIcon from "material-icons-react";
import styled from 'styled-components'; import styled from "styled-components";
import { Button } from './button'; import appData from "./data/apps.json";
import { selectedTheme } from '../selectedTheme';
const AppListContainer = styled.div` import selectedTheme from "./themeManager";
padding: 2rem 0 2rem 0;
`;
const AppsContainer = styled.div` import { Headline, ListContainer, ItemList, Item } from "./elements";
display: flex;
flex-direction: row;
flex-wrap: wrap;
@media (max-width: 600px) {
flex-direction: column;
}
`;
const AppContainer = styled.div`
display: flex;
flex-direction: row;
flex: 1 0 21%;
padding: 1rem 0 1rem 0;
@media (max-width: 750px) {
flex: 1 0 42%;
}
`;
const IconContainer = styled.div` const IconContainer = styled.div`
margin-right: 5px; margin-right: 0.5vh;
`; `;
const AppDetails = styled.div` const DetailsContainer = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
`;
const ApplicationsText = styled.h3`
font-family: Roboto, sans-serif;
font-weight: 900;
text-transform: uppercase;
margin: 0px;
font-size: 20px;
color: ${selectedTheme.mainColor};
`; `;
const Link = styled.a` const Link = styled.a`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
color: ${selectedTheme.mainColor}; flex: 1 0 auto;
font-weight: 500; color: ${selectedTheme.mainColor};
text-transform: uppercase; font-weight: 500;
margin: 0px; text-transform: uppercase;
text-decoration: none; margin: 0;
font-size: 15px; text-decoration: none;
font-size: 1rem;
`; `;
const Description = styled.p` const Description = styled.p`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
text-transform: uppercase; text-transform: uppercase;
margin: 0px; margin: 0;
font-size: 10px; font-size: 0.65rem;
font-weight: 400; font-weight: 400;
color: ${selectedTheme.accentColor}; color: ${selectedTheme.accentColor};
`;
const App = styled.div`
display: flex;
flex-basis: 25%;
padding: 1rem;
`; `;
const ErrorMessage = styled.p` const ErrorMessage = styled.p`

View file

@ -1,76 +1,53 @@
import React from 'react'; import React from "react";
import styled from 'styled-components'; import styled from "styled-components";
import bookmarkData from './data/bookmarks.json'; import bookmarkData from "./data/bookmarks.json";
import { selectedTheme } from '../selectedTheme'; import selectedTheme from "./themeManager";
import { Headline, ListContainer, ItemList, Item } from "./elements";
const BookmarksText = styled.h3` const Group = styled.h4`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
text-transform: uppercase; font-weight: 700;
margin: 0; margin: 0;
font-size: 20px; text-transform: uppercase;
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
`; `;
const GroupText = styled.h4` const BookmarkGroup = styled.div`
font-family: Roboto, sans-serif; display: flex;
font-weight: 700; flex-direction: column;
margin: 0; flex: 2 1 auto;
text-transform: uppercase; padding: 1rem 0 1rem 0;
color: ${selectedTheme.mainColor};
`;
const BookmarkListContainer = styled.div`
padding: 2rem 0 2rem 0;
`;
const BookmarksContainer = styled.div`
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
@media (max-width: 600px) {
flex-direction: column;
}
`;
const BookmarkGroupContainer = styled.div`
display: flex;
flex-direction: column;
flex: 1 0 21%;
padding-top: 2rem;
font-size: 15px;
`; `;
const Bookmark = styled.a` const Bookmark = styled.a`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 400; font-weight: 400;
text-decoration: none; text-decoration: none;
color: ${selectedTheme.accentColor}; color: ${selectedTheme.accentColor};
padding: 10px 0 0 0; padding: 10px 0 0 0;
font-size: 14px; font-size: 14px;
`; `;
const BookmarkList = () => ( const bookmarkList = () => (
<BookmarkListContainer> <ListContainer>
<BookmarksText>Bookmarks</BookmarksText> <Headline>Bookmarks</Headline>
<BookmarksContainer> <ItemList>
{bookmarkData.groups.map(({ name, items }) => { {bookmarkData.groups.map(({ name, items }) => (
return ( <Item key={name}>
<BookmarkGroupContainer key={name}> <BookmarkGroup>
<GroupText>{name}</GroupText> <Group>{name}</Group>
{items.map(({ url, name: linkName }) => ( {group.items.map(({ url, name: linkName }) => (
<Bookmark key={linkName} href={url}> <Bookmark key={linkName} href={url}>
{linkName} {linkName}
</Bookmark> </Bookmark>
))} ))}
</BookmarkGroupContainer> </BookmarkGroup>
); </Item>
})} ))}
</BookmarksContainer> </ItemList>
</BookmarkListContainer> </ListContainer>
); );
export default BookmarkList; export default bookmarkList;

View file

@ -2,56 +2,56 @@
"apps": [ "apps": [
{ {
"name": "PiHole", "name": "PiHole",
"displayURL": "example.com", "displayURL": "192.168.1.253",
"URL": "https://example.com", "URL": "/admin/",
"icon": "vpn_lock" "icon": "vpn_lock"
}, },
{ {
"name": "Plex", "name": "Plex",
"displayURL": "example.com", "displayURL": "app.plex.tv",
"URL": "https://example.com", "URL": "https://app.plex.tv",
"icon": "tv" "icon": "tv"
}, },
{ {
"name": "NextCloud", "name": "NextCloud",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/cloud/",
"icon": "filter_drama" "icon": "filter_drama"
}, },
{ {
"name": "Ghost", "name": "Ghost",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/blog/",
"icon": "rss_feed" "icon": "rss_feed"
}, },
{ {
"name": "Minecraft", "name": "Minecraft",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/minecraft/index.html",
"icon": "games" "icon": "games"
}, },
{ {
"name": "pfSense", "name": "pfSense",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech:1111/",
"icon": "security" "icon": "security"
}, },
{ {
"name": "ESXi", "name": "ESXi",
"displayURL": "example.com", "displayURL": "rhsttpba1.ur.de",
"URL": "https://example.com", "URL": "https://rhsttpba1.ur.de",
"icon": "dns" "icon": "dns"
}, },
{ {
"name": "Tautulli", "name": "Tautulli",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/tautulli/",
"icon": "bar_chart" "icon": "bar_chart"
}, },
{ {
"name": "Grafana", "name": "Grafana",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/grafana/",
"icon": "show_chart" "icon": "show_chart"
} }
] ]

View file

@ -1,53 +1,15 @@
{ {
"groups": [ "groups": [
{ {
"name": "Communicate", "name": "Wikis",
"items": [ "items": [
{ {
"name": "Discord", "name": "Wikipedia",
"url": "https://example.com" "url": "https://en.wikipedia.org/"
}, },
{ {
"name": "Gmail", "name": "Arch Linux Wiki",
"url": "https://example.com" "url": "https://archlinux.org/"
},
{
"name": "Slack",
"url": "https://example.com"
}
]
},
{
"name": "Cloud",
"items": [
{
"name": "Box",
"url": "https://example.com"
},
{
"name": "Dropbox",
"url": "https://example.com"
},
{
"name": "Drive",
"url": "https://example.com"
}
]
},
{
"name": "Design",
"items": [
{
"name": "Awwwards",
"url": "https://example.com"
},
{
"name": "Dribbble",
"url": "https://example.com"
},
{
"name": "Muz.li",
"url": "https://example.com"
} }
] ]
}, },
@ -56,32 +18,15 @@
"items": [ "items": [
{ {
"name": "Codepen", "name": "Codepen",
"url": "https://example.com" "url": "https://codepen.io/"
}, },
{ {
"name": "Devdocs", "name": "JSFiddle",
"url": "https://example.com" "url": "https://jsfiddle.net/"
}, },
{ {
"name": "Devhints", "name": "Pastebin",
"url": "https://example.com" "url": "https://pastebin.com/"
}
]
},
{
"name": "Lifestyle",
"items": [
{
"name": "Design Milk",
"url": "https://example.com"
},
{
"name": "Dwell",
"url": "https://example.com"
},
{
"name": "Freshome",
"url": "https://example.com"
} }
] ]
}, },
@ -89,33 +34,46 @@
"name": "Media", "name": "Media",
"items": [ "items": [
{ {
"name": "Spotify", "name": "Soundcloud",
"url": "https://example.com" "url": "https://soundcloud.com"
},
{
"name": "Trakt",
"url": "https://example.com"
}, },
{ {
"name": "YouTube", "name": "YouTube",
"url": "https://example.com" "url": "https://youtube.com"
},
{
"name": "Twitch",
"url": "https://twitch.tv"
} }
] ]
}, },
{ {
"name": "Reading", "name": "Social Networks",
"items": [ "items": [
{ {
"name": "Instapaper", "name": "Facebook",
"url": "https://example.com" "url": "https://facebook.com"
}, },
{ {
"name": "Medium", "name": "Twitter",
"url": "https://example.com" "url": "https://twitter.com"
}, },
{
"name": "Instagram",
"url": "https://instagram.com"
}
]
},
{
"name": "Imageboards",
"items": [
{ {
"name": "Reddit", "name": "Reddit",
"url": "https://example.com" "url": "https://reddit.com"
},
{
"name": "4chan",
"url": "https://4chan.org"
} }
] ]
}, },
@ -123,16 +81,16 @@
"name": "Tech", "name": "Tech",
"items": [ "items": [
{ {
"name": "TheNextWeb", "name": "Hackernoon",
"url": "https://example.com" "url": "https://hackernoon.com"
}, },
{ {
"name": "The Verge", "name": "The Verge",
"url": "https://example.com" "url": "https://theverge.com"
}, },
{ {
"name": "MIT Technology Review", "name": "Hackernews",
"url": "https://example.com" "url": "https://news.ycombinator.com"
} }
] ]
} }

View file

@ -0,0 +1,32 @@
import styled from "styled-components";
import selectedTheme from "./themeManager";
const ListContainer = styled.div`
padding: 2rem 0 2rem 0;
`;
const Headline = styled.h3`
font-family: Roboto, sans-serif;
font-weight: 900;
text-transform: uppercase;
margin: 0px;
font-size: 1.5rem;
color: ${selectedTheme.mainColor};
`;
const ItemList = styled.ul`
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 1rem;
padding: 0;
list-style: none;
`;
const Item = styled.li`
max-height: 100px;
overflow: hidden;
position: relative;
list-style: none;
`;
export { Headline, ListContainer, ItemList, Item };

View file

@ -1,27 +1,27 @@
import React from 'react'; import React from "react";
import styled from 'styled-components'; import styled from "styled-components";
import { selectedTheme } from '../selectedTheme'; import selectedTheme from "./themeManager";
const GreeterContainer = styled.div` const GreeterContainer = styled.div`
padding: 2rem 0 2rem 0; padding: 2rem 0 2rem 0;
`; `;
const GreetText = styled.h1` const GreetText = styled.h1`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 900; font-weight: 900;
font-size: 45px; font-size: 45px;
margin: 0.5rem 0 0.5rem 0; margin: 0.5rem 0 0.5rem 0;
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
`; `;
const DateText = styled.h3` const DateText = styled.h3`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 400; font-weight: 400;
font-size: 15px; font-size: 15px;
text-transform: uppercase; text-transform: uppercase;
margin: 0; margin: 0;
color: ${selectedTheme.accentColor}; color: ${selectedTheme.accentColor};
`; `;
const getGreeting = () => { const getGreeting = () => {

View file

@ -1,68 +1,66 @@
import React, { useState } from 'react'; import React, { useState } from "react";
import styled from 'styled-components'; import styled from "styled-components";
import searchData from './data/search.json'; import searchData from "./data/search.json";
import { selectedTheme } from '../selectedTheme'; import selectedTheme from "./themeManager";
const SearchInput = styled.input` const SearchInput = styled.input`
width: 100%; width: 100%;
font-size: 16px; font-size: 16px;
border: none; border: none;
border-bottom: 1px solid ${selectedTheme.accentColor}; border-bottom: 1px solid ${selectedTheme.accentColor};
background: none; background: none;
border-radius: 0; border-radius: 0;
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
`; `;
const handleQueryWithProvider = (query) => { const handleQueryWithProvider = query => {
let queryArray = query.split(' '); let queryArray = query.split(" ");
let prefix = queryArray[0]; let prefix = queryArray[0];
queryArray.shift(); queryArray.shift();
let searchQuery = queryArray.join(' '); let searchQuery = queryArray.join(" ");
var foundProvider = false; var foundProvider = false;
searchData.providers.forEach((provider) => { searchData.providers.forEach(provider => {
if (provider.prefix === prefix) { if (provider.prefix === prefix) {
foundProvider = true; foundProvider = true;
window.location = provider.url + searchQuery; window.location = provider.url + searchQuery;
}
});
if (!foundProvider) {
window.location = 'https://google.com/search?q=' + query;
} }
});
if (!foundProvider) {
window.location = "https://google.com/search?q=" + query;
}
}; };
const SearchBar = () => { const SearchBar = () => {
let [input, setInput] = useState(); let [input, setInput] = useState();
const handleSearchQuery = (e) => { const handleSearchQuery = e => {
var query = input; var query = input;
console.log(query); if (query.split(" ")[0].includes("/")) {
handleQueryWithProvider(query);
} else {
window.location = "https://google.com/search?q=" + query;
}
if (query.split(' ')[0].includes('/')) { e.preventDefault();
handleQueryWithProvider(query); };
} else {
window.location = 'https://google.com/search?q=' + query;
}
e.preventDefault(); return (
}; <form onSubmit={e => handleSearchQuery(e)}>
<SearchInput
return ( type="text"
<form onSubmit={(e) => handleSearchQuery(e)}> onChange={e => setInput(e.target.value)}
<SearchInput ></SearchInput>
type="text" <button type="submit" hidden />
onChange={(e) => setInput(e.target.value)} </form>
></SearchInput> );
<button type="submit" hidden />
</form>
);
}; };
export default SearchBar; export default SearchBar;

View file

@ -1,182 +1,168 @@
import React, { useState } from 'react'; import React, { useState } from "react";
import MaterialIcon from 'material-icons-react'; import MaterialIcon from "material-icons-react";
import styled from 'styled-components'; import styled from "styled-components";
import Select from 'react-select'; import Select from "react-select";
import searchData from './data/search.json'; import searchData from './data/search.json';
import themeData from './data/themes.json'; import themeData from './data/themes.json';
import getTheme, { setTheme } from './themeManager'; import selectedTheme, { setTheme } from "./themeManager";
import { Button } from './button'; import { Button } from './button';
const selectedTheme = getTheme();
const ModalButton = styled.button` const ModalButton = styled.button`
float: right; float: right;
border: none;
border: none; background: none;
background: none; padding: 10px;
padding: 10px;
`; `;
const ExitButton = styled.button` const ExitButton = styled.button`
float: right; float: right;
border: none;
border: none; background: none;
background: none;
`; `;
const Modal = styled.div` const Modal = styled.div`
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
padding: 1rem; padding: 1rem;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
z-index: 10; z-index: 10;
border: 1px solid ${selectedTheme.mainColor}; border: 1px solid ${selectedTheme.mainColor};
background-color: ${selectedTheme.backgroundColor}; background-color: ${selectedTheme.backgroundColor};
`; `;
const SelectContainer = styled.div` const SelectContainer = styled.div`
padding-bottom: 1rem; padding-bottom: 1rem;
`; `;
const FormContainer = styled.div` const FormContainer = styled.div`
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: nowrap; flex-wrap: nowrap;
`; `;
const ApplyButton = Button;
const Headline = styled.h3` const Headline = styled.h3`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 900; font-weight: 900;
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
margin-top: 0; margin-top: 0;
`; `;
const SelectorStyle = {
control: (provided) => ({
...provided,
fontFamily: 'Roboto, sans-serif',
fontWeight: '500',
color: selectedTheme.mainColor,
textTransform: 'uppercase',
width: '200px',
background: 'none',
borderRadius: '0px',
border: '1px solid ' + selectedTheme.mainColor,
boxShadow: 0,
'&:hover': {
border: '1px solid ' + selectedTheme.mainColor,
},
}),
menu: (provided) => ({
...provided,
backgroundColor: selectedTheme.backgroundColor,
border: '1px solid ' + selectedTheme.mainColor,
borderRadius: '0px',
boxShadow: 0,
}),
option: (provided) => ({
...provided,
fontFamily: 'Roboto, sans-serif',
fontWeight: '500',
color: selectedTheme.mainColor,
textTransform: 'uppercase',
borderRadius: '0px',
boxShadow: 0,
backgroundColor: selectedTheme.backgroundColor,
'&:hover': {
backgroundColor: selectedTheme.mainColor,
color: selectedTheme.backgroundColor,
},
}),
singleValue: (provided) => {
return {
...provided,
color: selectedTheme.mainColor,
};
},
};
const Table = styled.table` const Table = styled.table`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 400; font-weight: 400;
background: none; background: none;
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
`; `;
const TableRow = styled.tr` const TableRow = styled.tr`
border-bottom: 1px solid ${selectedTheme.mainColor}; border-bottom: 1px solid ${selectedTheme.mainColor};
`; `;
const TableCell = styled.td` const TableCell = styled.td`
background: none; background: none;
padding-top: 0.5rem; padding-top: 0.5rem;
`; `;
const HeadCell = styled.th` const HeadCell = styled.th`
font-weight: 700; font-weight: 700;
background: none; background: none;
`; `;
const SettingsModal = () => { const SelectorStyle = {
const [modalHidden, setModalHidden] = useState(true); control: provided => ({
const [newTheme, setNewTheme] = useState(); ...provided,
fontFamily: "Roboto, sans-serif",
fontWeight: "500",
color: selectedTheme.mainColor,
textTransform: "uppercase",
width: "200px",
background: "none",
borderRadius: "0px",
border: "1px solid " + selectedTheme.mainColor,
boxShadow: 0,
"&:hover": {
border: "1px solid " + selectedTheme.mainColor
}
}),
menu: provided => ({
...provided,
backgroundColor: selectedTheme.backgroundColor,
border: "1px solid " + selectedTheme.mainColor,
borderRadius: "0px",
boxShadow: 0
}),
option: provided => ({
...provided,
fontFamily: "Roboto, sans-serif",
fontWeight: "500",
color: selectedTheme.mainColor,
textTransform: "uppercase",
borderRadius: "0px",
boxShadow: 0,
backgroundColor: selectedTheme.backgroundColor,
"&:hover": {
backgroundColor: selectedTheme.mainColor,
color: selectedTheme.backgroundColor
}
}),
singleValue: provided => {
return {
...provided,
color: selectedTheme.mainColor
};
}
};
return ( const SettingsModal = () => {
<> const [modalHidden, setModalHidden] = useState(true);
<ModalButton onClick={() => setModalHidden(!modalHidden)}> const [newTheme, setNewTheme] = useState();
<MaterialIcon icon="settings" color={selectedTheme.mainColor} />
</ModalButton> return (
<Modal hidden={modalHidden}> <>
<ExitButton onClick={() => setModalHidden(!modalHidden)}> <ModalButton onClick={() => setModalHidden(!modalHidden)}>
<MaterialIcon <MaterialIcon icon="settings" color={selectedTheme.mainColor} />
icon="close" </ModalButton>
color={selectedTheme.mainColor} <Modal hidden={modalHidden}>
/> <ExitButton onClick={() => setModalHidden(!modalHidden)}>
</ExitButton> <MaterialIcon icon="close" color={selectedTheme.mainColor} />
<SelectContainer> </ExitButton>
<Headline>Theme:</Headline> <SelectContainer>
<FormContainer> <Headline>Theme:</Headline>
<Select <FormContainer>
options={themeData.themes} <Select
defaultValue={selectedTheme} options={themeData.themes}
onChange={(e) => { defaultValue={selectedTheme}
setNewTheme(e); onChange={e => {
}} setNewTheme(e);
styles={SelectorStyle} }}
/> styles={SelectorStyle}
<ApplyButton />
onClick={() => setTheme(JSON.stringify(newTheme))} <Button onClick={() => setTheme(JSON.stringify(newTheme))}>
> Apply
Apply </Button>
</ApplyButton> </FormContainer>
</FormContainer> </SelectContainer>
</SelectContainer> <Table>
<Table> <tbody>
<tbody> <TableRow>
<TableRow> <HeadCell>Search Provider</HeadCell>
<HeadCell>Search Provider</HeadCell> <HeadCell>Prefix</HeadCell>
<HeadCell>Prefix</HeadCell> </TableRow>
</TableRow> {searchData.providers.map((provider, index) => (
{searchData.providers.map((provider) => { <TableRow key={provider.name + index}>
const { name, prefix } = provider; <TableCell>{provider.name}</TableCell>
return ( <TableCell>{provider.prefix}</TableCell>
<TableRow key={name}> </TableRow>
<TableCell>{name}</TableCell> ))}
<TableCell>{prefix}</TableCell> </tbody>
</TableRow> </Table>
); </Modal>
})} </>
</tbody> );
</Table>
</Modal>
</>
);
}; };
export default SettingsModal; export default SettingsModal;

View file

@ -1,27 +1,29 @@
import themeData from './data/themes.json'; import themeData from "./data/themes.json";
const setTheme = (theme) => { const setTheme = theme => {
localStorage.setItem('theme', theme); localStorage.setItem("theme", theme);
window.location.reload(); window.location.reload();
}; };
const resetTheme = () => { const resetTheme = () => {
localStorage.removeItem('theme'); localStorage.removeItem("theme");
}; };
const getTheme = () => { const getTheme = () => {
let selectedTheme = themeData.themes[0]; let selectedTheme = themeData.themes[0];
if ( if (
localStorage.getItem('theme') && localStorage.getItem("theme") &&
localStorage.getItem('theme') !== undefined localStorage.getItem("theme") !== undefined
) { ) {
selectedTheme = JSON.parse(localStorage.getItem('theme')); selectedTheme = JSON.parse(localStorage.getItem("theme"));
} }
return selectedTheme; return selectedTheme;
}; };
const selectedTheme = getTheme();
export { setTheme, resetTheme }; export { setTheme, resetTheme };
export default getTheme; export default selectedTheme;