Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: Add homepage dash button when signed in
Richie McIlroy55e9e6b05722
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsxindex 2160a9e6c..49d610402 100644--- a/apps/web/app/layout.tsx+++ b/apps/web/app/layout.tsx@@ -3,6 +3,7 @@ import { Toaster } from "react-hot-toast";import { Navbar } from "@/components/Navbar";import { Footer } from "@/components/Footer";import type { Metadata } from "next";+import { getCurrentUser } from "@cap/database/auth/session";export const metadata: Metadata = {title: "Cap — Beautiful, shareable screen recordings. Open source.",@@ -23,6 +24,8 @@ export default async function RootLayout({}: {children: React.ReactNode;}) {+ const user = await getCurrentUser();+return (<html lang="en"><head>@@ -51,7 +54,7 @@ export default async function RootLayout({<body><Toaster /><main className="w-full overflow-hidden">- <Navbar />+ <Navbar auth={user ? true : false} />{children}<Footer /></main>diff --git a/apps/web/app/page.tsx b/apps/web/app/page.tsxindex ce8363265..83bc2b177 100644--- a/apps/web/app/page.tsx+++ b/apps/web/app/page.tsx@@ -1,12 +1,5 @@-"use client";-import { HomePage } from "@/components/pages/HomePage";-import { ParallaxProvider } from "react-scroll-parallax";-export default function Roadmap() {- return (- <ParallaxProvider>- <HomePage />- </ParallaxProvider>- );+export default async function Home() {+ return <HomePage />;}diff --git a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx b/apps/web/app/s/[videoId]/_components/ShareVideo.tsxindex d6a1e1d3f..8818bf1f2 100644--- a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx+++ b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx@@ -96,20 +96,20 @@ export const ShareVideo = ({}, []);const handlePlayPauseClick = async () => {- setIsPlaying(!isPlaying);-const videoElement = videoRef.current;if (!videoElement) return;if (isPlaying) {videoElement.pause();+ setIsPlaying(false);} else {try {await videoElement.play();+ setIsPlaying(true);+ videoElement.muted = false;} catch (error) {console.error("Error with playing:", error);- setIsPlaying(false); // Revert the isPlaying state on error}}};diff --git a/apps/web/app/s/[videoId]/_components/VideoPlayer.tsx b/apps/web/app/s/[videoId]/_components/VideoPlayer.tsxindex c40bcaf1b..e58ce9111 100644--- a/apps/web/app/s/[videoId]/_components/VideoPlayer.tsx+++ b/apps/web/app/s/[videoId]/_components/VideoPlayer.tsx@@ -23,14 +23,35 @@ export const VideoPlayer = memo(media: HTMLMediaElement,hlsInstance: React.MutableRefObject<Hls | null>) => {- const hls = new Hls({ progressive: true });- hls.on(Hls.Events.ERROR, (event, data) => {- console.error("HLS error:", data);- });-- hlsInstance.current = hls;- hls.loadSource(src);- hls.attachMedia(media);+ if (Hls.isSupported()) {+ const hls = new Hls({ progressive: true });+ hls.on(Hls.Events.ERROR, (event, data) => {+ console.error("HLS error:", data);+ if (data.fatal) {+ switch (data.type) {+ case Hls.ErrorTypes.NETWORK_ERROR:+ hls.startLoad();+ break;+ case Hls.ErrorTypes.MEDIA_ERROR:+ hls.recoverMediaError();+ break;+ default:+ initializeFallback(src, media);+ break;+ }+ }+ });++ hlsInstance.current = hls;+ hls.loadSource(src);+ hls.attachMedia(media);+ } else {+ initializeFallback(src, media);+ }+ };++ const initializeFallback = (src: string, media: HTMLMediaElement) => {+ media.src = src;};useEffect(() => {@@ -50,6 +71,7 @@ export const VideoPlayer = memo(preload="metadata"playsInlinecontrols={false}+ muted/>);})diff --git a/apps/web/components/Navbar.tsx b/apps/web/components/Navbar.tsxindex c8a42b48a..91fbce0a7 100644--- a/apps/web/components/Navbar.tsx+++ b/apps/web/components/Navbar.tsx@@ -2,8 +2,10 @@import { usePathname } from "next/navigation";import { Logo } from "@cap/ui";+import { Button } from "@cap/ui";+import Link from "next/link";-export const Navbar = () => {+export const Navbar = ({ auth }: { auth: boolean }) => {const pathname = usePathname();const isHomePage = pathname === "/";@@ -64,6 +66,11 @@ export const Navbar = () => {</svg></a></li>+ {auth === true && (+ <li>+ <Button href="/dashboard">Dashboard</Button>+ </li>+ )}</ul></nav>);diff --git a/apps/web/components/pages/HomePage.tsx b/apps/web/components/pages/HomePage.tsxindex e7bbfc797..1a426d3b7 100644--- a/apps/web/components/pages/HomePage.tsx+++ b/apps/web/components/pages/HomePage.tsx@@ -5,7 +5,7 @@import { useState, useRef } from "react";import { Parallax } from "react-scroll-parallax";import toast from "react-hot-toast";-import Image from "next/image";+import { ParallaxProvider } from "react-scroll-parallax";export const HomePage = () => {const [showEmail, setShowEmail] = useState<boolean>(false);@@ -44,7 +44,7 @@ export const HomePage = () => {};return (- <>+ <ParallaxProvider><div className="w-full custom-bg"><div className="wrapper wrapper-sm mx-auto"><div className="mb-auto -mt-20 text-center md:px-4 pt-32 pb-52 md:pt-44 md:pb-64 space-y-8">@@ -168,6 +168,6 @@ export const HomePage = () => {/></Parallax></div>- </>+ </ParallaxProvider>);};diff --git a/packages/ui/src/components/Button.tsx b/packages/ui/src/components/Button.tsxindex 3e311d2cb..8706e21f3 100644--- a/packages/ui/src/components/Button.tsx+++ b/packages/ui/src/components/Button.tsx@@ -35,18 +35,28 @@ export interface ButtonPropsVariantProps<typeof buttonVariants> {asChild?: boolean;spinner?: boolean;+ href?: string;}const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((- { className, variant, size, asChild = false, spinner = false, ...props },+ {+ className,+ variant,+ size,+ asChild = false,+ spinner = false,+ href,+ ...props+ },ref) => {- const Comp = asChild ? Slot : "button";+ const Comp = href ? "a" : asChild ? Slot : ("button" as any);return (<CompclassName={classNames(buttonVariants({ variant, size, className }))}- ref={ref}+ ref={ref as any}+ href={href || undefined}{...props}>{props.children}