restructured youtube paths, added search modal
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
d2cef1f072
commit
189c651941
@ -0,0 +1,54 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@nextui-org/react";
|
||||
import { FC, useState } from "react";
|
||||
import { useHotkeys } from "react-hotkeys-hook";
|
||||
|
||||
import {
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader
|
||||
} from "@nextui-org/modal";
|
||||
|
||||
import { Search } from "@/components/Search";
|
||||
|
||||
export const SearchModal: FC = () => {
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
|
||||
useHotkeys(
|
||||
"ctrl+k",
|
||||
() => {
|
||||
setOpen(true);
|
||||
},
|
||||
{ preventDefault: true }
|
||||
);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isOpen}
|
||||
onOpenChange={(isOpen) => {
|
||||
setOpen(isOpen);
|
||||
}}
|
||||
size="2xl"
|
||||
>
|
||||
<ModalContent>
|
||||
{(onClose) => (
|
||||
<>
|
||||
<ModalHeader className="flex flex-col gap-1">Search</ModalHeader>
|
||||
<ModalBody>
|
||||
<Search onSearch={() => onClose()} />
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="danger" variant="light" onPress={onClose}>
|
||||
Close
|
||||
</Button>
|
||||
<Button color="primary">Search</Button>
|
||||
</ModalFooter>
|
||||
</>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
import { SearchModal } from "./SearchModal";
|
||||
|
||||
import { Component } from "@/typings/component";
|
||||
|
||||
const YoutubeLayout: Component = ({ children }) => {
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
<SearchModal />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default YoutubeLayout;
|
@ -1,37 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { FC } from "react";
|
||||
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
|
||||
import { SearchType } from "@/client/typings/search/options";
|
||||
|
||||
import { Search as SearchInput } from "@/components/Search";
|
||||
|
||||
import { Filter } from "./Filter";
|
||||
|
||||
export const SearchPageHeader: FC<{
|
||||
query?: string;
|
||||
filter?: SearchType;
|
||||
}> = ({ query, filter }) => {
|
||||
const searchFor = useSearch();
|
||||
|
||||
const searchForQuery = (query: string): void => {
|
||||
searchFor(query, filter);
|
||||
};
|
||||
|
||||
const searchWithFilter = (filter: SearchType): void => {
|
||||
if (query) searchFor(query, filter);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-row gap-2">
|
||||
<div className="flex-1">
|
||||
<SearchInput query={query} setQuery={searchForQuery} />
|
||||
</div>
|
||||
<div>
|
||||
<Filter filter={filter ?? "all"} setFilter={searchWithFilter} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { FC } from "react";
|
||||
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
|
||||
import { SearchType } from "@/client/typings/search/options";
|
||||
|
||||
import { Filter } from "./Filter";
|
||||
import { Input } from "./Input";
|
||||
|
||||
export const Search: FC<{
|
||||
query?: string;
|
||||
filter?: SearchType;
|
||||
onSearch?: (query: string, filter: SearchType) => void;
|
||||
}> = ({ query = "", filter = "all", onSearch }) => {
|
||||
const searchFor = useSearch();
|
||||
|
||||
const searchForQuery = (query: string): void => {
|
||||
searchFor(query, filter);
|
||||
if (onSearch) onSearch(query, filter);
|
||||
};
|
||||
|
||||
const searchWithFilter = (filter: SearchType): void => {
|
||||
searchFor(query, filter);
|
||||
if (onSearch) onSearch(query, filter);
|
||||
};
|
||||
|
||||
return (
|
||||
<form>
|
||||
<div className="flex flex-row gap-2">
|
||||
<div className="flex-1">
|
||||
<Input query={query} setQuery={searchForQuery} />
|
||||
</div>
|
||||
<div>
|
||||
<Filter filter={filter} setFilter={searchWithFilter} />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
};
|
Loading…
Reference in new issue