diff --git a/src/components/Article/Cover/components/Article.tsx b/src/components/Article/Cover/components/Article.tsx index c020f4a..fb35fa8 100644 --- a/src/components/Article/Cover/components/Article.tsx +++ b/src/components/Article/Cover/components/Article.tsx @@ -2,6 +2,10 @@ import { QueueListIcon } from '@heroicons/react/24/solid'; import { QuestionMarkCircleIcon } from '@heroicons/react/24/solid'; import { ArticleDetail } from '@/utils/article-page/types'; import React from 'react'; +import { useState } from 'react'; +import ArticleBlock from './ArticleBlock'; +import Image from 'next/image'; +import czw from '@/public/images/czw.jpg'; //mock data const Detail: Array = [ @@ -12,7 +16,7 @@ const Detail: Array = [ 'เกริ่นบทความมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมม', fullinfo: 'ข้อความแบบจริงจังงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงง', - img: '', + img: 'images/czw.jpg', }, { topic: 'ห้องน้ำ', @@ -21,7 +25,7 @@ const Detail: Array = [ 'เกริ่นบทความมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมม', fullinfo: 'ข้อความแบบจริงจังงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงงง', - img: '', + img: 'images/og.png', }, { topic: 'คำถาม', @@ -44,21 +48,45 @@ const Detail: Array = [ ]; const Article: React.FC = () => { + const [isVisible, setIsVisible] = useState(true); + function handleButtonClick() { + setIsVisible(!isVisible); + } return (
- {Detail.map((article, index) => ( - + {Detail.map((article: ArticleDetail, index: number) => ( + + + // ))}
); diff --git a/src/components/Article/Cover/components/ArticleBlock.tsx b/src/components/Article/Cover/components/ArticleBlock.tsx new file mode 100644 index 0000000..f3be0f0 --- /dev/null +++ b/src/components/Article/Cover/components/ArticleBlock.tsx @@ -0,0 +1,58 @@ +import { ArticleDetail } from '@/utils/article-page/types'; +import React, { useState, useRef } from 'react'; +import Image from 'next/image'; + +interface ArticleBlockProps { + article: ArticleDetail; + index: number; +} + +function ArticleBlock({ article, index }: ArticleBlockProps) { + const [expanded, setExpanded] = useState(false); + const fullInfoRef = useRef(null); + + function handleButtonClick() { + setExpanded(!expanded); + } + + return ( + + ); +} + +export default ArticleBlock; diff --git a/src/components/Article/Cover/index.tsx b/src/components/Article/Cover/index.tsx index 3f90632..b87e170 100644 --- a/src/components/Article/Cover/index.tsx +++ b/src/components/Article/Cover/index.tsx @@ -2,7 +2,7 @@ import Article from '@/components/Article/Cover/components/Article'; const ArticlePage = () => { return ( -
+
); diff --git a/src/components/DefaultButton.tsx b/src/components/DefaultButton.tsx new file mode 100644 index 0000000..083ff2d --- /dev/null +++ b/src/components/DefaultButton.tsx @@ -0,0 +1,19 @@ +import React from 'react'; + +const DefaultButton = ({ content, additionalStyle, onClick, disabled }) => { + const buttonClassName = + `max-w-full w-40 mx-auto items-center py-2 text-white transition-all duration-500 hover:ring-8 disabled:cursor-not-allowed disabled:ring-0 ` + + additionalStyle; + + return ( + + ); +}; + +export default DefaultButton;