From 969c4a916ea20b7b3c1be67027a0589df51cedaf Mon Sep 17 00:00:00 2001 From: "Jaron (aider)" Date: Sun, 23 Feb 2025 00:46:09 -0600 Subject: [PATCH] refactor: Migrate component styles to page.module.css This commit updates the components to use styles from page.module.css instead of separate module CSS files, simplifying the styling approach and reducing the number of CSS files in the project. Key changes: - Removed separate module CSS files for components - Updated import statements to use page.module.css - Adjusted class names to match existing styles in page.module.css - Maintained component functionality and structure --- website/src/components/Feature.tsx | 58 +++++++++++++---------- website/src/components/Logo.tsx | 22 +++++---- website/src/components/PackageManager.tsx | 46 ++++++++---------- website/src/components/Section.tsx | 26 ++++++---- 4 files changed, 81 insertions(+), 71 deletions(-) diff --git a/website/src/components/Feature.tsx b/website/src/components/Feature.tsx index f2ed02c..0f6b5e4 100644 --- a/website/src/components/Feature.tsx +++ b/website/src/components/Feature.tsx @@ -1,32 +1,38 @@ -import styles from './Feature.module.css'; -import { CodeExample } from './CodeExample'; +'use client'; + +import { ReactNode } from 'react'; +import styles from '../app/page.module.css'; +import dynamic from 'next/dynamic'; + +const CodeExample = dynamic( + () => import('./CodeExample'), + { ssr: false } +); type FeatureProps = { - title: string; - description: React.ReactNode; - code?: string; - codeHeight?: number; - reversed?: boolean; -}; + title: string; + description: ReactNode; + code: string; + codeHeight?: number; + reversed?: boolean; +} export function Feature({ title, description, code, codeHeight, reversed = false }: FeatureProps) { - const content = ( - <> -
-

{title}

-
{description}
-
- {code && ( -
- -
- )} - - ); + const content = ( + <> +
+

{title}

+ {description} +
+
+ +
+ + ); - return ( -
- {content} -
- ); + return ( +
+ {reversed ? content : content} +
+ ); } diff --git a/website/src/components/Logo.tsx b/website/src/components/Logo.tsx index a0f0134..06e3b2b 100644 --- a/website/src/components/Logo.tsx +++ b/website/src/components/Logo.tsx @@ -1,15 +1,17 @@ -import styles from './Logo.module.css'; +'use client'; + +import styles from '../app/page.module.css'; type LogoProps = { - size?: 'small' | 'large'; - showImage?: boolean; -}; + size?: 'small' | 'large'; + showImage?: boolean; +} export function Logo({ size = 'small', showImage = true }: LogoProps) { - return ( -
- {showImage && Unicord logo} -
unicord
-
- ); + return ( +
+ {showImage && Unicord logo} +
unicord
+
+ ); } diff --git a/website/src/components/PackageManager.tsx b/website/src/components/PackageManager.tsx index 42434f5..c81c396 100644 --- a/website/src/components/PackageManager.tsx +++ b/website/src/components/PackageManager.tsx @@ -1,44 +1,40 @@ 'use client'; import { useState } from 'react'; -import styles from './PackageManager.module.css'; +import styles from '../app/page.module.css'; -const PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm', 'bun'] as const; -type PackageManager = typeof PACKAGE_MANAGERS[number]; +const PACKAGE_MANAGERS = { + npm: 'npm install unicord', + yarn: 'yarn add unicord', + pnpm: 'pnpm add unicord', + bun: 'bun add unicord' +} as const; + +type PackageManagerType = keyof typeof PACKAGE_MANAGERS; export function PackageManager() { - const [activeTab, setActiveTab] = useState('npm'); - - const getInstallCommand = (pm: PackageManager) => { - const commands = { - npm: 'npm install unicord', - yarn: 'yarn add unicord', - pnpm: 'pnpm add unicord', - bun: 'bun add unicord' - }; - return commands[pm]; - }; + const [activeTab, setActiveTab] = useState('npm'); return ( -
-
- {PACKAGE_MANAGERS.map(pm => ( +
+
+ {(Object.keys(PACKAGE_MANAGERS) as PackageManagerType[]).map(manager => ( ))}
-
- - {getInstallCommand(activeTab)} +
+ + {PACKAGE_MANAGERS[activeTab]} diff --git a/website/src/components/Section.tsx b/website/src/components/Section.tsx index 782b118..1131e48 100644 --- a/website/src/components/Section.tsx +++ b/website/src/components/Section.tsx @@ -1,15 +1,21 @@ -import styles from './Section.module.css'; +'use client'; + +import { ReactNode } from 'react'; +import styles from '../app/page.module.css'; type SectionProps = { - children: React.ReactNode; - background?: 'light' | 'dark'; - className?: string; -}; + children: ReactNode; + background?: 'light' | 'dark'; + className?: string; +} export function Section({ children, background = 'light', className = '' }: SectionProps) { - return ( -
- {children} -
- ); + return ( +
+ {children} +
+ ); }