Skip to content

Commit

Permalink
Merge pull request #447 from Marukome0743/pr447
Browse files Browse the repository at this point in the history
♻️refactor: rename menu
  • Loading branch information
Marukome0743 authored Jul 18, 2024
2 parents 9a737aa + d0894a2 commit 1786d00
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { ABOUT } from "@/app/lib/constant"
import type React from "react"

export default function About(): React.JSX.Element {

Check warning on line 5 in app/about/page.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/style/noDefaultExport

Avoid default exports.
return <Heading navigation={ABOUT} />
return <Heading menu={ABOUT} />
}
7 changes: 3 additions & 4 deletions app/components/button/scrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use client"

import { ChevronDoubleUpIcon } from "@heroicons/react/24/solid"
import { useEffect, useRef, useState } from "react"
import { type RefObject, useEffect, useRef, useState } from "react"
import type React from "react"

export function ScrollToTop(): React.JSX.Element {
const ref: React.RefObject<HTMLButtonElement> =
useRef<HTMLButtonElement>(null)
const ref: RefObject<HTMLButtonElement> = useRef<HTMLButtonElement>(null)
const scrollBtn: HTMLButtonElement = ref.current as HTMLButtonElement
const [scrollY, setScrollY] = useState<number>(0)
const [isScrollDown, setIsScrollDown] = useState<boolean>(false)
Expand All @@ -27,7 +26,7 @@ export function ScrollToTop(): React.JSX.Element {
}
})

function scrollToTop() {
function scrollToTop(): void {
scrollBtn.classList.remove("fade-in-up")
scrollBtn.classList.add("fade-out-down")
window.scrollTo({ top: 0, behavior: "smooth" })
Expand Down
26 changes: 13 additions & 13 deletions app/components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"

import type { Theme } from "@/app/interfaces/theme"
import { SITE_TITLE, navigation } from "@/app/lib/constant"
import { NAVIGATION, SITE_TITLE } from "@/app/lib/constant"
import {
Bars3CenterLeftIcon,
ChevronDownIcon,
Expand Down Expand Up @@ -77,7 +77,7 @@ export function Header(): React.JSX.Element {
</Link>
</div>
<nav className="navbar-center hidden lg:flex">
<NavItems />
<Navigation />
</nav>
<div className="navbar-end">
<ThemeController />
Expand All @@ -94,11 +94,11 @@ function DropdownMenu(): React.JSX.Element {
</div>
<nav>
<ul className="menu menu-sm dropdown-content z-10 mt-3 w-52 rounded-box bg-base-100 p-2 shadow">
{navigation.map((item) => (
<li key={item.name}>
<Link href={item.href} className="font-bold">
<item.icon className={`size-5 ${item.color}`} />
{item.name}
{NAVIGATION.map((menu) => (
<li key={menu.name}>
<Link href={menu.href} className="font-bold">
<menu.icon className={`size-5 ${menu.color}`} />
{menu.name}
</Link>
</li>
))}
Expand All @@ -108,14 +108,14 @@ function DropdownMenu(): React.JSX.Element {
)
}

function NavItems(): React.JSX.Element {
function Navigation(): React.JSX.Element {
return (
<ul className="menu menu-horizontal px-1">
{navigation.map((item) => (
<li key={item.name} className="hover:scale-110">
<Link href={item.href} className="font-bold">
<item.icon className={`size-5 ${item.color}`} />
{item.name}
{NAVIGATION.map((menu) => (
<li key={menu.name} className="hover:scale-110">
<Link href={menu.href} className="font-bold">
<menu.icon className={`size-5 ${menu.color}`} />
{menu.name}
</Link>
</li>
))}
Expand Down
24 changes: 8 additions & 16 deletions app/components/layout/heading.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
import type { Navigation } from "@/app/interfaces/navigation"
import type { Menu } from "@/app/interfaces/menu"
import { HomeIcon } from "@heroicons/react/24/solid"
import Link from "next/link"
import type React from "react"

export function Heading({
navigation,
}: Readonly<{ navigation: Navigation }>): React.JSX.Element {
export function Heading({ menu }: Readonly<{ menu: Menu }>): React.JSX.Element {
return (
<section>
<div className="max-w-fit mx-auto">
<h1 className="typing font-bold text-3xl">
<navigation.icon
className={`inline size-9 mr-1 mb-1 ${navigation.color}`}
/>
{navigation.name}
<menu.icon className={`inline size-9 mr-1 mb-1 ${menu.color}`} />
{menu.name}
</h1>
</div>
<Breadcrumb crumb={navigation} />
<Breadcrumb menu={menu} />
</section>
)
}

function Breadcrumb({
crumb,
}: Readonly<{ crumb: Navigation }>): React.JSX.Element {
function Breadcrumb({ menu }: Readonly<{ menu: Menu }>): React.JSX.Element {
return (
<div className="text-sm breadcrumbs">
<ul>
Expand All @@ -34,10 +28,8 @@ function Breadcrumb({
</Link>
</li>
<li>
<Link href={crumb.href}>
<crumb.icon className={`size-5 mr-1 ${crumb.color}`} />
{crumb.name}
</Link>
<menu.icon className={`size-5 mr-1 ${menu.color}`} />
{menu.name}
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/contact/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { CONTACT } from "@/app/lib/constant"
import type React from "react"

export default function Contact(): React.JSX.Element {

Check warning on line 5 in app/contact/page.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/style/noDefaultExport

Avoid default exports.
return <Heading navigation={CONTACT} />
return <Heading menu={CONTACT} />
}
2 changes: 1 addition & 1 deletion app/info/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { INFO } from "@/app/lib/constant"
import type React from "react"

export default function Info(): React.JSX.Element {

Check warning on line 5 in app/info/page.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/style/noDefaultExport

Avoid default exports.
return <Heading navigation={INFO} />
return <Heading menu={INFO} />
}
2 changes: 1 addition & 1 deletion app/interfaces/navigation.ts → app/interfaces/menu.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type React from "react"

export type Navigation = {
export type Menu = {
name: string
href: string
color: string
Expand Down
12 changes: 6 additions & 6 deletions app/lib/constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Navigation } from "@/app/interfaces/navigation"
import type { Menu } from "@/app/interfaces/menu"
import {
EnvelopeIcon,
NewspaperIcon,
Expand All @@ -8,29 +8,29 @@ import {

export const SITE_TITLE: string = "OPENUP ラボ滝沢"

export const INFO: Navigation = {
export const INFO: Menu = {
name: "最新情報",
href: "/info",
color: "text-primary",
icon: NewspaperIcon,
}
export const ABOUT: Navigation = {
export const ABOUT: Menu = {
name: "ラボ滝沢とは?",
href: "/about",
color: "text-accent",
icon: QuestionMarkCircleIcon,
}
export const MEMBER: Navigation = {
export const MEMBER: Menu = {
name: "メンバー",
href: "/member",
color: "text-secondary",
icon: UserGroupIcon,
}
export const CONTACT: Navigation = {
export const CONTACT: Menu = {
name: "お問い合わせ",
href: "/contact",
color: "text-info",
icon: EnvelopeIcon,
}

export const navigation: Navigation[] = [INFO, ABOUT, MEMBER, CONTACT] as const
export const NAVIGATION: Menu[] = [INFO, ABOUT, MEMBER, CONTACT] as const
2 changes: 1 addition & 1 deletion app/member/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { MEMBER } from "@/app/lib/constant"
import type React from "react"

export default function Member(): React.JSX.Element {

Check warning on line 5 in app/member/page.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/style/noDefaultExport

Avoid default exports.
return <Heading navigation={MEMBER} />
return <Heading menu={MEMBER} />
}
Binary file modified bun.lockb
Binary file not shown.

0 comments on commit 1786d00

Please sign in to comment.