Skip to content

Commit

Permalink
Merge pull request #473 from 1chooo/refactor/#472
Browse files Browse the repository at this point in the history
Refactor/#472
  • Loading branch information
1chooo authored Nov 21, 2024
2 parents 5e79ef7 + f965842 commit 47caabc
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 312 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions apps/web/src/app/portfolio/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Link from "next/link";
import Image from "next/image";
import PageHeader from "@/components/page-header";
import FilterSelectBox from "@/components/portfolio/v2/filter-select-box";
import FilterList from "@/components/portfolio/v2/filter-list";
import FilterSelectBox from "@/components/portfolio/filter-select-box";
import FilterList from "@/components/portfolio/filter-list";
import MarkdownRenderer from "@/components/markdown/markdown-renderer";
import { getPortfolioPosts } from "@/lib/db/portfolio";
import config from "@/config";
Expand Down
41 changes: 23 additions & 18 deletions apps/web/src/components/portfolio/filter-list.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import React from 'react';
import { projectTags } from '@/config/portfolio';
import { handleItemClick } from '@/lib/utils/filter-utils';
import Link from 'next/link';

interface FilterListProps {
selectedValue: string;
setSelectedValue: React.Dispatch<React.SetStateAction<string>>;
selectedTag: string;
blogTags: string[];
}

const FilterList: React.FC<FilterListProps> = ({ selectedValue, setSelectedValue }) => (
<ul className="filter-list">
{projectTags.map((tag) => (
<li className="filter-item" key={tag}>
<button
className={`filter-btn ${selectedValue === tag ? 'active' : ''}`}
onClick={() => handleItemClick(tag, setSelectedValue)}
>
{tag}
</button>
</li>
))}
</ul>
);
const FilterList: React.FC<FilterListProps> = ({
selectedTag,
blogTags
}) => {

return (
<ul className="filter-list">
{blogTags.map((tag, index) => (
<li className="filter-item" key={index}>
<Link
href={`/portfolio?tag=${encodeURIComponent(tag || '')}`}
className={`filter-btn ${selectedTag === tag ? 'active' : ''}`}
>
{tag}
</Link>
</li>
))}
</ul>
);
};

export default FilterList;
88 changes: 45 additions & 43 deletions apps/web/src/components/portfolio/filter-select-box.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
import React from 'react';
import { MdExpandMore } from "react-icons/md";
import { projectTags } from '@/config/portfolio';
import { handleItemClick } from '@/lib/utils/filter-utils';
"use client";

import React, { useState } from 'react';
import { MdExpandMore } from 'react-icons/md';
import Link from 'next/link';

interface FilterSelectBoxProps {
selectedValue: string;
isSelectActive: boolean;
setIsSelectActive: React.Dispatch<React.SetStateAction<boolean>>;
setSelectedValue: React.Dispatch<React.SetStateAction<string>>;
selectedTag: string;
blogTags: string[];
}

const FilterSelectBox: React.FC<FilterSelectBoxProps> = ({
selectedValue,
isSelectActive,
setIsSelectActive,
setSelectedValue,
}) => (
<div className="filter-select-box">
<button
className={`filter-select ${isSelectActive ? 'active' : ''}`}
onClick={() => setIsSelectActive(!isSelectActive)}
>
<div className="select-value">
{selectedValue || 'Select category'}
</div>
<div className="select-icon">
<MdExpandMore />
</div>
</button>
{isSelectActive && (
<ul className="select-list">
{projectTags.map((tag: string) => (
<li className="select-item" key={tag}>
<button
onClick={() => {
handleItemClick(tag, setSelectedValue);
setIsSelectActive(false);
}}
>
{tag}
</button>
</li>
))}
</ul>
)}
</div>
);
selectedTag,
blogTags
}) => {
const [isSelectActive, setIsSelectActive] = useState(false);

return (
<div className="filter-select-box">
<button
className={`filter-select ${isSelectActive ? 'active' : ''}`}
onClick={() => setIsSelectActive(!isSelectActive)}
>
<div className="select-value">
{selectedTag || 'Select category'}
</div>
<div className="select-icon">
<MdExpandMore />
</div>
</button>
{isSelectActive && (
<ul className="select-list">
{blogTags.map((tag: string) => (
<li className="select-item" key={tag}>
<button
onClick={() => {
setIsSelectActive(false);
}}
>
<Link href={`/portfolio?tag=${encodeURIComponent(tag || '')}`}>
{tag}
</Link>
</button>
</li>
))}
</ul>
)}
</div>
);
};

export default FilterSelectBox;
39 changes: 0 additions & 39 deletions apps/web/src/components/portfolio/project-item.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions apps/web/src/components/portfolio/projects.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions apps/web/src/components/portfolio/v2/filter-list.tsx

This file was deleted.

52 changes: 0 additions & 52 deletions apps/web/src/components/portfolio/v2/filter-select-box.tsx

This file was deleted.

Loading

0 comments on commit 47caabc

Please sign in to comment.