Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
fix loading, refactor code, add icon title
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicname committed Aug 22, 2022
1 parent 883c78d commit 5b8f1c8
Show file tree
Hide file tree
Showing 35 changed files with 233 additions and 196 deletions.
Binary file added assets/otaku.ico
Binary file not shown.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Anime Website</title>
<link rel="shortcut icon" href="./assets/otaku.ico" type="image/x-icon">
<title>Anime, Manga Information Page</title>
</head>
<body>
<div id="root"></div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/anime-details/DetailListItem.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { memo } from "react";
import { NavLink } from "react-router-dom";

const DetailListItem = ({ items, title }) => {
Expand All @@ -18,4 +18,4 @@ const DetailListItem = ({ items, title }) => {
);
};

export default DetailListItem;
export default memo(DetailListItem);
4 changes: 3 additions & 1 deletion src/components/anime-details/DetailStatus.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const DetailStatus = ({ type, content, className }) => {
return (
<span className={`flex gap-x-2 ${className}`}>
Expand All @@ -7,4 +9,4 @@ const DetailStatus = ({ type, content, className }) => {
);
};

export default DetailStatus;
export default memo(DetailStatus);
3 changes: 2 additions & 1 deletion src/components/anime/AnimeItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useNavigate } from "react-router-dom";
import IconStar from "../icons/IconStar";
import IconFavorite from "../icons/IconFavorite";
import Button from "../buttons/Button";
import { memo } from "react";

const AnimeItem = ({ anime }) => {
const navigate = useNavigate();
Expand Down Expand Up @@ -39,4 +40,4 @@ const AnimeItem = ({ anime }) => {
);
};

export default AnimeItem;
export default memo(AnimeItem);
3 changes: 2 additions & 1 deletion src/components/anime/AnimeItemSkeleton.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import IconStar from "../icons/IconStar";
import IconFavorite from "../icons/IconFavorite";
import LoadingSkeleton from "../loading/LoadingSkeleton";
import { memo } from "react";

const AnimeItemSkeleton = () => {
return (
Expand Down Expand Up @@ -31,4 +32,4 @@ const AnimeItemSkeleton = () => {
);
};

export default AnimeItemSkeleton;
export default memo(AnimeItemSkeleton);
3 changes: 2 additions & 1 deletion src/components/anime/AnimeList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getListAnime } from "../../apis/apis";
import { useQuery } from "@tanstack/react-query";
import { toast } from "react-toastify";
import { useNavigate } from "react-router-dom";
import { memo } from "react";

const AnimeList = ({ type }) => {
const { data, isError, isLoading } = useQuery(["list-anime", type], () =>
Expand Down Expand Up @@ -39,4 +40,4 @@ const AnimeList = ({ type }) => {
);
};

export default AnimeList;
export default memo(AnimeList);
4 changes: 3 additions & 1 deletion src/components/buttons/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const Button = ({ className = "", onClick = () => {}, children }) => {
return (
<button
Expand All @@ -9,4 +11,4 @@ const Button = ({ className = "", onClick = () => {}, children }) => {
);
};

export default Button;
export default memo(Button);
4 changes: 2 additions & 2 deletions src/components/character/CharacterItem.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { memo } from "react";
import { useNavigate } from "react-router-dom";
import IconFavorite from "../icons/IconFavorite";
import Button from "../buttons/Button";
Expand Down Expand Up @@ -32,4 +32,4 @@ const CharacterItem = ({ character }) => {
);
};

export default CharacterItem;
export default memo(CharacterItem);
3 changes: 2 additions & 1 deletion src/components/character/CharacterItemSkeleton.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { memo } from "react";
import LoadingSkeleton from "../loading/LoadingSkeleton";
import IconFavorite from "../icons/IconFavorite";

Expand All @@ -22,4 +23,4 @@ const CharacterItemSkeleton = () => {
);
};

export default CharacterItemSkeleton;
export default memo(CharacterItemSkeleton);
33 changes: 0 additions & 33 deletions src/components/character/CharacterList.jsx

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/header/HeaderHamburger.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const HeaderHamburger = ({ show }) => {
return (
<>
Expand All @@ -20,4 +22,4 @@ const HeaderHamburger = ({ show }) => {
);
};

export default HeaderHamburger;
export default memo(HeaderHamburger);
5 changes: 3 additions & 2 deletions src/components/header/HeaderLink.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { NavLink } from "react-router-dom";
import { memo } from "react";

const HeaderLink = ({ to, setShow, children }) => {
return (
<li className="p-3 font-semibold">
<li className="m-3 font-semibold w-full lg:w-auto">
<NavLink
className={({ isActive }) =>
`p-3 ${isActive && "bg-green-500"} text-white rounded-lg`
Expand All @@ -16,4 +17,4 @@ const HeaderLink = ({ to, setShow, children }) => {
);
};

export default HeaderLink;
export default memo(HeaderLink);
4 changes: 3 additions & 1 deletion src/components/icons/IconEmail.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const IconEmail = ({ className }) => {
return (
<svg
Expand All @@ -17,4 +19,4 @@ const IconEmail = ({ className }) => {
);
};

export default IconEmail;
export default memo(IconEmail);
4 changes: 3 additions & 1 deletion src/components/icons/IconFavorite.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const IconFavorite = ({ className }) => {
return (
<svg
Expand All @@ -15,4 +17,4 @@ const IconFavorite = ({ className }) => {
);
};

export default IconFavorite;
export default memo(IconFavorite);
4 changes: 3 additions & 1 deletion src/components/icons/IconPhone.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const IconPhone = ({ className }) => {
return (
<svg
Expand All @@ -17,4 +19,4 @@ const IconPhone = ({ className }) => {
);
};

export default IconPhone;
export default memo(IconPhone);
4 changes: 3 additions & 1 deletion src/components/icons/IconRank.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const IconRank = ({ className }) => {
return (
<svg
Expand All @@ -15,4 +17,4 @@ const IconRank = ({ className }) => {
);
};

export default IconRank;
export default memo(IconRank);
4 changes: 3 additions & 1 deletion src/components/icons/IconStar.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const IconStar = ({ className }) => {
return (
<svg
Expand All @@ -11,4 +13,4 @@ const IconStar = ({ className }) => {
);
};

export default IconStar;
export default memo(IconStar);
4 changes: 3 additions & 1 deletion src/components/icons/IconUserGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const IconUserGroup = ({ className }) => {
return (
<svg
Expand All @@ -11,4 +13,4 @@ const IconUserGroup = ({ className }) => {
);
};

export default IconUserGroup;
export default memo(IconUserGroup);
48 changes: 48 additions & 0 deletions src/components/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import AnimeItem from "./anime/AnimeItem";
import AnimeItemSkeleton from "./anime/AnimeItemSkeleton";
import AnimeList from "./anime/AnimeList";

import DetailListItem from "./anime-details/DetailListItem";
import DetailStatus from "./anime-details/DetailStatus";

import Button from "./buttons/Button";

import CharacterItem from "./character/CharacterItem";
import CharacterItemSkeleton from "./character/CharacterItemSkeleton";

import HeaderHamburger from "./header/HeaderHamburger";
import HeaderLink from "./header/HeaderLink";

import IconEmail from "./icons/IconEmail";
import IconFavorite from "./icons/IconFavorite";
import IconPhone from "./icons/IconPhone";
import IconRank from "./icons/IconRank";
import IconStar from "./icons/IconStar";
import IconUserGroup from "./icons/IconUserGroup";

import ShareLayout from "./layout/ShareLayout";

import LoadingSkeleton from "./loading/LoadingSkeleton";
import LoadingComponent from "./loading/LoadingComponent";

export {
LoadingComponent,
ShareLayout,
IconRank,
IconStar,
Button,
LoadingSkeleton,
IconUserGroup,
IconPhone,
IconFavorite,
IconEmail,
HeaderLink,
HeaderHamburger,
CharacterItemSkeleton,
AnimeList,
CharacterItem,
DetailStatus,
DetailListItem,
AnimeItemSkeleton,
AnimeItem,
};
3 changes: 2 additions & 1 deletion src/components/layout/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import IconEmail from "../icons/IconEmail";
import IconPhone from "../icons/IconPhone";
import { memo } from "react";

const Footer = () => {
return (
Expand Down Expand Up @@ -32,4 +33,4 @@ const Footer = () => {
);
};

export default Footer;
export default memo(Footer);
4 changes: 2 additions & 2 deletions src/components/layout/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from "react";
import { memo, useState } from "react";
import { NavLink } from "react-router-dom";
import HeaderLink from "../header/HeaderLink";
import HeaderHamburger from "../header/HeaderHamburger";
Expand Down Expand Up @@ -59,4 +59,4 @@ const Header = () => {
);
};

export default Header;
export default memo(Header);
3 changes: 2 additions & 1 deletion src/components/layout/ShareLayout.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Outlet } from "react-router-dom";
import Header from "./Header";
import Footer from "./Footer";
import { memo } from "react";

const ShareLayout = () => {
return (
Expand All @@ -12,4 +13,4 @@ const ShareLayout = () => {
);
};

export default ShareLayout;
export default memo(ShareLayout);
4 changes: 3 additions & 1 deletion src/components/loading/LoadingComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const LoadingComponent = () => {
return (
<div className="fixed inset-0 w-screen h-screen bg-gray-400 flex items-center justify-center">
Expand All @@ -23,4 +25,4 @@ const LoadingComponent = () => {
);
};

export default LoadingComponent;
export default memo(LoadingComponent);
4 changes: 3 additions & 1 deletion src/components/loading/LoadingSkeleton.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { memo } from "react";

const LoadingSkeleton = ({ className, width, height, radius }) => {
return (
<div
Expand All @@ -11,4 +13,4 @@ const LoadingSkeleton = ({ className, width, height, radius }) => {
);
};

export default LoadingSkeleton;
export default memo(LoadingSkeleton);
Loading

1 comment on commit 5b8f1c8

@vercel
Copy link

@vercel vercel bot commented on 5b8f1c8 Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.