From cae01bcbd63593b0a425fa288a78d381d6144c1f Mon Sep 17 00:00:00 2001 From: Maharshi Alpesh Date: Mon, 16 Dec 2024 12:43:29 +0530 Subject: [PATCH] fix: making the transitions smoother --- .../marketing/nextui-pro-section.tsx | 49 ++++++++++++------- apps/docs/tailwind.config.js | 5 ++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/apps/docs/components/marketing/nextui-pro-section.tsx b/apps/docs/components/marketing/nextui-pro-section.tsx index 5a842c2190..102676b308 100644 --- a/apps/docs/components/marketing/nextui-pro-section.tsx +++ b/apps/docs/components/marketing/nextui-pro-section.tsx @@ -1,8 +1,9 @@ "use client"; -import {Button, Chip} from "@nextui-org/react"; +import {Button, Chip, cn} from "@nextui-org/react"; import {useEffect, useState} from "react"; import {useTheme} from "next-themes"; +import NextImage from "next/image"; import {sectionWrapper, title, titleWrapper, subtitle} from "../primitives"; @@ -33,13 +34,23 @@ export const NextUIProSection = () => { : "/images/nextuipro-section-background-light.webp"; } - const mobileClassName: string = isDarkMode - ? "h-full w-full bg-[linear-gradient(to_left,_rgba(255,255,255,_0)_5%,_rgba(0,0,0,1)_100%)]" - : "h-full w-full bg-[linear-gradient(to_left,_rgba(0,0,0,_0)_5%,_rgba(255,255,255,1)_100%)]"; + useEffect(() => { + const imagesToPreload = [ + "/images/nextuipro-section-background.webp", + "/images/nextuipro-section-background-light.webp", + "/images/nextuipro-section-background@mobile.webp", + "/images/nextuipro-section-background-light@mobile.webp", + ]; + const preloadImages = (images) => { + images.forEach((src) => { + const img = new Image(); + + img.src = src; + }); + }; - const webClassName: string = isDarkMode - ? "ease-in-out h-full w-full bg-[radial-gradient(at_80%_50%,_rgba(255,255,255,_0)_20%,_rgba(0,0,0,_0.8)_40%,_rgba(0,0,0,1)_100%)]" - : "ease-in-out h-full w-full bg-[radial-gradient(at_80%_50%,_rgba(0,0,0,_0)_20%,_rgba(255,255,255,_0.9)_40%,_rgba(255,255,255,1)_100%)]"; + preloadImages(imagesToPreload); + }, []); if (!mounted) return null; @@ -156,25 +167,27 @@ export const NextUIProSection = () => {
- Hero Background -
-
-
- -
-
-
+
diff --git a/apps/docs/tailwind.config.js b/apps/docs/tailwind.config.js index 8636036624..391e7fdc27 100644 --- a/apps/docs/tailwind.config.js +++ b/apps/docs/tailwind.config.js @@ -327,6 +327,10 @@ module.exports = { from: {transform: "translateY(0)"}, to: {transform: "translateY(calc(-50% - var(--gap)/2))"}, }, + fadeIn: { + "0%": { opacity: 0 }, + "100%": { opacity: 1 }, + }, }, animation: { heartbeat: "heartbeat 1s ease-in-out infinite", @@ -336,6 +340,7 @@ module.exports = { "text-gradient": "text-gradient 4s linear 0s infinite normal forwards running", "scrolling-banner": "scrolling-banner var(--duration) linear infinite", "scrolling-banner-vertical": "scrolling-banner-vertical var(--duration) linear infinite", + fadeIn: "fadeIn 0.5s ease-in-out forwards", }, maxWidth: { "8xl": "90rem", // 1440px