Skip to content

Commit

Permalink
Merge pull request #16 from ErickLimaS/dev
Browse files Browse the repository at this point in the history
Add News Feed and Few Fixes
  • Loading branch information
ErickLimaS authored Mar 3, 2024
2 parents d5edbfc + 7aea315 commit 805dd13
Show file tree
Hide file tree
Showing 22 changed files with 1,500 additions and 39 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Project of animes and mangas website, utilizing the <a href='https://anilist.git
- [x] `Read`: Read any manga chapter available.
- [x] `Comment`: Write what you thougth of that episode or just tell something that every should know about.
- [x] `Log In`: You can log in with your Google or GitHub Account.
- [x] `News Feed`: Keep up with the latest news of animes, mangas and the industry.
- [x] `Bookmark your favourite animes e mangas`: Save for later your animes and mangas.
- [x] `Bookmark the episodes you watched`: And keep watching from there later

## :pushpin: Under Development

- [ ] `News Feed Section`
- [ ] `Keep track of what you watched last`
- [ ] `Be notified when a new episode/chapter is released`

Expand Down Expand Up @@ -114,3 +114,13 @@ Its simple!

![Playlist page 1](https://github.com/ErickLimaS/anime-website/assets/69987890/c8ed47e5-6ac8-4ec2-adc4-fdbf2119cc11)

### News Home Page

![News Home Page 1](https://github.com/ErickLimaS/anime-website/assets/69987890/4dd2c9d4-9c96-4c20-904b-b1abdf71aa37)
![News Home Page 2](https://github.com/ErickLimaS/anime-website/assets/69987890/78a5889e-4fe9-4ebf-bae0-e8c014772196)
![News Home Page 3](https://github.com/ErickLimaS/anime-website/assets/69987890/f6852a01-b012-43f0-a69b-d4c2113988e3)


### News Article Page

![News Article Page 1](https://github.com/ErickLimaS/anime-website/assets/69987890/216eca9e-4e9f-4c9f-9b0d-3ae40cb53772)
56 changes: 56 additions & 0 deletions api/news.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { News } from "@/app/ts/interfaces/newsInterface"
import Axios from "axios"
import { cache } from "react"

const CONSUMET_API_URL = process.env.NEXT_PUBLIC_CONSUMET_API_URL

// eslint-disable-next-line import/no-anonymous-default-export
export default {

// GET ALL NEWS, OR NEWS BY TOPIC
getNews: cache(async (topic?: string) => {

try {

const { data } = await Axios({
url: `${CONSUMET_API_URL}/news/ann/recent-feeds${topic ? `?topic=${topic}` : ""}`,
method: "GET"
})

return data as News[]

}
catch (err) {

console.log(err)

return err

}

}),

// GET NEWS ARTICLE BY ID
getNewsInfo: cache(async (id: string) => {

try {

const { data } = await Axios({
url: `${CONSUMET_API_URL}/news/ann/info?id=${id}`,
method: "GET"
})

return data as News

}
catch (err) {

console.log(err)

return err

}

})

}
13 changes: 6 additions & 7 deletions app/components/SwiperListContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,27 @@ import styles from "./styles.module.css"
import { ApiDefaultResult } from '@/app/ts/interfaces/apiAnilistDataInterface';
import ListCarousel from '../HomePage/HeroListCarousel';

function SwiperListContainer({ data, options, children, customHeroSection }: {
function SwiperListContainer({ data, options, customHeroSection }: {
data?: ApiDefaultResult[],
options?: {
slidesPerView?: number
bp480: number,
bp740: number,
bp1275: number,
},
children?: any,
customHeroSection?: boolean
}) {

return (
<Swiper
className={styles.list_container}
modules={[Navigation, Pagination, A11y]}
slidesPerView={options?.slidesPerView || 3}
slidesPerView={options?.slidesPerView || 3.4}
spaceBetween={16}
breakpoints={{
480: { slidesPerView: options?.bp480 || 4 },
740: { slidesPerView: options?.bp740 || 5 },
1275: { slidesPerView: options?.bp1275 || 6 },
480: { slidesPerView: options?.bp480 || 4.4 },
740: { slidesPerView: options?.bp740 || 5.4 },
1275: { slidesPerView: options?.bp1275 || 6.4 },
}}
>

Expand Down
11 changes: 10 additions & 1 deletion app/layout/header/components/NavListMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,16 @@ function NavListMenu() {
<li><Link href={`/search?type=manga&sort=score_desc`}>Highest Rated</Link></li>
</ul>
</li>
{/* <li role='menuitem'>Movies</li> */}

<li role='menuitem'>

<h5
className='display_flex_row align_items_center'
>
<Link href={`/news`}>News</Link>
</h5>

</li>
</ul>

</motion.div>
Expand Down
123 changes: 123 additions & 0 deletions app/layout/header/components/NewsNavListHover/component.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#news_header_nav_container {

z-index: 2;
position: absolute;
top: 69px;
left: 0;

padding-top: 32px;
padding-bottom: 64px;
padding-left: 64px;
padding-right: 64px;

background-color: var(--black-100);

width: 100%;


}

#news_header_nav_container .link_container {

max-width: var(--breakpoint-xxl);
margin: auto;
margin-bottom: 32px;


}

#news_header_nav_container .link_container a {

width: fit-content;

border-bottom: 2px solid var(--white-75);

}

#news_header_nav_container>ul {

max-width: var(--breakpoint-xxl);
margin: auto;

display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 0 32px;

}

#news_header_nav_container>ul[data-loading=true] {

display: flex;
align-items: center;
justify-content: center;

}


#news_header_nav_container>ul>li {

padding-top: 32px;
padding-right: 32px;

}

#news_header_nav_container>ul>li:not(:nth-child(5)):not(:last-child) {

border-right: 1px solid var(--white-50);

}

#news_header_nav_container>ul>li .image_container {

aspect-ratio: 16/9;
position: relative;

}

#news_header_nav_container>ul>li .image_container img {

object-fit: cover;

border-radius: 4px;

}

#news_header_nav_container>ul>li .title_container {

margin-top: 8px;

}

#news_header_nav_container>ul>li .title_container a {

transition: all ease-in-out 300ms;

font-size: var(--font-size--small-1);
color: var(--white-100);

display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;

}

#news_header_nav_container>ul>li:hover .title_container a {

color: var(--brand-color);

}

#news_header_nav_container>ul>li .title_container small {

display: flex;
align-items: center;
gap: 0 4px;

width: max-content;

color: var(--white-75);
margin-top: 8px;
margin-left: auto;

}
66 changes: 66 additions & 0 deletions app/layout/header/components/NewsNavListHover/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"use client"
import React, { useLayoutEffect, useState } from 'react'
import styles from "./component.module.css"
import Link from 'next/link'
import LoadingSvg from "@/public/assets/ripple-1s-200px.svg"
import news from '@/api/news'
import { News } from '@/app/ts/interfaces/newsInterface'
import SvgCalendar from "@/public/assets/calendar3.svg"
import Image from 'next/image'

function AnimeNavListHover() {

const [animeData, setAnimeData] = useState<News[]>()

const loadData = async () => {

const data = await news.getNews() as News[]

setAnimeData(data)

}

useLayoutEffect(() => {
loadData()
}, [])

return (
<div id={styles.news_header_nav_container}>

<div className={styles.link_container}>
<Link href={`/news`}>Go to News Page</Link>
</div>

<ul data-loading={animeData == undefined}>

{animeData ? (

animeData.slice(0, 10).map((item, key) => (
<li key={key}>

<div className={styles.image_container}>
<Link href={`/news/${item.id}`}>
<Image fill src={item.thumbnail} alt={item.title}></Image>
</Link>
</div>

<div className={styles.title_container}>

<h5><Link href={`/news/${item.id}`}>{item.title}</Link></h5>

<small><SvgCalendar width={16} height={16} alt="Calendar" /> {item.uploadedAt}</small>

</div>

</li>
))
) : (
<LoadingSvg width={200} height={200} alt="Loading" />
)}

</ul>
</div>
)
}

export default AnimeNavListHover
12 changes: 4 additions & 8 deletions app/layout/header/headerComponent.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ header>div#container {
}
}

/* @media((min-width: 992px) and (max-width: 1200px)) {
header>div#container {
width: var(--breakpoint-md);
}
} */

@media((min-width: 1201px) and (max-width: 1400px)) {
header>div#container {
width: var(--breakpoint-xl);
Expand Down Expand Up @@ -155,7 +149,8 @@ header#background button svg {

}

#navbar_container>ul>li>ul {
#navbar_container>ul>li>ul,
#navbar_container>ul>li>div {
display: none;
}

Expand All @@ -168,7 +163,8 @@ header#background button svg {

}

#navbar_container>ul>li:hover>ul {
#navbar_container>ul>li:hover>ul,
#navbar_container>ul>li:hover>div {

display: block;

Expand Down
7 changes: 5 additions & 2 deletions app/layout/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import MangaNavListHover from './components/MangaNavListHover'
import UserSideMenu from './components/UserSideMenu'
import NavListMenu from './components/NavListMenu'
import SearchContainer from './components/SearchContainer'
import NewsNavListHover from './components/NewsNavListHover'

function Header() {

Expand Down Expand Up @@ -41,8 +42,10 @@ function Header() {

<MangaNavListHover />
</li>
<li className='display_flex_row align_items_center' style={{ textDecoration: "line-through" }}>
News <ChevronDownIcon alt="Open News List" width={16} height={16} />
<li className='display_flex_row align_items_center'>
<Link href={'/news'}>News <ChevronDownIcon alt="Open News List" width={16} height={16} /></Link>

<NewsNavListHover />
</li>
</ul>
</div>
Expand Down
Loading

0 comments on commit 805dd13

Please sign in to comment.