Skip to content
6 changes: 3 additions & 3 deletions scripts/create-problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"dir_name": "list_2_iterating"
},
{
"display_name": "List-3: Complex Loop",
"input_name": "list3",
"dir_name": "list_3_complex_loop"
"display_name": "Level-3: Complex Problems",
"input_name": "level3",
"dir_name": "level_3_complex_problems"
},
{
"display_name": "Logic",
Expand Down
2 changes: 1 addition & 1 deletion src/blog-posts
15 changes: 13 additions & 2 deletions src/components/BlogList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ interface BlogListItemProps {
blog: BlogPost;
activeBlog: string | null;
closeDrawer: () => void;
kbFocus: string;
kbSelectedBlog: string | null;
}

function BlogListItem({ blog, activeBlog, closeDrawer, kbSelectedBlog }: BlogListItemProps) {
function BlogListItem({
blog,
activeBlog,
closeDrawer,
kbFocus,
kbSelectedBlog
}: BlogListItemProps) {
const itemRef = useRef<HTMLAnchorElement>(null);

useEffect(() => {
Expand All @@ -32,7 +39,8 @@ function BlogListItem({ blog, activeBlog, closeDrawer, kbSelectedBlog }: BlogLis
to={`/blogs/${blog.meta.blog_slug}`}
onClick={closeDrawer}
sx={{
...(blog.meta.blog_slug === kbSelectedBlog && { backgroundColor: '#FFE293 !important' })
...(blog.meta.blog_slug === kbSelectedBlog && kbFocus === "content" &&
{ backgroundColor: '#FFE293 !important' })
}}
>
<Stack width="100%" direction="row" justifyContent="space-between">
Expand All @@ -50,6 +58,7 @@ interface BlogListProps {
selectedCategory: string | null;
activeBlog: string | null;
closeDrawer: () => void;
kbFocus: string;
kbSelectedBlog: string | null;
}

Expand All @@ -61,6 +70,7 @@ export default function BlogList({
selectedCategory,
activeBlog,
closeDrawer,
kbFocus,
kbSelectedBlog
}: BlogListProps) {
const handleTabChange = (_: any, newValue: any) => {
Expand Down Expand Up @@ -136,6 +146,7 @@ export default function BlogList({
blog={blog}
activeBlog={activeBlog}
closeDrawer={closeDrawer}
kbFocus={kbFocus}
kbSelectedBlog={kbSelectedBlog}
/>)
})}
Expand Down
9 changes: 6 additions & 3 deletions src/components/BlogMenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export interface BlogMenuProps {
activeCategory: string | null;
onSelectCategory: (cat: string) => void;
category: string;
kbFocus: string;
kbSelectedCategory: string | null;
}

export default function BlogMenuButton({
onSelectCategory,
activeCategory,
category,
kbFocus,
kbSelectedCategory
}: BlogMenuProps) {
const itemRef = useRef<HTMLDivElement>(null);
Expand All @@ -29,7 +31,7 @@ export default function BlogMenuButton({
selected={category === activeCategory}
onClick={() => onSelectCategory(category)}
className={
category === activeCategory
category === activeCategory
? 'category-active'
: 'category-inactive'
}
Expand All @@ -43,8 +45,9 @@ export default function BlogMenuButton({
margin: "10px 10px 10px 15px",
boxShadow: "5px 5px black",
border: "1px solid black",
...(category === kbSelectedCategory && {
backgroundColor: '#82d078 !important',
...(category === kbSelectedCategory && kbFocus === "category" &&
{
backgroundColor: '#82d078 !important',
})
}}
>
Expand Down
30 changes: 25 additions & 5 deletions src/components/CategoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import CategoryLock from "../utils/CategoryLock";
import CategoryListItems from "./CategoryListItem";
import BlogMenuButton from "./BlogMenuButton";
import { getCategoryListOrdered } from "../utils/getCategoryListOrdered";
import { fetchCategories } from "../utils/TestCategoriesFetch";

export interface CategoryListProps {
searchedProblems: Problem[];
activeCategory: string | null;
onSelectCategory: (cat: string) => void;
session: Session | null;
contractProgress: ContractProgress;
kbFocus: string;
kbSelectedCategory: string | null;
}

Expand All @@ -24,10 +26,21 @@ export default function CategoryList({
onSelectCategory,
session,
contractProgress,
kbFocus,
kbSelectedCategory
}: CategoryListProps) {
const [error, setError] = useState("");
const [progress, setProgress] = useState<Progress[]>([]);
const [fetchedCategories, setFetchedCategories] = useState<Map<string, boolean>>();

useEffect(() => {
(async () => {
const categoryResult = await fetchCategories();

if (!categoryResult) return;
setFetchedCategories(categoryResult)
})();
}, []);

// List of categories that show up in search results.
const categories = getCategoryListOrdered(searchedProblems
Expand Down Expand Up @@ -80,6 +93,8 @@ export default function CategoryList({
*/
function mapCategoryToLock(category: string) {
switch (category) {
case "Level 0":
return categoryLock.level_0;
case "Fundamentals":
return categoryLock.fundamentals;
case "Logic":
Expand All @@ -88,20 +103,18 @@ export default function CategoryList({
return categoryLock.string_1;
case "String-2":
return categoryLock.string_2;
case "String-3":
return categoryLock.string_3;
case "List-1: Indexing":
return categoryLock.list_1;
case "List-2: Iterating":
return categoryLock.list_2;
case "List-3: Complex Loop":
return categoryLock.list_3;
case "Level-3: Complex Problems":
return categoryLock.level_3;
case "Mutation":
return categoryLock.mutation;
case "Haystack":
return categoryLock.haystack;
default:
return categoryLock.fundamentals;
return categoryLock.level_0;
}
}

Expand All @@ -116,6 +129,7 @@ export default function CategoryList({
category="blogs"
activeCategory={activeCategory}
onSelectCategory={onSelectCategory}
kbFocus={kbFocus}
kbSelectedCategory={kbSelectedCategory}
/>
<Box>
Expand All @@ -130,7 +144,9 @@ export default function CategoryList({
onSelectCategory={onSelectCategory}
session={session}
contractProgress={contractProgress}
kbFocus={kbFocus}
kbSelectedCategory={kbSelectedCategory}
fetchedCategories={fetchedCategories}
/>
<Box>
<hr />
Expand All @@ -144,7 +160,9 @@ export default function CategoryList({
onSelectCategory={onSelectCategory}
session={session}
contractProgress={contractProgress}
kbFocus={kbFocus}
kbSelectedCategory={kbSelectedCategory}
fetchedCategories={fetchedCategories}
/>
<Box>
<hr />
Expand All @@ -158,7 +176,9 @@ export default function CategoryList({
onSelectCategory={onSelectCategory}
session={session}
contractProgress={contractProgress}
kbFocus={kbFocus}
kbSelectedCategory={kbSelectedCategory}
fetchedCategories={fetchedCategories}
/>
</>
</List>
Expand Down
13 changes: 7 additions & 6 deletions src/components/CategoryListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useState, useRef } from 'react';
import { ListItemButton, Typography } from "@mui/joy";
import { LockSimple } from "@phosphor-icons/react";
import { capitalizeString } from "../utils/capitalizeString";
import { fetchCategories } from "../utils/TestCategoriesFetch";

function CategoryListItem({
category,
Expand All @@ -13,6 +12,7 @@ function CategoryListItem({
onSelectCategory,
session,
contractProgress,
kbFocus,
kbSelectedCategory
}: any) {
const itemRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -58,7 +58,7 @@ function CategoryListItem({
margin: "10px 10px 10px 15px",
boxShadow: "5px 5px black",
border: "1px solid black",
...(category === kbSelectedCategory && {
...(category === kbSelectedCategory && kbFocus === "category" && {
backgroundColor: '#82d078 !important',
})
}}
Expand Down Expand Up @@ -90,14 +90,14 @@ export default function CategoryListItems({
onSelectCategory,
session,
contractProgress,
kbSelectedCategory
kbFocus,
kbSelectedCategory,
fetchedCategories
}: any) {
const [controlledCategories, setControlledCategories] = useState<string[]>([]);

useEffect(() => {
(async () => {
const fetchedCategories = await fetchCategories();

if (!fetchedCategories) return;

// Find the test categories that are toggled false
Expand All @@ -109,7 +109,7 @@ export default function CategoryListItems({

setControlledCategories(filteredCategories);
})();
}, [categories]);
}, [categories, fetchedCategories]);

return (
<>
Expand All @@ -124,6 +124,7 @@ export default function CategoryListItems({
onSelectCategory={onSelectCategory}
session={session}
contractProgress={contractProgress}
kbFocus={kbFocus}
kbSelectedCategory={kbSelectedCategory}
/>
))}
Expand Down
16 changes: 14 additions & 2 deletions src/components/ProblemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ export interface ProblemListItemProps {
problem: Problem;
activeProblem: string | null;
closeDrawer: () => void;
kbFocus: string;
kbSelectedProblem: string | null;
attempted: boolean;
solved: boolean;
}

function ProblemListItem({ problem, activeProblem, closeDrawer, kbSelectedProblem, attempted, solved }: ProblemListItemProps){
function ProblemListItem({
problem,
activeProblem,
closeDrawer,
kbFocus,
kbSelectedProblem,
attempted,
solved
}: ProblemListItemProps){
const itemRef = useRef<HTMLAnchorElement>(null);

useEffect(() => {
Expand All @@ -49,7 +58,7 @@ function ProblemListItem({ problem, activeProblem, closeDrawer, kbSelectedProble
to={`/problems/${problem.meta.name}`}
onClick={closeDrawer}
sx={
problem.meta.name === kbSelectedProblem
problem.meta.name === kbSelectedProblem && kbFocus === "content"
? { backgroundColor: '#FFE293 !important' }
: {}
}
Expand Down Expand Up @@ -177,6 +186,7 @@ export interface ProblemListProps {
session: Session | null;
contractProgress: ContractProgress;
progress: Submission[];
kbFocus: string;
kbSelectedProblem: string | null;
order: string;
setOrder: (order: string) => void;
Expand All @@ -195,6 +205,7 @@ export default function ProblemList({
session,
contractProgress,
progress,
kbFocus,
kbSelectedProblem,
order,
setOrder,
Expand Down Expand Up @@ -354,6 +365,7 @@ export default function ProblemList({
problem={p}
activeProblem={activeProblem}
closeDrawer={closeDrawer}
kbFocus={kbFocus}
kbSelectedProblem={kbSelectedProblem}
attempted={unsolvedProblems.includes(p.meta.name)}
solved={solvedProblems.includes(p.meta.name)}
Expand Down
12 changes: 5 additions & 7 deletions src/components/layout/SidebarDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CustomSearch from '../ProblemSearch';
import ProblemList from '../ProblemList';
import BlogList from '../BlogList';
import PasswordProtected from '../../routes/PasswordProtected';
import { Problem, BlogPost } from '../../types';
import { Problem } from '../../types';
import { TEST_CATEGORY_PATTERN } from '../../utils/constants';

interface Props {
Expand All @@ -18,13 +18,11 @@ interface Props {
query: string;
setQuery: React.Dispatch<React.SetStateAction<string>>;
searchedProblems: Problem[];
searchedBlogs: BlogPost[];
activeCategory: string | null;
handleSelectedCategory: (cat: string) => void;
problemListProps: any;
blogListProps: any;
selectedTab: string;
setSelectedTab: React.Dispatch<React.SetStateAction<string>>;
kbFocus: string;
kbSelectedCategory: string | null;
}

Expand All @@ -38,13 +36,11 @@ export default function SidebarDrawer({
query,
setQuery,
searchedProblems,
searchedBlogs,
activeCategory,
handleSelectedCategory,
problemListProps,
blogListProps,
selectedTab,
setSelectedTab,
kbFocus,
kbSelectedCategory
}: Props) {
return (
Expand Down Expand Up @@ -76,6 +72,7 @@ export default function SidebarDrawer({
onSelectCategory={handleSelectedCategory}
session={problemListProps.session}
contractProgress={problemListProps.contractProgress}
kbFocus={kbFocus}
kbSelectedCategory={kbSelectedCategory}
/>
</Drawer>
Expand All @@ -87,6 +84,7 @@ export default function SidebarDrawer({
onSelectCategory={handleSelectedCategory}
session={problemListProps.session}
contractProgress={problemListProps.contractProgress}
kbFocus={kbFocus}
kbSelectedCategory={kbSelectedCategory}
/>
</Box>
Expand Down
Loading
Loading