From beb8785ce6c25e10db6dffdce48b4d7fd0bb6f10 Mon Sep 17 00:00:00 2001 From: Bastian Meissner Date: Fri, 26 Jun 2020 16:27:43 +0200 Subject: [PATCH] Re-refactored Codebase --- src/components/app.js | 2 - .../{category.js => appCategory.js} | 6 +-- src/components/appList.js | 35 +++++--------- src/components/bookmarkGroup.js | 36 +++++++++++++++ src/components/bookmarkList.js | 46 ++++--------------- src/components/settingsModal.js | 1 - 6 files changed, 59 insertions(+), 67 deletions(-) rename src/components/{category.js => appCategory.js} (87%) create mode 100644 src/components/bookmarkGroup.js diff --git a/src/components/app.js b/src/components/app.js index 8e41931..f10fb31 100644 --- a/src/components/app.js +++ b/src/components/app.js @@ -19,7 +19,6 @@ const DetailsContainer = styled.div` `; const AppLink = styled.a` - font-family: Roboto, sans-serif; flex: 1 0 auto; color: ${selectedTheme.mainColor}; font-weight: 500; @@ -34,7 +33,6 @@ const AppLink = styled.a` `; const AppDescription = styled.p` - font-family: Roboto, sans-serif; text-transform: uppercase; margin: 0; font-size: 0.65rem; diff --git a/src/components/category.js b/src/components/appCategory.js similarity index 87% rename from src/components/category.js rename to src/components/appCategory.js index 3ba1530..8a77aac 100644 --- a/src/components/category.js +++ b/src/components/appCategory.js @@ -4,17 +4,17 @@ import { App } from './app'; import { ItemList, Item, SubHeadline } from './elements'; const CategoryHeadline = styled(SubHeadline)` + padding-top: 1rem; font-size: 1.25rem; `; const CategoryContainer = styled.div` width: 100%; - padding-top: 1rem; `; -export const Category = ({ name, items }) => ( +export const AppCategory = ({ name, items }) => ( - {name} + {name && {name}} {items.map((app, idx) => ( diff --git a/src/components/appList.js b/src/components/appList.js index 3c2c486..268a380 100644 --- a/src/components/appList.js +++ b/src/components/appList.js @@ -1,13 +1,10 @@ import React, { useCallback, useEffect, useState } from 'react'; -import { App } from './app'; -import { Category } from './category'; +import { AppCategory } from './appCategory'; import { handleResponse, Headline, ListContainer, - ItemList, - Item, ErrorMessage, } from './elements'; @@ -39,29 +36,19 @@ const AppList = () => { return ( Applications - + {error && {error}} {categories && - categories.map((category, idx) => ( - ( + ))} - - - {error && {error}} - {apps.map((app, idx) => ( - - - - ))} - + ); }; diff --git a/src/components/bookmarkGroup.js b/src/components/bookmarkGroup.js new file mode 100644 index 0000000..bf95893 --- /dev/null +++ b/src/components/bookmarkGroup.js @@ -0,0 +1,36 @@ +import React from 'react'; +import styled from 'styled-components'; +import { Item, SubHeadline } from './elements'; +import selectedTheme from './themeManager'; + +const GroupContainer = styled.div` + display: flex; + flex-direction: column; + flex: 2 1 auto; + padding: 1rem 0; +`; + +const Bookmark = styled.a` + font-weight: 400; + text-decoration: none; + color: ${selectedTheme.accentColor}; + padding-top: 10px; + font-size: 14px; + + &:hover { + text-decoration: underline; + } +`; + +export const BookmarkGroup = ({ name: groupName, items }) => ( + + + {groupName} + {items.map(({ name, url }, idx) => ( + + {name} + + ))} + + +); diff --git a/src/components/bookmarkList.js b/src/components/bookmarkList.js index df5ca60..02fcd25 100644 --- a/src/components/bookmarkList.js +++ b/src/components/bookmarkList.js @@ -1,35 +1,14 @@ import React, { useCallback, useEffect, useState } from 'react'; -import styled from 'styled-components'; -import selectedTheme from './themeManager'; import { handleResponse, Headline, - SubHeadline, ListContainer, ItemList, - Item, ErrorMessage, } from './elements'; -const BookmarkGroup = styled.div` - display: flex; - flex-direction: column; - flex: 2 1 auto; - padding: 1rem 0; -`; - -const Bookmark = styled.a` - font-weight: 400; - text-decoration: none; - color: ${selectedTheme.accentColor}; - padding-top: 10px; - font-size: 14px; - - &:hover { - text-decoration: underline; - } -`; +import { BookmarkGroup } from './bookmarkGroup'; const useBookmarkData = () => { const [bookmarkData, setBookmarkData] = useState({ @@ -63,22 +42,15 @@ const BookmarkList = () => { return ( Bookmarks + {error && {error}} - {error && {error}} - {groups.map((group, idx) => { - return ( - - - {group.name} - {group.items.map(({ url, name: linkName }) => ( - - {linkName} - - ))} - - - ); - })} + {groups.map(({ name, items }, idx) => ( + + ))} ); diff --git a/src/components/settingsModal.js b/src/components/settingsModal.js index 166f59d..f056c0b 100644 --- a/src/components/settingsModal.js +++ b/src/components/settingsModal.js @@ -39,7 +39,6 @@ const FormContainer = styled.div` `; const Table = styled.table` - font-family: Roboto, sans-serif; font-weight: 400; background: none; color: ${selectedTheme.mainColor};