mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
feat: add search modal mobile
This commit is contained in:
@@ -6,18 +6,22 @@ export default function ButtonLink({
|
|||||||
onClick,
|
onClick,
|
||||||
children,
|
children,
|
||||||
style = {},
|
style = {},
|
||||||
|
className = "",
|
||||||
}: {
|
}: {
|
||||||
href?: string;
|
href?: string;
|
||||||
onClick?: (...args: any) => any;
|
onClick?: (...args: any) => any;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
const handleClick = (event) => {
|
const handleClick = (event) => {
|
||||||
event.preventDefault();
|
if (!href || href === "#") {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
onClick && onClick();
|
onClick && onClick();
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Link href={href} onClick={handleClick} style={style}>
|
<Link href={href} onClick={handleClick} style={style} className={className}>
|
||||||
{children}
|
{children}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import LinkItem from "./LinkItem";
|
|||||||
|
|
||||||
import ButtonLink from "components/ButtonLink";
|
import ButtonLink from "components/ButtonLink";
|
||||||
import CreateItem from "components/QuickActions/CreateItem";
|
import CreateItem from "components/QuickActions/CreateItem";
|
||||||
|
import QuickActionSearch from "components/QuickActions/Search";
|
||||||
import { RxHamburgerMenu } from "react-icons/rx";
|
import { RxHamburgerMenu } from "react-icons/rx";
|
||||||
import styles from "./links.module.scss";
|
import styles from "./links.module.scss";
|
||||||
|
|
||||||
@@ -17,11 +18,13 @@ export default function Links({
|
|||||||
toggleFavorite,
|
toggleFavorite,
|
||||||
isMobile,
|
isMobile,
|
||||||
openMobileModal,
|
openMobileModal,
|
||||||
|
openSearchModal,
|
||||||
}: {
|
}: {
|
||||||
category: Category;
|
category: Category;
|
||||||
toggleFavorite: (linkId: Link["id"]) => void;
|
toggleFavorite: (linkId: Link["id"]) => void;
|
||||||
isMobile: boolean;
|
isMobile: boolean;
|
||||||
openMobileModal: () => void;
|
openMobileModal: () => void;
|
||||||
|
openSearchModal: () => void;
|
||||||
}) {
|
}) {
|
||||||
if (category === null) {
|
if (category === null) {
|
||||||
return (
|
return (
|
||||||
@@ -56,6 +59,7 @@ export default function Links({
|
|||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<span className={styles["category-controls"]}>
|
<span className={styles["category-controls"]}>
|
||||||
|
<QuickActionSearch openSearchModal={openSearchModal} />
|
||||||
<CreateItem type="link" categoryId={category.id} />
|
<CreateItem type="link" categoryId={category.id} />
|
||||||
<EditItem type="category" id={id} />
|
<EditItem type="category" id={id} />
|
||||||
<RemoveItem type="category" id={id} />
|
<RemoveItem type="category" id={id} />
|
||||||
|
|||||||
@@ -48,10 +48,12 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.modal-container {
|
.modal-container {
|
||||||
|
height: calc(100% - 2em);
|
||||||
width: calc(100% - 2em);
|
width: calc(100% - 2em);
|
||||||
min-width: unset;
|
min-width: unset;
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import LinkTag from "next/link";
|
import LinkTag from "next/link";
|
||||||
import { GrAdd } from "react-icons/gr";
|
import { IoAddOutline } from "react-icons/io5";
|
||||||
|
|
||||||
import { Category } from "types";
|
import { Category } from "types";
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ export default function CreateItem({
|
|||||||
onClick,
|
onClick,
|
||||||
}: {
|
}: {
|
||||||
type: "category" | "link";
|
type: "category" | "link";
|
||||||
categoryId: Category["id"];
|
categoryId?: Category["id"];
|
||||||
onClick?: (event: any) => void; // FIXME: find good event type
|
onClick?: (event: any) => void; // FIXME: find good event type
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -21,7 +21,7 @@ export default function CreateItem({
|
|||||||
className={styles["action"]}
|
className={styles["action"]}
|
||||||
onClick={onClick && onClick}
|
onClick={onClick && onClick}
|
||||||
>
|
>
|
||||||
<GrAdd />
|
<IoAddOutline />
|
||||||
</LinkTag>
|
</LinkTag>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/components/QuickActions/Search.tsx
Normal file
16
src/components/QuickActions/Search.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import ButtonLink from "components/ButtonLink";
|
||||||
|
import { BsSearch } from "react-icons/bs";
|
||||||
|
|
||||||
|
import styles from "./quickactions.module.scss";
|
||||||
|
|
||||||
|
export default function QuickActionSearch({
|
||||||
|
openSearchModal,
|
||||||
|
}: {
|
||||||
|
openSearchModal: () => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<ButtonLink className={styles["action"]} onClick={openSearchModal}>
|
||||||
|
<BsSearch />
|
||||||
|
</ButtonLink>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -19,11 +19,13 @@ export default function SearchModal({
|
|||||||
handleSelectCategory,
|
handleSelectCategory,
|
||||||
categories,
|
categories,
|
||||||
items,
|
items,
|
||||||
|
noHeader = true,
|
||||||
}: {
|
}: {
|
||||||
close: () => void;
|
close: () => void;
|
||||||
handleSelectCategory: (category: Category) => void;
|
handleSelectCategory: (category: Category) => void;
|
||||||
categories: Category[];
|
categories: Category[];
|
||||||
items: SearchItem[];
|
items: SearchItem[];
|
||||||
|
noHeader?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const autoFocusRef = useAutoFocus();
|
const autoFocusRef = useAutoFocus();
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ export default function SearchModal({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal title="Rechercher" close={close} noHeader padding={"0"}>
|
<Modal close={close} noHeader={noHeader} padding={"0"}>
|
||||||
<form onSubmit={handleSubmit} className={styles["search-form"]}>
|
<form onSubmit={handleSubmit} className={styles["search-form"]}>
|
||||||
<div className={styles["search-input-wrapper"]}>
|
<div className={styles["search-input-wrapper"]}>
|
||||||
<label htmlFor="search">
|
<label htmlFor="search">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from "react";
|
|||||||
import { useHotkeys } from "react-hotkeys-hook";
|
import { useHotkeys } from "react-hotkeys-hook";
|
||||||
|
|
||||||
import BlockWrapper from "components/BlockWrapper/BlockWrapper";
|
import BlockWrapper from "components/BlockWrapper/BlockWrapper";
|
||||||
|
import ButtonLink from "components/ButtonLink";
|
||||||
import Links from "components/Links/Links";
|
import Links from "components/Links/Links";
|
||||||
import Modal from "components/Modal/Modal";
|
import Modal from "components/Modal/Modal";
|
||||||
import PageTransition from "components/PageTransition";
|
import PageTransition from "components/PageTransition";
|
||||||
@@ -144,6 +145,9 @@ function Home(props: HomePageProps) {
|
|||||||
{mobileModal.isShowing && (
|
{mobileModal.isShowing && (
|
||||||
<Modal close={mobileModal.close}>
|
<Modal close={mobileModal.close}>
|
||||||
<BlockWrapper style={{ minHeight: "0", flex: "1" }}>
|
<BlockWrapper style={{ minHeight: "0", flex: "1" }}>
|
||||||
|
<ButtonLink href={PATHS.CATEGORY.CREATE}>
|
||||||
|
Créer categorie
|
||||||
|
</ButtonLink>
|
||||||
<Categories
|
<Categories
|
||||||
categories={categories}
|
categories={categories}
|
||||||
categoryActive={categoryActive}
|
categoryActive={categoryActive}
|
||||||
@@ -168,6 +172,7 @@ function Home(props: HomePageProps) {
|
|||||||
toggleFavorite={toggleFavorite}
|
toggleFavorite={toggleFavorite}
|
||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
openMobileModal={mobileModal.open}
|
openMobileModal={mobileModal.open}
|
||||||
|
openSearchModal={searchModal.open}
|
||||||
/>
|
/>
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{searchModal.isShowing && (
|
{searchModal.isShowing && (
|
||||||
@@ -176,6 +181,7 @@ function Home(props: HomePageProps) {
|
|||||||
categories={categories}
|
categories={categories}
|
||||||
items={itemsSearch}
|
items={itemsSearch}
|
||||||
handleSelectCategory={handleSelectCategory}
|
handleSelectCategory={handleSelectCategory}
|
||||||
|
noHeader={!isMobile}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
|||||||
Reference in New Issue
Block a user