Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsukiniwa committed Feb 28, 2024
1 parent 173bd49 commit 34ef937
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 7 deletions.
6 changes: 5 additions & 1 deletion admin/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import { NavigationHeader } from "@/components/NavigationHeader";
import { Sidebar } from "@/components/Sidebar";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -19,7 +20,10 @@ export default function RootLayout({
<html lang="en">
<body className={inter.className}>
<NavigationHeader />
{children}
<div className="grid grid-cols-9 gap-4 p-4 bg-gray-50">
<Sidebar />
{children}
</div>
</body>
</html>
);
Expand Down
26 changes: 26 additions & 0 deletions admin/src/app/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @link https://flowbite.com/docs/components/spinner
*/
export default function Loading() {
return (
<div role="status" className="min-h-dvh px-4 md:px-8 py-4 max-w-[80%]">
<svg
aria-hidden="true"
className="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-green-600"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span className="sr-only">Loading top page...</span>
</div>
);
}
11 changes: 7 additions & 4 deletions admin/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { CategoryLabel } from "@/components/CategoryLabel";
import { QuestionCard } from "@/components/QuestionCard";
import { getCategories, getQuestions } from "@/lib/data";

export const dynamic = "force-dynamic";

export default async function Home() {
const categories = await getCategories();
const questions = await getQuestions();

return (
<div>
<div className="px-4 md:px-8 py-4 bg-green-50">
<div className="col-span-9 sm:col-span-7">
<div className="px-4 md:px-8 py-4 bg-green-50 rounded-xl mb-4">
<h2 className="my-4 pl-3 text-xl font-bold border-l-4 border-green-300">
カテゴリから探す
</h2>
Expand All @@ -18,7 +20,8 @@ export default async function Home() {
))}
</div>
</div>
<div className="px-4 md:px-8 py-4 bg-gray-100">

<div className="px-4 md:px-8 py-4 bg-gray-100 rounded-xl mb-4">
<h2 className="my-4 pl-3 text-xl font-bold border-l-4 border-green-300">
人気の質問から探す
</h2>
Expand All @@ -33,7 +36,7 @@ export default async function Home() {
))}
</div>
</div>
<div className="px-4 md:px-8 py-4 bg-gray-100">
<div className="px-4 md:px-8 py-4 bg-gray-100 rounded-xl">
<h2 className="my-4 pl-3 text-xl font-bold border-l-4 border-green-300">
最新の質問から探す
</h2>
Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/QuestionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const QuestionCard = ({ id, title, content }: Props) => {
<p className="font-normal text-gray-700">{content}</p>
<Link
href={`/questions/${id}`}
className="md:w-1/3 mt-4 text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:ring-green-300 font-medium rounded text-sm px-3 py-2 text-center items-center"
className="md:w-1/2 mt-4 text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:ring-green-300 font-medium rounded text-sm px-3 py-2 text-center items-center"
>
Read more
</Link>
Expand Down
144 changes: 144 additions & 0 deletions admin/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
export const Sidebar = () => {
return (
<div className="hidden md:flex relative col-span-2 flex-col rounded-xl bg-white bg-clip-border p-4 text-gray-700 shadow-xl shadow-blue-gray-900/5">
<div className="p-4 mb-2">
<h5 className="block font-sans text-xl antialiased font-semibold leading-snug tracking-normal text-blue-gray-900">
Menu
</h5>
</div>
<nav className="flex min-w-[240px] flex-col gap-1 p-2 font-sans text-base font-normal text-blue-gray-700">
<div
role="button"
className="flex items-center w-full p-3 leading-tight transition-all rounded-lg outline-none text-start hover:bg-blue-gray-50 hover:bg-opacity-80 hover:text-blue-gray-900 focus:bg-blue-gray-50 focus:bg-opacity-80 focus:text-blue-gray-900 active:bg-blue-gray-50 active:bg-opacity-80 active:text-blue-gray-900"
>
<div className="grid mr-4 place-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
className="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M2.25 2.25a.75.75 0 000 1.5H3v10.5a3 3 0 003 3h1.21l-1.172 3.513a.75.75 0 001.424.474l.329-.987h8.418l.33.987a.75.75 0 001.422-.474l-1.17-3.513H18a3 3 0 003-3V3.75h.75a.75.75 0 000-1.5H2.25zm6.04 16.5l.5-1.5h6.42l.5 1.5H8.29zm7.46-12a.75.75 0 00-1.5 0v6a.75.75 0 001.5 0v-6zm-3 2.25a.75.75 0 00-1.5 0v3.75a.75.75 0 001.5 0V9zm-3 2.25a.75.75 0 00-1.5 0v1.5a.75.75 0 001.5 0v-1.5z"
clip-rule="evenodd"
></path>
</svg>
</div>
Dashboard
</div>
<div
role="button"
className="flex items-center w-full p-3 leading-tight transition-all rounded-lg outline-none text-start hover:bg-blue-gray-50 hover:bg-opacity-80 hover:text-blue-gray-900 focus:bg-blue-gray-50 focus:bg-opacity-80 focus:text-blue-gray-900 active:bg-blue-gray-50 active:bg-opacity-80 active:text-blue-gray-900"
>
<div className="grid mr-4 place-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
className="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M7.5 6v.75H5.513c-.96 0-1.764.724-1.865 1.679l-1.263 12A1.875 1.875 0 004.25 22.5h15.5a1.875 1.875 0 001.865-2.071l-1.263-12a1.875 1.875 0 00-1.865-1.679H16.5V6a4.5 4.5 0 10-9 0zM12 3a3 3 0 00-3 3v.75h6V6a3 3 0 00-3-3zm-3 8.25a3 3 0 106 0v-.75a.75.75 0 011.5 0v.75a4.5 4.5 0 11-9 0v-.75a.75.75 0 011.5 0v.75z"
clip-rule="evenodd"
></path>
</svg>
</div>
E-Commerce
</div>
<div
role="button"
className="flex items-center w-full p-3 leading-tight transition-all rounded-lg outline-none text-start hover:bg-blue-gray-50 hover:bg-opacity-80 hover:text-blue-gray-900 focus:bg-blue-gray-50 focus:bg-opacity-80 focus:text-blue-gray-900 active:bg-blue-gray-50 active:bg-opacity-80 active:text-blue-gray-900"
>
<div className="grid mr-4 place-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
className="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M6.912 3a3 3 0 00-2.868 2.118l-2.411 7.838a3 3 0 00-.133.882V18a3 3 0 003 3h15a3 3 0 003-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0017.088 3H6.912zm13.823 9.75l-2.213-7.191A1.5 1.5 0 0017.088 4.5H6.912a1.5 1.5 0 00-1.434 1.059L3.265 12.75H6.11a3 3 0 012.684 1.658l.256.513a1.5 1.5 0 001.342.829h3.218a1.5 1.5 0 001.342-.83l.256-.512a3 3 0 012.684-1.658h2.844z"
clip-rule="evenodd"
></path>
</svg>
</div>
Inbox
<div className="grid ml-auto place-items-center justify-self-end">
<div className="relative grid items-center px-2 py-1 font-sans text-xs font-bold uppercase rounded-full select-none whitespace-nowrap bg-blue-gray-500/20 text-blue-gray-900">
<span className="">14</span>
</div>
</div>
</div>
<div
role="button"
className="flex items-center w-full p-3 leading-tight transition-all rounded-lg outline-none text-start hover:bg-blue-gray-50 hover:bg-opacity-80 hover:text-blue-gray-900 focus:bg-blue-gray-50 focus:bg-opacity-80 focus:text-blue-gray-900 active:bg-blue-gray-50 active:bg-opacity-80 active:text-blue-gray-900"
>
<div className="grid mr-4 place-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
className="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M18.685 19.097A9.723 9.723 0 0021.75 12c0-5.385-4.365-9.75-9.75-9.75S2.25 6.615 2.25 12a9.723 9.723 0 003.065 7.097A9.716 9.716 0 0012 21.75a9.716 9.716 0 006.685-2.653zm-12.54-1.285A7.486 7.486 0 0112 15a7.486 7.486 0 015.855 2.812A8.224 8.224 0 0112 20.25a8.224 8.224 0 01-5.855-2.438zM15.75 9a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z"
clip-rule="evenodd"
></path>
</svg>
</div>
Profile
</div>
<div
role="button"
className="flex items-center w-full p-3 leading-tight transition-all rounded-lg outline-none text-start hover:bg-blue-gray-50 hover:bg-opacity-80 hover:text-blue-gray-900 focus:bg-blue-gray-50 focus:bg-opacity-80 focus:text-blue-gray-900 active:bg-blue-gray-50 active:bg-opacity-80 active:text-blue-gray-900"
>
<div className="grid mr-4 place-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
className="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 00-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 00-2.282.819l-.922 1.597a1.875 1.875 0 00.432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 000 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 00-.432 2.385l.922 1.597a1.875 1.875 0 002.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 002.28-.819l.923-1.597a1.875 1.875 0 00-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 000-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 00-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 00-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 00-1.85-1.567h-1.843zM12 15.75a3.75 3.75 0 100-7.5 3.75 3.75 0 000 7.5z"
clip-rule="evenodd"
></path>
</svg>
</div>
Settings
</div>
<div
role="button"
className="flex items-center w-full p-3 leading-tight transition-all rounded-lg outline-none text-start hover:bg-blue-gray-50 hover:bg-opacity-80 hover:text-blue-gray-900 focus:bg-blue-gray-50 focus:bg-opacity-80 focus:text-blue-gray-900 active:bg-blue-gray-50 active:bg-opacity-80 active:text-blue-gray-900"
>
<div className="grid mr-4 place-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
className="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M12 2.25a.75.75 0 01.75.75v9a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM6.166 5.106a.75.75 0 010 1.06 8.25 8.25 0 1011.668 0 .75.75 0 111.06-1.06c3.808 3.807 3.808 9.98 0 13.788-3.807 3.808-9.98 3.808-13.788 0-3.808-3.807-3.808-9.98 0-13.788a.75.75 0 011.06 0z"
clip-rule="evenodd"
></path>
</svg>
</div>
Log Out
</div>
</nav>
</div>
);
};
3 changes: 2 additions & 1 deletion admin/src/lib/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const getCategories = async () => {
await new Promise((resolve) => setTimeout(resolve, 3000))
const res = await fetch('http://localhost:3000/categories', {
method: "GET",
headers: {
Expand Down Expand Up @@ -38,7 +39,7 @@ export const getQuestions = async () => {
}
}).then(res => res.json())

return res as {
return res.filter((_: any, index: number) => index < 6) as {
id: number,
title: string,
content: string
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/layouts/NavigationHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export const NavigationHeader = () => {
<div className="">
<div className="relative">
<button
type="button"
role="button"
title="button"
onClick={() => setOpenMenu(!openMenu)}
className="rounded-md bg-white focus:outline-none"
>
Expand Down

0 comments on commit 34ef937

Please sign in to comment.