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}
; }