-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from woodnext/quiz_filter
Quiz filter
- Loading branch information
Showing
19 changed files
with
357 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ dist-ssr | |
*.sln | ||
*.sw? | ||
|
||
firebase.config.ts | ||
src/plugins/firebase.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import useSWR from "swr"; | ||
import { fetcher } from "../fetchers"; | ||
import { Checkbox, DefaultProps, Group } from "@mantine/core"; | ||
|
||
interface FilteringLevelProps extends DefaultProps { | ||
value: string[] | undefined, | ||
onChange: React.Dispatch<React.SetStateAction<string[]>>, | ||
} | ||
|
||
export interface Level{ | ||
id: number, | ||
name: string, | ||
color: string, | ||
} | ||
|
||
export default function FilteringLevel({ | ||
value, | ||
onChange, | ||
...others | ||
}: FilteringLevelProps) { | ||
const { data: levels } = useSWR<Level[]>('/levels', fetcher) | ||
|
||
return ( | ||
<Checkbox.Group | ||
value={value} | ||
onChange={onChange} | ||
defaultValue={[]} | ||
label="Select Workbook's Level" | ||
{...others} | ||
> | ||
<Group> | ||
{levels?.map(level => | ||
<Checkbox | ||
value={level.id.toString()} | ||
label={level.name} | ||
color={level.color} | ||
key={level.id} | ||
/> | ||
)} | ||
</Group> | ||
</Checkbox.Group> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { DefaultProps, Group, Radio, TextInput } from "@mantine/core" | ||
import { formInputProps } from "../hooks" | ||
|
||
export type optionProps = { | ||
value: string, | ||
onChange: (value: string) => void | ||
} | ||
|
||
interface FilteringWordProps extends DefaultProps { | ||
wordInputProps: formInputProps, | ||
wordSearchOption: optionProps, | ||
} | ||
|
||
export default function FilteringWord({ | ||
wordInputProps, | ||
wordSearchOption, | ||
className, | ||
...others | ||
}: FilteringWordProps) { | ||
return ( | ||
<> | ||
<TextInput | ||
className={className} | ||
label="Word Search" | ||
{...wordInputProps} | ||
{...others} | ||
/> | ||
<Radio.Group | ||
mt="sm" | ||
label="Search Option" | ||
{...wordSearchOption} | ||
> | ||
<Group> | ||
<Radio | ||
value="1" | ||
label="問題文と解答の両方" | ||
/> | ||
<Radio | ||
value="2" | ||
label="問題文のみ" | ||
/> | ||
<Radio | ||
value="3" | ||
label="解答のみ" | ||
/> | ||
</Group> | ||
|
||
</Radio.Group> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { forwardRef } from "react"; | ||
import useSWR from "swr"; | ||
import { fetcher } from "../fetchers"; | ||
import { Badge, DefaultProps, Group, MultiSelect } from "@mantine/core"; | ||
|
||
interface WorkbookProps extends React.ComponentPropsWithoutRef<'div'> { | ||
id: string, | ||
label: string, | ||
color: string, | ||
} | ||
|
||
export interface Workbook { | ||
id: number, | ||
label: string, | ||
color: string, | ||
} | ||
|
||
interface FilteringWorkbookProps extends DefaultProps { | ||
value: string[] | undefined, | ||
onChange: React.Dispatch<React.SetStateAction<string[]>> | ||
} | ||
|
||
export default function FilteringWorkbook({ | ||
value, | ||
onChange, | ||
...others | ||
}: FilteringWorkbookProps ) { | ||
const { data: workbooks } = useSWR<Workbook[]>('/workbooks/color', fetcher) | ||
|
||
const data = workbooks ? workbooks.map(({id, label, ...others}) => ({...others, value: String(id), key: id, label})) : [] | ||
|
||
const Item = forwardRef<HTMLDivElement, WorkbookProps>( | ||
({ id, label, color, ...others}: WorkbookProps, ref) => ( | ||
<div ref={ref} {...others}> | ||
<Group noWrap> | ||
<Badge | ||
size="lg" | ||
radius="sm" | ||
color={color} | ||
>{label}</Badge> | ||
</Group> | ||
</div> | ||
)) | ||
|
||
return ( | ||
<MultiSelect | ||
label="Select Workbooks" | ||
searchable | ||
data={data} | ||
itemComponent={Item} | ||
filter={(value, selected, item) => !selected && (item.label?.includes(value) || false)} | ||
value={value} | ||
onChange={onChange} | ||
{...others} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.