diff --git a/.gitignore b/.gitignore index 4d29575..1a47dc1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# /cons60-web \ No newline at end of file diff --git a/src/components/Constitution.jsx b/src/components/Constitution.jsx index 7847420..7c4ad2a 100644 --- a/src/components/Constitution.jsx +++ b/src/components/Constitution.jsx @@ -25,8 +25,6 @@ export default function Constitution({constitution, search = null}) { dangerouslySetInnerHTML={{__html: constitution.replace(new RegExp(search, 'gi'), `${search}`)}} > - - ) diff --git a/src/components/HamburgerSVG.jsx b/src/components/HamburgerSVG.jsx index ebb14a9..ff3b3db 100644 --- a/src/components/HamburgerSVG.jsx +++ b/src/components/HamburgerSVG.jsx @@ -6,6 +6,7 @@ export default function HamburgerSVG() { height="16" viewBox="0 0 25 16" fill="none" + aria-label="เมนู" > - sort === 0 ? b[1] - a[1] : a[1] - b[1] - ); + const sorted = Object.entries(newResult).sort((a, b) => { + if (sort === 2) { + const idA = parseInt(chapterNameToId[a[0]].match(/\d+/), 10); + const idB = parseInt(chapterNameToId[b[0]].match(/\d+/), 10); + + if (isNaN(idA)) return 1; + if (isNaN(idB)) return -1; + + return idA - idB ; + } else if (sort === 1) { + return a[1] - b[1]; + } else if (sort === 0) { + return b[1] - a[1]; + } + return 0; + }); + setResult(sorted); }, [sort]); @@ -39,7 +53,7 @@ function ByChapter() {
ค้นหาจากหมวด
- +
{result.map(([chapterName, count]) => ( @@ -61,4 +75,4 @@ function ByChapter() { ); } -export default ByChapter; +export default ByChapter; \ No newline at end of file diff --git a/src/components/Overview/BySection.jsx b/src/components/Overview/BySection.jsx index 0608655..808a65e 100644 --- a/src/components/Overview/BySection.jsx +++ b/src/components/Overview/BySection.jsx @@ -77,6 +77,12 @@ function BySection() { const sortResult = useCallback( (result) => { + if (sort === 2) { + return result.sort((a, b) => + sort === parseInt(b[0], 10) - parseInt(a[0], 10) + ); + } + return result.sort((a, b) => sort === 0 ? b[1].total - a[1].total : a[1].total - b[1].total ); @@ -141,7 +147,7 @@ function BySection() { )} )} - +
{result.map(([Section, { chapterName, total }]) => ( diff --git a/src/components/Sections.jsx b/src/components/Sections.jsx index b38e25b..5e22b16 100644 --- a/src/components/Sections.jsx +++ b/src/components/Sections.jsx @@ -1,4 +1,5 @@ import accordionToggle from "../utils/accordion.js"; +import React, { useState, useEffect } from 'react'; import "../styles/Section.css"; import "../styles/Normal.css"; @@ -6,18 +7,25 @@ export default function Sections({sections, search = null}) { const convertDate = dateStr => { const dateArr = dateStr.split('/'); - const date = new Date(dateArr[2]-543, dateArr[1]-1, dateArr[0]); + const date = new Date(dateArr[2] - 543, dateArr[1] - 1, dateArr[0]); return date.toLocaleDateString('th-TH', { day: 'numeric', month: 'long', year: 'numeric', }) }; - + + const [isTopicExpanded, setTopicIsExpanded] = useState(false); + const [isShown, setIsShown] = useState(false); + const sectionArr = sections.map((section, index) => ( -
+
- - + ) : ''} + {section.ประเด็นการพิจารณา.length ? ( + <> +
+

ประเด็นการพิจารณา

+
+
+
+
+
+
+ {isShown && + + } +
+
+ + ) : ''} +
)); - + return sectionArr; - + } diff --git a/src/components/SortBy.jsx b/src/components/SortBy.jsx index be65ddf..588a007 100644 --- a/src/components/SortBy.jsx +++ b/src/components/SortBy.jsx @@ -1,18 +1,24 @@ -function SortBy({ sort, setSort }) { +import React from 'react'; + +function SortBy({ sort, setSort, mode = "" }) { return (
); } -export default SortBy; +export default SortBy; \ No newline at end of file diff --git a/src/pages/Discussionist.jsx b/src/pages/Discussionist.jsx index 3b5797b..fe7e273 100644 --- a/src/pages/Discussionist.jsx +++ b/src/pages/Discussionist.jsx @@ -79,6 +79,11 @@ export default function Discussionist() { const sortResult = useCallback( (result) => { + if (sort === 2) { + return result.sort((a, b) => + sort === parseInt(b[0], 10) - parseInt(a[0], 10) + ); + } return result.sort((a, b) => sort === 0 ? b[1].total - a[1].total : a[1].total - b[1].total ); @@ -158,7 +163,7 @@ export default function Discussionist() { )} )} - +
{result.map(([Section, { chapterName, total }]) => ( diff --git a/src/pages/RelatedInfo.jsx b/src/pages/RelatedInfo.jsx index acc3dd1..3956f96 100644 --- a/src/pages/RelatedInfo.jsx +++ b/src/pages/RelatedInfo.jsx @@ -28,6 +28,9 @@ export default function RelatedInfo() { บันทึกการประชุมคณะกรรมการร่างรัฐธรรมนูญ ครั้งที่ 1-501 + + รัฐธรรมนูญฉบับแก้ไขเพิ่มเติม 2564 +
diff --git a/src/pages/Search.jsx b/src/pages/Search.jsx index f4de848..b7da152 100644 --- a/src/pages/Search.jsx +++ b/src/pages/Search.jsx @@ -90,9 +90,6 @@ export default function Search({ searchInputValue, setSearchInputValue }) { const handlePageClick = (event) => { const newOffset = (event.selected * itemsPerPage) % articleResult.length; - console.log( - `User requested page number ${event.selected}, which is offset ${newOffset}` - ); setItemOffset(newOffset); }; @@ -145,16 +142,11 @@ export default function Search({ searchInputValue, setSearchInputValue }) { const [itemOffset, setItemOffset] = useState(0); const itemsPerPage = 5 const endOffset = itemOffset + itemsPerPage; - console.log(`Loading items from ${itemOffset} to ${endOffset}`); const currentItems = discussionistResult.slice(itemOffset, endOffset); const pageCount = Math.ceil(discussionistResult.length / itemsPerPage); - console.log(currentItems); const handlePageClick = (event) => { const newOffset = (event.selected * itemsPerPage) % discussionistResult.length; - console.log( - `User requested page number ${event.selected}, which is offset ${newOffset}` - ); setItemOffset(newOffset); }; if (!discussionistResult || discussionistResult.length === 0) { @@ -214,6 +206,13 @@ export default function Search({ searchInputValue, setSearchInputValue }) { } }; + function uniq(array) { + var seen = {}; + return array.filter(function(item) { + return seen.hasOwnProperty(item) ? false : (seen[item] = true); + }); + } + useEffect(() => { if (searchInputValue.trim() === "") { setArticleResult([]); @@ -233,6 +232,7 @@ export default function Search({ searchInputValue, setSearchInputValue }) { chapterIdToName[obj.หมวด] + ")" ] ).filter(value => value[1] !== ""); + articleResult = uniq(articleResult) setArticleResult(articleResult); let discussionistNameSearch = [...new Set( diff --git a/src/styles/Home.css b/src/styles/Home.css index 5138e29..817ebe5 100644 --- a/src/styles/Home.css +++ b/src/styles/Home.css @@ -84,6 +84,29 @@ body { color: #ff5151; } +.truncate-7 { + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 7; + -webkit-box-orient: vertical; +} + +.truncate-500 { + display: -webkit-box; + -webkit-line-clamp: 5; /* Adjust the number of lines as needed */ + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + /* white-space: nowrap; */ + max-height: 100ch; +} + +.expanded { + /* Remove truncation styles */ + -webkit-line-clamp: initial; + max-height: none; +} + #truehits_div { position: absolute; left: -9999px; diff --git a/src/utils/accordion.js b/src/utils/accordion.js index 72a813b..2701baf 100644 --- a/src/utils/accordion.js +++ b/src/utils/accordion.js @@ -19,7 +19,6 @@ export default function accordionToggle(id, forceOpen=false) { const navExpanded = document.getElementById('nav-'+id); navActive.className = 'nav py-2 px-5 font-bold text-left w-full md:w-64 text-[#9F9F9F]'; navExpanded.className = 'nav nav-active py-2 px-5 font-bold text-left w-full md:w-64 bg-white rounded-lg text-[#131313]'; - return; }