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 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 "./components/themeManager";
|
||||
import selectedTheme from './components/themeManager';
|
||||
|
||||
const GlobalStyle = createGlobalStyle`
|
||||
body {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import React from "react";
|
||||
import MaterialIcon from "material-icons-react";
|
||||
import styled from "styled-components";
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import MaterialIcon from 'material-icons-react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import appData from "./data/apps.json";
|
||||
import selectedTheme from './themeManager';
|
||||
|
||||
import selectedTheme from "./themeManager";
|
||||
|
||||
import { Headline, ListContainer, ItemList, Item } from "./elements";
|
||||
import { Headline, ListContainer, ItemList, Item, Button } from './elements';
|
||||
|
||||
const IconContainer = styled.div`
|
||||
margin-right: 0.5vh;
|
||||
|
@ -61,10 +59,10 @@ function useAppData() {
|
|||
? fetch('/apps.json').then(handleResponse)
|
||||
: import('./data/apps.json')
|
||||
)
|
||||
.then((jsonResponse) => {
|
||||
.then(jsonResponse => {
|
||||
setAppData({ ...jsonResponse, error: false });
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(error => {
|
||||
setAppData({ apps: [], error: error.message });
|
||||
});
|
||||
}, []);
|
||||
|
@ -77,34 +75,36 @@ function useAppData() {
|
|||
const AppList = () => {
|
||||
const {
|
||||
appData: { apps, error },
|
||||
fetchAppData,
|
||||
fetchAppData
|
||||
} = useAppData();
|
||||
return (
|
||||
<AppListContainer>
|
||||
<ApplicationsText>
|
||||
<ListContainer>
|
||||
<Headline>
|
||||
Applications <Button onClick={fetchAppData}>refresh</Button>
|
||||
</ApplicationsText>
|
||||
<AppsContainer>
|
||||
</Headline>
|
||||
<ItemList>
|
||||
{error && <ErrorMessage>{error}</ErrorMessage>}
|
||||
{apps.map((app, idx) => {
|
||||
const { name } = app;
|
||||
return (
|
||||
<AppContainer key={[name, idx].join('')}>
|
||||
<Item key={[name, idx].join('')}>
|
||||
<App>
|
||||
<IconContainer>
|
||||
<MaterialIcon
|
||||
icon={app.icon}
|
||||
color={selectedTheme.mainColor}
|
||||
/>
|
||||
</IconContainer>
|
||||
<AppDetails>
|
||||
<DetailsContainer>
|
||||
<Link href={app.URL}>{app.name}</Link>
|
||||
<Description>{app.displayURL}</Description>
|
||||
</AppDetails>
|
||||
</AppContainer>
|
||||
</DetailsContainer>
|
||||
</App>
|
||||
</Item>
|
||||
);
|
||||
})}
|
||||
</AppsContainer>
|
||||
</AppListContainer>
|
||||
</ItemList>
|
||||
</ListContainer>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
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 "./themeManager";
|
||||
import { Headline, ListContainer, ItemList, Item } from "./elements";
|
||||
import selectedTheme from './themeManager';
|
||||
import { Headline, ListContainer, ItemList, Item } from './elements';
|
||||
|
||||
const Group = styled.h4`
|
||||
font-family: Roboto, sans-serif;
|
||||
|
@ -38,7 +38,7 @@ const bookmarkList = () => (
|
|||
<Item key={name}>
|
||||
<BookmarkGroup>
|
||||
<Group>{name}</Group>
|
||||
{group.items.map(({ url, name: linkName }) => (
|
||||
{items.map(({ url, name: linkName }) => (
|
||||
<Bookmark key={linkName} href={url}>
|
||||
{linkName}
|
||||
</Bookmark>
|
||||
|
|
|
@ -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,11 +1,15 @@
|
|||
import styled from "styled-components";
|
||||
import selectedTheme from "./themeManager";
|
||||
import React from 'react';
|
||||
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.
|
||||
|
||||
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-weight: 900;
|
||||
text-transform: uppercase;
|
||||
|
@ -14,7 +18,7 @@ const Headline = styled.h3`
|
|||
color: ${selectedTheme.mainColor};
|
||||
`;
|
||||
|
||||
const ItemList = styled.ul`
|
||||
export const ItemList = styled.ul`
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
grid-gap: 1rem;
|
||||
|
@ -22,11 +26,46 @@ const ItemList = styled.ul`
|
|||
list-style: none;
|
||||
`;
|
||||
|
||||
const Item = styled.li`
|
||||
export const Item = styled.li`
|
||||
max-height: 100px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
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,7 +1,7 @@
|
|||
import React from "react";
|
||||
import styled from "styled-components";
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import selectedTheme from "./themeManager";
|
||||
import selectedTheme from './themeManager';
|
||||
|
||||
const GreeterContainer = styled.div`
|
||||
padding: 2rem 0 2rem 0;
|
||||
|
@ -29,7 +29,7 @@ const getGreeting = () => {
|
|||
return 'Hello World!';
|
||||
};
|
||||
|
||||
const getExtension = (day) => {
|
||||
const getExtension = day => {
|
||||
let extension = '';
|
||||
|
||||
if ((day > 4 && day <= 20) || (day > 20 && day % 10 >= 4)) {
|
||||
|
@ -57,7 +57,7 @@ const monthNames = [
|
|||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December',
|
||||
'December'
|
||||
];
|
||||
|
||||
const weekDayNames = [
|
||||
|
@ -67,7 +67,7 @@ const weekDayNames = [
|
|||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday',
|
||||
'Saturday'
|
||||
];
|
||||
|
||||
const getDateString = () => {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
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 "./themeManager";
|
||||
import selectedTheme from './themeManager';
|
||||
|
||||
const SearchInput = styled.input`
|
||||
width: 100%;
|
||||
|
@ -16,13 +16,13 @@ const SearchInput = styled.input`
|
|||
`;
|
||||
|
||||
const handleQueryWithProvider = query => {
|
||||
let queryArray = query.split(" ");
|
||||
let queryArray = query.split(' ');
|
||||
|
||||
let prefix = queryArray[0];
|
||||
|
||||
queryArray.shift();
|
||||
|
||||
let searchQuery = queryArray.join(" ");
|
||||
let searchQuery = queryArray.join(' ');
|
||||
|
||||
var foundProvider = false;
|
||||
searchData.providers.forEach(provider => {
|
||||
|
@ -33,7 +33,7 @@ const handleQueryWithProvider = query => {
|
|||
});
|
||||
|
||||
if (!foundProvider) {
|
||||
window.location = "https://google.com/search?q=" + query;
|
||||
window.location = 'https://google.com/search?q=' + query;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -43,10 +43,10 @@ const SearchBar = () => {
|
|||
const handleSearchQuery = e => {
|
||||
var query = input;
|
||||
|
||||
if (query.split(" ")[0].includes("/")) {
|
||||
if (query.split(' ')[0].includes('/')) {
|
||||
handleQueryWithProvider(query);
|
||||
} else {
|
||||
window.location = "https://google.com/search?q=" + query;
|
||||
window.location = 'https://google.com/search?q=' + query;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
|
|
@ -1,27 +1,13 @@
|
|||
import React, { useState } from "react";
|
||||
import MaterialIcon from "material-icons-react";
|
||||
import styled from "styled-components";
|
||||
import React, { useState } from '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 selectedTheme, { setTheme } from "./themeManager";
|
||||
import { Button } from './button';
|
||||
|
||||
const ModalButton = styled.button`
|
||||
float: right;
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 10px;
|
||||
`;
|
||||
|
||||
const ExitButton = styled.button`
|
||||
float: right;
|
||||
border: none;
|
||||
background: none;
|
||||
`;
|
||||
import selectedTheme, { setTheme } from './themeManager';
|
||||
import { Button, IconButton } from './elements';
|
||||
|
||||
const Modal = styled.div`
|
||||
position: absolute;
|
||||
|
@ -75,36 +61,36 @@ const HeadCell = styled.th`
|
|||
const SelectorStyle = {
|
||||
control: provided => ({
|
||||
...provided,
|
||||
fontFamily: "Roboto, sans-serif",
|
||||
fontWeight: "500",
|
||||
fontFamily: 'Roboto, sans-serif',
|
||||
fontWeight: '500',
|
||||
color: selectedTheme.mainColor,
|
||||
textTransform: "uppercase",
|
||||
width: "200px",
|
||||
background: "none",
|
||||
borderRadius: "0px",
|
||||
border: "1px solid " + selectedTheme.mainColor,
|
||||
textTransform: 'uppercase',
|
||||
width: '200px',
|
||||
background: 'none',
|
||||
borderRadius: '0px',
|
||||
border: '1px solid ' + selectedTheme.mainColor,
|
||||
boxShadow: 0,
|
||||
"&:hover": {
|
||||
border: "1px solid " + selectedTheme.mainColor
|
||||
'&:hover': {
|
||||
border: '1px solid ' + selectedTheme.mainColor
|
||||
}
|
||||
}),
|
||||
menu: provided => ({
|
||||
...provided,
|
||||
backgroundColor: selectedTheme.backgroundColor,
|
||||
border: "1px solid " + selectedTheme.mainColor,
|
||||
borderRadius: "0px",
|
||||
border: '1px solid ' + selectedTheme.mainColor,
|
||||
borderRadius: '0px',
|
||||
boxShadow: 0
|
||||
}),
|
||||
option: provided => ({
|
||||
...provided,
|
||||
fontFamily: "Roboto, sans-serif",
|
||||
fontWeight: "500",
|
||||
fontFamily: 'Roboto, sans-serif',
|
||||
fontWeight: '500',
|
||||
color: selectedTheme.mainColor,
|
||||
textTransform: "uppercase",
|
||||
borderRadius: "0px",
|
||||
textTransform: 'uppercase',
|
||||
borderRadius: '0px',
|
||||
boxShadow: 0,
|
||||
backgroundColor: selectedTheme.backgroundColor,
|
||||
"&:hover": {
|
||||
'&:hover': {
|
||||
backgroundColor: selectedTheme.mainColor,
|
||||
color: selectedTheme.backgroundColor
|
||||
}
|
||||
|
@ -123,13 +109,15 @@ const SettingsModal = () => {
|
|||
|
||||
return (
|
||||
<>
|
||||
<ModalButton onClick={() => setModalHidden(!modalHidden)}>
|
||||
<MaterialIcon icon="settings" color={selectedTheme.mainColor} />
|
||||
</ModalButton>
|
||||
<IconButton
|
||||
icon="settings"
|
||||
onClick={() => setModalHidden(!modalHidden)}
|
||||
/>
|
||||
<Modal hidden={modalHidden}>
|
||||
<ExitButton onClick={() => setModalHidden(!modalHidden)}>
|
||||
<MaterialIcon icon="close" color={selectedTheme.mainColor} />
|
||||
</ExitButton>
|
||||
<IconButton
|
||||
icon="close"
|
||||
onClick={() => setModalHidden(!modalHidden)}
|
||||
/>
|
||||
<SelectContainer>
|
||||
<Headline>Theme:</Headline>
|
||||
<FormContainer>
|
||||
|
@ -141,7 +129,9 @@ const SettingsModal = () => {
|
|||
}}
|
||||
styles={SelectorStyle}
|
||||
/>
|
||||
<Button onClick={() => setTheme(JSON.stringify(newTheme))}>
|
||||
<Button
|
||||
onClick={() => setTheme(JSON.stringify(newTheme))}
|
||||
>
|
||||
Apply
|
||||
</Button>
|
||||
</FormContainer>
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
import themeData from "./data/themes.json";
|
||||
import themeData from './data/themes.json';
|
||||
|
||||
const setTheme = theme => {
|
||||
localStorage.setItem("theme", theme);
|
||||
localStorage.setItem('theme', theme);
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const resetTheme = () => {
|
||||
localStorage.removeItem("theme");
|
||||
localStorage.removeItem('theme');
|
||||
};
|
||||
|
||||
const getTheme = () => {
|
||||
let selectedTheme = themeData.themes[0];
|
||||
|
||||
if (
|
||||
localStorage.getItem("theme") &&
|
||||
localStorage.getItem("theme") !== undefined
|
||||
localStorage.getItem('theme') &&
|
||||
localStorage.getItem('theme') !== undefined
|
||||
) {
|
||||
selectedTheme = JSON.parse(localStorage.getItem("theme"));
|
||||
selectedTheme = JSON.parse(localStorage.getItem('theme'));
|
||||
}
|
||||
|
||||
return selectedTheme;
|
||||
|
|
|
@ -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) {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then((registration) => {
|
||||
.then(registration => {
|
||||
registration.onupdatefound = () => {
|
||||
const installingWorker = registration.installing;
|
||||
if (installingWorker == null) {
|
||||
|
@ -93,7 +93,7 @@ function registerValidSW(swUrl, config) {
|
|||
};
|
||||
};
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(error => {
|
||||
console.error('Error during service worker registration:', error);
|
||||
});
|
||||
}
|
||||
|
@ -101,9 +101,9 @@ function registerValidSW(swUrl, config) {
|
|||
function checkValidServiceWorker(swUrl, config) {
|
||||
// Check if the service worker can be found. If it can't reload the page.
|
||||
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.
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (
|
||||
|
@ -112,7 +112,7 @@ function checkValidServiceWorker(swUrl, config) {
|
|||
contentType.indexOf('javascript') === -1)
|
||||
) {
|
||||
// No service worker found. Probably a different app. Reload the page.
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.unregister().then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
|
@ -132,10 +132,10 @@ function checkValidServiceWorker(swUrl, config) {
|
|||
export function unregister() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready
|
||||
.then((registration) => {
|
||||
.then(registration => {
|
||||
registration.unregister();
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(error => {
|
||||
console.error(error.message);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue