From 7b202cdd645be50fd2ab96ad64f23e84b06d0534 Mon Sep 17 00:00:00 2001 From: Bastian Meissner Date: Fri, 10 Jul 2020 00:04:47 +0200 Subject: [PATCH] Tweaked CSS slightly --- package.json | 2 +- src/app.tsx | 14 ++++++++++---- src/components/elements.tsx | 6 +++++- src/components/greeter.tsx | 6 +++--- src/components/searchBar.tsx | 18 +++++++++--------- src/components/settingsModal.tsx | 29 +++++++++++++++++------------ src/components/themeManager.tsx | 18 ++++++++++++------ yarn.lock | 8 ++++---- 8 files changed, 61 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 5e22059..2111356 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "react-scripts": "3.4.1", "react-select": "^3.1.0", "styled-components": "^5.1.1", - "typescript": "~3.7.2" + "typescript": "^3.9.6" }, "scripts": { "start": "react-scripts start", diff --git a/src/app.tsx b/src/app.tsx index 8a2076c..b34ab8d 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -13,13 +13,19 @@ const GlobalStyle = createGlobalStyle` body { background-color: ${selectedTheme.backgroundColor}; font-family: Roboto, sans-serif; + + margin: auto; + max-width: 95%; + max-height: 100%; + + @media (min-width: 1366px) { + max-width: 70%; + } + } `; -const AppContainer = styled.div` - max-width: 95%; - margin: auto; -`; +const AppContainer = styled.div``; const App = () => ( <> diff --git a/src/components/elements.tsx b/src/components/elements.tsx index f7538b9..57a7e14 100644 --- a/src/components/elements.tsx +++ b/src/components/elements.tsx @@ -35,10 +35,14 @@ export const SubHeadline = styled.h3` export const ItemList = styled.ul` display: grid; - grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + grid-template-columns: repeat(4, 1fr); grid-gap: 1rem; padding: 0; list-style: none; + + @media (max-width: 750px) { + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + } `; export const Item = styled.li` diff --git a/src/components/greeter.tsx b/src/components/greeter.tsx index d2c8492..96af2f3 100644 --- a/src/components/greeter.tsx +++ b/src/components/greeter.tsx @@ -25,7 +25,7 @@ const DateText = styled.h3` const getGreeting = () => { switch (Math.floor(new Date().getHours() / 6)) { case 0: - return "Goor night!"; + return "Good night!"; case 1: return "Good morning!"; case 2: @@ -65,7 +65,7 @@ const monthNames = [ "September", "October", "November", - "December" + "December", ]; const weekDayNames = [ @@ -75,7 +75,7 @@ const weekDayNames = [ "Wednesday", "Thursday", "Friday", - "Saturday" + "Saturday", ]; const getDateString = () => { diff --git a/src/components/searchBar.tsx b/src/components/searchBar.tsx index a9067bd..8c6cd19 100644 --- a/src/components/searchBar.tsx +++ b/src/components/searchBar.tsx @@ -18,7 +18,7 @@ const SearchInput = styled.input` const useSearchProviders = () => { const [searchProviders, setSearchProviders] = useState({ providers: [{ prefix: "", url: "" }], - error: false + error: false, }); const fetchSearchProviders = useCallback(() => { @@ -26,10 +26,10 @@ const useSearchProviders = () => { ? fetch("/data/search.json").then(handleResponse) : import("./data/search.json") ) - .then(jsonResponse => { + .then((jsonResponse) => { setSearchProviders({ ...jsonResponse, error: false }); }) - .catch(error => { + .catch((error) => { setSearchProviders({ providers: [], error: error.message }); }); }, []); @@ -42,13 +42,13 @@ const useSearchProviders = () => { const SearchBar = () => { const { - searchProviders: { providers, error } + searchProviders: { providers, error }, } = useSearchProviders(); - let [input, setInput] = useState(); + let [input, setInput] = useState(""); const handleSearchQuery = (e: React.FormEvent) => { - var query = input; + var query = input || ""; if (query.split(" ")[0].includes("/")) { handleQueryWithProvider(query); @@ -67,7 +67,7 @@ const SearchBar = () => { let searchQuery = queryArray.join(" "); let providerFound = false; - providers.forEach(provider => { + providers.forEach((provider) => { if (provider.prefix === prefix) { providerFound = true; window.location.href = provider.url + searchQuery; @@ -79,11 +79,11 @@ const SearchBar = () => { }; return ( -
handleSearchQuery(e)}> + handleSearchQuery(e)}> {error && {error}} setInput(e.target.value)} + onChange={(e) => setInput(e.target.value)} >