Merge branch 'master' into master
This commit is contained in:
commit
8a39463caa
11 changed files with 376 additions and 447 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
![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
|
||||
|
||||
|
|
16
src/App.js
16
src/App.js
|
@ -1,13 +1,13 @@
|
|||
import React from 'react';
|
||||
import styled, { createGlobalStyle } from 'styled-components';
|
||||
import React from "react";
|
||||
import styled, { createGlobalStyle } from "styled-components";
|
||||
|
||||
import SearchBar from './components/searchBar';
|
||||
import Greeter from './components/greeter';
|
||||
import AppList from './components/appList';
|
||||
import BookmarkList from './components/bookmarkList';
|
||||
import SettingsModal from './components/settingsModal';
|
||||
import SearchBar from "./components/searchBar";
|
||||
import Greeter from "./components/greeter";
|
||||
import AppList from "./components/appList";
|
||||
import BookmarkList from "./components/bookmarkList";
|
||||
import SettingsModal from "./components/settingsModal";
|
||||
|
||||
import { selectedTheme } from './selectedTheme';
|
||||
import selectedTheme from "./components/themeManager";
|
||||
|
||||
const GlobalStyle = createGlobalStyle`
|
||||
body {
|
||||
|
|
|
@ -1,70 +1,46 @@
|
|||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import MaterialIcon from 'material-icons-react';
|
||||
import styled from 'styled-components';
|
||||
import React from "react";
|
||||
import MaterialIcon from "material-icons-react";
|
||||
import styled from "styled-components";
|
||||
|
||||
import { Button } from './button';
|
||||
import { selectedTheme } from '../selectedTheme';
|
||||
import appData from "./data/apps.json";
|
||||
|
||||
const AppListContainer = styled.div`
|
||||
padding: 2rem 0 2rem 0;
|
||||
`;
|
||||
import selectedTheme from "./themeManager";
|
||||
|
||||
const AppsContainer = styled.div`
|
||||
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%;
|
||||
}
|
||||
`;
|
||||
import { Headline, ListContainer, ItemList, Item } from "./elements";
|
||||
|
||||
const IconContainer = styled.div`
|
||||
margin-right: 5px;
|
||||
margin-right: 0.5vh;
|
||||
`;
|
||||
|
||||
const AppDetails = styled.div`
|
||||
display: flex;
|
||||
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 DetailsContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
`;
|
||||
|
||||
const Link = styled.a`
|
||||
font-family: Roboto, sans-serif;
|
||||
color: ${selectedTheme.mainColor};
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
margin: 0px;
|
||||
text-decoration: none;
|
||||
font-size: 15px;
|
||||
font-family: Roboto, sans-serif;
|
||||
flex: 1 0 auto;
|
||||
color: ${selectedTheme.mainColor};
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
text-decoration: none;
|
||||
font-size: 1rem;
|
||||
`;
|
||||
|
||||
const Description = styled.p`
|
||||
font-family: Roboto, sans-serif;
|
||||
text-transform: uppercase;
|
||||
margin: 0px;
|
||||
font-size: 10px;
|
||||
font-weight: 400;
|
||||
color: ${selectedTheme.accentColor};
|
||||
font-family: Roboto, sans-serif;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
font-size: 0.65rem;
|
||||
font-weight: 400;
|
||||
color: ${selectedTheme.accentColor};
|
||||
`;
|
||||
|
||||
const App = styled.div`
|
||||
display: flex;
|
||||
flex-basis: 25%;
|
||||
padding: 1rem;
|
||||
`;
|
||||
|
||||
const ErrorMessage = styled.p`
|
||||
|
@ -132,4 +108,4 @@ const AppList = () => {
|
|||
);
|
||||
};
|
||||
|
||||
export default AppList;
|
||||
export default AppList;
|
|
@ -1,76 +1,53 @@
|
|||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import React from "react";
|
||||
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`
|
||||
font-family: Roboto, sans-serif;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
color: ${selectedTheme.mainColor};
|
||||
const Group = styled.h4`
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
text-transform: uppercase;
|
||||
color: ${selectedTheme.mainColor};
|
||||
`;
|
||||
|
||||
const GroupText = styled.h4`
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
text-transform: uppercase;
|
||||
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 BookmarkGroup = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 2 1 auto;
|
||||
padding: 1rem 0 1rem 0;
|
||||
`;
|
||||
|
||||
const Bookmark = styled.a`
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 400;
|
||||
text-decoration: none;
|
||||
color: ${selectedTheme.accentColor};
|
||||
padding: 10px 0 0 0;
|
||||
font-size: 14px;
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 400;
|
||||
text-decoration: none;
|
||||
color: ${selectedTheme.accentColor};
|
||||
padding: 10px 0 0 0;
|
||||
font-size: 14px;
|
||||
`;
|
||||
|
||||
const BookmarkList = () => (
|
||||
<BookmarkListContainer>
|
||||
<BookmarksText>Bookmarks</BookmarksText>
|
||||
<BookmarksContainer>
|
||||
{bookmarkData.groups.map(({ name, items }) => {
|
||||
return (
|
||||
<BookmarkGroupContainer key={name}>
|
||||
<GroupText>{name}</GroupText>
|
||||
{items.map(({ url, name: linkName }) => (
|
||||
<Bookmark key={linkName} href={url}>
|
||||
{linkName}
|
||||
</Bookmark>
|
||||
))}
|
||||
</BookmarkGroupContainer>
|
||||
);
|
||||
})}
|
||||
</BookmarksContainer>
|
||||
</BookmarkListContainer>
|
||||
const bookmarkList = () => (
|
||||
<ListContainer>
|
||||
<Headline>Bookmarks</Headline>
|
||||
<ItemList>
|
||||
{bookmarkData.groups.map(({ name, items }) => (
|
||||
<Item key={name}>
|
||||
<BookmarkGroup>
|
||||
<Group>{name}</Group>
|
||||
{group.items.map(({ url, name: linkName }) => (
|
||||
<Bookmark key={linkName} href={url}>
|
||||
{linkName}
|
||||
</Bookmark>
|
||||
))}
|
||||
</BookmarkGroup>
|
||||
</Item>
|
||||
))}
|
||||
</ItemList>
|
||||
</ListContainer>
|
||||
);
|
||||
|
||||
export default BookmarkList;
|
||||
export default bookmarkList;
|
|
@ -2,56 +2,56 @@
|
|||
"apps": [
|
||||
{
|
||||
"name": "PiHole",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "192.168.1.253",
|
||||
"URL": "/admin/",
|
||||
"icon": "vpn_lock"
|
||||
},
|
||||
{
|
||||
"name": "Plex",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "app.plex.tv",
|
||||
"URL": "https://app.plex.tv",
|
||||
"icon": "tv"
|
||||
},
|
||||
{
|
||||
"name": "NextCloud",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "phntxx.tech",
|
||||
"URL": "https://phntxx.tech/cloud/",
|
||||
"icon": "filter_drama"
|
||||
},
|
||||
{
|
||||
"name": "Ghost",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "phntxx.tech",
|
||||
"URL": "https://phntxx.tech/blog/",
|
||||
"icon": "rss_feed"
|
||||
},
|
||||
{
|
||||
"name": "Minecraft",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "phntxx.tech",
|
||||
"URL": "https://phntxx.tech/minecraft/index.html",
|
||||
"icon": "games"
|
||||
},
|
||||
{
|
||||
"name": "pfSense",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "phntxx.tech",
|
||||
"URL": "https://phntxx.tech:1111/",
|
||||
"icon": "security"
|
||||
},
|
||||
{
|
||||
"name": "ESXi",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "rhsttpba1.ur.de",
|
||||
"URL": "https://rhsttpba1.ur.de",
|
||||
"icon": "dns"
|
||||
},
|
||||
{
|
||||
"name": "Tautulli",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "phntxx.tech",
|
||||
"URL": "https://phntxx.tech/tautulli/",
|
||||
"icon": "bar_chart"
|
||||
},
|
||||
{
|
||||
"name": "Grafana",
|
||||
"displayURL": "example.com",
|
||||
"URL": "https://example.com",
|
||||
"displayURL": "phntxx.tech",
|
||||
"URL": "https://phntxx.tech/grafana/",
|
||||
"icon": "show_chart"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,53 +1,15 @@
|
|||
{
|
||||
"groups": [
|
||||
{
|
||||
"name": "Communicate",
|
||||
"name": "Wikis",
|
||||
"items": [
|
||||
{
|
||||
"name": "Discord",
|
||||
"url": "https://example.com"
|
||||
"name": "Wikipedia",
|
||||
"url": "https://en.wikipedia.org/"
|
||||
},
|
||||
{
|
||||
"name": "Gmail",
|
||||
"url": "https://example.com"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
"name": "Arch Linux Wiki",
|
||||
"url": "https://archlinux.org/"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -56,32 +18,15 @@
|
|||
"items": [
|
||||
{
|
||||
"name": "Codepen",
|
||||
"url": "https://example.com"
|
||||
"url": "https://codepen.io/"
|
||||
},
|
||||
{
|
||||
"name": "Devdocs",
|
||||
"url": "https://example.com"
|
||||
"name": "JSFiddle",
|
||||
"url": "https://jsfiddle.net/"
|
||||
},
|
||||
{
|
||||
"name": "Devhints",
|
||||
"url": "https://example.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Lifestyle",
|
||||
"items": [
|
||||
{
|
||||
"name": "Design Milk",
|
||||
"url": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Dwell",
|
||||
"url": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Freshome",
|
||||
"url": "https://example.com"
|
||||
"name": "Pastebin",
|
||||
"url": "https://pastebin.com/"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -89,33 +34,46 @@
|
|||
"name": "Media",
|
||||
"items": [
|
||||
{
|
||||
"name": "Spotify",
|
||||
"url": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Trakt",
|
||||
"url": "https://example.com"
|
||||
"name": "Soundcloud",
|
||||
"url": "https://soundcloud.com"
|
||||
},
|
||||
{
|
||||
"name": "YouTube",
|
||||
"url": "https://example.com"
|
||||
"url": "https://youtube.com"
|
||||
},
|
||||
{
|
||||
"name": "Twitch",
|
||||
"url": "https://twitch.tv"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Reading",
|
||||
"name": "Social Networks",
|
||||
"items": [
|
||||
{
|
||||
"name": "Instapaper",
|
||||
"url": "https://example.com"
|
||||
"name": "Facebook",
|
||||
"url": "https://facebook.com"
|
||||
},
|
||||
{
|
||||
"name": "Medium",
|
||||
"url": "https://example.com"
|
||||
"name": "Twitter",
|
||||
"url": "https://twitter.com"
|
||||
},
|
||||
{
|
||||
"name": "Instagram",
|
||||
"url": "https://instagram.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Imageboards",
|
||||
"items": [
|
||||
{
|
||||
"name": "Reddit",
|
||||
"url": "https://example.com"
|
||||
"url": "https://reddit.com"
|
||||
},
|
||||
{
|
||||
"name": "4chan",
|
||||
"url": "https://4chan.org"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -123,16 +81,16 @@
|
|||
"name": "Tech",
|
||||
"items": [
|
||||
{
|
||||
"name": "TheNextWeb",
|
||||
"url": "https://example.com"
|
||||
"name": "Hackernoon",
|
||||
"url": "https://hackernoon.com"
|
||||
},
|
||||
{
|
||||
"name": "The Verge",
|
||||
"url": "https://example.com"
|
||||
"url": "https://theverge.com"
|
||||
},
|
||||
{
|
||||
"name": "MIT Technology Review",
|
||||
"url": "https://example.com"
|
||||
"name": "Hackernews",
|
||||
"url": "https://news.ycombinator.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
32
src/components/elements.js
Normal file
32
src/components/elements.js
Normal 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 };
|
|
@ -1,27 +1,27 @@
|
|||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import React from "react";
|
||||
import styled from "styled-components";
|
||||
|
||||
import { selectedTheme } from '../selectedTheme';
|
||||
import selectedTheme from "./themeManager";
|
||||
|
||||
const GreeterContainer = styled.div`
|
||||
padding: 2rem 0 2rem 0;
|
||||
padding: 2rem 0 2rem 0;
|
||||
`;
|
||||
|
||||
const GreetText = styled.h1`
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 900;
|
||||
font-size: 45px;
|
||||
margin: 0.5rem 0 0.5rem 0;
|
||||
color: ${selectedTheme.mainColor};
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 900;
|
||||
font-size: 45px;
|
||||
margin: 0.5rem 0 0.5rem 0;
|
||||
color: ${selectedTheme.mainColor};
|
||||
`;
|
||||
|
||||
const DateText = styled.h3`
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 15px;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
color: ${selectedTheme.accentColor};
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 15px;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
color: ${selectedTheme.accentColor};
|
||||
`;
|
||||
|
||||
const getGreeting = () => {
|
||||
|
@ -97,4 +97,4 @@ const Greeter = () => {
|
|||
);
|
||||
};
|
||||
|
||||
export default Greeter;
|
||||
export default Greeter;
|
|
@ -1,68 +1,66 @@
|
|||
import React, { useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import React, { useState } from "react";
|
||||
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`
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
border-bottom: 1px solid ${selectedTheme.accentColor};
|
||||
background: none;
|
||||
border-radius: 0;
|
||||
color: ${selectedTheme.mainColor};
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
border-bottom: 1px solid ${selectedTheme.accentColor};
|
||||
background: none;
|
||||
border-radius: 0;
|
||||
color: ${selectedTheme.mainColor};
|
||||
`;
|
||||
|
||||
const handleQueryWithProvider = (query) => {
|
||||
let queryArray = query.split(' ');
|
||||
const handleQueryWithProvider = query => {
|
||||
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;
|
||||
searchData.providers.forEach((provider) => {
|
||||
if (provider.prefix === prefix) {
|
||||
foundProvider = true;
|
||||
window.location = provider.url + searchQuery;
|
||||
}
|
||||
});
|
||||
|
||||
if (!foundProvider) {
|
||||
window.location = 'https://google.com/search?q=' + query;
|
||||
var foundProvider = false;
|
||||
searchData.providers.forEach(provider => {
|
||||
if (provider.prefix === prefix) {
|
||||
foundProvider = true;
|
||||
window.location = provider.url + searchQuery;
|
||||
}
|
||||
});
|
||||
|
||||
if (!foundProvider) {
|
||||
window.location = "https://google.com/search?q=" + query;
|
||||
}
|
||||
};
|
||||
|
||||
const SearchBar = () => {
|
||||
let [input, setInput] = useState();
|
||||
let [input, setInput] = useState();
|
||||
|
||||
const handleSearchQuery = (e) => {
|
||||
var query = input;
|
||||
const handleSearchQuery = e => {
|
||||
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('/')) {
|
||||
handleQueryWithProvider(query);
|
||||
} else {
|
||||
window.location = 'https://google.com/search?q=' + query;
|
||||
}
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={(e) => handleSearchQuery(e)}>
|
||||
<SearchInput
|
||||
type="text"
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
></SearchInput>
|
||||
<button type="submit" hidden />
|
||||
</form>
|
||||
);
|
||||
return (
|
||||
<form onSubmit={e => handleSearchQuery(e)}>
|
||||
<SearchInput
|
||||
type="text"
|
||||
onChange={e => setInput(e.target.value)}
|
||||
></SearchInput>
|
||||
<button type="submit" hidden />
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
export default SearchBar;
|
||||
|
|
|
@ -1,182 +1,168 @@
|
|||
import React, { useState } from 'react';
|
||||
import MaterialIcon from 'material-icons-react';
|
||||
import styled from 'styled-components';
|
||||
import React, { useState } from "react";
|
||||
import MaterialIcon from "material-icons-react";
|
||||
import styled from "styled-components";
|
||||
|
||||
import Select from 'react-select';
|
||||
import Select from "react-select";
|
||||
|
||||
import searchData from './data/search.json';
|
||||
import themeData from './data/themes.json';
|
||||
|
||||
import getTheme, { setTheme } from './themeManager';
|
||||
import selectedTheme, { setTheme } from "./themeManager";
|
||||
import { Button } from './button';
|
||||
|
||||
const selectedTheme = getTheme();
|
||||
|
||||
const ModalButton = styled.button`
|
||||
float: right;
|
||||
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 10px;
|
||||
float: right;
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 10px;
|
||||
`;
|
||||
|
||||
const ExitButton = styled.button`
|
||||
float: right;
|
||||
|
||||
border: none;
|
||||
background: none;
|
||||
float: right;
|
||||
border: none;
|
||||
background: none;
|
||||
`;
|
||||
|
||||
const Modal = styled.div`
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
padding: 1rem;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 10;
|
||||
border: 1px solid ${selectedTheme.mainColor};
|
||||
background-color: ${selectedTheme.backgroundColor};
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
padding: 1rem;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 10;
|
||||
border: 1px solid ${selectedTheme.mainColor};
|
||||
background-color: ${selectedTheme.backgroundColor};
|
||||
`;
|
||||
|
||||
const SelectContainer = styled.div`
|
||||
padding-bottom: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
`;
|
||||
|
||||
const FormContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
`;
|
||||
|
||||
const ApplyButton = Button;
|
||||
|
||||
const Headline = styled.h3`
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 900;
|
||||
color: ${selectedTheme.mainColor};
|
||||
margin-top: 0;
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 900;
|
||||
color: ${selectedTheme.mainColor};
|
||||
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`
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 400;
|
||||
background: none;
|
||||
color: ${selectedTheme.mainColor};
|
||||
font-family: Roboto, sans-serif;
|
||||
font-weight: 400;
|
||||
background: none;
|
||||
color: ${selectedTheme.mainColor};
|
||||
`;
|
||||
|
||||
const TableRow = styled.tr`
|
||||
border-bottom: 1px solid ${selectedTheme.mainColor};
|
||||
border-bottom: 1px solid ${selectedTheme.mainColor};
|
||||
`;
|
||||
|
||||
const TableCell = styled.td`
|
||||
background: none;
|
||||
padding-top: 0.5rem;
|
||||
background: none;
|
||||
padding-top: 0.5rem;
|
||||
`;
|
||||
|
||||
const HeadCell = styled.th`
|
||||
font-weight: 700;
|
||||
background: none;
|
||||
font-weight: 700;
|
||||
background: none;
|
||||
`;
|
||||
|
||||
const SettingsModal = () => {
|
||||
const [modalHidden, setModalHidden] = useState(true);
|
||||
const [newTheme, setNewTheme] = useState();
|
||||
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
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ModalButton onClick={() => setModalHidden(!modalHidden)}>
|
||||
<MaterialIcon icon="settings" color={selectedTheme.mainColor} />
|
||||
</ModalButton>
|
||||
<Modal hidden={modalHidden}>
|
||||
<ExitButton onClick={() => setModalHidden(!modalHidden)}>
|
||||
<MaterialIcon
|
||||
icon="close"
|
||||
color={selectedTheme.mainColor}
|
||||
/>
|
||||
</ExitButton>
|
||||
<SelectContainer>
|
||||
<Headline>Theme:</Headline>
|
||||
<FormContainer>
|
||||
<Select
|
||||
options={themeData.themes}
|
||||
defaultValue={selectedTheme}
|
||||
onChange={(e) => {
|
||||
setNewTheme(e);
|
||||
}}
|
||||
styles={SelectorStyle}
|
||||
/>
|
||||
<ApplyButton
|
||||
onClick={() => setTheme(JSON.stringify(newTheme))}
|
||||
>
|
||||
Apply
|
||||
</ApplyButton>
|
||||
</FormContainer>
|
||||
</SelectContainer>
|
||||
<Table>
|
||||
<tbody>
|
||||
<TableRow>
|
||||
<HeadCell>Search Provider</HeadCell>
|
||||
<HeadCell>Prefix</HeadCell>
|
||||
</TableRow>
|
||||
{searchData.providers.map((provider) => {
|
||||
const { name, prefix } = provider;
|
||||
return (
|
||||
<TableRow key={name}>
|
||||
<TableCell>{name}</TableCell>
|
||||
<TableCell>{prefix}</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</Table>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
const SettingsModal = () => {
|
||||
const [modalHidden, setModalHidden] = useState(true);
|
||||
const [newTheme, setNewTheme] = useState();
|
||||
|
||||
return (
|
||||
<>
|
||||
<ModalButton onClick={() => setModalHidden(!modalHidden)}>
|
||||
<MaterialIcon icon="settings" color={selectedTheme.mainColor} />
|
||||
</ModalButton>
|
||||
<Modal hidden={modalHidden}>
|
||||
<ExitButton onClick={() => setModalHidden(!modalHidden)}>
|
||||
<MaterialIcon icon="close" color={selectedTheme.mainColor} />
|
||||
</ExitButton>
|
||||
<SelectContainer>
|
||||
<Headline>Theme:</Headline>
|
||||
<FormContainer>
|
||||
<Select
|
||||
options={themeData.themes}
|
||||
defaultValue={selectedTheme}
|
||||
onChange={e => {
|
||||
setNewTheme(e);
|
||||
}}
|
||||
styles={SelectorStyle}
|
||||
/>
|
||||
<Button onClick={() => setTheme(JSON.stringify(newTheme))}>
|
||||
Apply
|
||||
</Button>
|
||||
</FormContainer>
|
||||
</SelectContainer>
|
||||
<Table>
|
||||
<tbody>
|
||||
<TableRow>
|
||||
<HeadCell>Search Provider</HeadCell>
|
||||
<HeadCell>Prefix</HeadCell>
|
||||
</TableRow>
|
||||
{searchData.providers.map((provider, index) => (
|
||||
<TableRow key={provider.name + index}>
|
||||
<TableCell>{provider.name}</TableCell>
|
||||
<TableCell>{provider.prefix}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</tbody>
|
||||
</Table>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsModal;
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
import themeData from './data/themes.json';
|
||||
import themeData from "./data/themes.json";
|
||||
|
||||
const setTheme = (theme) => {
|
||||
localStorage.setItem('theme', theme);
|
||||
window.location.reload();
|
||||
const setTheme = theme => {
|
||||
localStorage.setItem("theme", theme);
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const resetTheme = () => {
|
||||
localStorage.removeItem('theme');
|
||||
localStorage.removeItem("theme");
|
||||
};
|
||||
|
||||
const getTheme = () => {
|
||||
let selectedTheme = themeData.themes[0];
|
||||
let selectedTheme = themeData.themes[0];
|
||||
|
||||
if (
|
||||
localStorage.getItem('theme') &&
|
||||
localStorage.getItem('theme') !== undefined
|
||||
) {
|
||||
selectedTheme = JSON.parse(localStorage.getItem('theme'));
|
||||
}
|
||||
if (
|
||||
localStorage.getItem("theme") &&
|
||||
localStorage.getItem("theme") !== undefined
|
||||
) {
|
||||
selectedTheme = JSON.parse(localStorage.getItem("theme"));
|
||||
}
|
||||
|
||||
return selectedTheme;
|
||||
return selectedTheme;
|
||||
};
|
||||
|
||||
const selectedTheme = getTheme();
|
||||
|
||||
export { setTheme, resetTheme };
|
||||
|
||||
export default getTheme;
|
||||
export default selectedTheme;
|
||||
|
|
Loading…
Reference in a new issue