Commit e0c56a2e authored by Phạm Quang Bảo's avatar Phạm Quang Bảo

update/responsive home page and members page

parent 5dc31199
...@@ -3,16 +3,16 @@ import BASE_URL from '@/links' ...@@ -3,16 +3,16 @@ import BASE_URL from '@/links'
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import AppEditorContent from '@/components/shared/editor-content'; import AppEditorContent from '@/components/shared/editor-content';
function NewsContent({ news }: { news: NewsAdminItem }) { function CardNews({ news }: { news: NewsAdminItem }) {
return ( return (
<a <a
href={`${news.id}`} href={`${news.id}`}
className='flex flex-col sm:flex-row gap-3 mb-3 border border-gray-200 bg-white rounded-md p-3' className='flex flex-row gap-3 mb-3 border border-gray-200 bg-white rounded-md p-3'
> >
<img <img
src={`${BASE_URL.imageEndpoint}${news.thumbnail}`} src={`${BASE_URL.imageEndpoint}${news.thumbnail}`}
alt={news.title} alt={news.title}
className='w-full sm:w-[120px] h-20 object-cover rounded-sm' className='w-[120px] h-20 object-cover rounded-sm'
/> />
<div className='flex-1'> <div className='flex-1'>
<p className='text-[#0056b3] font-bold text-sm line-clamp-2'> <p className='text-[#0056b3] font-bold text-sm line-clamp-2'>
...@@ -27,4 +27,4 @@ function NewsContent({ news }: { news: NewsAdminItem }) { ...@@ -27,4 +27,4 @@ function NewsContent({ news }: { news: NewsAdminItem }) {
); );
} }
export default NewsContent; export default CardNews;
\ No newline at end of file \ No newline at end of file
export { default } from './NewsContent';
\ No newline at end of file
This diff is collapsed.
import { NewsAdminItem } from '@/api/types/news'
import { NewsItem } from '@app/dai-dien-gioi-chu/lib/types/NewsPage.type'; import BASE_URL from '@/links'
import Links from '@links/index'
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import AppEditorContent from '@/components/shared/editor-content';
import parse from 'html-react-parser' import parse from 'html-react-parser'
function NewsContent({ news }: { news: NewsItem }) {
function CardNews({ news }: { news: NewsAdminItem }) {
return ( return (
<a <a
href={`/tin-tuc/${news.id}`} href={`${news.id}`}
className="flex flex-col hover:no-underline sm:flex-row gap-2 mb-6 bg-white rounded-lg shadow-sm p-4 border items-start min-w-0" className="flex flex-col sm:flex-row gap-3 mb-3 border border-gray-200 bg-white rounded-md p-3 hover:shadow-md transition"
> >
<img <img
src={`${Links.imageEndpoint}${news.thumbnail}`} src={`${BASE_URL.imageEndpoint}${news.thumbnail}`}
alt={news.title} alt={news.title}
className="w-full sm:w-56 md:w-64 h-40 md:h-36 object-cover shrink-0" className="w-full sm:w-40 h-40 sm:h-28 object-cover rounded-md"
/> />
<div className="flex-1 min-w-0 pl-0 sm:pl-4"> <div className="flex-1">
<p className="text-primary font-semibold text-base md:text-lg hover:underline line-clamp-2 wrap-break-word hover:no-underline"> <p className="text-[#0056b3] font-bold text-sm sm:text-base line-clamp-2">
{news.title} {news.title}
</p> </p>
<p className="text-gray-500 text-xs sm:text-sm my-1">
<div className="text-sm my-2 text-[#00AED5]">{dayjs(news.release_at).format('DD/MM/YYYY')}</div> {dayjs(news.release_at).format('DD/MM/YYYY')}
</p>
<div className="text-sm text-[#777] line-clamp-3"> <div className="text-xs sm:text-sm text-[#777] line-clamp-3 prose tiptap">
<div className="text-sm prose tiptap">{parse(news.description)}</div> {parse(news.description)}
</div> </div>
</div> </div>
</a> </a>
) );
} }
export default NewsContent; export default CardNews;
\ No newline at end of file \ No newline at end of file
"use client" "use client"
import Link from "next/link" import Link from "next/link"
import { usePathname } from "next/navigation" import { usePathname, useRouter } from "next/navigation"
import React from "react" import React from "react"
type Category = { type Category = {
...@@ -18,17 +18,23 @@ const CATEGORIES: Category[] = [ ...@@ -18,17 +18,23 @@ const CATEGORIES: Category[] = [
const ListCategory: React.FC = () => { const ListCategory: React.FC = () => {
const pathname = usePathname() || "" const pathname = usePathname() || ""
const router = useRouter()
const isActive = (href: string) => { const isActive = (href: string) => {
if (href === "/hoi-vien") return pathname === "/hoi-vien" if (href === "/hoi-vien") return pathname === "/hoi-vien"
return pathname === href return pathname === href
} }
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
router.push(e.target.value)
}
return ( return (
<div className="border-t border-gray-200 bg-white p-2.5"> <div className="border-t border-gray-200 bg-white p-2.5">
<div className="max-w-7xl mx-auto"> <div className="max-w-7xl mx-auto">
<nav aria-label="Danh mục" className="py-3"> <nav aria-label="Danh mục" className="py-3">
<ul className="flex items-center"> {/* --- Desktop view --- */}
<ul className="hidden sm:flex items-center">
{CATEGORIES.map((c) => { {CATEGORIES.map((c) => {
const active = isActive(c.href) const active = isActive(c.href)
return ( return (
...@@ -38,8 +44,8 @@ const ListCategory: React.FC = () => { ...@@ -38,8 +44,8 @@ const ListCategory: React.FC = () => {
className={ className={
"text-sm font-bold py-3.5 px-5 transition-colors duration-150 " + "text-sm font-bold py-3.5 px-5 transition-colors duration-150 " +
(active (active
? "text-yellow-500 font-semibold decoration-yellow-300 " ? "text-yellow-500 font-semibold decoration-yellow-300"
: "text-gray-600 hover:text-yellow-500 ") : "text-gray-600 hover:text-yellow-500")
} }
> >
{c.title} {c.title}
...@@ -48,10 +54,25 @@ const ListCategory: React.FC = () => { ...@@ -48,10 +54,25 @@ const ListCategory: React.FC = () => {
) )
})} })}
</ul> </ul>
{/* --- Mobile view (Dropdown) --- */}
<div className="sm:hidden">
<select
value={pathname}
onChange={handleChange}
className="w-full border border-gray-300 rounded-md px-3 py-2 text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-yellow-400"
>
{CATEGORIES.map((c) => (
<option key={c.href} value={c.href}>
{c.title}
</option>
))}
</select>
</div>
</nav> </nav>
</div> </div>
</div> </div>
) )
} }
export default ListCategory export default ListCategory
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import ListCategory from "./../components/list-category"; import ListCategory from "./../components/list-category";
import ListFilter from "./../components/list-filter"; import ListFilter from "./../components/list-filter";
import NewsContent from "./../components/card-news"; import CardNews from "./../components/card-news";
import { Pagination } from '@components/base/pagination' import { Pagination } from '@components/base/pagination'
import Image from "next/image"; import Image from "next/image";
import { useGetNews } from '@api/endpoints/news' import { useGetNews } from '@api/endpoints/news'
...@@ -27,7 +27,7 @@ export default function Page() { ...@@ -27,7 +27,7 @@ export default function Page() {
<main className="lg:col-span-2 bg-background"> <main className="lg:col-span-2 bg-background">
<div className='pb-5 overflow-hidden'> <div className='pb-5 overflow-hidden'>
{allData?.responseData.rows.map((news) => ( {allData?.responseData.rows.map((news) => (
<NewsContent key={news.id} news={news} /> <CardNews key={news.id} news={news} />
))} ))}
<div className='w-full flex justify-center mt-4'> <div className='w-full flex justify-center mt-4'>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import ListCategory from "./../components/list-category"; import ListCategory from "./../components/list-category";
import ListFilter from "./../components/list-filter"; import ListFilter from "./../components/list-filter";
import NewsContent from "./../components/card-news"; import CardNews from "./../components/card-news";
import { Pagination } from '@components/base/pagination' import { Pagination } from '@components/base/pagination'
import Image from "next/image"; import Image from "next/image";
import { useGetNews } from '@api/endpoints/news' import { useGetNews } from '@api/endpoints/news'
...@@ -27,7 +27,7 @@ export default function Page() { ...@@ -27,7 +27,7 @@ export default function Page() {
<main className="lg:col-span-2 bg-background"> <main className="lg:col-span-2 bg-background">
<div className='pb-5 overflow-hidden'> <div className='pb-5 overflow-hidden'>
{allData?.responseData.rows.map((news) => ( {allData?.responseData.rows.map((news) => (
<NewsContent key={news.id} news={news} /> <CardNews key={news.id} news={news} />
))} ))}
<div className='w-full flex justify-center mt-4'> <div className='w-full flex justify-center mt-4'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment