v0.2 #2
@ -4,6 +4,7 @@ import Quick from "./Quick";
|
|||||||
import QuickItem from "./QuickItem";
|
import QuickItem from "./QuickItem";
|
||||||
import QuickCategory from "./QuickCategory";
|
import QuickCategory from "./QuickCategory";
|
||||||
import Clock from "./Clock";
|
import Clock from "./Clock";
|
||||||
|
import Search from "./Search";
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -14,6 +15,7 @@ class App extends React.Component {
|
|||||||
return <div>
|
return <div>
|
||||||
<div className="center-wrapper">
|
<div className="center-wrapper">
|
||||||
<Clock/>
|
<Clock/>
|
||||||
|
<Search/>
|
||||||
<Quick>
|
<Quick>
|
||||||
<QuickCategory name="Productivity">
|
<QuickCategory name="Productivity">
|
||||||
<QuickItem name="Nextcloud" url="#"/>
|
<QuickItem name="Nextcloud" url="#"/>
|
||||||
|
43
src/components/Search.tsx
Normal file
43
src/components/Search.tsx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import "../style/search.scss";
|
||||||
|
|
||||||
|
class Search extends React.Component {
|
||||||
|
|
||||||
|
private searchInput = React.createRef<HTMLInputElement>()
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleQuery(query: string) {
|
||||||
|
this.search(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
search(query: string){
|
||||||
|
const url = new URL("https://duckduckgo.com/");
|
||||||
|
const param = new URLSearchParams();
|
||||||
|
param.append("q",query);
|
||||||
|
url.search = param.toString();
|
||||||
|
window.location.href = url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyDown(event: React.KeyboardEvent) {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
this.handleQuery(this.searchInput.current.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): JSX.Element {
|
||||||
|
return <div className="search-component" >
|
||||||
|
<input type="text"
|
||||||
|
autoFocus
|
||||||
|
onKeyDown={(e)=>this.onKeyDown(e)}
|
||||||
|
ref={this.searchInput}
|
||||||
|
/>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Search;
|
12
src/style/search.scss
Normal file
12
src/style/search.scss
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
.search-component{
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 2em;
|
||||||
|
margin-bottom: 2em;
|
||||||
|
|
||||||
|
input[type=text]{
|
||||||
|
width: 40%;
|
||||||
|
border: none;
|
||||||
|
padding: 0.5em 1.5em;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user