From fb3baa1de8dd17ccb2eea3293057a8892f5255c3 Mon Sep 17 00:00:00 2001 From: Yee Kit Date: Thu, 1 Feb 2024 16:38:48 +0800 Subject: [PATCH] Refactored Code (#12) * Refactored Code --- .github/workflows/check-file-size.yml | 6 +++--- .github/workflows/pipeline.yml | 2 -- frontend/app/components/chat-section.tsx | 2 +- frontend/app/components/footer.tsx | 4 ++-- frontend/app/components/header.tsx | 10 +++++----- frontend/app/components/query-section.tsx | 2 +- frontend/app/components/search-section.tsx | 1 - frontend/app/components/ui/button.tsx | 2 +- frontend/app/components/ui/input.tsx | 2 +- frontend/app/components/ui/search/search-input.tsx | 4 ++-- .../app/components/ui/search/search-results.tsx | 4 ++-- frontend/app/components/ui/search/useSearch.tsx | 2 +- frontend/app/layout.tsx | 14 +++++++++----- frontend/app/page.tsx | 2 +- frontend/middleware.ts | 2 +- frontend/public/robots.txt | 2 -- frontend/tailwind.config.ts | 3 +-- 17 files changed, 31 insertions(+), 33 deletions(-) diff --git a/.github/workflows/check-file-size.yml b/.github/workflows/check-file-size.yml index 8c4578f..683bfca 100644 --- a/.github/workflows/check-file-size.yml +++ b/.github/workflows/check-file-size.yml @@ -4,9 +4,9 @@ on: # On pull requests to the main branch pull_request: branches: [main] - # On pushes to the main branch - push: - branches: [main] + # # Or directly On pushes to the main branch + # push: + # branches: [main] # to run this workflow manually from the Actions tab workflow_dispatch: # to run this workflow from another workflow diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 399123c..fe26341 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -8,8 +8,6 @@ on: # Test, Build and Deploy the app jobs: - check-file-size: - uses: ./.github/workflows/check-file-size.yml test-build-node-js-app: uses: ./.github/workflows/node-js-tests.yml test-build-python-package: diff --git a/frontend/app/components/chat-section.tsx b/frontend/app/components/chat-section.tsx index 04098fc..50bbfe3 100644 --- a/frontend/app/components/chat-section.tsx +++ b/frontend/app/components/chat-section.tsx @@ -1,7 +1,7 @@ "use client"; import { useChat } from "ai/react"; -import { ChatInput, ChatMessages } from "./ui/chat"; +import { ChatInput, ChatMessages } from "@/app/components/ui/chat"; export default function ChatSection() { const { diff --git a/frontend/app/components/footer.tsx b/frontend/app/components/footer.tsx index 4c99c46..7df23ce 100644 --- a/frontend/app/components/footer.tsx +++ b/frontend/app/components/footer.tsx @@ -1,7 +1,7 @@ "use client"; -import { FooterNavLink } from "./ui/navlink"; -import { IconGitHub } from "./ui/icons"; +import { FooterNavLink } from "@/app/components/ui/navlink"; +import { IconGitHub } from "@/app/components/ui/icons"; import { Text, Cookie } from "lucide-react"; export default function Footer() { diff --git a/frontend/app/components/header.tsx b/frontend/app/components/header.tsx index 49d6a41..eac4903 100644 --- a/frontend/app/components/header.tsx +++ b/frontend/app/components/header.tsx @@ -7,8 +7,8 @@ import { useEffect, useState } from "react"; import { useMedia } from 'react-use'; import useSWR from 'swr'; import logo from '@/public/smart-retrieval-logo.webp'; -import { HeaderNavLink } from './ui/navlink'; -import { MobileMenu } from './ui/mobilemenu'; +import { HeaderNavLink } from '@/app/components/ui/navlink'; +import { MobileMenu } from '@/app/components/ui/mobilemenu'; const MobileMenuItems = [ { @@ -125,7 +125,7 @@ export default function Header() { > {isMobileMenuOpen ? ( - + ) : ( @@ -133,8 +133,6 @@ export default function Header() { )} - {/* Mobile menu component */} - setMobileMenuOpen(false)} logoSrc={logo} items={MobileMenuItems} />
@@ -201,6 +199,8 @@ export default function Header() {
+ {/* Mobile menu component */} + setMobileMenuOpen(false)} logoSrc={logo} items={MobileMenuItems} /> ); diff --git a/frontend/app/components/query-section.tsx b/frontend/app/components/query-section.tsx index 736539e..bda4cf2 100644 --- a/frontend/app/components/query-section.tsx +++ b/frontend/app/components/query-section.tsx @@ -1,7 +1,7 @@ "use client"; import { useChat } from "ai/react"; -import { ChatInput, ChatMessages } from "./ui/chat"; +import { ChatInput, ChatMessages } from "@/app/components/ui/chat"; export default function QuerySection() { const { diff --git a/frontend/app/components/search-section.tsx b/frontend/app/components/search-section.tsx index df41696..0da5e04 100644 --- a/frontend/app/components/search-section.tsx +++ b/frontend/app/components/search-section.tsx @@ -1,7 +1,6 @@ // SearchSection.tsx "use client"; -import { SearchResult } from "@/app/components/ui/search/search-types"; import { useState, ChangeEvent, FormEvent } from "react"; import useSearch from "@/app/components/ui/search/useSearch"; import SearchResults from "@/app/components/ui/search/search-results"; diff --git a/frontend/app/components/ui/button.tsx b/frontend/app/components/ui/button.tsx index bfd16d0..f6424c9 100644 --- a/frontend/app/components/ui/button.tsx +++ b/frontend/app/components/ui/button.tsx @@ -1,7 +1,7 @@ import { Slot } from "@radix-ui/react-slot"; import { cva, type VariantProps } from "class-variance-authority"; import { forwardRef } from "react"; -import { cn } from "./lib/utils"; +import { cn } from "@/app/components/ui/lib/utils"; const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", diff --git a/frontend/app/components/ui/input.tsx b/frontend/app/components/ui/input.tsx index f955797..f9dcec0 100644 --- a/frontend/app/components/ui/input.tsx +++ b/frontend/app/components/ui/input.tsx @@ -1,6 +1,6 @@ import { forwardRef } from "react"; -import { cn } from "./lib/utils"; +import { cn } from "@/app/components/ui/lib/utils"; export interface InputProps extends React.InputHTMLAttributes {} diff --git a/frontend/app/components/ui/search/search-input.tsx b/frontend/app/components/ui/search/search-input.tsx index 31389fd..466950b 100644 --- a/frontend/app/components/ui/search/search-input.tsx +++ b/frontend/app/components/ui/search/search-input.tsx @@ -1,8 +1,8 @@ // SearchInput.tsx import { ChangeEvent, FormEvent } from "react"; -import { Button } from "../button"; -import { Input } from "../input"; +import { Button } from "@/app/components/ui/button"; +import { Input } from "@/app/components/ui/input"; import { Search } from "lucide-react"; interface SearchInputProps { diff --git a/frontend/app/components/ui/search/search-results.tsx b/frontend/app/components/ui/search/search-results.tsx index 1b159a3..60b1005 100644 --- a/frontend/app/components/ui/search/search-results.tsx +++ b/frontend/app/components/ui/search/search-results.tsx @@ -1,5 +1,5 @@ -import { SearchResult } from "./search-types"; -import { IconSpinner } from "../icons"; +import { SearchResult } from "@/app/components/ui/search/search-types" +import { IconSpinner } from "@/app/components/ui/icons"; import { Fragment, useState } from "react"; import { ArrowDownFromLine, ArrowUpFromLine, Copy } from "lucide-react"; import { ToastContainer, toast } from 'react-toastify'; diff --git a/frontend/app/components/ui/search/useSearch.tsx b/frontend/app/components/ui/search/useSearch.tsx index d6cd36e..6b0c2a1 100644 --- a/frontend/app/components/ui/search/useSearch.tsx +++ b/frontend/app/components/ui/search/useSearch.tsx @@ -1,7 +1,7 @@ "use client"; import { useState, useEffect } from "react"; -import { SearchResult } from "./search-types"; +import { SearchResult } from "@/app/components/ui/search/search-types"; interface UseSearchResult { searchResults: SearchResult[]; diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsx index a8a9a1d..033429c 100644 --- a/frontend/app/layout.tsx +++ b/frontend/app/layout.tsx @@ -1,12 +1,16 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; -import "./globals.css"; -import { Providers } from './providers' +import "@/app/globals.css"; +import { Providers } from "@/app/providers"; import Header from "@/app/components/header"; import Footer from "@/app/components/footer"; import Main from "@/app/components/ui/main-container"; -const inter = Inter({ subsets: ["latin"] }); +const inter = Inter({ + subsets: ['latin'], + display: 'swap', + variable: '--font-inter', +}) export const metadata: Metadata = { title: "Smart Retrieval", @@ -28,8 +32,8 @@ export default function RootLayout({ children: React.ReactNode; }) { return ( - - + +
diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 913c94e..785f677 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -1,5 +1,5 @@ import Home from '@/app/components/ui/home/client-component'; -import { Metadata } from 'next'; +import type { Metadata } from "next"; export const metadata: Metadata = { // Google Search Console HTML Tag Verification diff --git a/frontend/middleware.ts b/frontend/middleware.ts index 7464ca5..fa26b54 100644 --- a/frontend/middleware.ts +++ b/frontend/middleware.ts @@ -6,5 +6,5 @@ export { default } from "next-auth/middleware" // Ensure auth is required for all except the following paths export const config = { - matcher: ['/((?!api/auth|_next/static|_next/image|favicon.ico|about|sign-in|privacy-policy|terms-of-service|sitemap.xml|robots.txt).+)'] + matcher: ['/((?!api/auth|_next/static|_next/image|favicon.ico|favicon-16x16.png|apple-touch-icon.png|about|sign-in|privacy-policy|terms-of-service|sitemap.xml|robots.txt).+)'] }; diff --git a/frontend/public/robots.txt b/frontend/public/robots.txt index 458b1bd..7f0b75c 100644 --- a/frontend/public/robots.txt +++ b/frontend/public/robots.txt @@ -1,5 +1,3 @@ -//robots.txt - # Block all crawlers for /accounts User-agent: * Disallow: /accounts diff --git a/frontend/tailwind.config.ts b/frontend/tailwind.config.ts index 363f782..a86fd49 100644 --- a/frontend/tailwind.config.ts +++ b/frontend/tailwind.config.ts @@ -1,5 +1,4 @@ import type { Config } from "tailwindcss"; -import { fontFamily } from "tailwindcss/defaultTheme"; const config: Config = { darkMode: ["class"], @@ -59,7 +58,7 @@ const config: Config = { sm: "calc(var(--radius) - 4px)", }, fontFamily: { - sans: ["var(--font-sans)", ...fontFamily.sans], + sans: ["var(--font-inter)"], }, keyframes: { "accordion-down": {