Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add short descriptions to some components #1966

Merged
merged 6 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: adds description and examples to EntryCard
  • Loading branch information
gui-santos committed Mar 21, 2022
commit fe54efd20f2402eae181153e117b05b7d5d28b9e
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { EntryCard, MenuItem } from '@contentful/f36-components';

export default function EntryCardActionsExample() {
return (
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
actions={[
<MenuItem key="copy" onClick={() => alert('copy')}>
Copy
</MenuItem>,
<MenuItem key="delete" onClick={() => alert('delete')}>
Delete
</MenuItem>,
]}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { EntryCard } from '@contentful/f36-components';

export default function EntryCardClickableExample() {
return (
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
onClick={() => alert('click')}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { EntryCard } from '@contentful/f36-components';

export default function EntryCardDragHandleExample() {
return (
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
withDragHandle
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { EntryCard } from '@contentful/f36-components';

export default function EntryCardExample() {
return (
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { EntryCard } from '@contentful/f36-components';

export default function EntryCardLoadingExample() {
return (
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
isLoading
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { EntryCard, Stack } from '@contentful/f36-components';

export default function EntryCardSizesExample() {
return (
<Stack flexDirection="column">
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
size="small"
/>
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
size="default"
/>
</Stack>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { EntryCard } from '@contentful/f36-components';

export default function EntryCardThumbnailExample() {
return (
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
thumbnailElement={<img src="https://picsum.photos/200" />}
/>
);
}
106 changes: 16 additions & 90 deletions packages/components/card/src/EntryCard/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ typescript: ./EntryCard.tsx
storybook: 'https://v4-f36-storybook.netlify.app/?path=/story/components-card-entrycard--default'
---

import { Heading, Stack, TextLink } from '@contentful/f36-components';
import { ExternalLinkIcon } from '@contentful/f36-icons';

The EntryCard component is built on top of the [Card component](/components/card) and it provides more props
to help you manage the entries of your Contentful implementation.
Display entries with preview and other options.

## Import

Expand All @@ -30,122 +26,52 @@ you can pass one of "archived", "changed", "deleted", "draft", "new", or "publis

### Basic usage

```jsx
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
/>
```jsx file=../../examples/EntryCard/EntryCardExample.tsx

```

### Clickable card

Like the `Card` component, it’s possible to pass a function to the `onClick` prop
and it will be called when the user clicks on the card.

```jsx
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
onClick={() => alert('click')}
/>
```jsx file=../../examples/EntryCard/EntryCardClickableExample.tsx

```

### Card actions

To show a `...` button with a menu in the card, pass an array of `MenuItem` components

```jsx
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
actions={[
<MenuItem key="copy" onClick={() => alert('copy')}>
Copy
</MenuItem>,
<MenuItem key="delete" onClick={() => alert('delete')}>
Delete
</MenuItem>,
]}
/>
```jsx file=../../examples/EntryCard/EntryCardActionsExample.tsx

```

### Loading state

```jsx
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
isLoading
/>
```jsx file=../../examples/EntryCard/EntryCardLoadingExample.tsx

```

### Different sizes

```jsx
<Stack flexDirection="column">
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
size="small"
/>
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
size="default"
/>
</Stack>
```jsx file=../../examples/EntryCard/EntryCardSizesExample.tsx

```

### With a drag handle

```jsx
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
withDragHandle
/>
```jsx file=../../examples/EntryCard/EntryCardDragHandleExample.tsx

```

### With a thumbnail

```jsx
<EntryCard
status="published"
contentType="Author"
title="John Doe"
description="Research and recommendations for modern stack websites."
thumbnailElement={<img src="https://picsum.photos/200" />}
/>
```jsx file=../../examples/EntryCard/EntryCardThumbnailExample.tsx

```

<Stack justifyContent="space-between" marginTop="spacing2Xl" marginBottom="spacingL">
<Heading id="props-api-reference" as="h2" marginTop="none" marginBottom="none">
Props (API reference)
</Heading>

<TextLink
href="https://v4-f36-storybook.netlify.app/?path=/story/components-card-entrycard"
target="_blank"
alignIcon="end"
icon={<ExternalLinkIcon />}
>
Open in Storybook
</TextLink>
</Stack>
## Props (API reference)

<PropsTable of="EntryCard" />

Expand Down