From c491fd65470b5b952865966019e4fc28cf5014bb Mon Sep 17 00:00:00 2001 From: IwanIDev Date: Fri, 20 Mar 2026 15:20:27 +0000 Subject: Using shadcn/ui for this site. --- src/App.tsx | 86 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 20 deletions(-) (limited to 'src/App.tsx') diff --git a/src/App.tsx b/src/App.tsx index 3472fd0..396af37 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,10 @@ import { useEffect, useState } from 'react' import { fetchDrupalResource } from './lib/drupalClient' -import './App.css' +import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' +import { Badge } from '@/components/ui/badge' +import { Button } from '@/components/ui/button' +import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card' +import { Separator } from '@/components/ui/separator' type DrupalArticle = { id: string @@ -56,34 +60,76 @@ function App() { void loadArticles() }, []) - return ( -
-

Articles

- {!isLoading && !error && resourcePath &&

Using resource: {resourcePath}

} + const articleCount = articles.length + + const formatDate = (value?: string) => { + if (!value) { + return 'Unknown date' + } - {isLoading &&

Loading articles…

} + return new Date(value).toLocaleString() + } + + return ( +
+ + + Portfolio CMS Homepage + This homepage now uses shadcn/ui components and reads content from Drupal JSON:API. + + + + {isLoading ? 'Loading' : error ? 'Error' : 'Connected'} + + Articles: {articleCount} + {resourcePath && Resource: {resourcePath}} + + + Headless Drupal + Vite + shadcn/ui + + + {error && ( -

- Could not fetch articles: {error} -

+ + Could not fetch articles + {error} + )} - {!isLoading && !error && articles.length === 0 && ( -

Connected to Drupal, but no articles were returned.

+ {!isLoading && !error && articleCount === 0 && ( + + No articles found + Connected to Drupal successfully, but this resource currently has no content. + )} - {!isLoading && !error && articles.length > 0 && ( -
    + {!isLoading && !error && articleCount > 0 && ( +
    {articles.map((article) => ( -
  • - {article.attributes?.title ?? '(Untitled)'} -
    ID: {article.id}
    -
    Status: {article.attributes?.status ? 'Published' : 'Unpublished'}
    - {article.attributes?.created &&
    Created: {new Date(article.attributes.created).toLocaleString()}
    } -
  • + + + {article.attributes?.title ?? '(Untitled)'} + {article.id} + + + +
    + Status + + {article.attributes?.status ? 'Published' : 'Unpublished'} + +
    +
    + Created + {formatDate(article.attributes?.created)} +
    +
    +
    ))} -
+ )}
) -- cgit