Capgemini / dcx-react-library

React Library UI/UX agnostic
https://main--6069a6f47f4b9f002171f8e1.chromatic.com
MIT License
107 stars 7 forks source link

Card #550

Closed Ibabalola closed 4 months ago

Ibabalola commented 8 months ago

As a developer I want to be able to use a Card component so that I can create container for text, photos, and actions in the context of a single subject

The component should contain:

Code Guidance:

import { classNames } from '../common';
....
//for card-header
className={classNames(['dcx-card-header', className])}

Available Props:

Code Guidance (Card, CardHeader, CardContent, CardActions, CardFooter):

children: JSX.Element[]; 
//Relevant classes for shared / reusable styling
className?: string;
//additional properties to support something else that we didn't plan
props?: React.HTMLAttributes<HTMLElement>;

Code Guidance (CardImage):

//Relevant classes for shared / reusable styling
className?: string;
//additional properties to support something else that we didn't plan
props?: React.HTMLAttributes<HTMLElement>;
// src of the image to add
src: string;
// alternative text of the image
alt: string;

Example:

<Card className="" props={{}}>
  <CardHeader className="" props={{}}>{{ Section anchored to the top of the card (adds padding) }}</CardHeader>
  <CardContent className="" props={{}}>{{ Primary card content (adds padding) }}</CardContext>
  <CardImage className="" src="" alt="" props={{}}>{{ Card image. Stretches the image to the container width }}</CardImage>
  <CardActions className="" props={{}}>{{ Container for buttons at the bottom of the card (adds padding) }}</CardActions>
  <CardFooter className="" props={{}}>{{ Section anchored to the bottom of the card }}</CardFooter>
</Card>

Behind the scenes the Card component could be like so:

<article className="dcx-card myCardClass">
   <!-- CardHeader -->
   <div className="dcx-card-header myCardClass">{children}</div>
   <!-- CardContent -->
   <p className="dcx-card-content myCardClass" >{children}</p>
   <!-- CardImage -->
   <img className="dcx-card-image myCardClass" src={} alt={}  />
   <!-- CardActions -->
   <div className="dcx-card-actions myCardClass">{children}</div>
   <!-- CardFooter -->
   <div className="dcx-card-footer myCardClass">{children}</div>
</article>

Tasks:

Please follow the below to create your branch

git checkout release/1.0.0
git pull
git checkout -b 'feature/card'
daniele-zurico commented 4 months ago

closed by https://github.com/Capgemini/dcx-react-library/pull/593