Skip to content

Commit

Permalink
#44 add chapter text in chapter filter menu
Browse files Browse the repository at this point in the history
iampz committed Mar 11, 2024
1 parent 5cb70e1 commit 32f5880
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/SelectChapters/ChapterButton.jsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { Icon } from "@iconify/react";

import chapterColorCode from "../../constants/chapterColorCode";

function ChapterButton({ chapter, selected, onClick }) {
function ChapterButton({ chapter, wording, selected, onClick }) {
const activeStyle = "rounded-full text-black px-2";
const inactiveStyle = "text-[#9f9f9f] px-4";

@@ -33,7 +33,7 @@ function ChapterButton({ chapter, selected, onClick }) {
</div>
)}
<div className="text-ellipsis whitespace-nowrap overflow-hidden">
{chapter}
{wording}
</div>
</div>
</button>
8 changes: 7 additions & 1 deletion src/components/SelectChapters/SelectChapters.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ChapterButton from "./ChapterButton";
import chapters from "../../constants/chapters";
import chapters, { chapterNameToId } from "../../constants/chapters";

function SelectChapters(props) {
const { selectedChapters, onChange } = props;
@@ -9,6 +9,7 @@ function SelectChapters(props) {
<ChapterButton
key={"ทั้งหมด"}
chapter={"ทั้งหมด"}
wording={"ทั้งหมด"}
selected={selectedChapters.length === 0}
onClick={() => {
onChange([]);
@@ -18,6 +19,11 @@ function SelectChapters(props) {
<ChapterButton
key={chapter}
chapter={chapter}
wording={
chapterNameToId[chapter].match(/^[0-9]+$/)
? 'หมวด ' + chapterNameToId[chapter] + ' ' + chapter
: chapter
}
selected={selectedChapters.includes(chapter)}
onClick={() => {
if (selectedChapters.includes(chapter)) {

0 comments on commit 32f5880

Please sign in to comment.