Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
recommend のカテゴリ分けの merge -Like 対応
  • Loading branch information
hotman78 committed May 14, 2025
commit 4381c40ca5c3521cb3faa453e048b44a888a537f
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { React, useMemo } from "react";
import {
Button,
ButtonGroup,
Expand All @@ -9,6 +9,7 @@ import {
UncontrolledDropdown,
} from "reactstrap";
import { formatExcludeOption } from "../../../utils/LastSolvedTime";
import { isLikeContestCategory } from "../../../utils/LikeContestUtils";
const RECOMMEND_NUM_OPTIONS = [
{
text: "10",
Expand Down Expand Up @@ -51,6 +52,9 @@ const CategoryOptions = [
"ABC",
"ARC",
"AGC",
"ABC-Like",
"ARC-Like",
"AGC-Like",
"Other Sponsored",
] as const;
export type CategoryOption = typeof CategoryOptions[number];
Expand All @@ -67,90 +71,118 @@ interface Props {

showExperimental: boolean;
onChangeExperimentalVisibility: (showExperimental: boolean) => void;
mergeLikeContest: boolean;
onChangeMergeLikeContest: (mergeLikeContest: boolean) => void;

showCount: number;
onChangeShowCount: (count: number) => void;
}

export const RecommendController = (props: Props) => (
<>
<div>
<ButtonGroup className="mr-3">
{RecommendOptions.map((type) => (
<Button
key={type}
active={props.recommendOption === type}
onClick={() => props.onChangeRecommendOption(type)}
>
{type}
</Button>
))}
</ButtonGroup>
<ButtonGroup className="mr-3">
<UncontrolledDropdown>
<DropdownToggle caret>
{formatExcludeOption(props.excludeOption)}
</DropdownToggle>
<DropdownMenu>
{ExcludeOptions.map((option) => (
<DropdownItem
key={option}
onClick={(): void => props.onChangeExcludeOption(option)}
>
{formatExcludeOption(option)}
</DropdownItem>
))}
</DropdownMenu>
</UncontrolledDropdown>
</ButtonGroup>
<ButtonGroup className="mr-3">
<UncontrolledDropdown>
<DropdownToggle caret>
{props.categoryOption === "All"
? "Contest Category"
: props.categoryOption}
</DropdownToggle>
<DropdownMenu>
{CategoryOptions.map((option) => (
<DropdownItem
key={option}
onClick={(): void => props.onChangeCategoryOption(option)}
>
{option}
</DropdownItem>
))}
</DropdownMenu>
</UncontrolledDropdown>
</ButtonGroup>
<CustomInput
type="switch"
id="switchRecommendExperimental"
inline
label={
<span role="img" aria-label="experimental">
🧪
</span>
}
checked={props.showExperimental}
onChange={() =>
props.onChangeExperimentalVisibility(!props.showExperimental)
}
/>
</div>
<UncontrolledDropdown direction="left">
<DropdownToggle caret>
{props.showCount === Number.POSITIVE_INFINITY ? "All" : props.showCount}
</DropdownToggle>
<DropdownMenu>
{RECOMMEND_NUM_OPTIONS.map(({ text, value }) => (
<DropdownItem
key={value}
onClick={(): void => props.onChangeShowCount(value)}
>
{text}
</DropdownItem>
))}
</DropdownMenu>
</UncontrolledDropdown>
</>
);
export const RecommendController = (props: Props) => {
const filteredCategories = useMemo(() => {
return CategoryOptions.filter(
(category) =>
category === "All" ||
!props.mergeLikeContest ||
!isLikeContestCategory(category)
);
}, [props.mergeLikeContest]);
return (
<>
<div>
<ButtonGroup className="mr-3">
{RecommendOptions.map((type) => (
<Button
key={type}
active={props.recommendOption === type}
onClick={() => props.onChangeRecommendOption(type)}
>
{type}
</Button>
))}
</ButtonGroup>
<ButtonGroup className="mr-3">
<UncontrolledDropdown>
<DropdownToggle caret>
{formatExcludeOption(props.excludeOption)}
</DropdownToggle>
<DropdownMenu>
{ExcludeOptions.map((option) => (
<DropdownItem
key={option}
onClick={(): void => props.onChangeExcludeOption(option)}
>
{formatExcludeOption(option)}
</DropdownItem>
))}
</DropdownMenu>
</UncontrolledDropdown>
</ButtonGroup>
<ButtonGroup className="mr-3">
<UncontrolledDropdown>
<DropdownToggle caret>
{props.categoryOption === "All"
? "Contest Category"
: props.categoryOption}
</DropdownToggle>
<DropdownMenu>
{filteredCategories.map((option) => (
<DropdownItem
key={option}
onClick={(): void => props.onChangeCategoryOption(option)}
>
{option}
</DropdownItem>
))}
</DropdownMenu>
</UncontrolledDropdown>
</ButtonGroup>
<CustomInput
type="switch"
id="switchRecommendExperimental"
inline
label={
<span role="img" aria-label="experimental">
🧪
</span>
}
checked={props.showExperimental}
onChange={() =>
props.onChangeExperimentalVisibility(!props.showExperimental)
}
/>
<CustomInput
type="switch"
id="switchMergeLikeContest"
inline
label={
<span role="img" aria-label="experimental">
Merge &quot;-Like&quot; Contests
</span>
}
checked={props.mergeLikeContest}
onChange={() =>
props.onChangeMergeLikeContest(!props.mergeLikeContest)
}
/>
</div>
<UncontrolledDropdown direction="left">
<DropdownToggle caret>
{props.showCount === Number.POSITIVE_INFINITY
? "All"
: props.showCount}
</DropdownToggle>
<DropdownMenu>
{RECOMMEND_NUM_OPTIONS.map(({ text, value }) => (
<DropdownItem
key={value}
onClick={(): void => props.onChangeShowCount(value)}
>
{text}
</DropdownItem>
))}
</DropdownMenu>
</UncontrolledDropdown>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
getMaximumExcludeElapsedSecond,
} from "../../../utils/LastSolvedTime";
import { classifyContest } from "../../../utils/ContestClassifier";
import { getLikeContestCategory } from "../../../utils/LikeContestUtils";
import { recommendProblems } from "./RecommendProblems";
import {
CategoryOption,
Expand All @@ -59,6 +60,12 @@ export const Recommendations = (props: Props) => {
"recoomendExcludeOption",
"Exclude"
);

const [mergeLikeContest, setMergeLikeContest] = useLocalStorage<boolean>(
"recommendMergeLikeContest",
true
);

const [categoryOption, setCategoryOption] = useLocalStorage<CategoryOption>(
"recommendCategoryOption",
"All"
Expand Down Expand Up @@ -122,7 +129,8 @@ export const Recommendations = (props: Props) => {
}
return (
classifyContest(contest) === categoryOption ||
classifyContest(contest) === categoryOption + "-Like"
(mergeLikeContest &&
classifyContest(contest) === getLikeContestCategory(categoryOption))
);
},
(problemId: ProblemId) => problemModels?.get(problemId),
Expand All @@ -146,6 +154,8 @@ export const Recommendations = (props: Props) => {
onChangeExperimentalVisibility={(show) =>
setRecommendExperimental(show)
}
mergeLikeContest={mergeLikeContest}
onChangeMergeLikeContest={(merge) => setMergeLikeContest(merge)}
showCount={recommendNum}
onChangeShowCount={(value) => setRecommendNum(value)}
/>
Expand Down
1 change: 1 addition & 0 deletions atcoder-problems-frontend/src/utils/LocalStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const LocalStorageKeys = [
"showRating",
"recommendOption",
"recommendExperimental",
"recommendMergeLikeContest",
"recoomendExcludeOption",
"recommendCategoryOption",
"MergeLikeContest",
Expand Down