From 3a8c07b5df70ae73cb3069df0bc58181536bf895 Mon Sep 17 00:00:00 2001 From: corgifist Date: Tue, 29 Jul 2025 03:30:06 +0300 Subject: [PATCH] fixed git commit hash parsing and no more eslint warnings --- next.config.ts | 8 +--- src/Dockerfile | 8 +++- src/app/globals.css | 6 +-- src/app/page.tsx | 8 ++-- src/app/settings/page.tsx | 15 ++++--- src/app/settings/storage/page.tsx | 1 - .../scroll-fading-title/ScrollFadingTitle.tsx | 3 +- .../SidebarTriggerAdjustable.tsx | 41 +++++++++++++------ src/lib/build.ts | 4 +- 9 files changed, 50 insertions(+), 44 deletions(-) diff --git a/next.config.ts b/next.config.ts index 0e7e874..d38d65e 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,14 +1,8 @@ import type { NextConfig } from "next"; -import { version } from "./package.json"; const nextConfig: NextConfig = { output: "standalone", - generateBuildId: () => (process.env.GIT_COMMIT || null), - env: { - BUILD_ID: process.env.GIT_COMMIT, - VERSION: version - } - + generateBuildId: () => (process.env.NEXT_PUBLIC_GIT_COMMIT ? process.env.NEXT_PUBLIC_GIT_COMMIT : null) }; export default nextConfig; diff --git a/src/Dockerfile b/src/Dockerfile index 7ae489e..7cf06dc 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -39,8 +39,12 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED=1 RUN \ - GIT_COMMIT=$(git rev-parse HEAD); \ - echo $GIT_COMMIT; \ + NEXT_PUBLIC_GIT_COMMIT=$(git log --pretty=format:"%H" -n 1); \ + echo GIT_COMMIT: $NEXT_PUBLIC_GIT_COMMIT; \ + echo "NEXT_PUBLIC_GIT_COMMIT=${NEXT_PUBLIC_GIT_COMMIT}" >> .env; \ + NEXT_PUBLIC_PACKAGE_VERSION="$(node -pe "require('./package.json')['version']")"; \ + echo PACKAGE_VERSION: $NEXT_PUBLIC_PACKAGE_VERSION; \ + echo "NEXT_PUBLIC_PACKAGE_VERSION=${NEXT_PUBLIC_PACKAGE_VERSION}" >> .env; \ if [ -f yarn.lock ]; then yarn run build; \ elif [ -f package-lock.json ]; then npm run build; \ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ diff --git a/src/app/globals.css b/src/app/globals.css index fa281e9..34102ac 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -69,7 +69,7 @@ body { main { width: 100%; - height: max(100vh, 100%); + height: 100%; } .dark body { @@ -153,8 +153,4 @@ main { body { @apply bg-background text-foreground; } -} - -@utility h-safe-area-inset-top { - height: env(safe-area-inset-top); } \ No newline at end of file diff --git a/src/app/page.tsx b/src/app/page.tsx index 489001f..7efdae9 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,11 +1,10 @@ "use client"; -import { SidebarTrigger } from "@/components/ui/sidebar"; -import { createContext, Dispatch, MouseEventHandler, ReactNode, SetStateAction, useContext, useEffect, useState } from "react"; +import { createContext, Dispatch, ReactNode, SetStateAction, useContext, useState } from "react"; import { useLiveQuery } from "dexie-react-hooks"; import { addProject, db, deleteProject } from "@/lib/db"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; -import { ALargeSmallIcon, ArrowDownAZIcon, ArrowDownIcon, ArrowUpAZIcon, ArrowUpIcon, CalendarArrowDownIcon, CalendarArrowUpIcon, CalendarIcon, ClockArrowDownIcon, ClockArrowUpIcon, ClockIcon, CopyIcon, EditIcon, EllipsisIcon, Grid2X2, Grid2X2CheckIcon, Grid2x2X, Grid2X2XIcon, Grid2x2XIcon, InfoIcon, ListCheckIcon, PencilIcon, PlusIcon, TrashIcon } from "lucide-react"; +import { ALargeSmallIcon, ArrowDownIcon, ArrowUpIcon, CalendarIcon, ClockIcon, CopyIcon, EditIcon, EllipsisIcon, Grid2X2CheckIcon, Grid2X2XIcon, InfoIcon, PencilIcon, PlusIcon, TrashIcon } from "lucide-react"; import { Toggle } from "@/components/ui/toggle"; import Search from "@/components/search"; import { useIsMobile } from "@/hooks/use-mobile"; @@ -32,7 +31,6 @@ import { Separator } from "@/components/ui/separator"; import StaticSidebarTrigger from "@/components/static-sidebar-trigger"; import SidebarTriggerAdjustable from "@/components/sidebar-trigger-adjustable"; import ScrollFadingTitle from "@/components/scroll-fading-title"; -import { fa } from "zod/v4/locales"; import AscendingCard from "@/components/ascending-card"; type SortingType = "byCreationDate" @@ -78,7 +76,7 @@ const SortingTypeMenuItem = ({ currentSortingType: SortingType setSortingType: Dispatch>, }) => ( - setSortingType(sortingType)}> + setSortingType(sortingType)}> {sortingTypeToString(sortingType)} ); diff --git a/src/app/settings/page.tsx b/src/app/settings/page.tsx index e1005db..e930586 100644 --- a/src/app/settings/page.tsx +++ b/src/app/settings/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { ChartPieIcon, ChevronRightIcon, InfoIcon } from "lucide-react"; -import { ReactNode, useEffect, useState } from "react"; +import { ChartPieIcon, ChevronRightIcon } from "lucide-react"; +import { ReactNode, } from "react"; import StaticSidebarTrigger from "@/components/static-sidebar-trigger"; import ScrollFadingTitle from "@/components/scroll-fading-title"; import SidebarTriggerAdjustable from "@/components/sidebar-trigger-adjustable"; @@ -32,25 +32,24 @@ export default function Settings(): ReactNode {
-
+
- +

Storage

-

Memory usage, media, cache etc.

+

Memory usage, media, cache etc.

+ `https://github.com/ClipFusion-org/clipfusion/commit/${getBuildID()}` + }> {getVersion()} ({getBuildID()})
diff --git a/src/app/settings/storage/page.tsx b/src/app/settings/storage/page.tsx index f1fb53e..d86cab4 100644 --- a/src/app/settings/storage/page.tsx +++ b/src/app/settings/storage/page.tsx @@ -9,7 +9,6 @@ import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import WideContainer from "@/components/wide-container"; import { useIsMobile } from "@/hooks/use-mobile"; -import { cn } from "@/lib/utils"; import { ArrowLeftIcon } from "lucide-react"; import { useRouter } from "next/navigation"; import { ReactNode, useEffect, useState } from "react"; diff --git a/src/components/scroll-fading-title/ScrollFadingTitle.tsx b/src/components/scroll-fading-title/ScrollFadingTitle.tsx index 8f5af25..5f78e4f 100644 --- a/src/components/scroll-fading-title/ScrollFadingTitle.tsx +++ b/src/components/scroll-fading-title/ScrollFadingTitle.tsx @@ -1,5 +1,4 @@ -import { cn } from "@/lib/utils"; -import { ComponentProps, useEffect, useRef, useState } from "react"; +import { ComponentProps, useEffect, useRef } from "react"; const easeFade = (x: number) => ( x === 0 ? 0 : Math.pow(2, 10 * x - 10) diff --git a/src/components/sidebar-trigger-adjustable/SidebarTriggerAdjustable.tsx b/src/components/sidebar-trigger-adjustable/SidebarTriggerAdjustable.tsx index eb0fdd1..e223fdb 100644 --- a/src/components/sidebar-trigger-adjustable/SidebarTriggerAdjustable.tsx +++ b/src/components/sidebar-trigger-adjustable/SidebarTriggerAdjustable.tsx @@ -1,6 +1,6 @@ "use client"; import { useIsMobile } from "@/hooks/use-mobile"; -import { ComponentProps, useEffect, useState } from "react"; +import { ComponentProps, useEffect, useRef } from "react"; const easeSlide = (x: number) => ( 1 - Math.pow(1 - x, 3) @@ -16,13 +16,34 @@ export const SidebarTriggerAdjustable = (props: ComponentProps<"div"> & { }) => { const adjustWidth = props.adjustWidth === undefined ? 12 : +props.adjustWidth; const isMobile = useIsMobile(); - const [slideAmount, setSlideAmount] = useState(0); + const ref = useRef(null); useEffect(() => { - const handleScroll = () => - setSlideAmount(easeSlide( - Math.max(0, Math.min(1, window.scrollY / (window.innerHeight / 20))) - )); + let lastKnownScrollPosition = 0; + let ticking = false; + + const updateAdjustable = (scrollPos: number) => { + if (!ref.current) return; + const slideAmount = easeSlide( + Math.max(0, Math.min(1, scrollPos / (window.innerHeight / 20)))); + + ref.current.style.transform = `translateX(calc(var(--spacing) * ${adjustWidth * slideAmount}))`; + ref.current.style.marginTop = `calc(var(--spacing) * ${(isMobile ? 1 : 3) * slideAmount})`; + ref.current.style.width = `calc(100% - var(--spacing) * ${lerp(0, adjustWidth, 1 - slideAmount)})`; + }; + + const handleScroll = () => { + lastKnownScrollPosition = window.scrollY; + + if (!ticking) { + window.requestAnimationFrame(() => { + updateAdjustable(lastKnownScrollPosition); + ticking = false; + }); + + ticking = true; + } + } handleScroll(); window.addEventListener('scroll', handleScroll, { passive: true }); @@ -30,11 +51,7 @@ export const SidebarTriggerAdjustable = (props: ComponentProps<"div"> & { return () => { window.removeEventListener('scroll', handleScroll); }; - }, [isMobile]); + }, [isMobile, ref]); - return
{props.children}
; + return
{props.children}
; } \ No newline at end of file diff --git a/src/lib/build.ts b/src/lib/build.ts index 6e66a95..53e4000 100644 --- a/src/lib/build.ts +++ b/src/lib/build.ts @@ -1,7 +1,7 @@ export const getBuildID = () => ( - process.env.NODE_ENV == "development" ? "latest commit" : process.env.BUILD_ID + process.env.NODE_ENV == "development" ? "main" : process.env.NEXT_PUBLIC_GIT_COMMIT ); export const getVersion = () => ( - process.env.NODE_ENV == "development" ? "development" : process.env.VERSION + process.env.NODE_ENV == "development" ? "development" : process.env.NEXT_PUBLIC_PACKAGE_VERSION ); \ No newline at end of file