Skip to content

Commit

Permalink
anime card added #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Blink29 committed Jun 8, 2024
1 parent b1c9cc4 commit 7867f31
Show file tree
Hide file tree
Showing 8 changed files with 1,667 additions and 202 deletions.
1,649 changes: 1,570 additions & 79 deletions frontend/package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/material": "^5.15.19",
"axios": "^1.6.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -21,10 +24,13 @@
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.55.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
"vite": "^5.0.8"
}
}
6 changes: 6 additions & 0 deletions frontend/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
49 changes: 7 additions & 42 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,7 @@
/* #root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
} */
:root {
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #191919;
font-family: 'Roboto', sans-serif;
}
61 changes: 61 additions & 0 deletions frontend/src/components/animeCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from "react";

import Card from "@mui/material/Card";
import CardContent from "@mui/material/CardContent";
import CardMedia from "@mui/material/CardMedia";
import Typography from "@mui/material/Typography";
import { CardActionArea } from "@mui/material";

import { Link } from "react-router-dom";
import { useAnimeContext } from "../context/animeContext";

const AnimeCard = ({ anime }) => {
const { setAnimeId } = useAnimeContext();
const anime_id = anime._id;

const imgUrl = anime.image;
const img = imgUrl.split("https");

let anime_image;

if (typeof img[2] === "undefined") {
anime_image = `https` + img[1];
} else {
anime_image = `https` + img[2];
}

let anime_title;
const title = anime.title;
if (title.length > 25) {
anime_title = title.substring(0, 25) + `...`;
} else {
anime_title = title;
}

const anime_url = encodeURIComponent(anime.title);

return (
<Link to={`/${anime_url}`} onClick={() => setAnimeId(anime_id)}>
<Card sx={{ maxWidth: 150 }} className="h-full">
<CardActionArea>
<CardMedia
component="img"
height="150"
image={anime_image}
alt={anime.title}
/>
<CardContent>
{/* <Typography gutterBottom component="div">
{anime_title}
</Typography> */}
<Typography variant="body2" color="text.secondary">
{anime_title}
</Typography>
</CardContent>
</CardActionArea>
</Card>
</Link>
);
};

export default AnimeCard;
4 changes: 3 additions & 1 deletion frontend/src/components/home/home.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { useState, useEffect } from 'react'

import AnimeCard from '../anime-card/card'
// import AnimeCard from '../anime-card/card'
import AnimeCard from '../animeCard'
import './home.scss'

const Home = ({animeList}) => {

return (
<div className="home">
{animeList.map((anime) => (
// <AnimeCard key={anime._id} anime={anime} />
<AnimeCard key={anime._id} anime={anime} />
))}
</div>
Expand Down
83 changes: 3 additions & 80 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -1,80 +1,3 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');

:root {
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #191919;
font-family: 'Roboto', sans-serif;
}

/* :root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
} */


@tailwind base;
@tailwind components;
@tailwind utilities;
11 changes: 11 additions & 0 deletions frontend/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}

0 comments on commit 7867f31

Please sign in to comment.