Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Binary file added src/assets/Rectangle.png
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/assets/icons/pencil.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/assets/icons/play.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions src/components/ui/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type BottomSheetContextValue = {
onClose: () => void;
/** 풀페이지 → 이전 스냅(절반)으로 내리기 */
collapse: () => void;
/** 절반 → 풀페이지로 올리기 */
expand: () => void;
};

const BottomSheetContext = React.createContext<BottomSheetContextValue | null>(null);
Expand Down Expand Up @@ -110,14 +112,18 @@ function BottomSheet({
}
}

const isFullPage = activeSnap === lastSnap;
const isFullPage = snapPoints.length > 1 && activeSnap === lastSnap;

const collapse = React.useCallback(() => {
setActiveSnap(firstSnap);
}, [firstSnap]);

const expand = React.useCallback(() => {
setActiveSnap(lastSnap);
}, [lastSnap]);

return (
<BottomSheetContext.Provider value={{ isFullPage, onClose, collapse }}>
<BottomSheetContext.Provider value={{ isFullPage, onClose, collapse, expand }}>
<SheetRoot
open={open}
dismissible={dismissible}
Expand Down
2 changes: 1 addition & 1 deletion src/features/pin/components/SongCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function SongCard({ song, onClick }: SongCardProps) {
<button
type="button"
onClick={onClick}
className="flex w-full items-center gap-3 py-2 text-left"
className="flex w-full items-center gap-3 py-2 text-left cursor-pointer"
>
<div className="size-13 rounded-md bg-grayscale-0" />
<div>
Expand Down
20 changes: 12 additions & 8 deletions src/features/pin/components/SongSelectSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import { BottomSheet } from '@/components/ui/BottomSheet';
import { SearchInput } from '@/components/ui/SearchInput';
import { SongCard } from '@/features/pin/components/SongCard';
import type { Song } from '@/features/pin/types';
import { MOCK_SONG_CARD_LIST } from '@/features/pin/data/songPreview';

type SongSelectSheetProps = {
open: boolean;
onClose: () => void;
songs: Song[];
songs?: Song[];
onSelect?: (song: Song) => void;
};

export function SongSelectSheet({ open, onClose, songs, onSelect }: SongSelectSheetProps) {
export function SongSelectSheet({
open,
onClose,
songs = MOCK_SONG_CARD_LIST,
onSelect,
}: SongSelectSheetProps) {
const [query, setQuery] = useState('');
const [prevOpen, setPrevOpen] = useState(open);

Expand All @@ -35,12 +41,11 @@ export function SongSelectSheet({ open, onClose, songs, onSelect }: SongSelectSh
}, [query, songs]);

return (
<BottomSheet open={open} onClose={onClose}>
<BottomSheet.Header className="space-y-4 px-[15px]">
<BottomSheet.Title className="mt-5.5 text-center body-15-r text-grayscale-300">
<BottomSheet open={open} onClose={onClose} snapPoints={[0.5, 1]} className="bg-pli-black-85 ">
<BottomSheet.Header className="px-[15px]">
<BottomSheet.Title className="my-5.5 text-center body-15-r text-grayscale-300">
노래 선택하기
</BottomSheet.Title>

<SearchInput
variant="song"
value={query}
Expand All @@ -49,7 +54,7 @@ export function SongSelectSheet({ open, onClose, songs, onSelect }: SongSelectSh
/>
</BottomSheet.Header>

<BottomSheet.Content className="mt-5.5 px-4">
<BottomSheet.Content className="px-4 pt-5.5">
<ul>
{filteredSongs.map((song) => (
<li key={song.id}>
Expand All @@ -58,7 +63,6 @@ export function SongSelectSheet({ open, onClose, songs, onSelect }: SongSelectSh
onClick={() => {
onSelect?.(song);
onClose();
setQuery('');
}}
/>
</li>
Expand Down
56 changes: 56 additions & 0 deletions src/features/pin/data/songPreview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { Song } from '@/features/pin/types';
import newJeansArtistImage from '@/assets/Rectangle.png';

{
/* 노래 카드 목록 데이터 */
}
export const MOCK_SONG_CARD_LIST: Song[] = [
{ id: '1', title: 'Hype Boy', artist: 'NewJeans', artistImage: newJeansArtistImage },
{ id: '2', title: 'Hype Boy (250 Remix)', artist: 'NewJeans', artistImage: newJeansArtistImage },
];

{
/* 노래 프리뷰 데이터 */
}
export const MOCK_WAVEFORM_PEAKS = [
0.35, 0.55, 0.75, 0.9, 1, 0.85, 0.7, 0.95, 0.8, 0.65, 0.5, 0.4, 0.55, 0.7, 0.85, 0.95, 0.75, 0.6,
0.45, 0.35, 0.5, 0.65, 0.8, 0.7, 0.55, 0.4, 0.35, 0.45, 0.6, 0.75, 0.85, 0.7, 0.55, 0.4, 0.35,
0.45, 0.6, 0.75, 0.65, 0.5, 0.35, 0.55, 0.75, 0.9, 1, 0.85, 0.7, 0.95, 0.8, 0.65, 0.5, 0.4, 0.55,
0.7, 0.85, 0.95, 0.75, 0.6, 0.45, 0.35, 0.5, 0.65, 0.8, 0.7, 0.55, 0.4, 0.35, 0.45, 0.6, 0.75,
0.85, 0.7, 0.55, 0.4, 0.35, 0.45, 0.6, 0.75, 0.65, 0.5,
] as const;

export const MOCK_PREVIEW_DURATION = 30;
export const MIN_TRIM_DURATION = 5;
export const DEFAULT_TRIM_START_INDEX = 8;
export const DEFAULT_TRIM_END_INDEX = 24;

export const TAG_OPTIONS = [
'감성',
'고독',
'낭만',
'몽환',
'설렘',
'신남',
'위로',
'잔잔',
'청량',
'힙함',
] as const;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

export function peaksToTrimRange(
startIndex: number,
endIndex: number,
peaks: readonly number[],
duration: number,
) {
return {
start: (startIndex / peaks.length) * duration,
end: ((endIndex + 1) / peaks.length) * duration,
};
}

export function timeToPercent(time: number, duration: number) {
if (duration <= 0) return 0;
return (time / duration) * 100;
}
5 changes: 5 additions & 0 deletions src/features/pin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export type Song = {
id: string;
title: string;
artist: string;
artistImage: string;
};

export type SongDetail = Song & {
waveformPeaks: readonly number[];
};

export type PlaceResult = {
Expand Down
Loading
Loading