-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from P-r4Tes/feat/asidebar
Feat/asidebar Sidebar Component
- Loading branch information
Showing
23 changed files
with
2,388 additions
and
1,959 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
const nextConfig = { | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: "https", | ||
hostname: "avatars.githubusercontent.com", | ||
}, | ||
], | ||
} | ||
}; | ||
|
||
export default nextConfig; |
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
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,3 @@ | ||
export default function Page() { | ||
return <p>hello</p>; | ||
} |
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
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,35 @@ | ||
import React, { useState } from "react"; | ||
import { viewType } from "./types"; | ||
import MonthView from "./Content/MonthView"; | ||
|
||
const BUTTON_STYLE = "bg-blue-500 text-white rounded-md p-2"; | ||
|
||
const Calendar = () => { | ||
// 이 부분은 상당히 React스러운데 나중에 라우팅으로 돌리고 Next스럽게 리팩터링해도 좋을 것 같습니다. | ||
const [viewType, setViewType] = useState<viewType>("month"); | ||
|
||
const handleClick = (e: React.MouseEvent<HTMLElement>) => { | ||
const target = e.target as HTMLButtonElement; | ||
const value = target.value as viewType; | ||
setViewType(value); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<section onClick={handleClick} className="flex gap-2"> | ||
<button className={BUTTON_STYLE} value={"month"}> | ||
MONTH | ||
</button> | ||
<button className={BUTTON_STYLE} value={"week"}> | ||
WEEK | ||
</button> | ||
<button className={BUTTON_STYLE} value={"day"}> | ||
DAY | ||
</button> | ||
</section> | ||
{viewType === "month" && <MonthView />} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Calendar; |
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,18 @@ | ||
import React from "react"; | ||
|
||
const MonthView = () => { | ||
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; | ||
return ( | ||
<section className="flex flex-col flex-1"> | ||
<div className="flex w-full"> | ||
{days.map((day, index) => ( | ||
<div key={index} className="flex-1"> | ||
{day} | ||
</div> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default MonthView; |
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 @@ | ||
export type viewType = "month" | "week" | "day"; |
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,23 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import Header from "./Header"; | ||
|
||
const meta = { | ||
title: "Header", | ||
component: Header, | ||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs | ||
tags: ["autodocs"], | ||
parameters: { | ||
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout | ||
layout: "fullscreen", | ||
}, | ||
} satisfies Meta<typeof Header>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
export const Default: Story = { | ||
args: { | ||
user: { | ||
name: "Jane Doe", | ||
}, | ||
}, | ||
}; |
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,14 @@ | ||
import React from "react"; | ||
|
||
const Header = () => { | ||
return ( | ||
<header className="flex flex-col justify-center items-center bg-yellow-200"> | ||
<section>Search Section</section> | ||
<section className="w-full"> | ||
<h1>2024 년 03월</h1> | ||
</section> | ||
</header> | ||
); | ||
}; | ||
|
||
export default Header; |
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,15 @@ | ||
import Link from "next/link"; | ||
import PlusIcon from "@/components/Sidebar/PlusIcon"; | ||
|
||
type GroupProps = { | ||
href: string; | ||
}; | ||
const AddGroup = ({ href }: GroupProps) => { | ||
return ( | ||
<Link href={href} className="w-full h-auto rounded-full bg-slate-800 p-2"> | ||
<PlusIcon className="text-white" /> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default AddGroup; |
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,39 @@ | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
import clsx from "clsx"; | ||
import { MouseEventHandler } from "react"; | ||
|
||
// 임시 이미지 | ||
const tempSrc = "https://avatars.githubusercontent.com/u/161491870?s=200&v=4"; | ||
|
||
type GroupProps = Pick<group, "name"> & { | ||
href: string; | ||
selected: boolean; | ||
onSelect?: MouseEventHandler<HTMLAnchorElement>; | ||
}; | ||
const Group = ({ name, href, selected, onSelect }: GroupProps) => { | ||
return ( | ||
<Link | ||
href={href} | ||
className={clsx("", { | ||
"border-2 border-slate-100": selected, | ||
})} | ||
onClick={onSelect} | ||
> | ||
<Image | ||
className="rounded-full" | ||
src={tempSrc} | ||
alt={`그룹 ${name}`} | ||
sizes="100vw" | ||
style={{ | ||
width: "100%", | ||
height: "auto", | ||
}} | ||
width={360} | ||
height={360} | ||
/> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default Group; |
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,18 @@ | ||
import { SVGProps } from "react"; | ||
import clsx from "clsx"; | ||
|
||
const PlusIcon = ({ ...props }: SVGProps<SVGSVGElement>) => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
strokeWidth={3} | ||
stroke="currentColor" | ||
className={clsx("w-4 h-4", props?.className)} | ||
{...props} | ||
> | ||
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4.5v15m7.5-7.5h-15" /> | ||
</svg> | ||
); | ||
|
||
export default PlusIcon; |
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,28 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import Sidebar from "./Sidebar"; | ||
|
||
const meta = { | ||
title: "Sidebar", | ||
component: Sidebar, | ||
tags: ["autodocs"], | ||
parameters: { | ||
layout: "fullscreen", | ||
}, | ||
} satisfies Meta<typeof Sidebar>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
groups: [ | ||
{ | ||
id: "test1", | ||
name: "샘플", | ||
users: ["user1"], | ||
schedules: ["schedules"], | ||
}, | ||
], | ||
}, | ||
}; |
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,38 @@ | ||
"use client"; | ||
import React, { MouseEventHandler, useState } from "react"; | ||
import Group from "@/components/Sidebar/Group"; | ||
import AddGroup from "@/components/Sidebar/AddGroup"; | ||
|
||
type SidebarProps = { | ||
groups: (group & id)[]; | ||
}; | ||
const Sidebar = ({ groups }: SidebarProps) => { | ||
const [selectedIdx, setSelectedIdx] = useState(0); | ||
const height = groups.length * 80 + 80; | ||
|
||
return ( | ||
<div className="flex h-screen"> | ||
<aside className={"flex items-center w-20 bg-[#383A57] rounded-l-3xl"} style={{ height: height }}> | ||
<div className="flex flex-col items-center space-y-4 p-4"> | ||
{groups.map((group, idx) => { | ||
const onSelect: MouseEventHandler<HTMLAnchorElement> = () => { | ||
setSelectedIdx(idx); | ||
}; | ||
return ( | ||
<Group | ||
key={group.id} | ||
name={group.name} | ||
href={group.id} | ||
selected={idx === selectedIdx} | ||
onSelect={onSelect} | ||
/> | ||
); | ||
})} | ||
<AddGroup href="." /> | ||
</div> | ||
</aside> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Sidebar; |
Oops, something went wrong.