Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions src/features/search/ui/OotdResultGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useNavigate } from 'react-router-dom';
import useIsWideLayout from '@/shared/hooks/useIsWideLayout';
import { resolveImageUrl } from '@/shared/lib/resolveImageUrl';
import { saveRecentOotd } from '../api/searchApi';
import type { SearchOotdResponse } from '../api/types';
Expand All @@ -11,8 +12,6 @@ export interface OotdResultGridProps {
onLoadMore: () => void;
}

const COLUMN_COUNT = 2;

const splitIntoColumns = (items: SearchOotdResponse[], columnCount: number) => {
const columns: SearchOotdResponse[][] = Array.from({ length: columnCount }, () => []);
items.forEach((item, index) => columns[index % columnCount].push(item));
Expand All @@ -24,7 +23,8 @@ const splitIntoColumns = (items: SearchOotdResponse[], columnCount: number) => {
const OotdResultGrid = ({ items, hasNext, loading, onLoadMore }: OotdResultGridProps) => {
const navigate = useNavigate();
const sentinelRef = useInfiniteScrollSentinel(hasNext, onLoadMore);
const columns = splitIntoColumns(items, COLUMN_COUNT);
const isWideLayout = useIsWideLayout();
const columns = splitIntoColumns(items, isWideLayout ? 3 : 2);

const handleClick = (id: number) => {
saveRecentOotd(id);
Expand All @@ -33,7 +33,7 @@ const OotdResultGrid = ({ items, hasNext, loading, onLoadMore }: OotdResultGridP

return (
<>
<div className="grid grid-cols-2 gap-2">
<div className="grid grid-cols-2 gap-2 md:grid-cols-3">
{columns.map((column, columnIndex) => (
<div key={columnIndex} className="flex flex-col gap-2">
{column.map((item) => (
Expand Down
8 changes: 4 additions & 4 deletions src/features/search/ui/SearchOotdResultGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useNavigate } from 'react-router-dom';
import useIsWideLayout from '@/shared/hooks/useIsWideLayout';
import { saveRecentOotd } from '../api/searchApi';
import type { SearchOotdResponse } from '../api/types';
import { useInfiniteScrollSentinel } from '../lib/useInfiniteScrollSentinel';
import SearchOotdCard from './SearchOotdCard';

const COLUMN_COUNT = 2;

const splitIntoColumns = <T,>(items: T[], columnCount: number) => {
const columns: T[][] = Array.from({ length: columnCount }, () => []);
items.forEach((item, index) => columns[index % columnCount].push(item));
Expand Down Expand Up @@ -37,7 +36,8 @@ const SearchOotdResultGrid = ({
}: SearchOotdResultGridProps) => {
const navigate = useNavigate();
const sentinelRef = useInfiniteScrollSentinel(hasNext, onLoadMore);
const columns = splitIntoColumns(items, COLUMN_COUNT);
const isWideLayout = useIsWideLayout();
const columns = splitIntoColumns(items, isWideLayout ? 3 : 2);

const handleClick = (id: number) => {
saveRecentOotd(id);
Expand All @@ -46,7 +46,7 @@ const SearchOotdResultGrid = ({

return (
<>
<div className="grid grid-cols-2 gap-2">
<div className="grid grid-cols-2 gap-2 md:grid-cols-3">
{columns.map((column, columnIndex) => (
<div key={columnIndex} className="flex flex-col gap-2">
{column.map((item) => (
Expand Down
7 changes: 4 additions & 3 deletions src/pages/ootd/components/ViewHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ChevronLeft, Menu } from 'lucide-react';
import { Menu } from 'lucide-react';
import { leftArrow } from '@/shared/assets';

export interface ViewHeaderProps {
onBack: () => void;
onMoreClick: () => void;
}

const ViewHeader = ({ onBack, onMoreClick }: ViewHeaderProps) => (
<div className="bg-bg-white sticky top-0 z-30 flex items-center justify-between px-4 py-3">
<div className="bg-bg-white sticky top-0 z-30 flex items-center justify-between py-3">
<button type="button" onClick={onBack} aria-label="뒤로가기">
<ChevronLeft size={24} className="text-text-primary" />
<img src={leftArrow} alt="" className="size-5" />
</button>
<button type="button" onClick={onMoreClick} aria-label="더보기">
<Menu size={22} className="text-text-primary" />
Expand Down
Loading