Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions Mine/src/components/NewMagazineInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import {type KeyboardEvent } from 'react'

interface MagazineInputProps {
topic: string
userMood: string
onTopicChange: (value: string) => void
onUserMoodChange: (value: string) => void
onSubmit: () => void
}

export default function MagazineInput({
topic,
userMood,
onTopicChange,
onUserMoodChange,
onSubmit,
}: MagazineInputProps) {
const handleKeyDown = (e: KeyboardEvent <HTMLInputElement>) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault()
onSubmit()
}
}

return (
<div className="relative mx-auto flex flex-col w-192.5">
<div
className="flex items-center w-full border border-b-0 border-gray-500 bg-gray-100-op30"
style={{
height: '54px',
padding: '20px 28px',
borderRadius: '20px 20px 0 0', //Tailwind 미지원 값
}}
>
<div className="flex flex-col flex-1">
<span className="text-gray-100/50 font-medium12">주제</span>
<input
value={topic}
onChange={(e) => onTopicChange(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="관심있는 주제를 입력해 주세요."
className="w-full bg-transparent font-regular16 text-gray-100 outline-none placeholder-gray-100/40"
/>
</div>
</div>

<div
className="flex items-center w-full border border-gray-500 bg-gray-100-op30"
style={{
height: '54px',
padding: '20px 12px 20px 28px',
borderRadius: '0 0 20px 20px', //Tailwind 미지원 값
}}
>
<div className="flex flex-col flex-1">
<span className="text-gray-100/50 font-medium12">분위기</span>
<input
value={userMood}
onChange={(e) => onUserMoodChange(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="원하는 분위기를 입력해 주세요."
className="w-full bg-transparent font-regular16 text-gray-100 outline-none placeholder-gray-100/40"
/>
</div>
<button
onClick={onSubmit}
disabled={!topic.trim()}
className={`flex shrink-0 items-center justify-center transition-all duration-200 ${
topic.trim() ? 'bg-gray-500-op70' : ''
}`}
style={{
width: '53px',
height: '30px',
padding: '8px 16px',
borderRadius: '40px', //Tailwind 미지원 값
background: topic.trim() ? undefined : 'rgba(80, 80, 80, 0.40)', //디자인 시스템 변수 미지원 값
boxShadow: topic.trim()
? '0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 16px 32px 0 rgba(0, 0, 0, 0.20)' //디자인 시스템 변수 미지원 값
: 'none',
}}
>
<span className="text-gray-100 whitespace-nowrap font-medium14">입력</span>
</button>
</div>
</div>
)
}
7 changes: 5 additions & 2 deletions Mine/src/layout/sidebar/SidebarMagazine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function SidebarMagazine({ title, id, onclick }: SidebarMagazineP
<div className="w-full flex flex-col">
<div
key={id}
className={`w-full flex justify-between hover:bg-gray-600-op80 hover:text-gray-100 py-2 items-center pl-5 pr-4 text-gray-100-op70 font-medium14 select-none ${
className={`w-full flex justify-between group hover:bg-gray-600-op80 hover:text-gray-100 py-2 items-center pl-5 pr-4 text-gray-100-op70 font-medium14 select-none ${
isEditing ? 'bg-gray-600-op80' : ''
}`}
onClick={onclick}
Expand All @@ -109,7 +109,10 @@ export default function SidebarMagazine({ title, id, onclick }: SidebarMagazineP
/>
)}

<Hamburger className="cursor-pointer shrink-0" onClick={handleHamburger} />
<Hamburger
className="cursor-pointer shrink-0 text-gray-100-op70 opacity-0 group-hover:opacity-100"
onClick={handleHamburger}
/>
</div>

{isHamburgerOpen &&
Expand Down
31 changes: 16 additions & 15 deletions Mine/src/layout/sidebar/SidebarOpen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function SidebarOpen({ onclick }: SidebarProps) {
isError: isMagError,
} = useGetMyMagazineList({
page: 0,
size: 5,
size: 100,
sort: [],
})

Expand Down Expand Up @@ -82,21 +82,7 @@ export default function SidebarOpen({ onclick }: SidebarProps) {
<SidebarBlock icon={<Sidebar_like />} title="저장한 매거진" to="/magazine/saved" />
<SidebarBlock icon={<Sidebar_others />} title="둘러보기" to="/magazine/explore" />
</div>
<div className="flex flex-col">
<SidebarTitle onClick={handleMagazineToggleOpen} title="내 매거진" isOpen={isMagazineOpen} />

{isMagazineOpen && (
<>
{magazine?.content.map((magazine) => (
<SidebarMagazine
id={magazine.magazineId}
title={magazine.title}
onclick={() => handleMagazineClick(magazine.magazineId)}
/>
))}
</>
)}
</div>
<div className="flex flex-col">
<SidebarTitle
onClick={handleSectionToggleOpen}
Expand All @@ -117,6 +103,21 @@ export default function SidebarOpen({ onclick }: SidebarProps) {
</>
)}
</div>
<div className="flex flex-col">
<SidebarTitle onClick={handleMagazineToggleOpen} title="내 매거진" isOpen={isMagazineOpen} />

{isMagazineOpen && (
<div className="h-52 overflow-auto custom-scrollbar">
{magazine?.content.map((magazine) => (
<SidebarMagazine
id={magazine.magazineId}
title={magazine.title}
onclick={() => handleMagazineClick(magazine.magazineId)}
/>
))}
</div>
)}
</div>

<div className="flex justify-between mt-auto pl-6.5 pr-6 items-center ">
<div className="flex gap-2 items-center">
Expand Down
6 changes: 4 additions & 2 deletions Mine/src/layout/sidebar/SidebarSectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ export default function SidebarSectionList({ title, key, onclick, magazineId, se
return (
<div
key={key}
className="w-full flex justify-between hover:bg-gray-600-op80 hover:text-gray-100 py-2 items-center p-6 pr-4 text-gray-100-op70 font-medium14 select-none"
className="flex hover:bg-gray-600-op80 py-2 h-9 items-center pl-5 pr-5 select-none"
onClick={() => onclick(magazineId, sectionId)}
>
{title}
<label className="block w-full hover:text-gray-100 overflow-hidden text-ellipsis whitespace-nowrap text-gray-100-op70 font-medium14">
{title}
</label>
Comment on lines +16 to +18

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

<label> 태그는 폼 입력 요소와 연결될 때 사용됩니다. 여기서는 텍스트를 표시하는 목적이므로 시맨틱 HTML을 위해 <label> 대신 <span>이나 <div> 태그를 사용하는 것이 더 적절합니다.

Suggested change
<label className="block w-full hover:text-gray-100 overflow-hidden text-ellipsis whitespace-nowrap text-gray-100-op70 font-medium14">
{title}
</label>
<span className="block w-full hover:text-gray-100 overflow-hidden text-ellipsis whitespace-nowrap text-gray-100-op70 font-medium14">
{title}
</span>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 제가 했던 부분이 아닌데, 수정해야하나 말아야하나 모르겠네요

</div>
)
}
53 changes: 29 additions & 24 deletions Mine/src/pages/magazine/MagazinePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { useNavigate, useParams } from 'react-router-dom'
import SectionCover from './components/SectionCover'
import useGetMagazineDetail from '../../hooks/useGetMagazineDetail'
import { GridContainor } from './components/GridContainor'
import ProfileBox from './components/ProfileBox'
import useSidebarStore from '../../stores/sidebar'
import MagazineInfo from './components/MagazineInfo'
import { MagazineProvider } from './MagazineProvider'

const isValidUrl = (url?: string) => {
if (!url) return false
Expand Down Expand Up @@ -32,31 +33,35 @@ export default function MagazinePage() {
const content = data?.sections

return (
<div
style={{ backgroundImage: safeCoverImageUrl ? `url(${safeCoverImageUrl})` : 'none' }}
className="bg-cover overflow-hidden"
>
<div className={`mt-9 transition-all duration-300 ${isOpen ? 'ml-60' : 'ml-15'}`}>
{data.user && (
<ProfileBox
nickname={data.user.nickname}
profileImage={data.user.profileImageUrl}
classname="justify-end mr-6.5"
mode="magazine"
/>
)}
<div className="flex justify-center items-start p-30 h-screen overflow-auto">
<GridContainor>
{content?.map((item) => (
<SectionCover
key={item.sectionId}
imageUrl={item.thumbnailUrl}
onclick={() => handleSectionClick(Number(magazineId), item.sectionId)}
<MagazineProvider id={Number(magazineId)}>
<div
style={{ backgroundImage: safeCoverImageUrl ? `url(${safeCoverImageUrl})` : 'none' }}
className="bg-cover overflow-hidden"
>
<div className={`flex flex-col transition-all duration-300 ${isOpen ? 'ml-60' : 'ml-15'}`}>
{data.user && (
<div className="mt-9 pr-7 pl-10.5">
<MagazineInfo
nickname={data.user.nickname}
profileImage={data.user.profileImageUrl}
magazineId={data.magazineId}
mode="magazine"
/>
))}
</GridContainor>
</div>
)}
<div className="flex justify-center items-start p-20 h-screen overflow-auto">
<GridContainor>
{content?.map((item) => (
<SectionCover
key={item.sectionId}
imageUrl={item.thumbnailUrl}
onclick={() => handleSectionClick(Number(magazineId), item.sectionId)}
/>
))}
</GridContainor>
</div>
</div>
</div>
</div>
</MagazineProvider>
)
}
14 changes: 8 additions & 6 deletions Mine/src/pages/magazine/components/GridContainor.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React from 'react'
import { GRID_LAYOUT_PRESETS } from '../../../style/gridpattern'
import { GRID_ITEM_LAYOUT_PRESETS, GRID_LAYOUT_PRESENT } from '../../../style/gridpattern'

export const GridContainor = ({ children }: { children: React.ReactNode }) => {
const childrenArray = React.Children.toArray(children)
const count = childrenArray.length
const layoutPattern = GRID_LAYOUT_PRESETS[count]
const count = React.Children.count(children)
const itemPattern = GRID_ITEM_LAYOUT_PRESETS[count] || []
const layoutClass = GRID_LAYOUT_PRESENT[count] || 'grid-cols-4'
return (
<div className="w-full h-full grid grid-cols-4 gap-2 grid-flow-dense">
<div className={`w-full h-125 grid gap-2 grid-flow-dense overflow-hidden ${layoutClass}`}>
{React.Children.map(children, (child, index) => (
<div className={layoutPattern[index] || 'col-span-1'}>{child}</div>
<div key={index} className={itemPattern[index] || 'col-span-1'}>
{child}
</div>
))}
</div>
)
Expand Down
9 changes: 5 additions & 4 deletions Mine/src/pages/magazine/components/HeartCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import Heart from '../../../icon/heart.svg?react'
interface HeartCountProps {
hearts?: number
magazineId?: number
classname?: string
}

export default function HeartCount({ hearts, magazineId }: HeartCountProps) {
export default function HeartCount({ hearts, magazineId, classname }: HeartCountProps) {
// const [localLikeCount, setLocalLikeCount] = useState(Number(hearts))
const postMutation = usePostHeart()
const handleHeartClick = async () => {
Expand All @@ -15,9 +16,9 @@ export default function HeartCount({ hearts, magazineId }: HeartCountProps) {
}

return (
<div className="flex items-center gap-1 cursor-pointer">
<Heart className="text-black-icon" onClick={handleHeartClick} />
<div className="text-black-icon">{hearts}</div>
<div className={`flex items-center gap-1 cursor-pointer ${classname}`}>
<Heart className="text-gray-400" onClick={handleHeartClick} />
<div className="text-gray-400">{hearts}</div>
</div>
)
}
26 changes: 19 additions & 7 deletions Mine/src/pages/magazine/components/MagazineInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import { useMagazine } from '../MagazineProvider'
interface MagazineInfoProps {
nickname?: string
profileImage?: string
magazineId?: number
sectionId?: number
mode: 'section' | 'magazine'
onClick?: (magazineId: number) => void
}
export default function MagazineInfo({ nickname, profileImage, sectionId }: MagazineInfoProps) {
export default function MagazineInfo({ nickname, profileImage, sectionId, mode, onClick }: MagazineInfoProps) {
const magazinedata = useMagazine()
const [modalPos, setModalPos] = useState({ top: 0, left: 0 })
const [isHamburgerOpen, setIsHamburgerOpen] = useState(false)
Expand All @@ -25,10 +28,15 @@ export default function MagazineInfo({ nickname, profileImage, sectionId }: Maga
openHamburger()
}
return (
<div className="flex max-w-245 w-full justify-between items-center self-stretch mt-9">
<div className="flex items-center gap-2">
<div className="font-regular16 font-notoserif text-gray-600">{magazinedata?.title}</div>
<Hamburger className="rotate-90 text-black-icon" onClick={handleHamburger} />
<div className="flex w-full justify-between items-center self-stretch">
<div className="flex items-center gap-2 basis-100">
<div
className={`cursor-pointer ${mode === 'section' ? 'font-regular16 font-notoserif text-gray-600' : 'font-semibold20 font-pretendard text-gray-100'}`}
onClick={() => magazinedata?.magazineId && onClick?.(magazinedata.magazineId)}
>
{magazinedata?.title}
</div>
<Hamburger className="rotate-90 text-black-icon cursor-pointer" onClick={handleHamburger} />
{isHamburgerOpen && magazinedata?.magazineId !== undefined && sectionId !== undefined && (
<SectionHamburgerModal
handleClose={closeHamburger}
Expand All @@ -40,8 +48,12 @@ export default function MagazineInfo({ nickname, profileImage, sectionId }: Maga
/>
)}
</div>
<HeartCount hearts={magazinedata?.likeCount} magazineId={magazinedata?.magazineId} />
<ProfileBox nickname={nickname} profileImage={profileImage} mode="section" />
<HeartCount
hearts={magazinedata?.likeCount}
magazineId={magazinedata?.magazineId}
classname="basis-1 justify-center"
/>
<ProfileBox nickname={nickname} profileImage={profileImage} mode={mode} classname="basis-100 justify-end" />
</div>
)
}
2 changes: 1 addition & 1 deletion Mine/src/pages/magazine/components/ProfileBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface ProfileBoxProps {
export default function ProfileBox({ nickname, profileImage, classname, mode }: ProfileBoxProps) {
return (
<div className={`flex gap-2 items-center ${classname}`}>
<div className={`${mode === 'magazine' ? 'text-main-light' : 'text-black-smalltitle'} font-regular16`}>
<div className={`${mode === 'magazine' ? 'text-gray-100' : 'text-gray-600'} font-regular16`}>
{nickname}
</div>
<img src={profileImage} className="w-12.5 h-12.5 rounded-full object-cover" />
Expand Down
9 changes: 8 additions & 1 deletion Mine/src/pages/magazine/components/SectionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import MagazineInfo from './MagazineInfo'
import SectionIndexList from './SectionIndexList'
import ParagraphPart from './ParagraphPart'
import useSidebarStore from '../../../stores/sidebar'
import { useNavigate } from 'react-router-dom'

interface SectionContentProps {
sectionId: number
Expand All @@ -13,10 +14,14 @@ interface SectionContentProps {
export default function SectionContent({ sectionId, magazineId }: SectionContentProps) {
const { isOpen } = useSidebarStore()
const magazinedata = useMagazine()
const navigate = useNavigate()
const { data, isLoading } = useGetSectionDetail(Number(magazineId), Number(sectionId))
const user = magazinedata?.user
const content = data?.paragraphs

const handleClick = (magazineId: number) => {
navigate(`/magazine/${magazineId}`)
}
if (isLoading) {
return <></>
}
Expand All @@ -27,11 +32,13 @@ export default function SectionContent({ sectionId, magazineId }: SectionContent
className={`flex justify-center w-275 h-full bg-white relative transition-all duration-200 ${isOpen ? 'ml-60' : 'ml-15'}`}
>
<SectionIndexList sectionId={Number(sectionId)} />
<div className="flex flex-col w-245 items-center gap-14 mb-60 z-10">
<div className="flex flex-col w-245 items-center gap-14 mt-9 mb-60 z-10">
<MagazineInfo
nickname={user?.nickname}
profileImage={user?.profileImageUrl}
sectionId={Number(sectionId)}
mode="section"
onClick={handleClick}
/>

{content?.map((content) => (
Expand Down
Loading