Fix bugs caused by merge
Also formatted using Prettier
This commit is contained in:
parent
eb56ac3699
commit
4a58f79270
11 changed files with 356 additions and 345 deletions
16
src/App.js
16
src/App.js
|
@ -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 "./components/themeManager";
|
import selectedTheme from './components/themeManager';
|
||||||
|
|
||||||
const GlobalStyle = createGlobalStyle`
|
const GlobalStyle = createGlobalStyle`
|
||||||
body {
|
body {
|
||||||
|
|
|
@ -1,46 +1,44 @@
|
||||||
import React from "react";
|
import React, { useCallback, useEffect, 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 appData from "./data/apps.json";
|
import selectedTheme from './themeManager';
|
||||||
|
|
||||||
import selectedTheme from "./themeManager";
|
import { Headline, ListContainer, ItemList, Item, Button } from './elements';
|
||||||
|
|
||||||
import { Headline, ListContainer, ItemList, Item } from "./elements";
|
|
||||||
|
|
||||||
const IconContainer = styled.div`
|
const IconContainer = styled.div`
|
||||||
margin-right: 0.5vh;
|
margin-right: 0.5vh;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const DetailsContainer = styled.div`
|
const DetailsContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Link = styled.a`
|
const Link = styled.a`
|
||||||
font-family: Roboto, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
color: ${selectedTheme.mainColor};
|
color: ${selectedTheme.mainColor};
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 1rem;
|
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: 0;
|
margin: 0;
|
||||||
font-size: 0.65rem;
|
font-size: 0.65rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: ${selectedTheme.accentColor};
|
color: ${selectedTheme.accentColor};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = styled.div`
|
const App = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-basis: 25%;
|
flex-basis: 25%;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ErrorMessage = styled.p`
|
const ErrorMessage = styled.p`
|
||||||
|
@ -61,10 +59,10 @@ function useAppData() {
|
||||||
? fetch('/apps.json').then(handleResponse)
|
? fetch('/apps.json').then(handleResponse)
|
||||||
: import('./data/apps.json')
|
: import('./data/apps.json')
|
||||||
)
|
)
|
||||||
.then((jsonResponse) => {
|
.then(jsonResponse => {
|
||||||
setAppData({ ...jsonResponse, error: false });
|
setAppData({ ...jsonResponse, error: false });
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
setAppData({ apps: [], error: error.message });
|
setAppData({ apps: [], error: error.message });
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -77,35 +75,37 @@ function useAppData() {
|
||||||
const AppList = () => {
|
const AppList = () => {
|
||||||
const {
|
const {
|
||||||
appData: { apps, error },
|
appData: { apps, error },
|
||||||
fetchAppData,
|
fetchAppData
|
||||||
} = useAppData();
|
} = useAppData();
|
||||||
return (
|
return (
|
||||||
<AppListContainer>
|
<ListContainer>
|
||||||
<ApplicationsText>
|
<Headline>
|
||||||
Applications <Button onClick={fetchAppData}>refresh</Button>
|
Applications <Button onClick={fetchAppData}>refresh</Button>
|
||||||
</ApplicationsText>
|
</Headline>
|
||||||
<AppsContainer>
|
<ItemList>
|
||||||
{error && <ErrorMessage>{error}</ErrorMessage>}
|
{error && <ErrorMessage>{error}</ErrorMessage>}
|
||||||
{apps.map((app, idx) => {
|
{apps.map((app, idx) => {
|
||||||
const { name } = app;
|
const { name } = app;
|
||||||
return (
|
return (
|
||||||
<AppContainer key={[name, idx].join('')}>
|
<Item key={[name, idx].join('')}>
|
||||||
<IconContainer>
|
<App>
|
||||||
<MaterialIcon
|
<IconContainer>
|
||||||
icon={app.icon}
|
<MaterialIcon
|
||||||
color={selectedTheme.mainColor}
|
icon={app.icon}
|
||||||
/>
|
color={selectedTheme.mainColor}
|
||||||
</IconContainer>
|
/>
|
||||||
<AppDetails>
|
</IconContainer>
|
||||||
<Link href={app.URL}>{app.name}</Link>
|
<DetailsContainer>
|
||||||
<Description>{app.displayURL}</Description>
|
<Link href={app.URL}>{app.name}</Link>
|
||||||
</AppDetails>
|
<Description>{app.displayURL}</Description>
|
||||||
</AppContainer>
|
</DetailsContainer>
|
||||||
|
</App>
|
||||||
|
</Item>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</AppsContainer>
|
</ItemList>
|
||||||
</AppListContainer>
|
</ListContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AppList;
|
export default AppList;
|
||||||
|
|
|
@ -1,53 +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 "./themeManager";
|
import selectedTheme from './themeManager';
|
||||||
import { Headline, ListContainer, ItemList, Item } from "./elements";
|
import { Headline, ListContainer, ItemList, Item } from './elements';
|
||||||
|
|
||||||
const Group = styled.h4`
|
const Group = styled.h4`
|
||||||
font-family: Roboto, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: ${selectedTheme.mainColor};
|
color: ${selectedTheme.mainColor};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const BookmarkGroup = styled.div`
|
const BookmarkGroup = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 2 1 auto;
|
flex: 2 1 auto;
|
||||||
padding: 1rem 0 1rem 0;
|
padding: 1rem 0 1rem 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
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 = () => (
|
||||||
<ListContainer>
|
<ListContainer>
|
||||||
<Headline>Bookmarks</Headline>
|
<Headline>Bookmarks</Headline>
|
||||||
<ItemList>
|
<ItemList>
|
||||||
{bookmarkData.groups.map(({ name, items }) => (
|
{bookmarkData.groups.map(({ name, items }) => (
|
||||||
<Item key={name}>
|
<Item key={name}>
|
||||||
<BookmarkGroup>
|
<BookmarkGroup>
|
||||||
<Group>{name}</Group>
|
<Group>{name}</Group>
|
||||||
{group.items.map(({ url, name: linkName }) => (
|
{items.map(({ url, name: linkName }) => (
|
||||||
<Bookmark key={linkName} href={url}>
|
<Bookmark key={linkName} href={url}>
|
||||||
{linkName}
|
{linkName}
|
||||||
</Bookmark>
|
</Bookmark>
|
||||||
|
))}
|
||||||
|
</BookmarkGroup>
|
||||||
|
</Item>
|
||||||
))}
|
))}
|
||||||
</BookmarkGroup>
|
</ItemList>
|
||||||
</Item>
|
</ListContainer>
|
||||||
))}
|
|
||||||
</ItemList>
|
|
||||||
</ListContainer>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export default bookmarkList;
|
export default bookmarkList;
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
import styled from 'styled-components';
|
|
||||||
import { selectedTheme } from '../selectedTheme';
|
|
||||||
|
|
||||||
export const Button = styled.button`
|
|
||||||
font-family: Roboto, sans-serif;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-weight: 400;
|
|
||||||
border: 1px solid ${selectedTheme.mainColor};
|
|
||||||
color: ${selectedTheme.mainColor};
|
|
||||||
background: none;
|
|
||||||
margin-left: 1rem;
|
|
||||||
min-height: 3em;
|
|
||||||
`;
|
|
|
@ -1,32 +1,71 @@
|
||||||
import styled from "styled-components";
|
import React from 'react';
|
||||||
import selectedTheme from "./themeManager";
|
import styled from 'styled-components';
|
||||||
|
import selectedTheme from './themeManager';
|
||||||
|
import MaterialIcon from 'material-icons-react';
|
||||||
|
|
||||||
const ListContainer = styled.div`
|
// File for elements that are/can be reused across the entire site.
|
||||||
padding: 2rem 0 2rem 0;
|
|
||||||
|
export const ListContainer = styled.div`
|
||||||
|
padding: 2rem 0 2rem 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Headline = styled.h3`
|
export const Headline = styled.h3`
|
||||||
font-family: Roboto, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
color: ${selectedTheme.mainColor};
|
color: ${selectedTheme.mainColor};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ItemList = styled.ul`
|
export const ItemList = styled.ul`
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
grid-gap: 1rem;
|
grid-gap: 1rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Item = styled.li`
|
export const Item = styled.li`
|
||||||
max-height: 100px;
|
max-height: 100px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export { Headline, ListContainer, ItemList, Item };
|
export const Button = styled.button`
|
||||||
|
font-family: Roboto, sans-serif;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 400;
|
||||||
|
border: 1px solid ${selectedTheme.mainColor};
|
||||||
|
color: ${selectedTheme.mainColor};
|
||||||
|
background: none;
|
||||||
|
margin-left: 1rem;
|
||||||
|
min-height: 3em;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledButton = styled.button`
|
||||||
|
float: right;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const IconButton = props => {
|
||||||
|
if (
|
||||||
|
props.icon &&
|
||||||
|
props.icon !== '' &&
|
||||||
|
props.icon !== undefined &&
|
||||||
|
props.onClick &&
|
||||||
|
props.onClick !== '' &&
|
||||||
|
props.onClick !== undefined
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<StyledButton onClick={props.onClick}>
|
||||||
|
<MaterialIcon
|
||||||
|
icon={props.icon}
|
||||||
|
color={selectedTheme.mainColor}
|
||||||
|
/>
|
||||||
|
</StyledButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -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 "./themeManager";
|
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 = () => {
|
||||||
|
@ -29,7 +29,7 @@ const getGreeting = () => {
|
||||||
return 'Hello World!';
|
return 'Hello World!';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getExtension = (day) => {
|
const getExtension = day => {
|
||||||
let extension = '';
|
let extension = '';
|
||||||
|
|
||||||
if ((day > 4 && day <= 20) || (day > 20 && day % 10 >= 4)) {
|
if ((day > 4 && day <= 20) || (day > 20 && day % 10 >= 4)) {
|
||||||
|
@ -57,7 +57,7 @@ const monthNames = [
|
||||||
'September',
|
'September',
|
||||||
'October',
|
'October',
|
||||||
'November',
|
'November',
|
||||||
'December',
|
'December'
|
||||||
];
|
];
|
||||||
|
|
||||||
const weekDayNames = [
|
const weekDayNames = [
|
||||||
|
@ -67,7 +67,7 @@ const weekDayNames = [
|
||||||
'Wednesday',
|
'Wednesday',
|
||||||
'Thursday',
|
'Thursday',
|
||||||
'Friday',
|
'Friday',
|
||||||
'Saturday',
|
'Saturday'
|
||||||
];
|
];
|
||||||
|
|
||||||
const getDateString = () => {
|
const getDateString = () => {
|
||||||
|
@ -97,4 +97,4 @@ const Greeter = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Greeter;
|
export default Greeter;
|
||||||
|
|
|
@ -1,66 +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 "./themeManager";
|
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;
|
||||||
|
|
||||||
if (query.split(" ")[0].includes("/")) {
|
if (query.split(' ')[0].includes('/')) {
|
||||||
handleQueryWithProvider(query);
|
handleQueryWithProvider(query);
|
||||||
} else {
|
} else {
|
||||||
window.location = "https://google.com/search?q=" + query;
|
window.location = 'https://google.com/search?q=' + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={e => handleSearchQuery(e)}>
|
<form onSubmit={e => handleSearchQuery(e)}>
|
||||||
<SearchInput
|
<SearchInput
|
||||||
type="text"
|
type="text"
|
||||||
onChange={e => setInput(e.target.value)}
|
onChange={e => setInput(e.target.value)}
|
||||||
></SearchInput>
|
></SearchInput>
|
||||||
<button type="submit" hidden />
|
<button type="submit" hidden />
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SearchBar;
|
export default SearchBar;
|
||||||
|
|
|
@ -1,168 +1,158 @@
|
||||||
import React, { useState } from "react";
|
import React, { useState } from '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 selectedTheme, { setTheme } from "./themeManager";
|
import selectedTheme, { setTheme } from './themeManager';
|
||||||
import { Button } from './button';
|
import { Button, IconButton } from './elements';
|
||||||
|
|
||||||
const ModalButton = styled.button`
|
|
||||||
float: right;
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
padding: 10px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ExitButton = styled.button`
|
|
||||||
float: right;
|
|
||||||
border: 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 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 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 SelectorStyle = {
|
const SelectorStyle = {
|
||||||
control: provided => ({
|
control: provided => ({
|
||||||
...provided,
|
...provided,
|
||||||
fontFamily: "Roboto, sans-serif",
|
fontFamily: 'Roboto, sans-serif',
|
||||||
fontWeight: "500",
|
fontWeight: '500',
|
||||||
color: selectedTheme.mainColor,
|
color: selectedTheme.mainColor,
|
||||||
textTransform: "uppercase",
|
textTransform: 'uppercase',
|
||||||
width: "200px",
|
width: '200px',
|
||||||
background: "none",
|
background: 'none',
|
||||||
borderRadius: "0px",
|
borderRadius: '0px',
|
||||||
border: "1px solid " + selectedTheme.mainColor,
|
border: '1px solid ' + selectedTheme.mainColor,
|
||||||
boxShadow: 0,
|
boxShadow: 0,
|
||||||
"&:hover": {
|
'&:hover': {
|
||||||
border: "1px solid " + selectedTheme.mainColor
|
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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}),
|
|
||||||
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 SettingsModal = () => {
|
const SettingsModal = () => {
|
||||||
const [modalHidden, setModalHidden] = useState(true);
|
const [modalHidden, setModalHidden] = useState(true);
|
||||||
const [newTheme, setNewTheme] = useState();
|
const [newTheme, setNewTheme] = useState();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ModalButton onClick={() => setModalHidden(!modalHidden)}>
|
<IconButton
|
||||||
<MaterialIcon icon="settings" color={selectedTheme.mainColor} />
|
icon="settings"
|
||||||
</ModalButton>
|
onClick={() => setModalHidden(!modalHidden)}
|
||||||
<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))}>
|
<Modal hidden={modalHidden}>
|
||||||
Apply
|
<IconButton
|
||||||
</Button>
|
icon="close"
|
||||||
</FormContainer>
|
onClick={() => setModalHidden(!modalHidden)}
|
||||||
</SelectContainer>
|
/>
|
||||||
<Table>
|
<SelectContainer>
|
||||||
<tbody>
|
<Headline>Theme:</Headline>
|
||||||
<TableRow>
|
<FormContainer>
|
||||||
<HeadCell>Search Provider</HeadCell>
|
<Select
|
||||||
<HeadCell>Prefix</HeadCell>
|
options={themeData.themes}
|
||||||
</TableRow>
|
defaultValue={selectedTheme}
|
||||||
{searchData.providers.map((provider, index) => (
|
onChange={e => {
|
||||||
<TableRow key={provider.name + index}>
|
setNewTheme(e);
|
||||||
<TableCell>{provider.name}</TableCell>
|
}}
|
||||||
<TableCell>{provider.prefix}</TableCell>
|
styles={SelectorStyle}
|
||||||
</TableRow>
|
/>
|
||||||
))}
|
<Button
|
||||||
</tbody>
|
onClick={() => setTheme(JSON.stringify(newTheme))}
|
||||||
</Table>
|
>
|
||||||
</Modal>
|
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;
|
export default SettingsModal;
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
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();
|
const selectedTheme = getTheme();
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
import themeData from './components/data/themes.json';
|
|
||||||
|
|
||||||
export const selectedTheme = localStorage.getItem('theme')
|
|
||||||
? JSON.parse(localStorage.getItem('theme'))
|
|
||||||
: themeData.themes[0];
|
|
|
@ -57,7 +57,7 @@ export function register(config) {
|
||||||
function registerValidSW(swUrl, config) {
|
function registerValidSW(swUrl, config) {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register(swUrl)
|
.register(swUrl)
|
||||||
.then((registration) => {
|
.then(registration => {
|
||||||
registration.onupdatefound = () => {
|
registration.onupdatefound = () => {
|
||||||
const installingWorker = registration.installing;
|
const installingWorker = registration.installing;
|
||||||
if (installingWorker == null) {
|
if (installingWorker == null) {
|
||||||
|
@ -93,7 +93,7 @@ function registerValidSW(swUrl, config) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error('Error during service worker registration:', error);
|
console.error('Error during service worker registration:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -101,9 +101,9 @@ function registerValidSW(swUrl, config) {
|
||||||
function checkValidServiceWorker(swUrl, config) {
|
function checkValidServiceWorker(swUrl, config) {
|
||||||
// Check if the service worker can be found. If it can't reload the page.
|
// Check if the service worker can be found. If it can't reload the page.
|
||||||
fetch(swUrl, {
|
fetch(swUrl, {
|
||||||
headers: { 'Service-Worker': 'script' },
|
headers: { 'Service-Worker': 'script' }
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
// Ensure service worker exists, and that we really are getting a JS file.
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
const contentType = response.headers.get('content-type');
|
const contentType = response.headers.get('content-type');
|
||||||
if (
|
if (
|
||||||
|
@ -112,7 +112,7 @@ function checkValidServiceWorker(swUrl, config) {
|
||||||
contentType.indexOf('javascript') === -1)
|
contentType.indexOf('javascript') === -1)
|
||||||
) {
|
) {
|
||||||
// No service worker found. Probably a different app. Reload the page.
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
registration.unregister().then(() => {
|
registration.unregister().then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
@ -132,10 +132,10 @@ function checkValidServiceWorker(swUrl, config) {
|
||||||
export function unregister() {
|
export function unregister() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.ready
|
navigator.serviceWorker.ready
|
||||||
.then((registration) => {
|
.then(registration => {
|
||||||
registration.unregister();
|
registration.unregister();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue