Skip to content
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: Home 페이지 템플릿을 서비스 내로 옮깁니다. #82

Merged
merged 13 commits into from
Sep 9, 2023
Merged
7 changes: 7 additions & 0 deletions app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Home } from "components/(home)";

const HomePage = () => {
return <Home />;
};

export default HomePage;
22 changes: 18 additions & 4 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
import type { Metadata } from "next";
import { Titillium_Web } from "next/font/google";

import type { PropsWithChildren } from "react";

import { Providers } from "lib/providers";
import { Footer } from "components/shared/footer";
import { Header } from "components/shared/header";
import { Providers } from "components/shared/providers";

import "styles/normalize.css";
import "styles/main.css";
import "styles/ionicons.min.css";
import "styles/tailwind.css";

export const metadata: Metadata = {
title: "Real World",
description: "real world project",
};

const titillium = Titillium_Web({
subsets: ["latin"],
weight: "400",
variable: "--titillium-web-font",
});

const RootLayout = ({ children }: PropsWithChildren) => {
return (
<html lang="en">
<html lang="en" className={titillium.variable}>
<Providers>
<body>{children}</body>
<body>
<Header />
{children}
<Footer />
</body>
</Providers>
</html>
);
Expand Down
5 changes: 0 additions & 5 deletions app/page.tsx

This file was deleted.

43 changes: 43 additions & 0 deletions components/(home)/article-list-item/article-list-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Avatar } from "components/shared/ui/avatar";
import { Button } from "components/shared/ui/button";
import { ListItem } from "components/shared/ui/list-item";
import { Tags } from "components/shared/ui/tags";

export const ArticleListItem = () => {
return (
<ListItem.Root>
<Avatar.Root>
<Avatar.Anchor href="/profile/eric-simons">
<Avatar.Image src="http://i.imgur.com/Qr71crq.jpg" alt="" />
</Avatar.Anchor>

<Avatar.Info>
<Avatar.Anchor href="/profile/eric-simons">
<Avatar.Name>Eric Simons</Avatar.Name>
</Avatar.Anchor>

<Avatar.Description>January 20th</Avatar.Description>
</Avatar.Info>

<div className="pull-xs-right">
<Button outline>
<i className="ion-heart" /> 29
</Button>
</div>
</Avatar.Root>

<ListItem.Content href="/article/how-to-build-webapps-that-scale">
<ListItem.Title>How to build webapps that scale</ListItem.Title>

<ListItem.Description>This is the description for the post.</ListItem.Description>

<span>Read more...</span>

<Tags.Root>
<Tags.Item outline>realworld</Tags.Item>
<Tags.Item outline>implementations</Tags.Item>
</Tags.Root>
</ListItem.Content>
</ListItem.Root>
);
};
1 change: 1 addition & 0 deletions components/(home)/article-list-item/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ArticleListItem } from "./article-list-item";
10 changes: 10 additions & 0 deletions components/(home)/banner/banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const Banner = () => {
return (
<div className="banner">
<div className="container">
<h1 className="logo-font">conduit</h1>
<p>A place to share your knowledge.</p>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions components/(home)/banner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Banner } from "./banner";
31 changes: 31 additions & 0 deletions components/(home)/feed/feed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Pagination } from "components/shared/ui/pagination";
import { Tabs } from "components/shared/ui/tabs";

import { ArticleListItem } from "../article-list-item";

export const Feed = () => {
return (
<div className="col-md-9">
<Tabs.Root defaultValue="2">
<Tabs.List>
<Tabs.Trigger value="1">Your Feed</Tabs.Trigger>
<Tabs.Trigger value="2">Global Feed</Tabs.Trigger>
</Tabs.List>

<Tabs.Content value="1">
<ArticleListItem />
</Tabs.Content>

<Tabs.Content value="2">
<ArticleListItem />
<ArticleListItem />
<ArticleListItem />
<ArticleListItem />
<ArticleListItem />
</Tabs.Content>
</Tabs.Root>

<Pagination total={10} />
</div>
);
};
18 changes: 18 additions & 0 deletions components/(home)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Banner } from "./banner";
import { Feed } from "./feed/feed";
import { SideBar } from "./side-bar";

export const Home = () => {
return (
<div className="home-page">
<Banner />

<div className="page container">
<div className="row">
<Feed />
<SideBar />
</div>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions components/(home)/side-bar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SideBar } from "./side-bar";
15 changes: 15 additions & 0 deletions components/(home)/side-bar/side-bar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Tags } from "components/shared/ui/tags";

export const SideBar = () => {
return (
<div className="col-md-3">
<div className="sidebar">
<p>Popular Tags</p>

<Tags.Root as="div">
<Tags.Item as="a">tag</Tags.Item>
</Tags.Root>
</div>
</div>
);
};
15 changes: 15 additions & 0 deletions components/shared/footer/footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const Footer = () => {
return (
<footer>
<div className="container">
<a href="/" className="logo-font">
conduit
</a>
<span className="attribution">
An interactive learning project from <a href="https://thinkster.io">Thinkster</a>. Code &amp; design licensed
under MIT.
</span>
</div>
</footer>
);
};
1 change: 1 addition & 0 deletions components/shared/footer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Footer } from "./footer";
28 changes: 28 additions & 0 deletions components/shared/header/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const Header = () => {
return (
<nav className="navbar navbar-light">
<div className="container">
<a className="navbar-brand" href="/">
conduit
</a>
<ul className="nav navbar-nav pull-xs-right">
<li className="nav-item">
<a className="nav-link active" href="/">
Home
</a>
</li>
<li className="nav-item">
<a className="nav-link" href="/login">
Sign in
</a>
</li>
<li className="nav-item">
<a className="nav-link" href="/register">
Sign up
</a>
</li>
</ul>
</div>
</nav>
);
};
1 change: 1 addition & 0 deletions components/shared/header/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Header } from "./header";
File renamed without changes.
16 changes: 16 additions & 0 deletions components/shared/ui/avatar/anchor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Link from "next/link";

import { forwardRef } from "react";
import type { ComponentProps, ComponentPropsWithoutRef } from "react";

import type { Override } from "types/utilities";

type Props = Override<ComponentPropsWithoutRef<"a">, ComponentProps<typeof Link>>;

export const Anchor = forwardRef<HTMLAnchorElement, Props>(({ children, ...rest }, ref) => {
return (
<Link ref={ref} {...rest}>
{children}
</Link>
);
});
14 changes: 14 additions & 0 deletions components/shared/ui/avatar/description.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { ComponentPropsWithoutRef } from "react";
import { forwardRef } from "react";

import { clsx } from "lib/clsx";

type Props = ComponentPropsWithoutRef<"span">;

export const Description = forwardRef<HTMLSpanElement, Props>(({ children, className, ...rest }, ref) => {
return (
<span ref={ref} {...rest} className={clsx("date", className)}>
{children}
</span>
);
});
12 changes: 12 additions & 0 deletions components/shared/ui/avatar/image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import NextImage from "next/image";

import type { ComponentProps, ComponentPropsWithoutRef } from "react";
import { forwardRef } from "react";

import type { Override } from "types/utilities";

type Props = Override<ComponentPropsWithoutRef<"img">, ComponentProps<typeof NextImage>>;

export const Image = forwardRef<HTMLImageElement, Props>(({ ...rest }, ref) => {
return <NextImage ref={ref} {...rest} width={32} height={32} />;
});
15 changes: 15 additions & 0 deletions components/shared/ui/avatar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Anchor } from "./anchor";
import { Description } from "./description";
import { Image } from "./image";
import { Info } from "./info";
import { Name } from "./name";
import { Root } from "./root";

export const Avatar = {
Root,
Anchor,
Image,
Info,
Name,
Description,
};
14 changes: 14 additions & 0 deletions components/shared/ui/avatar/info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { ComponentPropsWithoutRef } from "react";
import { forwardRef } from "react";

import { clsx } from "lib/clsx";

type Props = ComponentPropsWithoutRef<"div">;

export const Info = forwardRef<HTMLDivElement, Props>(({ children, className, ...rest }, ref) => {
return (
<div ref={ref} {...rest} className={clsx("info", className)}>
{children}
</div>
);
});
14 changes: 14 additions & 0 deletions components/shared/ui/avatar/name.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { ComponentPropsWithoutRef } from "react";
import { forwardRef } from "react";

import { clsx } from "lib/clsx";

type Props = ComponentPropsWithoutRef<"span">;

export const Name = forwardRef<HTMLSpanElement, Props>(({ children, className, ...rest }, ref) => {
return (
<span ref={ref} {...rest} className={clsx("author", className)}>
{children}
</span>
);
});
14 changes: 14 additions & 0 deletions components/shared/ui/avatar/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { ComponentPropsWithoutRef } from "react";
import { forwardRef } from "react";

import { clsx } from "lib/clsx";

type Props = ComponentPropsWithoutRef<"div">;

export const Root = forwardRef<HTMLDivElement, Props>(({ children, className, ...rest }, ref) => {
return (
<div ref={ref} {...rest} className={clsx("article-meta", className)}>
{children}
</div>
);
});
30 changes: 30 additions & 0 deletions components/shared/ui/button/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { forwardRef, type ComponentPropsWithoutRef } from "react";

import { clsx } from "lib/clsx";
import type { Override } from "types/utilities";

type Variant = "primary" | "secondary" | "info" | "success" | "warning" | "danger";

type Size = "sm" | "lg";

type BaseProps = {
variant?: Variant;
size?: Size;
outline?: boolean;
};

type Props = Override<ComponentPropsWithoutRef<"button">, BaseProps>;

export const Button = forwardRef<HTMLButtonElement, Props>(
({ children, className, variant = "primary", size = "sm", outline = false, ...rest }, ref) => {
return (
<button
ref={ref}
{...rest}
className={clsx("btn", outline ? `btn-outline-${variant}` : `btn-${variant}`, `btn-${size}`, className)}
>
{children}
</button>
);
},
);
1 change: 1 addition & 0 deletions components/shared/ui/button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button } from "./button";
17 changes: 17 additions & 0 deletions components/shared/ui/list-item/content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Link from "next/link";

import { forwardRef } from "react";
import type { ComponentProps, ComponentPropsWithoutRef } from "react";

import { clsx } from "lib/clsx";
import type { Override } from "types/utilities";

type Props = Override<ComponentPropsWithoutRef<"a">, ComponentProps<typeof Link>>;

export const Content = forwardRef<HTMLAnchorElement, Props>(({ children, className, ...rest }, ref) => {
return (
<Link ref={ref} {...rest} className={clsx("preview-link", className)}>
{children}
</Link>
);
});
Loading