Skip to content

Commit

Permalink
feat(content): Add example Card with image with alt text
Browse files Browse the repository at this point in the history
Also renames the existing `Card with image` example
to `Card with decorative image` to more clearly
indicate `alt` text *should* be provided if the
image is *not* purely decorative.
  • Loading branch information
tulup-conner committed Apr 25, 2022
1 parent aef555c commit 7410610
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { FC, PropsWithChildren } from 'react';
import classNames from 'classnames';

export type CardProps = PropsWithChildren<{
alt?: string;
className?: string;
horizontal?: boolean;
imgAlt?: string;
imgSrc?: string;
}>;

export const Card: FC<CardProps> = ({ alt, children, className, horizontal, imgSrc }) => {
export const Card: FC<CardProps> = ({ imgAlt, children, className, horizontal, imgSrc }) => {
return (
<div
className={classNames(
Expand All @@ -27,7 +27,7 @@ export const Card: FC<CardProps> = ({ alt, children, className, horizontal, imgS
'h-96 w-full rounded-t-lg object-cover md:h-auto md:w-48 md:rounded-none md:rounded-l-lg': horizontal,
})}
src={imgSrc}
alt={alt ?? ''}
alt={imgAlt ?? ''}
/>
)}
<div className="flex h-full flex-col justify-center gap-4 p-6">{children}</div>
Expand Down
20 changes: 19 additions & 1 deletion src/pages/CardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CardPage: FC = () => {
codeClassName: 'dark:!bg-gray-900',
},
{
title: 'Card with image',
title: 'Card with decorative image',
code: (
<Card className="max-w-sm" imgSrc="https://flowbite.com/docs/images/blog/image-1.jpg">
<h5 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
Expand All @@ -33,6 +33,24 @@ const CardPage: FC = () => {
),
codeClassName: 'dark:!bg-gray-900',
},
{
title: 'Card with image with alt text',
code: (
<Card
className="max-w-sm"
imgAlt="Meaningful alt text for an image that is not purely decorative"
imgSrc="https://flowbite.com/docs/images/blog/image-1.jpg"
>
<h5 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
Noteworthy technology acquisitions 2021
</h5>
<p className="font-normal text-gray-700 dark:text-gray-400">
Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.
</p>
</Card>
),
codeClassName: 'dark:!bg-gray-900',
},
{
title: 'Horizontal card',
code: (
Expand Down

0 comments on commit 7410610

Please sign in to comment.