# All files / src/app/atoms page.tsx

0% Statements 0/43
0% Branches 0/1
0% Functions 0/1
0% Lines 0/43

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44

     'use client';

    import { motion } from 'framer-motion';
    import { AtomsSection } from '@/components/atoms/AtomsSection';
    import type { Snippet } from '@/lib/types';
    import { useCallback } from 'react';
    import { toast } from 'sonner';
    import { createSnippet } from '@/lib/db';
    import { PageLayout } from '../PageLayout';

    export default function AtomsPage() {
      const handleSaveSnippet = useCallback(async (snippetData: Omit<Snippet, 'id' | 'createdAt' | 'updatedAt'>) => {
        try {
          const newSnippet: Snippet = {
            ...snippetData,
            id: Date.now().toString(),
            createdAt: Date.now(),
            updatedAt: Date.now(),
          };
          await createSnippet(newSnippet);
          toast.success('Component saved as snippet!');
        } catch (error) {
          console.error('Failed to save snippet:', error);
          toast.error('Failed to save snippet');
        }
      }, []);

      return (
        <PageLayout>
          <motion.div
            initial={{ opacity: 0, y: 20 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ duration: 0.4 }}
          >
            <div className="mb-8">
              <h2 className="text-3xl font-bold tracking-tight mb-2">Atoms</h2>
              <p className="text-muted-foreground">Fundamental building blocks - basic HTML elements styled as reusable components</p>
            </div>
            <AtomsSection onSaveSnippet={handleSaveSnippet} />
          </motion.div>
        </PageLayout>
      );
    }