-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ErickLimaS/dev
Add News Feed and Few Fixes
- Loading branch information
Showing
22 changed files
with
1,500 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} | ||
|
||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
app/layout/header/components/NewsNavListHover/component.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.