simple show more news working
This commit is contained in:
@@ -274,3 +274,21 @@ export const HeroFollowBlock = styled.div`
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const HeroNewsMoreButton = styled.button`
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
font-size: 16px;
|
||||||
|
padding: 10px 24px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
align-self: center;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #000;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ import {
|
|||||||
HeroNewsItem,
|
HeroNewsItem,
|
||||||
HeroNewsItemContent,
|
HeroNewsItemContent,
|
||||||
HeroNewsItemDate,
|
HeroNewsItemDate,
|
||||||
|
HeroNewsMoreButton,
|
||||||
HeroNewsTitle,
|
HeroNewsTitle,
|
||||||
HeroRow,
|
HeroRow,
|
||||||
Img,
|
Img,
|
||||||
UDLLink,
|
UDLLink,
|
||||||
} from "@/components/HeroSection/HeroElements";
|
} from "@/components/HeroSection/HeroElements";
|
||||||
import img from "@/images/book_cover.jpg";
|
import img from "@/images/book_cover.jpg";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
const citation = `
|
const citation = `
|
||||||
@book{prince2023understanding,
|
@book{prince2023understanding,
|
||||||
@@ -140,6 +142,12 @@ const news = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default function HeroSection() {
|
export default function HeroSection() {
|
||||||
|
const [showMoreNews, setShowMoreNews] = useState(false);
|
||||||
|
|
||||||
|
const toggleShowMore = () => {
|
||||||
|
setShowMoreNews((p) => !p);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HeroContainer id="home">
|
<HeroContainer id="home">
|
||||||
<HeroContent>
|
<HeroContent>
|
||||||
@@ -147,12 +155,15 @@ export default function HeroSection() {
|
|||||||
<HeroColumn1>
|
<HeroColumn1>
|
||||||
<HeroNewsBlock>
|
<HeroNewsBlock>
|
||||||
<HeroNewsTitle>RECENT NEWS:</HeroNewsTitle>
|
<HeroNewsTitle>RECENT NEWS:</HeroNewsTitle>
|
||||||
{news.map((item, index) => (
|
{(showMoreNews ? news : news.slice(0, 7)).map((item, index) => (
|
||||||
<HeroNewsItem key={index}>
|
<HeroNewsItem key={index}>
|
||||||
<HeroNewsItemDate>{item.date}</HeroNewsItemDate>
|
<HeroNewsItemDate>{item.date}</HeroNewsItemDate>
|
||||||
{item.content}
|
{item.content}
|
||||||
</HeroNewsItem>
|
</HeroNewsItem>
|
||||||
))}
|
))}
|
||||||
|
<HeroNewsMoreButton onClick={toggleShowMore}>
|
||||||
|
{showMoreNews ? "Show less" : "Show more"}
|
||||||
|
</HeroNewsMoreButton>
|
||||||
</HeroNewsBlock>
|
</HeroNewsBlock>
|
||||||
<HeroCitationTitle>CITATION:</HeroCitationTitle>
|
<HeroCitationTitle>CITATION:</HeroCitationTitle>
|
||||||
<HeroCitationBlock>
|
<HeroCitationBlock>
|
||||||
|
|||||||
Reference in New Issue
Block a user