3월 협업 프로젝트(1석 4조) 👨‍👩‍👧‍👦

Header Notification box 구현

엄성준 2023. 4. 8. 03:01

import React from 'react'
import {Link} from 'react-router-dom'
import styled from 'styled-components'

interface Notification {
  setNotification: (value: boolean) => void
}

export default function Notification({setNotification}: Notification) {
  return (
    <Wrapper onMouseLeave={() => setNotification(false)}>
      <LinkBox>
        <NotificationLink to='Message'># (닉네임)님에게 메세지가 도착했습니다.</NotificationLink>
        <NotificationLink to='Message'># 안읽은 메세지가 있습니다.</NotificationLink>
        <NotificationLink to='MyPage'># (닉네임)님이 (게시글 제목)에 좋아요를 누르셨습니다.</NotificationLink>
        <NotificationLink to='MyPage'># (게시글 제목)에 좋아요가 추가되었습니다.</NotificationLink>
      </LinkBox>
    </Wrapper>
  )
}

const Wrapper = styled.div`
  position: absolute;
  width: 22rem;
  height: 7rem;
  background: rgb(255, 255, 255);
  top: 3.5rem;
  right: 2rem;
  padding: 1rem;
  border-radius: 5px;
  border: 1px solid #e9ebee;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 10px 0px;

  &:after {
    content: '';
    position: absolute;
    border-style: solid;
    border-width: 0px 16px 20px 17.5px;
    border-color: rgb(255, 255, 255) transparent;
    display: block;
    width: 0px;
    z-index: 1;
    top: -1.25rem;
    left: 17.9rem;
  }

  &:before {
    content: '';
    position: absolute;
    border-style: solid;
    border-width: 0px 16px 20px 17.5px;
    border-color: #e9ebee transparent;
    width: 0px;
    z-index: 0;
    top: -1.3rem;
    left: 17.9rem;
  }
`

const LinkBox = styled.div`
  min-height: 7rem;
  height: 7rem;
  display: flex;
  flex-direction: column;
  overflow: scroll;
  overflow-x: hidden;

  ::-webkit-scrollbar {
    width: 5px;
    height: 5px;
  }

  ::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 5px;
  }
`

const NotificationLink = styled(Link)`
  margin-bottom: 1rem;
  padding: 0.3rem;

  &:hover {
    color: #1877fe;
  }
`

코드는 위와 같고 백엔드 분들과 회의해야 될 내용이 생긴 것 같습니다. 

 

알림 내용을 얼마만큼 친절하게 대답해줄건지

# (닉네임)님에게 메세지가 도착했습니다. ---> Link to='Message'
# 안읽은 메시지가 있습니다.

# (닉네임)님이 (게시글 제목)에 좋아요를 누르셨습니다. ---> Link to='게시글'
#  (게시글 제목)에 좋아요가 추가되었습니다. ---> Link to='마이페이지'