-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
223 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
@import "../utils/common.module.scss"; | ||
|
||
// 포지션 설정 | ||
.fixedPositionCon { | ||
@include pageContainer; | ||
position: fixed; | ||
top: calc(62px + ((100vh - 62px) / 2)); | ||
left: 0; | ||
right: 0; | ||
|
||
.relativePostionCon { | ||
position: relative; | ||
width: 100%; | ||
|
||
.absolutePostionCon { | ||
position: absolute; | ||
top: 50%; | ||
left: 100%; | ||
transform: translate(calc(-50%), -50%); | ||
|
||
margin-left: 180px; | ||
@media (max-width: #{$max-screen + 700}) { | ||
margin-left: calc((100vw - 100%) / 4); | ||
} | ||
@media (max-width: #{$max-screen + 480}) { | ||
margin-left: 120px; | ||
} | ||
@media (max-width: #{$max-screen + 240}) { | ||
margin-left: 60px; | ||
} | ||
@media (max-width: #{$medium-screen + 100}) { | ||
margin-left: 20px; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// 스타일 설정 | ||
.listOpenIcon { | ||
width: 60px; | ||
height: 60px; | ||
border-radius: 50%; | ||
background-image: url("../assets/menu-svgrepo-com.svg"); | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
background-color: white; | ||
box-shadow: 0 2px 10px #aaaaaa; | ||
} | ||
|
||
.cardListCon { | ||
padding-right: 10px; | ||
|
||
@media (max-width: #{$max-screen + 480}) { | ||
transform: translate(calc(-10px - 50% + (100vw - 1560px) / 2)); | ||
} | ||
@media (max-width: #{$max-screen + 240}) { | ||
transform: translate(calc(-10px - 50% + (100vw - 1440px) / 2)); | ||
} | ||
@media (max-width: #{$max-screen + 120}) { | ||
transform: translate(calc(-50%)); | ||
} | ||
} | ||
.cardList { | ||
width: 200px; | ||
max-height: 80vh; | ||
padding: 0 20px; | ||
border: 1px solid $light-gray; | ||
border-radius: 10px; | ||
background-color: #eeeeee; | ||
overflow-y: scroll; | ||
|
||
@keyframes expandVertically { | ||
0% { | ||
transform: scaleY(0); | ||
} | ||
100% { | ||
transform: scaleY(1); | ||
} | ||
} | ||
animation: expandVertically 0.3s ease forwards; | ||
|
||
&::-webkit-scrollbar { | ||
width: 10px; | ||
} | ||
&::-webkit-scrollbar-track { | ||
border-radius: 10px; | ||
} | ||
&::-webkit-scrollbar-thumb { | ||
background: $light-gray; | ||
border-radius: 10px; | ||
} | ||
&::-webkit-scrollbar-thumb:hover { | ||
background: #bbbbbb; | ||
} | ||
|
||
header { | ||
padding: 10px 0; | ||
h2 { | ||
font-size: 15px; | ||
} | ||
} | ||
ul { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
li { | ||
list-style-type: none; | ||
|
||
img { | ||
width: 100%; | ||
} | ||
.contentTitleBox { | ||
margin-top: -4px; | ||
padding-bottom: 16px; | ||
font-size: 14px; | ||
font-weight: 500; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useState } from "react"; | ||
import styles from "./RecentlyViewedContents.module.scss"; | ||
import { Link } from "react-router-dom"; | ||
import useRecentContents from "../hooks/useRecentContents"; | ||
|
||
export default function RecentlyViewedContents() { | ||
const [isOpenRecentContents, setIsOpenRecentContents] = useState(false); | ||
const { recentContents } = useRecentContents(); | ||
|
||
return ( | ||
<div className={styles.fixedPositionCon}> | ||
<div className={styles.relativePostionCon}> | ||
<div className={styles.absolutePostionCon}> | ||
{isOpenRecentContents ? ( | ||
<div | ||
className={styles.cardListCon} | ||
onMouseLeave={() => setIsOpenRecentContents(false)} | ||
> | ||
<div className={styles.cardList}> | ||
<header> | ||
<h2>최근 구경한 영화({recentContents.length}건)</h2> | ||
</header> | ||
<ul> | ||
{recentContents.map((content) => ( | ||
<li key={content.movieCD}> | ||
<Link to={`/contents/${content.movieCD}`}> | ||
<img src={content.poster} alt="" /> | ||
<div className={styles.contentTitleBox}> | ||
{`${content.title_ko} · ${content.directors?.[0].name}`} | ||
</div> | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
) : ( | ||
<div | ||
className={styles.listOpenIcon} | ||
onMouseEnter={() => setIsOpenRecentContents(true)} | ||
></div> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { MovieType } from "../type"; | ||
|
||
export default function useRecentContents() { | ||
let recentContents: Partial<MovieType>[]; | ||
try { | ||
recentContents = JSON.parse(localStorage.getItem("recentContents") ?? "[]"); | ||
} catch (e) { | ||
localStorage.removeItem("recentContents"); | ||
recentContents = []; | ||
} | ||
|
||
function addRecentContent(newContent: Partial<MovieType>) { | ||
recentContents = recentContents.filter( | ||
(content) => content.movieCD !== newContent.movieCD | ||
); | ||
recentContents.push(newContent); | ||
recentContents.length > 10 && recentContents.splice(0, 1); | ||
|
||
localStorage.setItem("recentContents", JSON.stringify(recentContents)); | ||
} | ||
|
||
// 순서를 뒤집어 return | ||
return { recentContents: recentContents.reverse(), addRecentContent }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters