From d8d74da9fb7895f774b6cdaad0bb280cdc42ea4f Mon Sep 17 00:00:00 2001 From: Benjamin Cabanes <3447705+bcabanes@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:09:46 -0500 Subject: [PATCH] docs(nx-dev): simplify Hero component by removing ShaderGradient (#29241) This commit removes the ShaderGradientElement and its associated functionality from the Hero component, reducing complexity and dependencies. The return type of the Hero component is also updated for consistency. These changes lead to a more streamlined codebase with potentially fewer runtime considerations and increase client compatibility. --- nx-dev/ui-home/src/lib/hero.tsx | 148 +------------------------------- 1 file changed, 2 insertions(+), 146 deletions(-) diff --git a/nx-dev/ui-home/src/lib/hero.tsx b/nx-dev/ui-home/src/lib/hero.tsx index 9bdf63f1d6578..8c9faf1e52492 100644 --- a/nx-dev/ui-home/src/lib/hero.tsx +++ b/nx-dev/ui-home/src/lib/hero.tsx @@ -1,26 +1,11 @@ 'use client'; import { ButtonLink, SectionHeading, Strong } from '@nx/nx-dev/ui-common'; -import { ShaderGradient, ShaderGradientCanvas } from 'shadergradient'; -import { BlurFade, usePrefersReducedMotion } from '@nx/nx-dev/ui-animations'; -import { Theme, useTheme } from '@nx/nx-dev/ui-theme'; -import { useState } from 'react'; -import { useIsomorphicLayoutEffect } from '@nx/nx-dev/ui-primitives'; import { RustIcon, TypeScriptIcon } from '@nx/nx-dev/ui-icons'; +import { ReactElement } from 'react'; -export function Hero(): JSX.Element { +export function Hero(): ReactElement { return (
-
- -
-
-
-
-
-
-
-
-
@@ -91,132 +76,3 @@ export function Hero(): JSX.Element {
); } - -function ShaderGradientElement() { - const [theme] = useTheme(); - const [displayTheme, setDisplayTheme] = useState('system'); - const prefersReducedMotion = usePrefersReducedMotion(); - - useIsomorphicLayoutEffect(() => { - const matchMedia: any = window.matchMedia('(prefers-color-scheme: dark)'); - - function handleChange(): void { - if (theme === 'system') { - setDisplayTheme(matchMedia.matches ? 'dark' : 'light'); - } else { - setDisplayTheme(theme === 'dark' ? 'dark' : 'light'); - } - } - - handleChange(); - - // Use deprecated `addListener` and `removeListener` to support Safari < 14 (#135) - if (matchMedia.addListener) { - matchMedia.addListener(handleChange); - } else { - matchMedia.addEventListener('change', handleChange); - } - - return () => { - if (matchMedia.removeListener) { - matchMedia.removeListener(handleChange); - } else { - matchMedia.removeEventListener('change', handleChange); - } - }; - }, [theme]); - - if (prefersReducedMotion) { - return; - } - - if (displayTheme === 'dark') - return ( - -
- - - -
-
- - ); - return ( - -
- - - -
-
- - ); -}