Skip to content

Commit

Permalink
chore: convention update
Browse files Browse the repository at this point in the history
  • Loading branch information
henrynoowah committed May 6, 2024
1 parent dfd54fc commit a12109d
Show file tree
Hide file tree
Showing 26 changed files with 91 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const metadata: Metadata = {
}
}

import Header from '@/components/common/Header/Header'
import Header from '@/components/common/layouts/header/Header'
import { Metadata } from 'next'
import { ReactNode } from 'react'

Expand Down
2 changes: 1 addition & 1 deletion src/app/about/page.tsx → src/app/(routes)/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MarkdowRenderer } from '@/components/common/Markdowns'
import { MarkdowRenderer } from '@/components/common/markdowns'
import React from 'react'

const about = `**👋 Hi, I’m @henrynoowah**
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/layout.tsx → src/app/(routes)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Metadata } from 'next'
import './globals.css'
import 'src/app/styles/globals.css'

export const metadata: Metadata = {
title: 'NoowaH Blog',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable react-hooks/exhaustive-deps */
'use client'

import PostCard from '@/components/common/Cards/PostCard'
import PostCard_skeleton from '@/components/common/Cards/PostCard_skeleton'
import PostCard from '@/components/common/cards/PostCard'
import PostCard_skeleton from '@/components/common/cards/PostCard_skeleton'
import { getPosts } from '@/services/posts'
import { XMarkIcon } from '@heroicons/react/24/solid'
import dynamic from 'next/dynamic'
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MarkdowRenderer } from '@/components/common/Markdowns'
import { MarkdowRenderer } from '@/components/common/markdowns'
import { getPost } from '@/services/posts'
import { Metadata } from 'next/types'

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const metadata: Metadata = {
}
}

import Header from '@/components/common/Header/Header'
import Header from '@/components/common/layouts/header/Header'
import { Metadata } from 'next'
import { ReactNode } from 'react'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PostCard_skeleton from '@/components/common/Cards/PostCard_skeleton'
import PostCard_skeleton from '@/components/common/cards/PostCard_skeleton'

const LoadingPosts = () => {
return (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/works/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const metadata: Metadata = {
}
}

import Header from '@/components/common/Header/Header'
import Header from '@/components/common/layouts/header/Header'
import { Metadata } from 'next'
import { ReactNode } from 'react'

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Link from 'next/link'
import packageData from 'package.json'
import Button from '../Button'
import ThemeToggle from '../ThemeToggle/ThemeToggle'
import Button from '../../Button'
import Nav_mobile from './Nav_mobile'
import ShowSearchButton from './ShowSearchButton'
import { Suspense } from 'react'
import ThemeToggle from '../../themeToggle/ThemeToggle'

const HEADER_HEIGHT = 72

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { ChevronRightIcon } from '@heroicons/react/24/solid'
import Link from 'next/link'
import { useState } from 'react'
import Button from '../Button'
import Button from '../../Button'
import Button_nav from './Button_nav'

interface Params {
Expand Down
79 changes: 79 additions & 0 deletions src/components/common/layouts/header/SearchButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use client'

import { MagnifyingGlassIcon } from '@heroicons/react/24/solid'
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
import { FormEventHandler, useRef, useState } from 'react'

const SearchButton = () => {
const pathname = usePathname()
const searchParams = useSearchParams()
const router = useRouter()

const search = searchParams.get('search')

const [inputValue, setInputValue] = useState<string>(search ?? '')

const [showInput, setShowInput] = useState<boolean>(false)

const [isFocused, setIsFocused] = useState<boolean>(false)

const inputRef = useRef<HTMLInputElement>(null)

const handleSubmit: FormEventHandler = (e) => {
e.preventDefault()
if (inputValue !== null && inputValue !== '') {
router.push(`/posts?search=${inputValue}`)
} else {
router.push(`${pathname}`)
}
}

return pathname.startsWith('/posts') ? (
<form onSubmit={handleSubmit} className="flex justify-between relative group transition duration-300 ease-in-out">
<div
className={`h-[36px] relative duration-300 ease-in-out ring-1 ring-inset ring-light rounded-full overflow-hidden ${
showInput ? 'w-[160px] md:w-[240px]' : 'w-[36px]'
}`}
>
<input
ref={inputRef}
placeholder="Search Post"
onChange={(e) => setInputValue(e.target.value)}
onMouseDown={() => setIsFocused(true)}
onBlur={() => {
if (!inputValue) {
setIsFocused(false)
setShowInput(false)
}
}}
type="search"
className={[
`absolute w-full h-full items-center placeholder:italic placeholder:text-sm`,
`outline-none focus:outline-none transform`,
`px-4 text-light/60 bg-transparent`,
showInput ? `translate-x-0 pointer-events-auto ` : `translate-x-[100%] pointer-events-none hidden`
].join(' ')}
/>

<button
type="button"
className={`absolute right-0 w-[36px] h-[36px] flex justify-center items-center ring-inset ring-light rounded-full`}
onClick={() => {
if (!showInput) {
setShowInput(true)
}
}}
onBlur={() => {
if (!isFocused && !inputValue) {
setShowInput(false)
}
}}
>
<MagnifyingGlassIcon width={18} height={18} className="text-light z-20" />
</button>
</div>
</form>
) : null
}

export default SearchButton
File renamed without changes.

0 comments on commit a12109d

Please sign in to comment.