Skip to content

Commit

Permalink
refa[DST-610]: revise <Card> page (#4299)
Browse files Browse the repository at this point in the history
* DST-607: revise card component

* DST-607: add anatomy and appearance demo

* Create honest-lobsters-taste.md

* DST-607: change size control

* DST-607: edit changeset

* DST-610: edit comments
  • Loading branch information
aromko authored Nov 15, 2024
1 parent b4036c6 commit ac29d40
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 80 deletions.
8 changes: 8 additions & 0 deletions .changeset/honest-lobsters-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@marigold/docs": patch
"@marigold/components": patch
---

refa[DST-610]: Revise `<Card>` page

The `<Card>`is now revised according to our new component page guidelines.
26 changes: 26 additions & 0 deletions docs/content/components/content/card/card-appearance.demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
Card,
CardProps,
Center,
Inline,
Link,
Split,
} from '@marigold/components';
import { Close, ExternalLink } from '@marigold/icons';

export default (props: CardProps) => (
<Card {...props} p={3}>
<Inline alignY="top">
<Link href={'#'} target="blank">
<ExternalLink size={26} className="fill-[#990000]" />
</Link>
<Split />
<Close />
</Inline>
<Center>
<Link variant="cardText" href={'#'}>
Reservix GmbH (1)
</Link>
</Center>
</Card>
);
76 changes: 76 additions & 0 deletions docs/content/components/content/card/card-elevation.demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Card, Inline, Stack, Text } from '@marigold/components';

export default () => (
<>
<div className="bg-bg-surface-sunken shadow-surface-sunken rounded-xl p-4">
<p>sunken layer 👍</p>
<Card p={4}>
<Stack>
<Inline>
<Text>Earliest event date:</Text>
<Text weight="bold">
{new Date(Date.now()).toLocaleDateString()}
</Text>
</Inline>
<Inline>
<Text>Latest event date:</Text>
<Text weight="bold">
{new Date(Date.now() + 3600 * 1000 * 24).toLocaleDateString()}
</Text>
</Inline>
<Inline>
<Text>Total events:</Text>
<Text weight="bold">10</Text>
</Inline>
</Stack>
</Card>
</div>
<div className="bg-bg-surface shadow-surface rounded-xl p-4">
<p>default layer 👍</p>
<Card p={4}>
<Stack>
<Inline>
<Text>Earliest event date:</Text>
<Text weight="bold">
{new Date(Date.now()).toLocaleDateString()}
</Text>
</Inline>
<Inline>
<Text>Latest event date:</Text>
<Text weight="bold">
{' '}
{new Date(Date.now() + 3600 * 1000 * 24).toLocaleDateString()}
</Text>
</Inline>
<Inline>
<Text>Total events:</Text>
<Text weight="bold">10</Text>
</Inline>
</Stack>
</Card>
</div>
<div className="bg-bg-surface-raised shadow-surface-raised rounded-xl p-4">
<p>Same layer like card 👎</p>
<Card p={4}>
<Stack>
<Inline>
<Text>Earliest event date:</Text>
<Text weight="bold">
{new Date(Date.now()).toLocaleDateString()}
</Text>
</Inline>
<Inline>
<Text>Latest event date:</Text>
<Text weight="bold">
{new Date(Date.now() + 3600 * 1000 * 24).toLocaleDateString()}
</Text>
</Inline>
<Inline>
<Text>Total events:</Text>
<Text weight="bold">10</Text>
</Inline>
</Stack>
</Card>
</div>
</>
);
20 changes: 0 additions & 20 deletions docs/content/components/content/card/card-form.demo.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions docs/content/components/content/card/card-infos.demo.tsx

This file was deleted.

76 changes: 59 additions & 17 deletions docs/content/components/content/card/card.mdx
Original file line number Diff line number Diff line change
@@ -1,38 +1,80 @@
---
title: Card
caption: Component to support the structuring of information.
badge: updated
---

The `<Card>` is a content component to group informations inside the UI, as well it provides a better readability and helps the user to find relevant informations in an easy way.
A `<Card>` component is a versatile UI element used to display content in a concise, visually organized format.
It’s typically presented as a rectangular box with various content elements such as images, text, buttons, and icons.
Cards are ideal for grouping related information and making it easily digestible, often used to display previews of articles, products, user profiles, and other content types.

`<Card>` components usually contain images, text, links or action components like buttons.
## Anatomy

If you want, you can style the `<Card>` and create custom variants and sizes.
The `<Card>` component consists of a container which is basically a `<div>`. You can pass any content and components as `children` to the component.

## Import

```tsx
import { Card } from '@marigold/components';
```
<Image
src="/card/card-anatomy.jpg"
alt="Anatomy of card component"
width={800}
height={550}
className="mx-auto block"
/>

## Appearance

<AppearanceDemo component={title} />

<AppearanceTable component={title} />

## Props
## Usage

<PropsTable component={title} />
The `<Card>` component enhances the visual hierarchy and organization of content, making it easier for users to engage with various pieces of information.

## Examples
## Elevation layer

### Card with form fields
`<Card>` uses the raised elevation layer to create a visual distinction between the card and the background.
According to our design guidelines, the card should be used on top of the [sunken](../../../foundations/elevation#sunken) or [default](../../../foundations/elevation#default) layer.

The Example shows how to use the `<Card>` in a common use case with form fields.
<ComponentDemo file="./card-elevation.demo.tsx" />

<ComponentDemo file="./card-form.demo.tsx" />
<GuidelineTiles>
<Do>
<Do.Description>
Use Card on top of default or sunken layers.
</Do.Description>
</Do>
<Dont>
<Dont.Description>
Don’t use card in cards or same elevation layers.
</Dont.Description>
</Dont>
</GuidelineTiles>

### Card with some Text
## Props

<StorybookHintMessage component={title} />

On this example you can see an imformation card with used prop `p`.
<PropsTable component={title} />

<ComponentDemo file="./card-infos.demo.tsx" />
## Related

<TeaserList
items={[
{
title: 'Elevation',
href: '../../../foundations/elevation',
caption:
'This page should introduce you on how to use elevation with Marigold.',
icon: (
<svg
viewBox="0 0 24 24"
className="size-6"
strokeWidth="1.5"
stroke="currentColor"
>
<path d="M3.5625 6.375H20.4375V8.25H3.5625V6.375ZM3.5625 16.125H20.4375V18H3.5625V16.125ZM20.4375 11.25H3.5625V13.125H20.4375V11.25Z"></path>
</svg>
),
},
]}
/>
Binary file added docs/public/card/card-anatomy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/card/card-do-elevation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/card/card-dont-elevation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 44 additions & 18 deletions packages/components/src/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const meta = {
},
size: {
control: {
type: 'text',
type: 'radio',
},
description: 'The size of the card',
options: ['default', 'stretch', 'small'],
},
p: {
control: {
Expand Down Expand Up @@ -134,22 +135,47 @@ export const CoreCard: Story = {

export const Stretch: Story = {
render: args => (
<div className="flex h-full">
<Card {...args} size="stretch">
<h2>Professor Severus Snape</h2>
<section>
<p>
<strong>Professor Severus Snape</strong> (9 January, 1960[1] - 2
May, 1998)[2] was an English half-blood[3] wizard serving as Potions
Master (1981-1996), Head of Slytherin House (1981-1997), Defence
Against the Dark Arts professor (1996-1997), and Headmaster
(1997-1998) of the Hogwarts School of Witchcraft and Wizardry as
well as a member of the Order of the Phoenix and a Death Eater. His
double life played an extremely important role in both of the
Wizarding Wars against Voldemort.
</p>
</section>
</Card>
</div>
<Card {...args} size={'stretch'}>
<h2>Professor Severus Snape</h2>
<section>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam
et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
takimata sanctus est Lorem ipsum dolor sit amet.
</p>
</section>
</Card>
),
};

export const PaddingAndSpace: Story = {
render: args => (
<Card {...args} p={8} space={4}>
<h2>Professor Severus Snape</h2>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
ipsum dolor sit amet.
</p>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet.
</p>
</Card>
),
};

0 comments on commit ac29d40

Please sign in to comment.