feat: 피드를 시간대별 카드로 다시 짜고 하늘 배경·내 캐릭터 추가, 다른 시안 정리

- 피드: 그날 카드 12장을 03:00에 한 번에 만들고, 시간대(아침·낮·저녁·밤, 저녁은 일몰 2시간 전부터)마다 순서를 바꾸고 조건이 맞는 카드만 켠다. 새 카드 우산·특보, 내일 미리보기, 한 문장·시(예시 seed). 흐린 날 노을은 한 줄 카드.
- 캐시를 feed:{구}:{시간대}로 나누고 시간대 경계·일몰·예보 갱신 때 만료해 새 카드가 늦게 보이던 문제를 고친다.
- 히어로는 오늘 1위 각만 보여 준다.
- 각 점수·노을 점수를 7일 지나면 지운다.
- 화면 전체 하늘 배경(시간대별 색, 느린 일렁임, 밤 별)과 화면 끝까지 이어지는 위·아래 바.
- 상단바 로그인 버튼, 내 정보 창(캐릭터 6종·배경색 6종·오늘 기분 8종·닉네임·로그아웃), PATCH /v1/auth/me, 댓글·상단바에 캐릭터·배경색·기분 표시. users.character·color·mood 칸 추가.
- 카드 슬라이드와 가로 줄을 Embla 카로셀로 바꿔 PC에서도 마우스로 끌어 넘기고 화살표로 넘긴다.
- 좋아요·저장을 받아 둔 피드 데이터에도 반영해 다른 탭에 다녀와도 유지되게 고치고, 좋아요 때 하트가 터지는 애니메이션을 넣는다.
- 보내기에서 게시물을 인스타 스토리 크기(1080×1920) 이미지로 공유하거나 내려받는다 (modern-screenshot).
- 창이 열려 있는 동안 뒤 페이지 스크롤을 잠근다.
- 시안 B 확정: 시안 A 아이콘(public/a)과 쓰지 않는 전역 스타일·글꼴 삭제.
- 문서: 데이터 흐름 지도(backend/docs/data-flow-map.html), 확정 시안(docs/시안B_확정.html), 피드 기획 v2, 호출량·DB 크기 추정, data-pipeline 갱신. 보고 폴더와 예전 시안 html 삭제.
This commit is contained in:
minaChoi committed 2026-10-02 15:47:20 +09:00
1 parent f8b47f064a
commit a9ddbaab3c
93 files changed
+2322 -2751

No files matched your search

@@ -3,8 +3,8 @@
import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, type UseMutationOptions } from '@tanstack/react-query';
import { client } from '../client.gen';
import { addComment, deleteComment, getArticle, getFeed, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getWeatherNow, getWeatherToday, getWeek, healthzHealthzGet, likeComment, likePost, listArticles, listComments, listEvents, listIndices, listPlaces, listRegions, listSaved, login, me, nearestRegion, type Options, refresh, savePost, signup, unlikeComment, unlikePost, unsavePost } from '../sdk.gen';
import type { AddCommentData, AddCommentError, AddCommentResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, LoginData, LoginError, LoginResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, SavePostData, SavePostError, SavePostResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnsavePostData, UnsavePostError, UnsavePostResponse } from '../types.gen';
import { addComment, deleteComment, getArticle, getFeed, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getWeatherNow, getWeatherToday, getWeek, healthzHealthzGet, likeComment, likePost, listArticles, listComments, listEvents, listIndices, listPlaces, listRegions, listSaved, login, me, nearestRegion, type Options, refresh, savePost, signup, unlikeComment, unlikePost, unsavePost, updateMe } from '../sdk.gen';
import type { AddCommentData, AddCommentError, AddCommentResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, LoginData, LoginError, LoginResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, SavePostData, SavePostError, SavePostResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnsavePostData, UnsavePostError, UnsavePostResponse, UpdateMeData, UpdateMeError, UpdateMeResponse } from '../types.gen';
export type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
@@ -396,6 +396,23 @@ export const meOptions = (options?: Options<MeData>) => queryOptions<MeResponse,
queryKey: meQueryKey(options)
});
/**
* 내 정보 바꾸기 (닉네임 2~12자, 캐릭터 rabbit·bear·dog·sun·moon·cloud, 배경색 orange·blue·green·purple·pink·brown, 기분 clear·partly·cloudy·rain·thunder·snow·fog·rainbow, 빈 문자열이면 지움)
*/
export const updateMeMutation = (options?: Partial<Options<UpdateMeData>>): UseMutationOptions<UpdateMeResponse, UpdateMeError, Options<UpdateMeData>> => {
const mutationOptions: UseMutationOptions<UpdateMeResponse, UpdateMeError, Options<UpdateMeData>> = {
mutationFn: async (fnOptions) => {
const { data } = await updateMe({
...options,
...fnOptions,
throwOnError: true
});
return data;
}
};
return mutationOptions;
};
/**
* 좋아요 취소
*/
+2 -2
View File
@@ -1,4 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts
export { addComment, deleteComment, getArticle, getFeed, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getWeatherNow, getWeatherToday, getWeek, healthzHealthzGet, likeComment, likePost, listArticles, listComments, listEvents, listIndices, listPlaces, listRegions, listSaved, login, me, nearestRegion, type Options, refresh, savePost, signup, unlikeComment, unlikePost, unsavePost } from './sdk.gen';
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekResponse, type GetWeekResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsResponses, type ListSavedData, type ListSavedError, type ListSavedErrors, type ListSavedResponse, type ListSavedResponses, type LoginData, type LoginError, type LoginErrors, type LoginResponse, type LoginResponses, type Me, type MeData, type MeError, type MeErrors, type MeResponse, type MeResponses, type NearestRegionData, type NearestRegionError, type NearestRegionErrors, type NearestRegionResponse, type NearestRegionResponses, type PlaceData, type PostData, PostType, type Rain2h, type RainHourData, RainType, type RankData, type RefreshData, type RefreshError, type RefreshErrors, type RefreshResponse, type RefreshResponses, type RegionData, type ReqComment, type ReqLogin, type ReqRefresh, type ReqSignup, type ResArticle, type ResArticleList, type ResAuth, type ResComment, type ResCommentLike, type ResCommentList, type ResEventList, type ResFeed, type ResHealth, type ResIndexDetail, type ResIndexList, type ResMe, type ResPlaceList, type ResPost, type ResPostLike, type ResPostSave, type ResRegion, type ResRegionList, type ResSavedList, type ResSeasonWeek, type ResSky, type ResSkyRanking, type ResWeatherNow, type ResWeatherToday, type ResWebPacketProtocol, type ResWeek, type Row, type RowsSlide, type SavedPost, type SavePostData, type SavePostError, type SavePostErrors, type SavePostResponse, type SavePostResponses, type SignupData, type SignupError, type SignupErrors, type SignupResponse, type SignupResponses, Sky, SkyGrade, type SkyScoreData, SkyType, SlotTone, type SpotData, type SunsetSlide, type TermData, type Tomorrow, type TopIndex, type TrendPoint, type UnlikeCommentData, type UnlikeCommentError, type UnlikeCommentErrors, type UnlikeCommentResponse, type UnlikeCommentResponses, type UnlikePostData, type UnlikePostError, type UnlikePostErrors, type UnlikePostResponse, type UnlikePostResponses, type UnsavePostData, type UnsavePostError, type UnsavePostErrors, type UnsavePostResponse, type UnsavePostResponses, type ValidationError, type WarningData, WarningLevel, WarningType, type WeatherSlot, type WeekDay, type WeekSlide } from './types.gen';
export { addComment, deleteComment, getArticle, getFeed, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getWeatherNow, getWeatherToday, getWeek, healthzHealthzGet, likeComment, likePost, listArticles, listComments, listEvents, listIndices, listPlaces, listRegions, listSaved, login, me, nearestRegion, type Options, refresh, savePost, signup, unlikeComment, unlikePost, unsavePost, updateMe } from './sdk.gen';
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekResponse, type GetWeekResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsResponses, type ListSavedData, type ListSavedError, type ListSavedErrors, type ListSavedResponse, type ListSavedResponses, type LoginData, type LoginError, type LoginErrors, type LoginResponse, type LoginResponses, type Me, type MeData, type MeError, type MeErrors, type MeResponse, type MeResponses, type NearestRegionData, type NearestRegionError, type NearestRegionErrors, type NearestRegionResponse, type NearestRegionResponses, type PlaceData, type PostData, PostType, type Rain2h, type RainHourData, RainType, type RankData, type RefreshData, type RefreshError, type RefreshErrors, type RefreshResponse, type RefreshResponses, type RegionData, type ReqComment, type ReqLogin, type ReqRefresh, type ReqSignup, type ReqUpdateMe, type ResArticle, type ResArticleList, type ResAuth, type ResComment, type ResCommentLike, type ResCommentList, type ResEventList, type ResFeed, type ResHealth, type ResIndexDetail, type ResIndexList, type ResMe, type ResPlaceList, type ResPost, type ResPostLike, type ResPostSave, type ResRegion, type ResRegionList, type ResSavedList, type ResSeasonWeek, type ResSky, type ResSkyRanking, type ResWeatherNow, type ResWeatherToday, type ResWebPacketProtocol, type ResWeek, type Row, type RowsSlide, type SavedPost, type SavePostData, type SavePostError, type SavePostErrors, type SavePostResponse, type SavePostResponses, type SignupData, type SignupError, type SignupErrors, type SignupResponse, type SignupResponses, Sky, SkyGrade, type SkyScoreData, SkyType, SlotTone, type SpotData, type SunsetSlide, type TermData, type Tomorrow, type TopIndex, type TrendPoint, type UnlikeCommentData, type UnlikeCommentError, type UnlikeCommentErrors, type UnlikeCommentResponse, type UnlikeCommentResponses, type UnlikePostData, type UnlikePostError, type UnlikePostErrors, type UnlikePostResponse, type UnlikePostResponses, type UnsavePostData, type UnsavePostError, type UnsavePostErrors, type UnsavePostResponse, type UnsavePostResponses, type UpdateMeData, type UpdateMeError, type UpdateMeErrors, type UpdateMeResponse, type UpdateMeResponses, type ValidationError, type WarningData, WarningLevel, WarningType, type WeatherSlot, type WeekDay, type WeekSlide } from './types.gen';
+13 -1
View File
@@ -2,7 +2,7 @@
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
import { client } from './client.gen';
import type { AddCommentData, AddCommentErrors, AddCommentResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, LoginData, LoginErrors, LoginResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, SavePostData, SavePostErrors, SavePostResponses, SignupData, SignupErrors, SignupResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses } from './types.gen';
import type { AddCommentData, AddCommentErrors, AddCommentResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, LoginData, LoginErrors, LoginResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, SavePostData, SavePostErrors, SavePostResponses, SignupData, SignupErrors, SignupResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses } from './types.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
/**
@@ -139,6 +139,18 @@ export const refresh = <ThrowOnError extends boolean = true>(options: Options<Re
*/
export const me = <ThrowOnError extends boolean = true>(options?: Options<MeData, ThrowOnError>): RequestResult<MeResponses, MeErrors, ThrowOnError> => (options?.client ?? client).get<MeResponses, MeErrors, ThrowOnError>({ url: '/v1/auth/me', ...options });
/**
* 내 정보 바꾸기 (닉네임 2~12자, 캐릭터 rabbit·bear·dog·sun·moon·cloud, 배경색 orange·blue·green·purple·pink·brown, 기분 clear·partly·cloudy·rain·thunder·snow·fog·rainbow, 빈 문자열이면 지움)
*/
export const updateMe = <ThrowOnError extends boolean = true>(options: Options<UpdateMeData, ThrowOnError>): RequestResult<UpdateMeResponses, UpdateMeErrors, ThrowOnError> => (options.client ?? client).patch<UpdateMeResponses, UpdateMeErrors, ThrowOnError>({
url: '/v1/auth/me',
...options,
headers: {
'Content-Type': 'application/json',
...options.headers
}
});
/**
* 좋아요 취소
*/
+104 -6
View File
@@ -73,7 +73,11 @@ export const ArticleCategory = {
/**
* GAK
*/
GAK: 3
GAK: 3,
/**
* QUOTE
*/
QUOTE: 4
} as const;
/**
@@ -216,6 +220,18 @@ export type CommentData = {
* Nickname
*/
nickname: string;
/**
* Character
*/
character: string;
/**
* Color
*/
color: string;
/**
* Mood
*/
mood?: string | null;
/**
* Body
*/
@@ -533,10 +549,7 @@ export type Hero = {
* Weather Score
*/
weather_score?: number | null;
/**
* Top3
*/
top3?: Array<TopIndex>;
top1?: TopIndex | null;
/**
* Bubble
*/
@@ -670,6 +683,18 @@ export type Me = {
* Nickname
*/
nickname: string;
/**
* Character
*/
character: string;
/**
* Color
*/
color: string;
/**
* Mood
*/
mood?: string | null;
provider: AuthProvider;
};
@@ -752,6 +777,10 @@ export type PostData = {
* Published At
*/
published_at: string;
/**
* Size
*/
size?: 'full' | 'line';
/**
* Liked
*/
@@ -793,7 +822,19 @@ export const PostType = {
/**
* WEEK
*/
WEEK: 7
WEEK: 7,
/**
* ALERT
*/
ALERT: 8,
/**
* TOMORROW
*/
TOMORROW: 9,
/**
* QUOTE
*/
QUOTE: 10
} as const;
/**
@@ -970,6 +1011,28 @@ export type ReqSignup = {
nickname: string;
};
/**
* Req_UpdateMe
*/
export type ReqUpdateMe = {
/**
* Nickname
*/
nickname?: string | null;
/**
* Character
*/
character?: string | null;
/**
* Color
*/
color?: string | null;
/**
* Mood
*/
mood?: string | null;
};
/**
* Res_Article
*/
@@ -1103,6 +1166,10 @@ export type ResFeed = {
* Region Name
*/
region_name?: string | null;
/**
* Slot
*/
slot?: 'morning' | 'day' | 'evening' | 'night' | null;
hero?: Hero | null;
/**
* Stories
@@ -2644,6 +2711,37 @@ export type MeResponses = {
export type MeResponse = MeResponses[keyof MeResponses];
export type UpdateMeData = {
body: ReqUpdateMe;
headers?: {
/**
* Authorization
*/
authorization?: string | null;
};
path?: never;
query?: never;
url: '/v1/auth/me';
};
export type UpdateMeErrors = {
/**
* Validation Error
*/
422: HttpValidationError;
};
export type UpdateMeError = UpdateMeErrors[keyof UpdateMeErrors];
export type UpdateMeResponses = {
/**
* Successful Response
*/
200: ResMe;
};
export type UpdateMeResponse = UpdateMeResponses[keyof UpdateMeResponses];
export type UnlikePostData = {
body?: never;
headers?: {
+95 -9
View File
@@ -1,13 +1,17 @@
import { useEffect } from 'react'
import { useEffect, useMemo, useState, type ReactNode } from 'react'
import { NavLink, Outlet, useLocation } from 'react-router'
import { cx } from '../lib/utils'
import { kindOfHour, kst, type TimeKind } from './lib'
import './b.css'
import { AuthProvider } from './auth'
import { RegionProvider } from './region'
import { useAuth } from './authContext'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { SheetProvider } from './Sheets'
import { SkyContext, useSky } from './skyContext'
import { PinIcon, TabIcon } from './svg'
import { Avatar } from './ui'
const TABS = [
{ to: '/', key: 'today', label: '오늘', title: null },
@@ -21,24 +25,85 @@ function TopBar() {
const { pathname } = useLocation()
const { region } = useRegion()
const { open } = useSheet()
const { me } = useAuth()
const tab = TABS.find((t) => t.to !== '/' && pathname.startsWith(t.to))
return (
<header className="sticky top-0 z-20 flex h-[54px] items-center justify-between gap-2.5 bg-[rgb(247_251_255/0.9)] px-4 backdrop-blur-md">
<header className="sticky top-0 z-20 flex h-[54px] items-center justify-between gap-2.5 px-4">
{tab?.title ? <h1 className="font-jua text-[22px] font-normal">{tab.title}</h1> : <h1 className="font-jua text-[25px] font-normal text-(--orange)">날씨각</h1>}
<button
type="button"
onClick={() => open({ type: 'region' })}
aria-label={`위치 바꾸기, 지금 ${region.name}`}
className="flex cursor-pointer items-center gap-1 rounded-full bg-white px-3 py-1.5 text-[13.5px] font-bold shadow-[inset_0_-4px_0_var(--shade),0_6px_12px_rgb(40_48_74/0.07)]"
className="ml-auto flex cursor-pointer items-center gap-1 rounded-full bg-white px-3 py-1.5 text-[13.5px] font-bold shadow-[inset_0_-4px_0_var(--shade),0_6px_12px_rgb(40_48_74/0.07)]"
>
<PinIcon className="size-3.5" />
{region.name}
</button>
{me ? (
<button type="button" onClick={() => open({ type: 'me' })} aria-label={`내 정보, ${me.nickname}`} className="shrink-0 cursor-pointer rounded-full shadow-[0_6px_12px_rgb(40_48_74/0.12)]">
<Avatar character={me.character} color={me.color} mood={me.mood} size={36} />
</button>
) : (
<button type="button" onClick={() => open({ type: 'login' })} className="shrink-0 cursor-pointer rounded-full bg-(--ink) px-3 py-1.5 text-[13px] font-extrabold text-white">
로그인
</button>
)}
</header>
)
}
const STARS = Array.from({ length: 46 }, (_, i) => ({
left: `${(i * 41 + 7) % 100}%`,
top: `${(i * 67 + 3) % 96}%`,
'--s': `${1 + (i % 3) * 0.8}px`,
'--tw': `${3 + (i % 5)}s`,
'--dl': `-${(i * 0.7) % 6}s`,
}))
/** 화면 전체 하늘: 시간대별 색, 아주 느리게 일렁이는 색 덩어리, 밤에는 별 */
function SkyBg() {
const { kind } = useSky()
const [hidden, setHidden] = useState(false)
useEffect(() => {
const onVis = () => setHidden(document.hidden)
document.addEventListener('visibilitychange', onVis)
return () => document.removeEventListener('visibilitychange', onVis)
}, [])
return (
<div className={cx('b-skybg pointer-events-none fixed inset-0 overflow-hidden', hidden && 'b-paused')} data-t={kind} aria-hidden="true">
{(['morning', 'day', 'sunset', 'night'] as const).map((k) => (
<div key={k} className={cx('b-sky-lay absolute inset-0', `b-sky-${k}`)} />
))}
<span className="b-blob b-blob-1" />
<span className="b-blob b-blob-2" />
<span className="b-blob b-blob-3" />
<div className="b-skystars absolute inset-0">
{STARS.map((s, i) => (
<i key={i} style={s} />
))}
<span className="b-shoot" />
</div>
</div>
)
}
function SkyProvider({ children }: { children: ReactNode }) {
const [preview, setPreview] = useState<TimeKind | null>(null)
const [serverKind, setServerKind] = useState<TimeKind | null>(null)
const [now, setNow] = useState(() => new Date())
useEffect(() => {
const id = setInterval(() => setNow(new Date()), 60000)
return () => clearInterval(id)
}, [])
const t = kst(now)
const kind = preview ?? serverKind ?? kindOfHour(t.h, t.mo, t.mi)
const api = useMemo(() => ({ kind, setPreview, setServerKind }), [kind])
return (
<SkyContext value={api}>{children}</SkyContext>
)
}
function Shell() {
const { pathname } = useLocation()
useEffect(() => {
@@ -46,13 +111,16 @@ function Shell() {
}, [pathname])
return (
<div className="min-h-dvh bg-(--outer) text-(--ink)">
<div className="relative mx-auto min-h-dvh max-w-[440px] overflow-x-clip bg-(--page) pb-[calc(70px+env(safe-area-inset-bottom,0px))]">
<div className="min-h-dvh text-(--ink)">
<SkyBg />
{/* 위·아래 바: 띠는 화면 끝까지, 내용은 가운데 440px 안 */}
<div className="b-topbg fixed inset-x-0 top-0 z-[19] h-[54px] backdrop-blur-md" aria-hidden="true" />
<div className="relative mx-auto min-h-dvh max-w-[440px] overflow-x-clip pb-[calc(70px+env(safe-area-inset-bottom,0px))]">
<TopBar />
<main>
<main className="relative z-[1]">
<Outlet />
</main>
<nav aria-label="주요 메뉴" className="fixed bottom-0 left-1/2 z-30 grid w-full max-w-[440px] -translate-x-1/2 grid-cols-5 border-t border-(--line) bg-white/96 px-1 pt-[7px] pb-[calc(8px+env(safe-area-inset-bottom,0px))] backdrop-blur-[10px]">
<nav aria-label="주요 메뉴" className="b-tabbar fixed inset-x-0 bottom-0 z-30 grid grid-cols-5 border-t px-[max(4px,calc((100%-432px)/2))] pt-[7px] pb-[calc(8px+env(safe-area-inset-bottom,0px))] backdrop-blur-[10px]">
{TABS.map((t) => (
<NavLink key={t.key} to={t.to} end={t.to === '/'} className={({ isActive }) => cx('flex flex-col items-center gap-0.5 text-[11px] font-extrabold', isActive ? 'text-(--ink) [&_svg]:stroke-[2.4]' : 'text-(--ink3) [&_svg]:stroke-[1.9]')}>
<TabIcon name={t.key} className="size-[25px]" />
@@ -65,9 +133,27 @@ function Shell() {
)
}
/** .b-app 에 지금 시간대를 달아 밤에는 바깥 글자를 밝게 바꾼다 */
function SkyRoot({ children }: { children: ReactNode }) {
return (
<SkyProvider>
<SkyApp>{children}</SkyApp>
</SkyProvider>
)
}
function SkyApp({ children }: { children: ReactNode }) {
const { kind } = useSky()
return (
<div className="b-app" data-t={kind}>
{children}
</div>
)
}
export function BLayout() {
return (
<div className="b-app">
<SkyRoot>
<AuthProvider>
<RegionProvider>
<SheetProvider>
@@ -75,6 +161,6 @@ export function BLayout() {
</SheetProvider>
</RegionProvider>
</AuthProvider>
</div>
</SkyRoot>
)
}
+100 -44
View File
@@ -1,16 +1,17 @@
import { useRef, useState, type MouseEvent, type ReactNode } from 'react'
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PostData, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
import { useRef, useState, type CSSProperties, type MouseEvent, type ReactNode } from 'react'
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PostData, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
import { cx } from '../lib/utils'
import { ago, cardBg, clockShort, fall } from './lib'
import { cardBg, clockShort, fall } from './lib'
import type { SlideBg } from './types'
import { deg } from './weatherText'
import { useMutation } from '@tanstack/react-query'
import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query'
import { likePostMutation, savePostMutation, unlikePostMutation, unsavePostMutation } from '../api/client/@tanstack/react-query.gen'
import { useAuth } from './authContext'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { CommentIcon, HeartIcon, MoreIcon, SaveIcon, SendIcon } from './svg'
import { Ic, Rows } from './ui'
import { useCarousel } from './carousel'
import { Arrows, Ic, Rows } from './ui'
const ACCOUNTS: Record<PostType, readonly [string, string]> = {
[PostType.WEATHER]: ['오늘 날씨', 'sun'],
@@ -20,6 +21,9 @@ const ACCOUNTS: Record<PostType, readonly [string, string]> = {
[PostType.EVENT]: ['행사', 'fireworks'],
[PostType.TIP]: ['날씨 상식', 'bulb'],
[PostType.WEEK]: ['주말 추천', 'calendar'],
[PostType.ALERT]: ['생활 알림', 'umbrella'],
[PostType.TOMORROW]: ['내일 미리보기', 'moon'],
[PostType.QUOTE]: ['오늘의 한 문장', 'letter'],
}
type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide
@@ -65,7 +69,7 @@ function Pic({ name, className }: { name: string; className?: string }) {
)
}
const slideBase = 'relative flex h-full w-full shrink-0 snap-start flex-col px-5 py-[22px]'
const slideBase = 'relative flex h-full w-full shrink-0 flex-col px-5 py-[22px]'
function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
const { open } = useSheet()
@@ -161,60 +165,91 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
type PostProps = { post: PostData }
const HEART = 'M12 20.5s-8-4.9-8-11A4.6 4.6 0 0 1 12 6.8a4.6 4.6 0 0 1 8 2.7c0 6.1-8 11-8 11z'
// 좋아요 때 튀어 나가는 작은 하트: [x, y, 회전, 색]
const BURST: [number, number, number, string][] = [
[-86, -60, -24, '#ff3b5c'],
[84, -66, 22, '#ff8e4e'],
[-104, 18, -40, '#ffc86e'],
[102, 24, 36, '#ff3b5c'],
[-48, -104, -8, '#ff8aa0'],
[52, -100, 12, '#ffc86e'],
]
/** 받아 둔 피드 데이터에도 좋아요·저장을 반영한다. 안 하면 다른 탭에 다녀왔을 때 예전 값으로 다시 그려진다 */
function patchFeed(queryClient: QueryClient, postId: number, patch: Partial<PostData>) {
queryClient.setQueriesData<ResFeed>({ predicate: (q) => (q.queryKey[0] as { _id?: string } | undefined)?._id === 'getFeed' }, (feed) =>
feed?.posts ? { ...feed, posts: feed.posts.map((p) => (p.post_id === postId ? { ...p, ...patch } : p)) } : feed,
)
}
/** 한 줄 카드 (흐린 날 노을처럼 큰 그림이 필요 없는 소식) */
function LineCard({ post }: PostProps) {
const [account, avatar] = ACCOUNTS[post.post_type]
return (
<article className="mx-3 mt-3.5 flex items-center gap-3 rounded-[22px] bg-white px-4 py-3 shadow-[inset_0_-4px_0_var(--shade)]" aria-label={post.title}>
<Ic name={post.icon || avatar} className="w-10 shrink-0" />
<p className="m-0 min-w-0 text-sm">
<small className="block text-xs font-bold text-(--ink3)">{account}</small>
<b className="font-jua text-base font-normal">{post.title}</b> <span className="text-(--ink2)">{post.caption}</span>
</p>
</article>
)
}
/** 인스타식 게시물: 옆으로 넘기는 슬라이드, 두 번 눌러 좋아요 */
export function PostCard({ post }: PostProps) {
return post.size === 'line' ? <LineCard post={post} /> : <FullCard post={post} />
}
function FullCard({ post }: PostProps) {
const { open } = useSheet()
const { region } = useRegion()
const { loggedIn } = useAuth()
const [liked, setLiked] = useState(!!post.liked)
const [likeCount, setLikeCount] = useState(post.like_count)
const [saved, setSaved] = useState(!!post.saved)
const liked = !!post.liked
const likeCount = post.like_count
const saved = !!post.saved
const queryClient = useQueryClient()
const like = useMutation(likePostMutation())
const unlike = useMutation(unlikePostMutation())
const save = useMutation(savePostMutation())
const unsave = useMutation(unsavePostMutation())
const [index, setIndex] = useState(0)
const { ref: sliderRef, api: slider, prev: canPrev, next: canNext, index } = useCarousel({ align: 'start' })
const [pop, setPop] = useState(0)
const lastTap = useRef(0)
const cardRef = useRef<HTMLDivElement>(null)
const [account, avatar] = ACCOUNTS[post.post_type]
const n = post.slides.length
const bgs = post.slides.map((sl) => slideBg(post, sl))
const accountName = post.post_type === PostType.EVENT ? `${region.name.split(' ')[0]} ${account}` : account
const share = () => open({ type: 'share', share: { title: post.title, icon: post.icon, bg: bgs[0] ?? 'sky', messages: post.share_messages ?? [] } })
const share = () => open({ type: 'share', share: { title: post.title, icon: post.icon, bg: bgs[0] ?? 'sky', messages: post.share_messages ?? [], card: cardRef.current } })
const comments = () => open({ type: 'comments', postId: post.post_id })
const patch = (values: Partial<PostData>) => patchFeed(queryClient, post.post_id, values)
// 화면을 먼저 바꾸고, 실패하면 되돌린다
const setLike = (next: boolean) => {
const setLike = (on: boolean) => {
if (!loggedIn) return open({ type: 'login' })
if (next === liked) return
setLiked(next)
setLikeCount((n) => n + (next ? 1 : -1))
;(next ? like : unlike).mutate(
if (on === liked) return
if (on) setPop((p) => p + 1)
patch({ liked: on, like_count: likeCount + (on ? 1 : -1) })
;(on ? like : unlike).mutate(
{ path: { post_id: post.post_id } },
{
onSuccess: (res) => {
if (res.liked != null) setLiked(res.liked)
if (res.like_count != null) setLikeCount(res.like_count)
},
onError: () => {
setLiked(!next)
setLikeCount((n) => n + (next ? -1 : 1))
},
onSuccess: (res) => patch({ liked: res.liked ?? on, ...(res.like_count != null ? { like_count: res.like_count } : {}) }),
onError: () => patch({ liked, like_count: likeCount }),
},
)
}
const toggleSave = () => {
if (!loggedIn) return open({ type: 'login' })
const next = !saved
setSaved(next)
;(next ? save : unsave).mutate(
const on = !saved
patch({ saved: on })
;(on ? save : unsave).mutate(
{ path: { post_id: post.post_id } },
{
onSuccess: (res) => {
if (res.saved != null) setSaved(res.saved)
},
onError: () => setSaved(!next),
onSuccess: (res) => patch({ saved: res.saved ?? on }),
onError: () => patch({ saved }),
},
)
}
@@ -223,8 +258,8 @@ export function PostCard({ post }: PostProps) {
if ((e.target as HTMLElement).closest('button')) return
const now = Date.now()
if (now - lastTap.current < 320) {
setLike(true)
if (loggedIn) setPop((p) => p + 1)
if (liked && loggedIn) setPop((p) => p + 1)
else setLike(true)
}
lastTap.current = now
}
@@ -245,27 +280,48 @@ export function PostCard({ post }: PostProps) {
<MoreIcon />
</button>
</div>
<div className="relative aspect-[4/5] overflow-hidden" onClick={onTap}>
<div ref={cardRef} className="relative aspect-[4/5] overflow-hidden" onClick={onTap}>
{n > 1 && (
<span className="absolute top-3 right-3 z-[2] rounded-full bg-[rgb(30_36_56/0.55)] px-[9px] py-[3px] text-xs font-extrabold text-white" aria-hidden="true">
<span data-noshot className="absolute top-3 right-3 z-[2] rounded-full bg-[rgb(30_36_56/0.55)] px-[9px] py-[3px] text-xs font-extrabold text-white" aria-hidden="true">
{index + 1}/{n}
</span>
)}
<div
className="b-noscroll flex h-full snap-x snap-mandatory overflow-x-auto"
onScroll={(e) => setIndex(Math.round(e.currentTarget.scrollLeft / e.currentTarget.clientWidth))}
ref={sliderRef}
className="h-full overflow-hidden"
tabIndex={n > 1 ? 0 : undefined}
aria-label={n > 1 ? `슬라이드 ${n}장, 옆으로 넘겨 보세요` : undefined}
role={n > 1 ? 'region' : undefined}
onKeyDown={(e) => {
if (e.key === 'ArrowLeft') slider?.scrollPrev()
if (e.key === 'ArrowRight') slider?.scrollNext()
}}
>
{post.slides.map((s, i) => (
<SlideView key={i} slide={s} bg={bgs[i]} />
))}
<div className="flex h-full">
{post.slides.map((s, i) => (
<SlideView key={i} slide={s} bg={bgs[i]} />
))}
</div>
</div>
{n > 1 && <Arrows api={slider} prev={canPrev} next={canNext} />}
{pop > 0 && (
<svg key={pop} className="b-heart-pop pointer-events-none absolute top-1/2 left-1/2 z-[4] -mt-12 -ml-12 w-24 opacity-0" viewBox="0 0 24 24" fill="#fff" aria-hidden="true">
<path d="M12 20.5s-8-4.9-8-11A4.6 4.6 0 0 1 12 6.8a4.6 4.6 0 0 1 8 2.7c0 6.1-8 11-8 11z" />
</svg>
<div key={pop} data-noshot className="pointer-events-none absolute inset-0 z-[4] grid place-items-center" aria-hidden="true">
{BURST.map((b, k) => (
<svg key={k} className="b-like-bit absolute w-5" style={{ '--dx': `${b[0]}px`, '--dy': `${b[1]}px`, '--rot': `${b[2]}deg` } as CSSProperties} viewBox="0 0 24 24" fill={b[3]}>
<path d={HEART} />
</svg>
))}
<svg className="b-heart-pop w-28 opacity-0 drop-shadow-[0_10px_18px_rgb(255_59_92/0.45)]" viewBox="0 0 24 24" fill="url(#b-like-grad)">
<defs>
<linearGradient id="b-like-grad" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stopColor="#ff8aa0" />
<stop offset="1" stopColor="#ff3b5c" />
</linearGradient>
</defs>
<path d={HEART} />
</svg>
<span className="b-like-toast absolute top-[62%] rounded-full bg-white px-4 py-2 font-jua text-[17px] text-(--heart) opacity-0 shadow-[0_8px_18px_rgb(40_48_74/0.18)]">좋아요했어요!</span>
</div>
)}
</div>
<div className="relative flex items-center gap-3.5 px-3 pt-2.5 pb-1 [&_svg]:size-[26px] [&_svg]:stroke-[1.9]">
@@ -297,7 +353,7 @@ export function PostCard({ post }: PostProps) {
<button type="button" onClick={comments} className="block cursor-pointer px-3 pt-[3px] text-sm font-semibold text-(--ink3)">
{post.comment_count ? `댓글 ${post.comment_count}개 모두 보기` : '첫 댓글 남기기'}
</button>
<p className="px-3 pt-1 pb-3 text-[11.5px] font-semibold text-(--ink3)">{ago(post.published_at)}</p>
<p className="px-3 pt-1 pb-3 text-[11.5px] font-semibold text-(--ink3)">오늘</p>
</article>
)
}
+202 -21
View File
@@ -13,17 +13,21 @@ import {
listCommentsOptions,
listRegionsOptions,
loginMutation,
meQueryKey,
signupMutation,
unlikeCommentMutation,
updateMeMutation,
} from '../api/client/@tanstack/react-query.gen'
import type { CommentData, Factor, ResAuth, ResIndexDetail } from '../api/client/types.gen'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { ago, ARTICLE_CAT, articleMeta, cardBg, dayLabel, shortDay } from './lib'
import { AVATAR_COLORS, ago, ARTICLE_CAT, articleMeta, cardBg, CHARACTERS, dayLabel, MOODS, shortDay } from './lib'
import { useRegion } from './regionContext'
import { useSky } from './skyContext'
import { storyImage } from './storyImage'
import { SheetContext, useSheet, type SharePayload, type SheetState } from './sheetContext'
import { HeartIcon } from './svg'
import { Ic, StateBox } from './ui'
import { Avatar, Ic, StateBox } from './ui'
export function SheetProvider({ children }: { children: ReactNode }) {
const [state, setState] = useState<SheetState>(null)
@@ -42,7 +46,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
)
}
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', region: '지역 바꾸기' } as const
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기' } as const
/** 아래에서 올라오는 창: 네이티브 <dialog>라 ESC·포커스 가두기·포커스 되돌리기가 기본으로 된다 */
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
@@ -57,6 +61,18 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
if (!state && el.open) el.close()
}, [state])
// 창이 열려 있는 동안 뒤 페이지는 스크롤되지 않게 잠근다
const isOpen = state != null
useEffect(() => {
if (!isOpen) return
const root = document.documentElement
const before = root.style.overflow
root.style.overflow = 'hidden'
return () => {
root.style.overflow = before
}
}, [isOpen])
const title = !state ? '' : state.type === 'gak' ? gakTitle : state.type === 'article' ? articleTitle || TITLES.article : TITLES[state.type]
return (
@@ -84,6 +100,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
{state.type === 'share' && <ShareSheet share={state.share} />}
{state.type === 'comments' && <CommentsSheet postId={state.postId} />}
{state.type === 'login' && <LoginSheet onDone={onClose} />}
{state.type === 'me' && <MeSheet onDone={onClose} />}
{state.type === 'region' && <RegionSheet onDone={onClose} />}
</div>
)}
@@ -92,7 +109,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
}
function Body({ children, className }: { children: ReactNode; className?: string }) {
return <div className={cx('flex-1 overflow-auto px-4 pt-3.5 pb-[18px]', className)}>{children}</div>
return <div className={cx('flex-1 overflow-auto overscroll-contain px-4 pt-3.5 pb-[18px]', className)}>{children}</div>
}
/* ---------- 각 계산 근거 ---------- */
@@ -264,6 +281,52 @@ function ShareSheet({ share }: { share: SharePayload }) {
const url = window.location.origin
const text = `${msg} — ${share.title} · 날씨각`
const { kind } = useSky()
const [image, setImage] = useState<{ blob: Blob; src: string } | null>(null)
const [imageError, setImageError] = useState(false)
// 창이 열리면 카드를 스토리 크기 이미지로 미리 만들어 둔다
useEffect(() => {
if (!share.card) return
let src = ''
let alive = true
storyImage(share.card, { title: share.title, sub: `${region.name} · 날씨각`, sky: kind }).then(
(blob) => {
if (!alive) return
src = URL.createObjectURL(blob)
setImage({ blob, src })
},
(e: unknown) => {
console.error('[share] story image', e)
if (alive) setImageError(true)
},
)
return () => {
alive = false
if (src) URL.revokeObjectURL(src)
}
}, [share.card, share.title, region.name, kind])
// 휴대폰은 공유창에 이미지 파일을 넘기고(인스타 스토리·카톡 등), 안 되면 이미지를 내려받는다
const shareImage = () => {
if (!image) return
const file = new File([image.blob], 'nalssigak.png', { type: 'image/png' })
if (navigator.canShare?.({ files: [file] })) {
navigator.share({ files: [file], title: share.title, text }).then(
() => setToast('보냈어요'),
(e: unknown) => {
if (e instanceof DOMException && e.name === 'AbortError') return
setToast('공유하지 못했어요. 이미지를 내려받아 올려 주세요')
},
)
return
}
const a = document.createElement('a')
a.href = image.src
a.download = 'nalssigak.png'
a.click()
setToast('이미지를 내려받았어요. 인스타 스토리에 올려 보세요')
}
// 휴대폰 기본 공유창. 없거나 실패하면 링크 복사로 대신한다.
const shareNative = () => {
@@ -319,6 +382,18 @@ function ShareSheet({ share }: { share: SharePayload }) {
className="mt-1.5 w-full resize-none rounded-[14px] border border-[#dfe5ee] px-3 py-2.5"
/>
)}
{share.card && (
<div className="mt-3.5 flex items-center gap-3 rounded-[18px] bg-[#f3f6fb] p-2.5">
{image ? <img src={image.src} alt="공유할 이미지 미리보기" className="h-28 rounded-[10px] shadow-[0_4px_10px_rgb(40_48_74/0.15)]" /> : <span className="grid h-28 w-16 place-items-center rounded-[10px] bg-white text-xs font-bold text-(--ink3)">{imageError ? '실패' : '만드는 중'}</span>}
<div className="flex flex-1 flex-col gap-1.5">
<b className="text-sm font-extrabold">이미지로 보내기</b>
<small className="text-xs font-semibold text-(--ink2)">인스타 스토리 크기(9:16)로 만들어요</small>
<button type="button" onClick={shareImage} disabled={!image} className="cursor-pointer rounded-[14px] bg-(--orange) py-2.5 font-jua text-[15px] text-white shadow-[inset_0_-4px_0_var(--orange-deep)] disabled:opacity-50">
이미지 공유하기
</button>
</div>
</div>
)}
<div className="mt-3.5 grid grid-cols-2 gap-2">
<button type="button" onClick={shareNative} className="cursor-pointer rounded-[16px] bg-(--orange-deep) py-3 font-jua text-base text-white">
공유하기
@@ -335,10 +410,9 @@ function ShareSheet({ share }: { share: SharePayload }) {
}
/* ---------- 댓글 ---------- */
const AV_COLORS = ['#ff8e4e', '#4f97e3', '#1f9d62', '#7a5cd6', '#d6457a', '#c2471b']
const EMOJIS = ['☀️', '🌂', '🍻', '🌇', '😍', '👍']
function CommentRow({ c, index, postId }: { c: CommentData; index: number; postId: number }) {
function CommentRow({ c, postId }: { c: CommentData; postId: number }) {
const { region } = useRegion()
const { loggedIn } = useAuth()
const { open } = useSheet()
@@ -382,9 +456,7 @@ function CommentRow({ c, index, postId }: { c: CommentData; index: number; postI
return (
<div className="grid grid-cols-[34px_1fr_24px] items-start gap-2.5 py-2">
<span className="grid size-[34px] place-items-center rounded-full text-[13px] font-extrabold text-white" style={{ background: AV_COLORS[(c.nickname.charCodeAt(0) + index) % AV_COLORS.length] }} aria-hidden="true">
{c.nickname[0]}
</span>
<Avatar character={c.character} color={c.color} mood={c.mood} />
<div>
<p className="m-0 text-sm">
<b className="mr-1.5 font-extrabold">{c.nickname}</b>
@@ -442,7 +514,7 @@ function CommentsSheet({ postId }: { postId: number }) {
<>
<Body>
{comments.length ? (
comments.map((c, k) => <CommentRow key={c.comment_id} c={c} index={k} postId={postId} />)
comments.map((c) => <CommentRow key={c.comment_id} c={c} postId={postId} />)
) : list.isSuccess ? (
<p className="my-6 text-center font-semibold text-(--ink3)">
아직 댓글이 없어요.
@@ -490,7 +562,7 @@ const AUTH_ERRORS: Record<string, string> = {
}
function LoginSheet({ onDone }: { onDone: () => void }) {
const { me, logout } = useAuth()
const { me } = useAuth()
const [mode, setMode] = useState<'login' | 'signup'>('login')
const [loginId, setLoginId] = useState('')
const [password, setPassword] = useState('')
@@ -517,15 +589,7 @@ function LoginSheet({ onDone }: { onDone: () => void }) {
else signup.mutate({ body: { login_id: loginId.trim(), password, nickname: nickname.trim() } }, { onSuccess: done, onError: fail })
}
if (me)
return (
<Body className="flex flex-col gap-2.5 text-center">
<p className="text-sm font-semibold text-(--ink2)">{me.nickname}(으)로 로그인했어요.</p>
<button type="button" onClick={logout} className="cursor-pointer rounded-[14px] bg-[#f3f6fb] p-[13px] text-[15px] font-extrabold text-(--ink)">
로그아웃
</button>
</Body>
)
if (me) return <MeSheet onDone={onDone} />
const field = 'w-full rounded-[14px] border border-[#dfe5ee] bg-[#f7f9fc] px-3.5 py-3'
return (
@@ -545,7 +609,7 @@ function LoginSheet({ onDone }: { onDone: () => void }) {
))}
</div>
<input value={loginId} onChange={(e) => setLoginId(e.target.value)} autoComplete="username" required minLength={4} maxLength={20} placeholder="아이디" aria-label="아이디" className={field} />
<input value={password} onChange={(e) => setPassword(e.target.value)} type="password" autoComplete={mode === 'login' ? 'current-password' : 'new-password'} required minLength={8} placeholder="비밀번호 (8자 이상)" aria-label="비밀번호" className={field} />
<input value={password} onChange={(e) => setPassword(e.target.value)} type="password" autoComplete={mode === 'login' ? 'current-password' : 'new-password'} required minLength={mode === 'signup' ? 8 : undefined} placeholder={mode === 'signup' ? '비밀번호 (8자 이상)' : '비밀번호'} aria-label="비밀번호" className={field} />
{mode === 'signup' && <input value={nickname} onChange={(e) => setNickname(e.target.value)} required minLength={2} maxLength={12} placeholder="닉네임 (2~12자)" aria-label="닉네임" className={field} />}
<p className="min-h-5 text-center text-[13px] font-bold text-(--heart)" aria-live="polite">
{error}
@@ -561,6 +625,123 @@ function LoginSheet({ onDone }: { onDone: () => void }) {
)
}
/* ---------- 내 정보: 캐릭터·닉네임·로그아웃 ---------- */
function MeSheet({ onDone }: { onDone: () => void }) {
const { me, logout } = useAuth()
const queryClient = useQueryClient()
const update = useMutation(updateMeMutation())
const [nickname, setNickname] = useState(me?.nickname ?? '')
const [error, setError] = useState('')
if (!me) return null
const save = (body: { nickname?: string; character?: string; color?: string; mood?: string }) => {
setError('')
update.mutate(
{ body },
{
onSuccess: (res) => {
if (!res.result?.success) return setError(res.result?.desc === 'INVALID_INPUT' ? '닉네임은 2~12자로 써 주세요.' : '잠시 뒤에 다시 해 주세요.')
queryClient.setQueryData(meQueryKey(), res)
// 댓글에 보이는 내 캐릭터·닉네임도 바뀐다
queryClient.invalidateQueries({ predicate: (q) => (q.queryKey[0] as { _id?: string } | undefined)?._id === 'listComments' })
},
onError: () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.'),
},
)
}
return (
<Body className="flex flex-col gap-3">
<div className="flex flex-col items-center gap-1.5">
<Avatar character={me.character} color={me.color} mood={me.mood} size={64} />
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">{me.login_id}(으)로 로그인했어요</p>
</div>
<section aria-label="내 캐릭터">
<h4 className="m-0 mb-2 text-sm font-extrabold">내 캐릭터</h4>
<div className="grid grid-cols-3 gap-2" role="radiogroup" aria-label="캐릭터 고르기">
{CHARACTERS.map(([key, label]) => (
<button
key={key}
type="button"
role="radio"
aria-checked={me.character === key}
disabled={update.isPending}
onClick={() => save({ character: key })}
className={cx('flex cursor-pointer flex-col items-center gap-1 rounded-[18px] border-2 bg-[#f7f9fc] py-2.5 font-jua text-[15px]', me.character === key ? 'border-(--orange) text-(--orange)' : 'border-transparent text-(--ink)')}
>
<Ic name={key} className="w-12" />
{label}
</button>
))}
</div>
</section>
<section aria-label="배경색">
<h4 className="m-0 mb-2 text-sm font-extrabold">배경색</h4>
<div className="flex flex-wrap gap-2.5" role="radiogroup" aria-label="배경색 고르기">
{Object.entries(AVATAR_COLORS).map(([key, hex]) => (
<button
key={key}
type="button"
role="radio"
aria-checked={me.color === key}
aria-label={key}
disabled={update.isPending}
onClick={() => save({ color: key })}
className={cx('size-9 cursor-pointer rounded-full border-[3px]', me.color === key ? 'border-(--ink)' : 'border-white shadow-[0_0_0_1px_var(--line)]')}
style={{ background: hex }}
/>
))}
</div>
</section>
<section aria-label="오늘 기분">
<h4 className="m-0 mb-2 text-sm font-extrabold">오늘 기분</h4>
<div className="grid grid-cols-4 gap-2" role="radiogroup" aria-label="오늘 기분 고르기">
{MOODS.map(([key, emoji, label]) => (
<button
key={key}
type="button"
role="radio"
aria-checked={me.mood === key}
disabled={update.isPending}
onClick={() => save({ mood: me.mood === key ? '' : key })}
className={cx('flex cursor-pointer flex-col items-center gap-0.5 rounded-[14px] border-2 bg-[#f7f9fc] py-2 text-xs font-bold', me.mood === key ? 'border-(--orange) text-(--orange)' : 'border-transparent text-(--ink2)')}
>
<span className="text-[22px] leading-none">{emoji}</span>
{label}
</button>
))}
</div>
<p className="m-0 mt-1.5 text-xs font-semibold text-(--ink3)">한 번 더 누르면 지워져요</p>
</section>
<form
className="flex items-center gap-2"
onSubmit={(e) => {
e.preventDefault()
save({ nickname: nickname.trim() })
}}
>
<input value={nickname} onChange={(e) => setNickname(e.target.value)} required minLength={2} maxLength={12} aria-label="닉네임" placeholder="닉네임 (2~12자)" className="flex-1 rounded-[14px] border border-[#dfe5ee] bg-[#f7f9fc] px-3.5 py-3" />
<button type="submit" disabled={update.isPending || nickname.trim() === me.nickname} className="cursor-pointer rounded-[14px] bg-(--ink) px-4 py-3 text-sm font-extrabold text-white disabled:opacity-40">
바꾸기
</button>
</form>
<p className="m-0 min-h-5 text-center text-[13px] font-bold text-(--heart)" aria-live="polite">
{error}
</p>
<button
type="button"
onClick={() => {
logout()
onDone()
}}
className="cursor-pointer rounded-[14px] bg-[#f3f6fb] p-[13px] text-[15px] font-extrabold text-(--ink)"
>
로그아웃
</button>
</Body>
)
}
/* ---------- 지역 ---------- */
const LOCATE_TEXT = { idle: '', locating: '위치를 찾는 중이에요…', denied: '위치 권한이 꺼져 있어요. 아래 목록에서 골라 주세요.', error: '위치를 찾지 못했어요. 아래 목록에서 골라 주세요.' } as const
+21 -20
View File
@@ -8,6 +8,7 @@ import { cardBg, fall, kindOfHour, kst, MEDALS, sidoOf, WEEKDAYS, type TimeKind
import { PostCard } from './Post'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { useSky } from './skyContext'
import { Ic, Rail, Sec, StateBox } from './ui'
import { deg, skyText, slotAt } from './weatherText'
@@ -17,7 +18,7 @@ const MODES: [Mode, string][] = [
['now', '지금 시간'],
['morning', '아침'],
['day', '낮'],
['sunset', '노을'],
['sunset', '저녁'],
['night', '밤'],
]
@@ -25,16 +26,12 @@ const MODES: [Mode, string][] = [
const PREVIEW: Record<TimeKind, { label: string; clock: string; hour: number }> = {
morning: { label: '아침', clock: '07:40', hour: 7 },
day: { label: '낮', clock: '13:20', hour: 13 },
sunset: { label: '노을', clock: '18:25', hour: 18 },
sunset: { label: '저녁', clock: '18:25', hour: 18 },
night: { label: '밤', clock: '22:10', hour: 22 },
}
const STARS = Array.from({ length: 26 }, (_, i) => ({ left: `${(i * 37) % 100}%`, top: `${(i * 53) % 60}%`, opacity: 0.4 + ((i * 7) % 6) / 10 }))
const ORB_POS = [
{ left: '66%', top: '6px', d: '.5s', f: '4.4s' },
{ left: '0%', top: '34px', d: '.7s', f: '5.1s' },
{ left: '4%', top: '184px', d: '.9s', f: '4.7s' },
]
const ORB_POS = { left: '66%', top: '6px', d: '.5s', f: '4.4s' }
function useNow(ms = 20000) {
const [now, setNow] = useState(() => new Date())
@@ -52,13 +49,18 @@ function Hero({ hero, today }: HeroProps) {
const [mode, setMode] = useState<Mode>('now')
const clock = useNow()
const t = kst(clock)
const kind = mode === 'now' ? (hero?.sky_mode ?? kindOfHour(t.h)) : mode
const kind = mode === 'now' ? (hero?.sky_mode ?? kindOfHour(t.h, t.mo, t.mi)) : mode
const { setServerKind, setPreview } = useSky()
// 화면 전체 하늘 배경도 같은 시간대로 맞춘다
useEffect(() => setServerKind(hero?.sky_mode ?? null), [hero?.sky_mode, setServerKind])
useEffect(() => setPreview(mode === 'now' ? null : mode), [mode, setPreview])
useEffect(() => () => setPreview(null), [setPreview])
const slots = today?.slots ?? []
const slot = slots.length ? slotAt(slots, mode === 'now' ? t.h : PREVIEW[mode].hour) : undefined
// 지금은 /v1/feed hero 값을, 미리보기는 그 시각의 예보 칸을 쓴다
const temp = mode === 'now' && hero ? hero.temp_c : slot?.temp_c
const feels = mode === 'now' && hero ? hero.feels_c : slot?.feels_c
const top3 = hero?.top3 ?? []
const top1 = hero?.top1
const who = kind === 'night' ? 'bear' : 'rabbit'
return (
@@ -112,24 +114,23 @@ function Hero({ hero, today }: HeroProps) {
</span>
</div>
<span className="b-cloud b-fall top-[188px] left-[54%] h-10 w-[118px]" style={fall('.25s', '6.4s')} aria-hidden="true" />
{top3.map((g, i) => (
{top1 && (
<button
key={g.index_id}
type="button"
onClick={() => open({ type: 'gak', indexId: g.index_id })}
aria-label={`${i + 1}위 ${g.name} ${g.score}점, 계산 근거 보기`}
onClick={() => open({ type: 'gak', indexId: top1.index_id })}
aria-label={`1위 ${top1.name} ${top1.score}점, 계산 근거 보기`}
className="b-fall absolute z-[2] flex w-24 cursor-pointer flex-col items-center"
style={{ left: ORB_POS[i].left, top: ORB_POS[i].top, ...fall(ORB_POS[i].d, ORB_POS[i].f) }}
style={{ left: ORB_POS.left, top: ORB_POS.top, ...fall(ORB_POS.d, ORB_POS.f) }}
>
<span className={cx('relative', i === 0 ? 'w-[78px]' : 'w-[60px]')}>
<Ic name={g.icon} className="w-full drop-shadow-[0_10px_12px_rgb(40_48_74/0.16)]" />
<Ic name={MEDALS[i]} className="absolute -top-2 -left-3.5 w-[30px]" />
<span className="relative w-[78px]">
<Ic name={top1.icon} className="w-full drop-shadow-[0_10px_12px_rgb(40_48_74/0.16)]" />
<Ic name={MEDALS[0]} className="absolute -top-2 -left-3.5 w-[30px]" />
</span>
<span className="b-orb-label font-jua text-sm whitespace-nowrap">
{i + 1}위 {g.name} <em className="font-bagel text-(--orange) not-italic">{g.score}</em>
1위 {top1.name} <em className="font-bagel text-(--orange) not-italic">{top1.score}</em>
</span>
</button>
))}
)}
</div>
{hero?.bubble && (
<div className="relative z-[3] flex items-end gap-2">
@@ -257,7 +258,7 @@ export function TodayPage() {
<div>
{posts.map((p, i) => (
<Fragment key={p.post_id}>
<PostCard key={`${p.post_id}-${p.liked}-${p.saved}-${p.like_count}`} post={p} />
<PostCard post={p} />
{bandAt.find(([at]) => at === i + 1)?.[1]}
</Fragment>
))}
+227 -8
View File
@@ -20,13 +20,6 @@
outline-offset: 2px;
}
.b-noscroll {
scrollbar-width: none;
}
.b-noscroll::-webkit-scrollbar {
display: none;
}
/* 하늘에서 떨어진 뒤 둥둥 */
.b-fall {
animation:
@@ -84,6 +77,46 @@
}
}
.b-like-bit {
opacity: 0;
animation: b-bit 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) 0.08s;
}
@keyframes b-bit {
0% {
opacity: 0;
transform: translate(0, 0) scale(0.4) rotate(0deg);
}
25% {
opacity: 1;
}
100% {
opacity: 0;
transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--rot));
}
}
.b-like-toast {
animation: b-toast 1.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes b-toast {
0% {
opacity: 0;
transform: translateY(14px) scale(0.85);
}
18% {
opacity: 1;
transform: translateY(0) scale(1.06);
}
30%,
78% {
opacity: 1;
transform: translateY(0) scale(1);
}
100% {
opacity: 0;
transform: translateY(-8px);
}
}
.b-sheet {
animation: b-up 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@@ -97,10 +130,12 @@
@media (prefers-reduced-motion: reduce) {
.b-fall,
.b-heart-pop,
.b-like-bit,
.b-sheet {
animation: none !important;
}
.b-heart-pop {
.b-heart-pop,
.b-like-bit {
opacity: 0;
}
}
@@ -263,3 +298,187 @@
.b-sheet-dialog::backdrop {
background: rgb(20 26 45 / 0.45);
}
/* ===== 화면 전체 하늘 배경: 시간대별 색 + 아주 느린 일렁임 + 밤 별 ===== */
.b-skybg {
z-index: 0;
--b1: #a9d8ff;
--b2: #d9f0ff;
--b3: #fff6d6;
--bo: 0.45;
}
.b-sky-lay {
opacity: 0;
transition: opacity 1.4s ease;
}
.b-sky-morning {
background: linear-gradient(180deg, #ffe0c4 0%, #fff0e2 38%, #e4f2ff 100%);
}
.b-sky-day {
background: linear-gradient(180deg, #cde7ff 0%, #e9f5ff 45%, #f7fbff 100%);
}
.b-sky-sunset {
background: linear-gradient(180deg, #ffd0b5 0%, #f9c3cf 42%, #ddd2f6 100%);
}
.b-sky-night {
background: linear-gradient(180deg, #0e1433 0%, #1b2356 50%, #2a2e6e 100%);
}
.b-skybg[data-t='morning'] .b-sky-morning,
.b-skybg[data-t='day'] .b-sky-day,
.b-skybg[data-t='sunset'] .b-sky-sunset,
.b-skybg[data-t='night'] .b-sky-night {
opacity: 1;
}
.b-skybg[data-t='morning'] {
--b1: #ffc39b;
--b2: #bfe5ff;
--b3: #fff0b0;
--bo: 0.6;
}
.b-skybg[data-t='sunset'] {
--b1: #ff9b74;
--b2: #f48db0;
--b3: #a99af0;
--bo: 0.62;
}
.b-skybg[data-t='night'] {
--b1: #3b40a0;
--b2: #20407e;
--b3: #4c3a8e;
--bo: 0.7;
}
.b-blob {
position: absolute;
border-radius: 50%;
filter: blur(46px);
opacity: var(--bo);
transition: background-color 1.4s ease, opacity 1.4s ease;
will-change: transform;
}
.b-blob-1 {
width: 340px;
height: 300px;
left: calc(50% - 310px);
top: 8%;
background: var(--b1);
animation: b-drift1 32s ease-in-out infinite alternate;
}
.b-blob-2 {
width: 300px;
height: 280px;
right: calc(50% - 330px);
top: 42%;
background: var(--b2);
animation: b-drift2 38s ease-in-out infinite alternate;
}
.b-blob-3 {
width: 280px;
height: 260px;
left: calc(50% - 180px);
bottom: -80px;
background: var(--b3);
animation: b-drift3 44s ease-in-out infinite alternate;
}
.b-skybg[data-t='day'] .b-blob {
animation-duration: 56s;
}
@media (min-width: 700px) {
.b-blob {
width: 46vw;
height: 40vw;
}
}
@keyframes b-drift1 {
50% { transform: translate3d(70px, 40px, 0) scale(1.12); }
100% { transform: translate3d(20px, 110px, 0) scale(0.94); }
}
@keyframes b-drift2 {
50% { transform: translate3d(-80px, -50px, 0) scale(1.1); }
100% { transform: translate3d(-30px, 60px, 0) scale(1.05); }
}
@keyframes b-drift3 {
50% { transform: translate3d(60px, -70px, 0) scale(1.15); }
100% { transform: translate3d(-40px, -20px, 0) scale(0.96); }
}
.b-skystars {
opacity: 0;
transition: opacity 1.4s ease;
}
.b-skybg[data-t='night'] .b-skystars {
opacity: 1;
}
.b-skystars i {
position: absolute;
width: var(--s, 2px);
height: var(--s, 2px);
border-radius: 50%;
background: #fff;
box-shadow: 0 0 6px rgb(255 255 255 / 0.8);
animation: b-twinkle var(--tw, 5s) ease-in-out infinite;
animation-delay: var(--dl, 0s);
}
@keyframes b-twinkle {
0%, 100% { opacity: 0.25; }
50% { opacity: 1; }
}
.b-shoot {
position: absolute;
top: 14%;
left: 70%;
width: 90px;
height: 1.5px;
border-radius: 2px;
background: linear-gradient(90deg, rgb(255 255 255 / 0), #fff);
opacity: 0;
animation: b-shoot 14s ease-in 6s infinite;
}
@keyframes b-shoot {
0%, 92% { opacity: 0; transform: rotate(-24deg) translateX(0); }
94% { opacity: 1; }
100% { opacity: 0; transform: rotate(-24deg) translateX(-220px); }
}
.b-paused * {
animation-play-state: paused !important;
}
@media (prefers-reduced-motion: reduce) {
.b-blob,
.b-skystars i {
animation: none !important;
}
.b-shoot {
display: none;
}
}
/* 위·아래 바는 반투명으로 하늘이 비치게 */
.b-topbg {
background: rgb(255 255 255 / 0.18);
transition: background 1.4s ease;
}
.b-tabbar {
background: rgb(255 255 255 / 0.6);
border-color: rgb(255 255 255 / 0.4);
}
.b-app[data-t='night'] .b-topbg {
background: rgb(14 20 51 / 0.35);
}
.b-app[data-t='night'] .b-tabbar {
background: rgb(18 24 60 / 0.62);
border-color: rgb(255 255 255 / 0.08);
}
/* 밤: 하늘 위 글자는 밝게, 카드 안은 원래 색 */
.b-app[data-t='night'] {
--ink: #f1f3ff;
--ink2: #bcc3ea;
--ink3: #a3abdc;
}
.b-app[data-t='night'] :is(article, .bg-white, [class*='bg-white/'], [class*='b-bg-'], .b-stat, .b-sheet) {
--ink: #28304a;
--ink2: #5a6380;
--ink3: #8a92aa;
}
.b-app[data-t='night'] .b-tabbar {
--ink: #fff;
--ink3: #9aa2d4;
}
+20
View File
@@ -0,0 +1,20 @@
import useEmblaCarousel from 'embla-carousel-react'
import { useEffect, useState } from 'react'
export type Carousel = ReturnType<typeof useEmblaCarousel>[1]
/** 마우스로 끌기·터치로 넘기기 (Embla). 넘길 수 있는 쪽 정보도 같이 준다 */
export function useCarousel(options: Parameters<typeof useEmblaCarousel>[0]) {
const [ref, api] = useEmblaCarousel(options)
const [state, setState] = useState({ prev: false, next: false, index: 0 })
useEffect(() => {
if (!api) return
const update = () => setState({ prev: api.canScrollPrev(), next: api.canScrollNext(), index: api.selectedScrollSnap() })
update()
api.on('select', update).on('reInit', update).on('scroll', update)
return () => {
api.off('select', update).off('reInit', update).off('scroll', update)
}
}, [api])
return { ref, api, ...state }
}
+35 -4
View File
@@ -11,6 +11,33 @@ export function iconSrc(name: string) {
export const MEDALS = ['gold', 'silver', 'bronze'] as const
/** 고를 수 있는 프로필 캐릭터 (백엔드 CHARACTERS 와 같아야 한다) */
export const CHARACTERS = [
['rabbit', '토끼'],
['bear', '곰'],
['dog', '강아지'],
['sun', '해님'],
['moon', '달님'],
['cloud', '구름'],
] as const
/** 프로필 배경색 (백엔드 COLORS 와 같아야 한다) */
export const AVATAR_COLORS: Record<string, string> = { orange: '#ff8e4e', blue: '#4f97e3', green: '#1f9d62', purple: '#7a5cd6', pink: '#d6457a', brown: '#a8643a' }
/** 오늘 기분 (백엔드 MOODS 와 같아야 한다) */
export const MOODS = [
['clear', '☀️', '맑음'],
['partly', '⛅', '구름조금'],
['cloudy', '☁️', '흐림'],
['rain', '🌧️', '비'],
['thunder', '⚡', '번개'],
['snow', '❄️', '눈'],
['fog', '🌫️', '안개'],
['rainbow', '🌈', '무지개'],
] as const
export const moodEmoji = (mood?: string | null) => MOODS.find(([k]) => k === mood)?.[1]
export const fall = (d: string, f = '4.8s', amp?: string) => ({ '--d': d, '--f': f, ...(amp ? { '--amp': amp } : {}) }) as CSSProperties
export const WEEKDAYS = ['일', '월', '화', '수', '목', '금', '토'] as const
@@ -58,10 +85,14 @@ export function dayLabel(date: string, index: number) {
export type TimeKind = 'morning' | 'day' | 'sunset' | 'night'
export function kindOfHour(h: number): TimeKind {
if (h >= 5 && h < 9) return 'morning'
if (h >= 9 && h < 16) return 'day'
if (h >= 16 && h < 19) return 'sunset'
// 서울 월별 대략 일몰 시각(시). 서버 값(/v1/feed hero.sky_mode)이 없을 때만 쓴다
const SUNSET_HOUR = [17.7, 18.2, 18.6, 19.1, 19.5, 19.9, 19.9, 19.5, 18.9, 18.2, 17.6, 17.3]
/** 피드와 같은 시간대: 아침 05–11 · 낮 11–일몰 2시간 전 · 저녁(sunset) 일몰 2시간 전–21 · 밤 21–05 */
export function kindOfHour(h: number, month = new Date().getMonth() + 1, minute = 0): TimeKind {
const at = h + minute / 60
if (at >= 5 && at < 11) return 'morning'
if (at >= 11 && at < 21) return at < SUNSET_HOUR[month - 1] - 2 ? 'day' : 'sunset'
return 'night'
}
+2 -1
View File
@@ -1,7 +1,7 @@
import { createContext, use } from 'react'
import type { SlideBg } from './types'
export type SharePayload = { title: string; icon: string; bg: SlideBg; messages: string[] }
export type SharePayload = { title: string; icon: string; bg: SlideBg; messages: string[]; card?: HTMLElement | null }
export type SheetState =
| { type: 'gak'; indexId: number }
@@ -10,6 +10,7 @@ export type SheetState =
| { type: 'comments'; postId: number }
| { type: 'seasonWeek' }
| { type: 'login' }
| { type: 'me' }
| { type: 'region' }
| null
+13
View File
@@ -0,0 +1,13 @@
import { createContext, use } from 'react'
import type { TimeKind } from './lib'
/** 화면 전체 하늘 배경의 시간대. 히어로의 미리보기 버튼이 잠시 바꿀 수 있다 */
export type SkyApi = { kind: TimeKind; setServerKind: (k: TimeKind | null) => void; setPreview: (k: TimeKind | null) => void }
export const SkyContext = createContext<SkyApi | null>(null)
export function useSky() {
const ctx = use(SkyContext)
if (!ctx) throw new Error('useSky must be used inside SkyProvider')
return ctx
}
+67
View File
@@ -0,0 +1,67 @@
import { domToCanvas } from 'modern-screenshot'
const W = 1080
const H = 1920
const CARD_W = 900
// 시간대별 스토리 배경 (화면 하늘 배경과 같은 색)
const SKY: Record<string, [string, string, string]> = {
morning: ['#ffe0c4', '#fff0e2', '#e4f2ff'],
day: ['#cde7ff', '#e9f5ff', '#f7fbff'],
sunset: ['#ffd0b5', '#f9c3cf', '#ddd2f6'],
night: ['#0e1433', '#1b2356', '#2a2e6e'],
}
function roundRect(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) {
ctx.beginPath()
ctx.roundRect(x, y, w, h, r)
}
/** 게시물 카드 한 장을 인스타 스토리 크기(1080×1920) PNG로 만든다 */
export async function storyImage(card: HTMLElement, opts: { title: string; sub: string; sky: string }): Promise<Blob> {
const shot = await domToCanvas(card, { scale: CARD_W / card.offsetWidth, filter: (n) => !(n instanceof HTMLElement && n.dataset.noshot != null) })
const canvas = document.createElement('canvas')
canvas.width = W
canvas.height = H
const ctx = canvas.getContext('2d')
if (!ctx) throw new Error('canvas 2d context unavailable')
const dark = opts.sky === 'night'
const [c1, c2, c3] = SKY[opts.sky] ?? SKY.day
const bg = ctx.createLinearGradient(0, 0, 0, H)
bg.addColorStop(0, c1)
bg.addColorStop(0.45, c2)
bg.addColorStop(1, c3)
ctx.fillStyle = bg
ctx.fillRect(0, 0, W, H)
ctx.textAlign = 'center'
ctx.fillStyle = '#ff7a45'
ctx.font = '84px Jua, sans-serif'
ctx.fillText('날씨각', W / 2, 230)
const cardH = (shot.height / shot.width) * CARD_W
const x = (W - CARD_W) / 2
const y = (H - cardH) / 2 + 20
ctx.save()
ctx.shadowColor = 'rgb(40 48 74 / 0.25)'
ctx.shadowBlur = 60
ctx.shadowOffsetY = 24
roundRect(ctx, x, y, CARD_W, cardH, 48)
ctx.fillStyle = '#fff'
ctx.fill()
ctx.restore()
ctx.save()
roundRect(ctx, x, y, CARD_W, cardH, 48)
ctx.clip()
ctx.drawImage(shot, x, y, CARD_W, cardH)
ctx.restore()
ctx.fillStyle = dark ? '#f1f3ff' : '#28304a'
ctx.font = '60px Jua, sans-serif'
ctx.fillText(opts.title, W / 2, y + cardH + 120, W - 120)
ctx.fillStyle = dark ? '#bcc3ea' : '#5a6380'
ctx.font = 'bold 38px "Pretendard Variable", sans-serif'
ctx.fillText(opts.sub, W / 2, y + cardH + 190, W - 120)
return new Promise((resolve, reject) => canvas.toBlob((b) => (b ? resolve(b) : reject(new Error('toBlob failed'))), 'image/png'))
}
+60 -5
View File
@@ -1,7 +1,8 @@
import type { CSSProperties, ReactNode } from 'react'
import { Link } from 'react-router'
import { cx } from '../lib/utils'
import { iconSrc } from './lib'
import { useCarousel, type Carousel } from './carousel'
import { AVATAR_COLORS, iconSrc, moodEmoji } from './lib'
type IcProps = { name: string; className?: string; alt?: string; style?: CSSProperties }
@@ -9,6 +10,23 @@ export function Ic({ name, className, alt = '', style }: IcProps) {
return <img src={iconSrc(name)} alt={alt} className={cx('block', className)} style={style} decoding="async" />
}
type AvatarProps = { character: string; color?: string | null; mood?: string | null; size?: number; className?: string }
/** 프로필 동그라미: 고른 배경색 위에 캐릭터, 오른쪽 위에 오늘 기분 */
export function Avatar({ character, color, mood, size = 34, className }: AvatarProps) {
const emoji = moodEmoji(mood)
return (
<span className={cx('relative inline-grid shrink-0 place-items-center rounded-full', className)} style={{ width: size, height: size, background: AVATAR_COLORS[color ?? ''] ?? AVATAR_COLORS.orange }}>
<Ic name={character} style={{ width: size * 0.7 }} />
{emoji && (
<span className="absolute -top-1 -right-1 grid place-items-center rounded-full bg-white leading-none shadow-[0_1px_3px_rgb(40_48_74/0.25)]" style={{ width: size * 0.48, height: size * 0.48, fontSize: size * 0.3 }} aria-hidden="true">
{emoji}
</span>
)}
</span>
)
}
type SecProps = { title: string; sub?: ReactNode; more?: { to: string; label?: string }; className?: string }
export function Sec({ title, sub, more, className }: SecProps) {
@@ -27,10 +45,35 @@ export function Sec({ title, sub, more, className }: SecProps) {
)
}
export function Rail({ children, className, label }: { children: ReactNode; className?: string; label?: string }) {
/** PC(마우스)에서만 보이는 좌우 화살표 */
export function Arrows({ api, prev, next, className }: { api: Carousel; prev: boolean; next: boolean; className?: string }) {
const btn = 'absolute top-1/2 z-[3] hidden size-8 -translate-y-1/2 cursor-pointer place-items-center rounded-full bg-white/90 text-lg font-extrabold text-[#28304a] shadow-[0_4px_10px_rgb(40_48_74/0.18)] pointer-fine:grid'
return (
<div className={cx('b-noscroll flex snap-x snap-proximity gap-2.5 overflow-x-auto px-4 pt-3 pb-1 *:shrink-0 *:snap-start', className)} role={label ? 'group' : undefined} aria-label={label}>
{children}
<>
{prev && (
<button type="button" data-noshot onClick={() => api?.scrollPrev()} aria-label="이전" className={cx(btn, 'left-1.5', className)}>
‹
</button>
)}
{next && (
<button type="button" data-noshot onClick={() => api?.scrollNext()} aria-label="다음" className={cx(btn, 'right-1.5', className)}>
›
</button>
)}
</>
)
}
const STRIP = { align: 'start', dragFree: true, containScroll: 'trimSnaps' } as const
export function Rail({ children, className, label }: { children: ReactNode; className?: string; label?: string }) {
const { ref, api, prev, next } = useCarousel(STRIP)
return (
<div className="relative" role={label ? 'group' : undefined} aria-label={label}>
<div ref={ref} className="overflow-hidden">
<div className={cx('flex gap-2.5 px-4 pt-3 pb-1 *:shrink-0', className)}>{children}</div>
</div>
<Arrows api={api} prev={prev} next={next} />
</div>
)
}
@@ -39,7 +82,7 @@ type ChipsProps<K extends string> = { items: readonly (readonly [K, string])[];
export function Chips<K extends string>({ items, value, onChange, label }: ChipsProps<K>) {
return (
<div className="b-noscroll flex gap-2 overflow-x-auto px-4 pt-3 pb-0.5" role="group" aria-label={label}>
<ChipStrip label={label}>
{items.map(([k, l]) => (
<button
key={k}
@@ -51,6 +94,18 @@ export function Chips<K extends string>({ items, value, onChange, label }: Chips
{l}
</button>
))}
</ChipStrip>
)
}
function ChipStrip({ children, label }: { children: ReactNode; label: string }) {
const { ref, api, prev, next } = useCarousel(STRIP)
return (
<div className="relative" role="group" aria-label={label}>
<div ref={ref} className="overflow-hidden">
<div className="flex gap-2 px-4 pt-3 pb-0.5">{children}</div>
</div>
<Arrows api={api} prev={prev} next={next} className="mt-[5px] size-7 text-base" />
</div>
)
}
-137
View File
@@ -5,46 +5,10 @@
--font-jua: 'Jua', 'Pretendard Variable', sans-serif;
--font-bagel: 'Bagel Fat One', 'Jua', sans-serif;
--font-batang: 'Gowun Batang', 'Nanum Myeongjo', serif;
--font-poster: 'Gasoek One', 'Black Han Sans', sans-serif;
--font-block: 'Black Han Sans', 'Pretendard Variable', sans-serif;
--color-pop-orange: #ff5c1f;
--color-pop-blue: #2346d9;
--color-pop-yellow: #ffd23f;
--color-pop-cream: #fff6e0;
--color-pop-pink: #ff8fc7;
--color-pop-green: #1fbf6a;
--color-pop-sky: #8fb3ff;
--color-pop-navy: #1d2a5c;
--color-ink: #28304a;
--color-ink-2: #5a6380;
--color-sky-1: #bfe3ff;
--color-sky-2: #e5f2ff;
--color-page: #f7fbff;
--color-orange: #ff7a45;
--color-orange-deep: #d4552a;
--color-butter: #fff1c4;
--color-butter-deep: #7a6320;
--color-mint: #dcf4e8;
--color-peach: #fff4ec;
--color-lilac: #ece7ff;
--color-rain: #4f97e3;
--color-clay-shade: #d9e5f4;
--color-gold: #d89413;
--color-silver: #7f8aa3;
--color-bronze: #b0673a;
--shadow-clay: inset 0 -6px 0 var(--color-clay-shade), 0 10px 20px rgb(40 48 74 / 0.08);
--shadow-clay-lg: inset 0 -9px 0 var(--color-clay-shade), 0 12px 20px rgb(40 48 74 / 0.08);
--shadow-btn: inset 0 -6px 0 var(--color-orange-deep), 0 12px 22px rgb(240 106 58 / 0.28);
--animate-marquee: marquee 40s linear infinite;
@keyframes marquee {
to {
transform: translateX(-50%);
}
}
}
@layer base {
@@ -61,104 +25,3 @@
outline-offset: 3px;
}
}
@utility clay-sun {
border-radius: 9999px;
background: radial-gradient(circle at 34% 30%, #fff5cf 0%, #ffc86e 30%, #ff8e4e 68%, #ee6436 100%);
box-shadow:
inset -20px -28px 44px rgb(170 50 20 / 0.34),
inset 18px 20px 32px rgb(255 255 255 / 0.55),
0 34px 64px rgb(240 106 58 / 0.32);
}
@utility clay-cloud {
position: relative;
border-radius: 9999px;
background: #fff;
box-shadow:
inset 0 -14px 22px rgb(160 190 230 / 0.45),
0 20px 34px rgb(40 70 120 / 0.13);
&::before,
&::after {
content: '';
position: absolute;
border-radius: 9999px;
background: #fff;
box-shadow: inset 0 -12px 18px rgb(160 190 230 / 0.35);
}
&::before {
left: 16%;
top: -58%;
width: 46%;
aspect-ratio: 1;
}
&::after {
left: 50%;
top: -36%;
width: 36%;
aspect-ratio: 1;
}
}
@utility drop-icon {
filter: drop-shadow(0 10px 12px rgb(40 48 74 / 0.16));
}
/* 히어로 오브젝트: 하늘에서 떨어진 뒤 계속 둥둥 떠 있기 */
@keyframes sky-drop {
0% {
transform: translateY(-110vh) rotate(-10deg);
opacity: 0;
}
55% {
opacity: 1;
}
72% {
transform: translateY(0) rotate(2deg) scale(1.04, 0.96);
}
86% {
transform: translateY(-14px) rotate(-1deg);
}
100% {
transform: none;
opacity: 1;
}
}
@keyframes sky-float {
0%,
100% {
transform: translateY(0) rotate(0deg);
}
50% {
transform: translateY(calc(var(--amp, 12px) * -1)) rotate(var(--tilt, 1.5deg));
}
}
@utility sky-fall {
animation:
sky-drop 1.1s cubic-bezier(0.22, 0.9, 0.3, 1) var(--delay, 0s) both,
sky-float var(--float, 4.6s) ease-in-out calc(var(--delay, 0s) + 1.1s) infinite;
}
/* PC: 모든 섹션 최소 한 화면(메뉴 바 제외) + 섹션 단위 스냅 */
@utility screen-fill {
@media (width >= 64rem) {
min-height: calc(100svh - var(--nav, 76px));
scroll-snap-align: start;
scroll-margin-top: var(--nav, 76px);
}
}
@media (width >= 64rem) {
html {
scroll-snap-type: y proximity;
}
}
@media (prefers-reduced-motion: reduce) {
.animate-marquee,
.sky-fall {
animation: none;
}
}