import { ReactElement, useState } from 'react'; import { DateDisplay } from './components/DateDisplay'; import { CountdownTimer } from './components/CountdownTimer'; import { cn } from './utilities'; const components: Record = { CountdownTimer: , DateDisplay: ( {new Date()} ), }; const componentDocs: Record = { CountdownTimer: (

CountdownTimer Component

The CountdownTimer component counts down to a target date and displays the remaining time.

Props

  • targetDate (Date): The date to count down to.
  • className (string, optional): Additional CSS classes to apply to the container element.
  • timeLeftText (string, optional): Text to display when the countdown reaches zero.

Usage


                {`import { CountdownTimer } from './components/CountdownTimer';

function Example() {
    return (
        
    );
}`}
            
), DateDisplay: (

DateDisplay Component

The DateDisplay component formats and displays a date using the specified pattern.

Props

  • children (Date): The date to be formatted and displayed.
  • className (string, optional): Additional CSS classes to apply to the span element.
  • pattern (string): The format pattern to use for displaying the date.

Usage


                {`import { DateDisplay } from './components/DateDisplay';

function Example() {
    return (
        
            {new Date()}
        
    );
}`}
            
            
), }; export function App() { const [selectedComponent, setSelectedComponent] = useState('DateDisplay'); const sortedComponentKeys = Object.keys(components).sort(); return (
{componentDocs[selectedComponent]}

Component Preview

{components[selectedComponent]}
); }