-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] 관리자 게시판 미리보기 컴포넌트 추가 #40
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.container { | ||
width: 600px; | ||
border: 0.5px solid var(--mantine-color-dimmed-border); | ||
} | ||
|
||
.title_bar { | ||
width: 100%; | ||
height: 70px; | ||
border-bottom: 1px solid #888888; | ||
|
||
background-color: var(--color-surfaceVariant); | ||
|
||
border-radius: 8px 8px 0px 0px; | ||
} | ||
|
||
.col_icon { | ||
width: 10%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.col_title { | ||
font-size: 20px; | ||
line-height: 32px; | ||
font-weight: 600; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
} | ||
|
||
.pagination { | ||
padding: 20px 10px; | ||
width: 100%; | ||
display: flex; | ||
justify-content: flex-end; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { AdminNoticePreview } from "./AdminNoticePreview"; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export | ||
const meta = { | ||
title: "AdminNoticePreview", | ||
component: AdminNoticePreview, | ||
parameters: { | ||
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout | ||
layout: "centered", | ||
}, | ||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs | ||
tags: ["autodocs"], | ||
// More on argTypes: https://storybook.js.org/docs/api/argtypes | ||
argTypes: {}, | ||
// More on Action Args : https://storybook.js.org/docs/essentials/actions#action-args | ||
args: {}, | ||
} satisfies Meta<typeof AdminNoticePreview>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args | ||
export const Usage: Story = { | ||
args: { | ||
title: "공지사항", | ||
pagingData: [ | ||
{ | ||
data: [ | ||
{ pinned: true, title: "S-TOP 리뉴얼 안내", writer: "SCG", registeredDate: new Date() }, | ||
{ | ||
pinned: true, | ||
title: "S-TOP 리뉴얼 안내 재공지", | ||
writer: "SCG", | ||
registeredDate: new Date(), | ||
}, | ||
{ | ||
pinned: true, | ||
title: "S-TOP 리뉴얼 안내 22", | ||
writer: "SCG", | ||
registeredDate: new Date(), | ||
}, | ||
{ | ||
pinned: false, | ||
title: "공지사항 제목입니다. 엄청 긴 제목입니다. 더 긴 제목", | ||
writer: "행정실", | ||
registeredDate: new Date(), | ||
}, | ||
{ | ||
pinned: false, | ||
title: "공지사항 제목입니다.", | ||
writer: "소프트웨어융합대학 행정실", | ||
registeredDate: new Date(), | ||
}, | ||
], | ||
}, | ||
{ | ||
data: [ | ||
{ | ||
pinned: false, | ||
title: "공지사항 제목입니다.", | ||
writer: "행정실", | ||
registeredDate: new Date(), | ||
}, | ||
{ | ||
pinned: false, | ||
title: "공지사항 제목입니다. 2", | ||
writer: "소프트웨어융합대학 행정실", | ||
registeredDate: new Date(), | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Stack, Pagination, Flex } from "@mantine/core"; | ||
import { useState } from "react"; | ||
import Image from "next/image"; | ||
import { AdminNoticePreviewRow } from "./AdminNoticePreviewRow/AdminNoticePreviewRow"; | ||
import classes from "./AdminNoticePreview.module.css"; | ||
|
||
export interface IAdminNoticePreviewRow { | ||
pinned: boolean; | ||
title: string; | ||
writer: string; | ||
registeredDate: Date; | ||
onClickRow?: () => void; | ||
} | ||
|
||
interface Props { | ||
title: string; | ||
pagingData: { | ||
data: IAdminNoticePreviewRow[]; | ||
}[]; | ||
} | ||
|
||
export function AdminNoticePreview({ title, pagingData }: Props) { | ||
const [activePage, setPage] = useState(1); | ||
const data: IAdminNoticePreviewRow[] = pagingData[activePage - 1].data; | ||
|
||
return ( | ||
<Stack gap={0} align="flex-start" justify="flex-start" className={classes.container}> | ||
<Flex className={classes.title_bar}> | ||
<div className={classes.col_icon}> | ||
<Image alt="table icon" src="/icons/Table.svg" width={24} height={24} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아이콘이 얇아 잘 보이지 않는 것 같아 다른 아이콘 또는 여기를 참고해 Tabler를 사용하면 좋을 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정했습니다! |
||
</div> | ||
<div className={classes.col_title}>{title}</div> | ||
</Flex> | ||
{data.map((item, index) => ( | ||
<AdminNoticePreviewRow key={index} {...item} /> | ||
))} | ||
<div className={classes.pagination}> | ||
<Pagination total={pagingData.length} value={activePage} onChange={setPage} /> | ||
</div> | ||
</Stack> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.row { | ||
border-bottom: 0.5px solid #afb1b6; | ||
height: 70px; | ||
width: 100%; | ||
font-size: 16px; | ||
line-height: 24px; | ||
} | ||
|
||
.row:hover { | ||
background-color: var(--color-background); | ||
} | ||
|
||
.column_pinned { | ||
width: 10%; | ||
height: 100%; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.column_title { | ||
width: 50%; | ||
height: 100%; | ||
text-align: left; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
padding-right: 10px; | ||
|
||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.column_writer { | ||
width: 20%; | ||
height: 100%; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
padding-right: 10px; | ||
|
||
min-width: 0; | ||
|
||
color: #888888; | ||
} | ||
|
||
.text_ellipsis { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.column_date { | ||
width: 20%; | ||
height: 100%; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
|
||
color: #888888; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Flex, Text } from "@mantine/core"; | ||
import classes from "./AdminNoticePreviewRow.module.css"; | ||
import Image from "next/image"; | ||
import { IAdminNoticePreviewRow } from "../AdminNoticePreview"; | ||
|
||
export function AdminNoticePreviewRow({ | ||
pinned, | ||
title, | ||
writer, | ||
registeredDate, | ||
onClickRow, | ||
}: IAdminNoticePreviewRow) { | ||
function formatDate(date: Date) { | ||
const year = date.getFullYear(); | ||
const month = String(date.getMonth() + 1).padStart(2, "0"); // getMonth()는 0부터 시작하므로 +1 | ||
const day = String(date.getDate()).padStart(2, "0"); | ||
|
||
return `${year}.${month}.${day}`; | ||
} | ||
return ( | ||
<Flex | ||
gap={0} | ||
align="center" | ||
justify="flex-start" | ||
direction="row" | ||
wrap="nowrap" | ||
className={classes.row} | ||
onClick={onClickRow} | ||
> | ||
<div className={classes.column_pinned}> | ||
{pinned && <Image src="/icons/Pin_fill.svg" alt="pinned" width={24} height={24} />} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin 아이콘도 Tabler에 같은 모양이 있으니 여기를 참고해 편하게 쓰실 수 있을 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정했습니다! |
||
</div> | ||
<div className={classes.column_title}> | ||
<Text className={classes.text_ellipsis}>{title}</Text> | ||
</div> | ||
<div className={classes.column_writer}> | ||
<Text className={classes.text_ellipsis}>{writer}</Text> | ||
</div> | ||
<div className={classes.column_date}>{formatDate(registeredDate)}</div> | ||
</Flex> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
부모 스타일에 맞게 유동적으로 너비가 변할 수 있도록 width를 고정하지는 않아도 괜찮을 것 같습니다!