fix: fixed perf issues

This commit is contained in:
Raj 2024-02-18 20:56:51 +05:30
parent 1df0fba292
commit eb98cc6bd7
6 changed files with 34 additions and 14 deletions

View File

@ -1,7 +1,7 @@
"use client";
import { useEffect, useState } from "react";
import { nanoid, customAlphabet } from "nanoid";
import { customAlphabet } from "nanoid";
const generate = customAlphabet("abcdefghijklmnopqrstuvwxyz", 9);
@ -37,7 +37,10 @@ export function Connect() {
className="flex items-center text-primary justify-center"
href={`mailto:${random_id}@raj.how`}
>
<span className="w-[68px] overflow-hidden font-mono tabular-nums text-right">
<span
suppressHydrationWarning
className="w-[68px] overflow-hidden font-mono tabular-nums text-right"
>
{random_id}
</span>
<span>@raj.how</span>

View File

@ -1,13 +1,10 @@
import {
BackgroundGradentProvider,
GradientProvider,
SymetricGradProvider,
} from "@/components/gradient-provider";
import { BackgroundGradentProvider } from "@/components/gradient-provider";
import GrainProvider from "@/components/grain";
import { StyledNotion } from "@/components/notion/styled";
import { ExternalLink, Sparkle } from "lucide-react";
import { Footer } from "./Footer";
import { Connect } from "./Connect";
import { motion } from "framer-motion";
export default function Page() {
return (
@ -91,7 +88,7 @@ function Stories() {
My tech blogs and other writings.
</p>
</div>
<StyledNotion blockId="d149cfb269aa4a5699bbf919a1b0b137" />
<StyledNotion className="" blockId="d149cfb269aa4a5699bbf919a1b0b137" />
</div>
);
}

View File

@ -27,7 +27,12 @@ const Clock: React.FC = () => {
const seconds = time.getSeconds();
return (
<svg width="18px" height="18px" viewBox="0 0 100 100">
<svg
suppressHydrationWarning
width="18px"
height="18px"
viewBox="0 0 100 100"
>
<circle
cx="50"
cy="50"
@ -41,6 +46,7 @@ const Clock: React.FC = () => {
y1="50"
x2="50"
y2="20"
suppressHydrationWarning
transform={calculateRotation(hours, true)}
stroke="black"
strokeWidth="4"
@ -50,6 +56,7 @@ const Clock: React.FC = () => {
y1="50"
x2="50"
y2="15"
suppressHydrationWarning
transform={calculateRotation(minutes)}
stroke="black"
strokeWidth="4"
@ -59,6 +66,7 @@ const Clock: React.FC = () => {
y1="50"
x2="50"
y2="10"
suppressHydrationWarning
transform={calculateRotation(seconds)}
stroke="black"
strokeWidth="2"

View File

@ -60,9 +60,10 @@ export function BackgroundGradentProvider({
)}
>
<motion.div
// blur and fade in
initial={{ opacity: 0, filter: "blur(10px)" }}
animate={{ opacity: 1, filter: "blur(0px)" }}
className="w-full h-full"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<Image
className="w-full h-full object-cover"

View File

@ -1,5 +1,6 @@
"use client";
import { motion } from "framer-motion";
import React, { useEffect, useRef, useCallback } from "react";
type GrainOptions = {
@ -81,7 +82,10 @@ export const GrainProvider = ({
}, [animate]);
return (
<canvas
<motion.canvas
initial={{ opacity: 0, filter: "blur(10px)" }}
animate={{ opacity: 1, filter: "blur(0px)" }}
transition={{ duration: 2 }}
ref={canvasRef}
id="grained-canvas"
className="fixed left-0 top-0 inset-0 z-50 pointer-events-none w-full h-full"

View File

@ -3,6 +3,8 @@ import { type ExtendedRecordMap } from "notion-types";
import dynamic from "next/dynamic";
import { NotionRenderer } from "react-notion-x";
import { motion } from "framer-motion";
import { cn } from "@/lib/utils";
const Code = dynamic(() =>
import("react-notion-x/build/third-party/code").then((m) => m.Code),
@ -33,7 +35,12 @@ export function NRenderer({
fullPage?: boolean;
}) {
return (
<div className={className}>
<motion.div
// blur and fade in and animate height to auto
initial={{ opacity: 0, filter: "blur(10px)" }}
animate={{ opacity: 1, filter: "blur(0px)" }}
className={cn("", className)}
>
<NotionRenderer
components={{
Code,
@ -45,6 +52,6 @@ export function NRenderer({
fullPage={fullPage}
recordMap={recordMap}
/>
</div>
</motion.div>
);
}