From aa0bc66967fa74fc9084c7afdf27d67fccbb0a1e Mon Sep 17 00:00:00 2001 From: Niklas Date: Sat, 25 Apr 2020 02:31:03 +0200 Subject: [PATCH] changed quick to use the bookmarks --- src/components/App.tsx | 20 +------------------ src/components/Quick.tsx | 34 ++++++++++++++++++++++++++------ src/components/QuickCategory.tsx | 15 ++++++++------ src/components/QuickItem.tsx | 8 ++++---- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index c48eb76..7318706 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,8 +1,6 @@ import * as React from "react"; import Quick from "./Quick"; -import QuickItem from "./QuickItem"; -import QuickCategory from "./QuickCategory"; import Clock from "./Clock"; import Search from "./Search"; @@ -16,23 +14,7 @@ class App extends React.Component {
- - - - - - - - - - - - - - - - - +
; } diff --git a/src/components/Quick.tsx b/src/components/Quick.tsx index 11be145..52b93c5 100644 --- a/src/components/Quick.tsx +++ b/src/components/Quick.tsx @@ -1,21 +1,43 @@ import * as React from "react"; import "../style/quick.scss"; +import { Bookmarks } from "../types/Bookmarks"; +import QuickCategory from "./QuickCategory"; +import getBookmarks from "../functions/getBookmarks"; -interface Props { - children: React.ReactNode; +interface State { + bookmarks: Bookmarks; } -class Quick extends React.Component { - - constructor(props){ +class Quick extends React.Component<{}, State> { + + constructor(props) { super(props); + this.state = { + bookmarks: { + folder: [], + orphans: [] + } + }; + } + + async getBookmarks(): Promise { + const bookmarks = await getBookmarks(); + this.setState({ + bookmarks: bookmarks + }); + } + + componentDidMount() { + this.getBookmarks(); } render(): JSX.Element { return
- {this.props.children} + {this.state.bookmarks.folder.map((e, i) => { + return ; + })}
; } diff --git a/src/components/QuickCategory.tsx b/src/components/QuickCategory.tsx index d784a51..a4ce0ac 100644 --- a/src/components/QuickCategory.tsx +++ b/src/components/QuickCategory.tsx @@ -1,25 +1,28 @@ import * as React from "react"; import "../style/quickCategory.scss"; +import { BookmarkFolder } from "../types/Bookmarks"; +import QuickItem from "./QuickItem"; interface Props { - children: React.ReactNode; - name: string; + folder: BookmarkFolder; } class QuickCategory extends React.Component { - - constructor(props){ + + constructor(props) { super(props); } render(): JSX.Element { return
- {this.props.name} + {this.props.folder.name}
- {this.props.children} + {this.props.folder.bookmarks.map((e, i) => { + return ; + })}
; } diff --git a/src/components/QuickItem.tsx b/src/components/QuickItem.tsx index 08400dd..29a096b 100644 --- a/src/components/QuickItem.tsx +++ b/src/components/QuickItem.tsx @@ -1,10 +1,10 @@ import * as React from "react"; import "../style/quickItem.scss"; +import { Bookmark } from "../types/Bookmarks"; interface Props { - name: string; - url: string; + bookmark: Bookmark; } class QuickItem extends React.Component { @@ -14,12 +14,12 @@ class QuickItem extends React.Component { } onClick() { - window.location.href = this.props.url; + window.location.href = this.props.bookmark.url; } render(): JSX.Element { return
this.onClick()}> - {this.props.name} + {this.props.bookmark.name}
; }