changed quick to use the bookmarks

This commit is contained in:
Niklas 2020-04-25 02:31:03 +02:00
parent ed98f821bb
commit aa0bc66967
4 changed files with 42 additions and 35 deletions

View File

@ -1,8 +1,6 @@
import * as React from "react"; import * as React from "react";
import Quick from "./Quick"; import Quick from "./Quick";
import QuickItem from "./QuickItem";
import QuickCategory from "./QuickCategory";
import Clock from "./Clock"; import Clock from "./Clock";
import Search from "./Search"; import Search from "./Search";
@ -16,23 +14,7 @@ class App extends React.Component {
<div className="center-wrapper"> <div className="center-wrapper">
<Clock/> <Clock/>
<Search/> <Search/>
<Quick> <Quick/>
<QuickCategory name="Productivity">
<QuickItem name="Nextcloud" url="https://nc.kapelle.org"/>
<QuickItem name="Git" url="https://git.kapelle.org"/>
<QuickItem name="GitHub" url="https://github.com/"/>
</QuickCategory>
<QuickCategory name="Personal">
<QuickItem name="Youtube" url="https://youtube.com/"/>
<QuickItem name="Reddit" url="https://reddit.com/"/>
<QuickItem name="Netflix" url="https://netflix.com/"/>
</QuickCategory>
<QuickCategory name="Other">
<QuickItem name="Bitwarden" url="https://vault.kapelle.org"/>
</QuickCategory>
</Quick>
</div> </div>
</div>; </div>;
} }

View File

@ -1,21 +1,43 @@
import * as React from "react"; import * as React from "react";
import "../style/quick.scss"; import "../style/quick.scss";
import { Bookmarks } from "../types/Bookmarks";
import QuickCategory from "./QuickCategory";
import getBookmarks from "../functions/getBookmarks";
interface Props { interface State {
children: React.ReactNode; bookmarks: Bookmarks;
} }
class Quick extends React.Component<Props> { class Quick extends React.Component<{}, State> {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
bookmarks: {
folder: [],
orphans: []
}
};
}
async getBookmarks(): Promise<void> {
const bookmarks = await getBookmarks();
this.setState({
bookmarks: bookmarks
});
}
componentDidMount() {
this.getBookmarks();
} }
render(): JSX.Element { render(): JSX.Element {
return <div className="quick-component"> return <div className="quick-component">
<div className="container"> <div className="container">
{this.props.children} {this.state.bookmarks.folder.map((e, i) => {
return <QuickCategory folder={e} key={i} />;
})}
</div> </div>
</div>; </div>;
} }

View File

@ -1,10 +1,11 @@
import * as React from "react"; import * as React from "react";
import "../style/quickCategory.scss"; import "../style/quickCategory.scss";
import { BookmarkFolder } from "../types/Bookmarks";
import QuickItem from "./QuickItem";
interface Props { interface Props {
children: React.ReactNode; folder: BookmarkFolder;
name: string;
} }
class QuickCategory extends React.Component<Props> { class QuickCategory extends React.Component<Props> {
@ -16,10 +17,12 @@ class QuickCategory extends React.Component<Props> {
render(): JSX.Element { render(): JSX.Element {
return <div className="quickCategory-component"> return <div className="quickCategory-component">
<div className="title"> <div className="title">
{this.props.name} {this.props.folder.name}
</div> </div>
<div className="children"> <div className="children">
{this.props.children} {this.props.folder.bookmarks.map((e, i) => {
return <QuickItem bookmark={e} key={i} />;
})}
</div> </div>
</div>; </div>;
} }

View File

@ -1,10 +1,10 @@
import * as React from "react"; import * as React from "react";
import "../style/quickItem.scss"; import "../style/quickItem.scss";
import { Bookmark } from "../types/Bookmarks";
interface Props { interface Props {
name: string; bookmark: Bookmark;
url: string;
} }
class QuickItem extends React.Component<Props> { class QuickItem extends React.Component<Props> {
@ -14,12 +14,12 @@ class QuickItem extends React.Component<Props> {
} }
onClick() { onClick() {
window.location.href = this.props.url; window.location.href = this.props.bookmark.url;
} }
render(): JSX.Element { render(): JSX.Element {
return <div className="quickItem-component" onClick={() => this.onClick()}> return <div className="quickItem-component" onClick={() => this.onClick()}>
{this.props.name} {this.props.bookmark.name}
</div>; </div>;
} }