feat/fix/chore: refactor project structure + add favicon

- Changement de structure de fichier
- Ajout des favicons des sites
- Suppression et mise à jour de dépendances
- Ajout React-Icons pour gérer les icons
- Amélioration du l'UI
This commit is contained in:
Sonny
2023-04-20 18:18:03 +02:00
parent f68bb22a01
commit 45f5455f94
47 changed files with 1274 additions and 1350 deletions

View File

@@ -1,11 +1,9 @@
import LinkTag from "next/link";
import { Category, Link } from "../../types";
import { Category } from "../../types";
import LinkItem from "./LinkItem";
import EditSVG from "../../public/icons/edit.svg";
import RemoveSVG from "../../public/icons/remove.svg";
import styles from "../../styles/home/links.module.scss";
import styles from "./links.module.scss";
export default function Links({ category }: { category: Category }) {
if (category === null) {
@@ -24,7 +22,9 @@ export default function Links({ category }: { category: Category }) {
<p>
Aucun lien pour <b>{category.name}</b>
</p>
<LinkTag href="/link/create">Créer un lien</LinkTag>
<LinkTag href={`/link/create?categoryId=${category.id}`}>
Créer un lien
</LinkTag>
</div>
);
}
@@ -43,54 +43,3 @@ export default function Links({ category }: { category: Category }) {
</div>
);
}
function LinkItem({ link }: { link: Link }) {
const { id, name, url, category } = link;
return (
<li className={styles["link"]} key={id}>
<LinkTag href={url} target={"_blank"} rel={"noreferrer"}>
<span className={styles["link-name"]}>
{name}
<span className={styles["link-category"]}> {category.name}</span>
</span>
<LinkItemURL url={url} />
</LinkTag>
<div className={styles["controls"]}>
<LinkTag href={`/link/edit/${id}`} className={styles["edit"]}>
<EditSVG />
</LinkTag>
<LinkTag href={`/link/remove/${id}`} className={styles["remove"]}>
<RemoveSVG />
</LinkTag>
</div>
</li>
);
}
function LinkItemURL({ url }: { url: string }) {
try {
const { origin, pathname, search } = new URL(url);
let text = "";
if (pathname !== "/") {
text += pathname;
}
if (search !== "") {
if (text === "") {
text += "/";
}
text += search;
}
return (
<span className={styles["link-url"]}>
{origin}
<span className={styles["url-pathname"]}>{text}</span>
</span>
);
} catch (error) {
console.error("error", error);
return <span className={styles["link-url"]}>{url}</span>;
}
}