fix: fix bug with articles section

This commit is contained in:
jinhojang6
2024-10-17 01:03:41 +09:00
parent 7ba4c6b126
commit a677319fa3
2 changed files with 12 additions and 4 deletions
+11 -3
View File
@@ -1,6 +1,6 @@
import styled from '@emotion/styled'
import Link from 'next/link'
import React, { useEffect } from 'react'
import React, { useEffect, useState } from 'react'
import { Section, SectionTitle } from './StyledComponents'
interface Article {
@@ -70,16 +70,22 @@ const MAX_ARTICLES = 4
const ArticlesSection: React.FC = () => {
const [showSeeMore, setShowSeeMore] = React.useState(false)
const [count, setCount] = useState(MAX_ARTICLES)
useEffect(() => {
setShowSeeMore(articlesData.length > MAX_ARTICLES)
}, [])
const handleSeeMore = () => {
setCount(articlesData.length)
setShowSeeMore(false)
}
return (
<Section id="articles">
<SectionTitle>Articles</SectionTitle>
<ArticleList>
{articlesData.map((article, index) => (
{articlesData.slice(0, count).map((article, index) => (
<ArticleItem key={index}>
{article.image && (
<CustomLink href={article.href} target="_blank">
@@ -95,7 +101,9 @@ const ArticlesSection: React.FC = () => {
</ArticleItem>
))}
</ArticleList>
{/* {showSeeMore && <SeeMoreButton>See more</SeeMoreButton>} */}
{showSeeMore && (
<SeeMoreButton onClick={handleSeeMore}>See more</SeeMoreButton>
)}
</Section>
)
}
@@ -29,7 +29,7 @@ const LightningTalksModal = ({
<Modal isOpen={isOpen} onClose={onClose}>
<Container>
<Header>
<h2>Submit Your Talk</h2>
<h2>SUBMIT YOUR TALK</h2>
<CloseButton onClick={onClose}>
<img src="/assets/close.svg" />
</CloseButton>