-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from neo4j-labs/feature/cards-component
[Components] Cards component #36
- Loading branch information
Showing
7 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Box, Typography } from '@neo4j-ndl/react'; | ||
import React, { ReactNode } from 'react'; | ||
|
||
interface CardProps { | ||
layout: 'vertical' | 'horizontal'; | ||
imageSrc?: string; | ||
imageSize?: 'full' | 'small'; | ||
iconSystem?: React.ComponentType<React.SVGProps<SVGSVGElement>>; | ||
children: ReactNode; | ||
className?: string; | ||
} | ||
|
||
interface CardHeaderProps { | ||
children: ReactNode; | ||
} | ||
|
||
interface CardSubheaderProps { | ||
children: ReactNode; | ||
} | ||
|
||
interface CardContentProps { | ||
children: ReactNode; | ||
} | ||
|
||
const Card: React.FC<CardProps> & { | ||
Header: React.FC<CardHeaderProps>; | ||
Subheader: React.FC<CardSubheaderProps>; | ||
Content: React.FC<CardContentProps>; | ||
} = ({ layout, imageSrc, imageSize = 'small', iconSystem, children, className }) => { | ||
return ( | ||
<Box | ||
className={`n-bg-palette-neutral-bg-weak border rounded-3xl shadow-lg mx-auto ${layout === 'horizontal' ? 'flex' : 'block'} ${className}`} | ||
style={{ padding: 0 }} | ||
> | ||
<div className={`n-bg-palette-neutral-bg-weak border rounded-3xl shadow-lg mx-auto ${layout === 'horizontal' ? 'flex' : 'block'} ${className}`}> | ||
{imageSrc && ( | ||
<div className={`relative overflow-hidden ${layout === 'horizontal' ? (imageSize === 'full' ? 'w-1/3' : 'w-16 h-16 mr-4') : (imageSize === 'full' ? 'w-full h-64' : 'w-16 h-16 mb-4')}`}> | ||
<img | ||
src={imageSrc} | ||
alt="Card Image" | ||
className={`${imageSize === 'full' ? 'object-cover w-full h-full' : 'object-cover w-16 h-16'} ${layout === 'horizontal' ? 'rounded-tl-3xl rounded-bl-3xl' : 'rounded-tl-3xl rounded-tr-3xl'}`} | ||
|
||
/> | ||
</div> | ||
)} | ||
{iconSystem && ( | ||
<div className='p-4'> | ||
{React.createElement(iconSystem, { className: 'w-8 h-8' })} | ||
</div> | ||
)} | ||
<div className={`p-4 ${layout === 'horizontal' ? 'flex flex-col justify-between w-2/3' : ''}`}> | ||
{children} | ||
</div> | ||
</div> | ||
</Box> | ||
); | ||
} | ||
|
||
const Header: React.FC<CardHeaderProps> = ({ children }) => ( | ||
<Typography variant="h5" className="mb-2">{children}</Typography> | ||
); | ||
|
||
const Subheader: React.FC<CardSubheaderProps> = ({ children }) => ( | ||
<Typography variant="subheading-large" className="mb-2">{children}</Typography> | ||
); | ||
|
||
const Content: React.FC<CardContentProps> = ({ children }) => ( | ||
<Typography variant="body-small" className='flex flex-col gap-3'>{children}</Typography> | ||
); | ||
|
||
Card.Header = Header; | ||
Card.Subheader = Subheader; | ||
Card.Content = Content; | ||
|
||
export default Card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import Card from './Card'; | ||
import testImg from '../assets/cardImg.png'; | ||
import { Button, Typography } from '@neo4j-ndl/react'; | ||
import { AcademicCapIconOutline, RocketLaunchIconOutline } from '@neo4j-ndl/react/icons'; | ||
|
||
export default function DemoCards() { | ||
return ( | ||
<div className="min-h-screen max-h-full p-8 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 n-bg-palette-neutral-bg-default"> | ||
<Card layout="vertical" imageSrc={testImg} imageSize="full" className="h-auto w-96"> | ||
<Card.Header>Header text</Card.Header> | ||
<Card.Subheader>Subtitle or description</Card.Subheader> | ||
<Card.Content> | ||
<p>Some description about relatively important things but not too long since this is a card component.</p> | ||
<ul className="list-disc list-inside"> | ||
<li>1 Key information</li> | ||
<li>12.59 Key information</li> | ||
<li>3 Key information</li> | ||
</ul> | ||
<div className='flex flex-row min-w-full justify-between'> | ||
<Button size='small' color='danger' className='w-2/5 mx-2.5'><Typography variant="body-small">Cancel</Typography></Button> | ||
<Button size='small' color='primary' className='w-2/5 mx-2.5'><Typography variant="body-small">Sign</Typography></Button> | ||
</div> | ||
</Card.Content> | ||
</Card> | ||
|
||
<Card layout="vertical" imageSrc={testImg} imageSize="full" className="h-auto w-96"> | ||
<Card.Content> | ||
<p>Some description about relatively important things but not too long since this is a card component.</p> | ||
<ul className="list-disc list-inside"> | ||
<li>18 Key information</li> | ||
<li>12.59 Key information</li> | ||
<li>5 Key information</li> | ||
</ul> | ||
</Card.Content> | ||
</Card> | ||
|
||
<Card layout="vertical" className="h-auto w-96" iconSystem={RocketLaunchIconOutline}> | ||
<Card.Header>Header text</Card.Header> | ||
<Card.Content> | ||
<p>Some description about relatively important things but not too long since this is a card component.</p> | ||
<ul className="list-disc list-inside"> | ||
<li>18 Key information</li> | ||
<li>12.59 Key information</li> | ||
<li>5 Key information</li> | ||
</ul> | ||
</Card.Content> | ||
</Card> | ||
|
||
<Card layout="horizontal" imageSrc={testImg} imageSize="full" className="h-72"> | ||
<Card.Header>Header text</Card.Header> | ||
<Card.Subheader>Subtitle or description</Card.Subheader> | ||
<Card.Content> | ||
<p>Some description about relatively important things but not too long since this is a card component.</p> | ||
<ul className="list-disc list-inside"> | ||
<li>18 Key information</li> | ||
<li>12.59 Key information</li> | ||
<li>5 Key information</li> | ||
</ul> | ||
<div className='flex flex-row min-w-full justify-between'> | ||
<Button size='small' color='danger' className='w-2/5 mx-2.5'><Typography variant="body-small">Cancel</Typography></Button> | ||
<Button size='small' color='primary' className='w-2/5 mx-2.5'><Typography variant="body-small">Sign</Typography></Button> | ||
</div> | ||
</Card.Content> | ||
</Card> | ||
|
||
<Card layout="horizontal" imageSrc={testImg} imageSize="full" className="h-44"> | ||
<Card.Content> | ||
<p>Some description about relatively important things but not too long since this is a card component.</p> | ||
<ul className="list-disc list-inside"> | ||
<li>1 Key information</li> | ||
<li>12.59 Key information</li> | ||
<li>3 Key information</li> | ||
</ul> | ||
</Card.Content> | ||
</Card> | ||
|
||
<Card layout="horizontal" iconSystem={AcademicCapIconOutline}> | ||
<Card.Header>Header text</Card.Header> | ||
<Card.Content> | ||
<p>Some description about relatively important things but not too long since this is a card component.</p> | ||
<ul className="list-disc list-inside"> | ||
<li>18 Key information</li> | ||
<li>12.59 Key information</li> | ||
<li>5 Key information</li> | ||
</ul> | ||
</Card.Content> | ||
</Card> | ||
|
||
</div> | ||
); | ||
} |