Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.1.0 Develop - 마이포즈 데이터 갯수, 포즈피드 스켈레톤 사이즈 #87

Merged
merged 8 commits into from
Aug 28, 2024
8 changes: 8 additions & 0 deletions public/icons/bookmark_black_empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions public/icons/bookmark_black_fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/apis/apis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
FilterTagsResponse,
MyposeCountResponse,
PoseDetailResponse,
PoseFeedContents,
PoseFeedResponse,
Expand Down Expand Up @@ -62,3 +63,5 @@ export const getBookmarkFeed = (pageNumber: number) =>
privateApi.get<PoseFeedContents>('/bookmark/feed', {
params: { pageNumber, pageSize: 10 },
});

export const getMyposeCount = () => privateApi.get<MyposeCountResponse>(`/pose/user/mypose`);
5 changes: 5 additions & 0 deletions src/apis/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import {

import {
FilterTagsResponse,
MyposeCountResponse,
PoseFeedContents,
PoseFeedResponse,
PosePickResponse,
PoseTalkResponse,
getBookmarkFeed,
getFilterTag,
getMyposeCount,
getPoseDetail,
getPoseFeed,
getPosePick,
Expand Down Expand Up @@ -68,3 +70,6 @@ export const useBookmarkFeedQuery = (options?: UseInfiniteQueryOptions<PoseFeedC

export const useFilterTagQuery = (options?: UseQueryOptions<FilterTagsResponse>) =>
useSuspenseQuery<FilterTagsResponse>(['filterTag'], getFilterTag, { ...options });

export const useMyposeCountQuery = (options?: UseQueryOptions<MyposeCountResponse>) =>
useQuery<MyposeCountResponse>(['myposeCount'], getMyposeCount, { ...options });
8 changes: 8 additions & 0 deletions src/apis/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface PoseInfo {
tagAttributes: string;
updatedAt: string;
bookmarkCheck: boolean;
width: number;
height: number;
}

// 포즈피드
Expand Down Expand Up @@ -92,3 +94,9 @@ export interface RegisterResponse {
expiresIn: number;
};
}

// 마이포즈
export interface MyposeCountResponse {
bookmarkCount: number;
uploadCount: number;
}
12 changes: 10 additions & 2 deletions src/app/(Main)/MainFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import AppDownloadBanner from '../../components/Header/AppDownloadBanner';
import { StrictPropsWithChildren } from '@/types';
import { isIOS } from '@/utils';

export function MainFooter({ children }: StrictPropsWithChildren) {
interface MainFooterI extends StrictPropsWithChildren {
grow?: boolean;
}

export function MainFooter({ children, grow = true }: MainFooterI) {
return (
<>
<div className="fixed inset-x-0 bottom-0 z-30">
<div className="mx-auto max-w-layout bg-white px-20 pb-24 pt-10">
<div className="flex gap-8 [&>*]:flex-1 [&>*]:grow">{children}</div>
{grow ? (
<div className="flex gap-8 [&>*]:grow">{children}</div>
) : (
<div className="flex gap-8">{children}</div>
)}
</div>
{isIOS() && <AppDownloadBanner />}
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/app/(Main)/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import { usePathname } from 'next/navigation';

import Tab from './Tab';
import FilterTab from '@/app/(Main)/feed/FilterTab';
import MyposeTab from '@/app/(Main)/mypose/MyposeTab';
import Header from '@/components/Header';
import FilterTab from '@/components/Header/FilterTab';
import MyposeTab from '@/components/Header/MyposeTab';
import Tab from '@/components/Header/Tab';
import { Spacing } from '@/components/Spacing';

export default function MainHeader() {
Expand Down
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions src/app/(Main)/mypose/MyposeTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useState } from 'react';

import { useMyposeCountQuery } from '@/apis';
import { COOKIE_ACCESS_TOKEN } from '@/constants';
import { getClientCookie } from '@/utils';

const Data = {
upload: { title: '등록', path: '/mypose' },
bookmark: { title: '저장', path: '/mypose/bookmark' },
};

interface TabItemI {
title: string;
path: string;
current: boolean;
}
const TabItem = ({ title, path, current }: TabItemI) =>
current ? (
<Link href={path} className="flex flex-1 items-center justify-center rounded-8 bg-white">
<div id="subtitle-1" className="text-main-violet">
{title}
</div>
</Link>
) : (
<Link href={path} className="flex flex-1 items-center justify-center rounded-8">
<div id="subtitle-1" className="text-tertiary">
{title}
</div>
</Link>
);

export default function MyposeTab() {
const path = usePathname();
const accesstoken = getClientCookie(COOKIE_ACCESS_TOKEN);

const [countData, setCountData] = useState({ uploadCount: 0, bookmarkCount: 0 });

const query = useMyposeCountQuery({
enabled: accesstoken !== '',
onSuccess: (data) => {
setCountData(data);
},
});

return (
<div className="h-72 px-20 py-12">
<div className="flex h-full gap-4 rounded-8 bg-divider p-4 ">
<TabItem
key="upload"
title={`${Data.upload.title} ${countData.uploadCount}`}
path={Data.upload.path}
current={path === Data.upload.path}
/>
<TabItem
key="bookmark"
title={`${Data.bookmark.title} ${countData.bookmarkCount}`}
path={Data.bookmark.path}
current={path === Data.bookmark.path}
/>
</div>
</div>
);
}
5 changes: 4 additions & 1 deletion src/app/(Main)/mypose/bookmark/BookmarkSecion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import BookmarkEmpty from './BookmarkEmpty';
import { useBookmarkFeedQuery } from '@/apis';
import FeedSection from '@/components/Feed/FeedSection';
import { COOKIE_ACCESS_TOKEN } from '@/constants';
import { getClientCookie } from '@/utils';

export default function BookmarkSecion() {
const query = useBookmarkFeedQuery();
const accesstoken = getClientCookie(COOKIE_ACCESS_TOKEN);
const query = useBookmarkFeedQuery({ enabled: accesstoken !== '' });

return (
<FeedSection query={query}>
Expand Down
4 changes: 2 additions & 2 deletions src/app/(Sub)/detail/[id]/DetailSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export default function DetailSection({ poseId }: DetailSectionProps) {
<TagButton type="frame" value={frameCount} name={`${frameCount}컷`} />
{tagAttributes?.split(',').map((tag, index) => <TagButton key={index} name={tag} />)}
</div>
<MainFooter>
<MainFooter grow={false}>
<PrimaryButton
text="링크 공유"
onClick={handleShareLink}
variant="secondary"
className="border border-border-default"
/>
<PrimaryButton text="카카오 공유" onClick={() => shareKakao(poseId)} />
<PrimaryButton className="grow" text="카카오 공유" onClick={() => shareKakao(poseId)} />
</MainFooter>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/(Sub)/detail/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { Metadata } from 'next';

import DetailSection from './DetailSection';
import { getPoseDetail } from '@/apis';
import { IconButton } from '@/components/Button';
import { RejectedFallback } from '@/components/ErrorBoundary';
import Header from '@/components/Header';
import { Loading } from '@/components/Loading';
import { PageAnimation } from '@/components/PageAnimation';
import { HydrationProvider } from '@/components/Provider';
import { ICON, OPEN_GRAPH } from '@/constants';
import { OPEN_GRAPH } from '@/constants';

export async function generateMetadata({ params }: { params: { id: string } }): Promise<Metadata> {
const id = parseInt(params.id);
Expand All @@ -33,6 +32,7 @@ export default function DetailPage({ params }: { params: { id: number } }) {

return (
<div>
{/* <Header close={true} menu={true} additional={<BookmarkButton style='black'/>} /> */}
<Header close={true} menu={true} />
<QueryAsyncBoundary
rejectedFallback={RejectedFallback}
Expand Down
8 changes: 7 additions & 1 deletion src/components/Button/PrimaryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ const styleMap: Record<StyleType, string> = {
warning: 'bg-warning text-white',
};

export default function PrimaryButton({ icon, text, onClick, variant = 'fill', className }: ButtonProps) {
export default function PrimaryButton({
icon,
text,
onClick,
variant = 'fill',
className,
}: ButtonProps) {
return (
<button
onClick={onClick}
Expand Down
13 changes: 11 additions & 2 deletions src/components/Feed/BookmarkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useState } from 'react';

import { Icon } from '../Button/Icon';
import { Icon, IconButton } from '../Button/Icon';
import { deleteBookmark, postBookmark } from '@/apis';
import LoginModal from '@/components/Login/LoginModal';
import { useOverlay } from '@/components/Overlay/useOverlay';
Expand All @@ -13,8 +13,9 @@ import { getClientCookie } from '@/utils';
interface BookmarkButtonI {
poseId: number;
isMarked: boolean;
style?: 'circle' | 'black';
}
export default function BookmarkButton({ poseId, isMarked }: BookmarkButtonI) {
export default function BookmarkButton({ poseId, isMarked, style = 'circle' }: BookmarkButtonI) {
const { open } = useOverlay();
const token = getClientCookie(COOKIE_ACCESS_TOKEN);
const [marked, setMarked] = useState(isMarked);
Expand All @@ -35,6 +36,14 @@ export default function BookmarkButton({ poseId, isMarked }: BookmarkButtonI) {
}
}

if (style === 'black') {
return (
<IconButton
icon={marked ? ICON.bookmark.black.fill : ICON.bookmark.black.empty}
onClick={onClick}
/>
);
}
return (
<button
className="absolute bottom-6 right-6 h-36 w-36 rounded-24 bg-[#141218] bg-opacity-30 p-6"
Expand Down
24 changes: 14 additions & 10 deletions src/components/Feed/Photo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ import Link from 'next/link';
import { useState } from 'react';

import BookmarkButton from './BookmarkButton';
import { PoseInfo } from '@/apis';

interface Photo {
imageKey?: string;
source?: string;
id: number;
isMarked: boolean;
interface PhotoI {
data: PoseInfo;
}

export default function Photo({ imageKey, source, id, isMarked }: Photo) {
export default function Photo({ data }: PhotoI) {
const { imageKey, source, bookmarkCheck, poseId, width, height } = data;
const [loaded, setLoaded] = useState(false);
console.log(width / height);

return (
<div className="relative mb-16 inline-block w-full rounded-8">
{imageKey && (
<>
<Link href={`/detail/${id}`}>
<Link href={`/detail/${poseId}`}>
<Image
src={imageKey}
alt={source || ''}
Expand All @@ -36,8 +35,13 @@ export default function Photo({ imageKey, source, id, isMarked }: Photo) {
/>
</Link>

{loaded && <BookmarkButton isMarked={isMarked} poseId={id} />}
{loaded || <div className="h-200 w-full rounded-8 bg-sub-white" />}
{loaded && <BookmarkButton isMarked={bookmarkCheck} poseId={poseId} />}
{loaded || (
<div
style={{ aspectRatio: `${width}/${height}` }}
className="w-full rounded-8 bg-sub-white"
/>
)}
</>
)}
</div>
Expand Down
8 changes: 1 addition & 7 deletions src/components/Feed/PhotoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ export default function PhotoList({ data }: PhotoList) {
return (
<>
{data.content.map((item) => (
<Photo
key={item.poseInfo.poseId}
imageKey={item.poseInfo.imageKey}
source={item.poseInfo.source}
id={item.poseInfo.poseId}
isMarked={item.poseInfo.bookmarkCheck}
/>
<Photo key={item.poseInfo.poseId} data={item.poseInfo} />
))}
</>
);
Expand Down
47 changes: 0 additions & 47 deletions src/components/Header/MyposeTab.tsx

This file was deleted.

Loading