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

feat(Stories): Add content property #225

Merged
merged 4 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/components/Stories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Component for displaying stories. It looks like a carousel in a modal with given
| Field | Type | Required | Default | Description |
| ----------- | ------------------ | -------- | ------- | -------------------------------- |
| title | `String` | | | Title |
| description | `String` | | | Main text |
| description | `String` | | | Main text, deprecated |
| content | `React.ReactNode` | | | Main content |
| url | `String` | | | Link to display more information |
| media | `StoriesItemMedia` | | | Media content |

Expand All @@ -41,7 +42,7 @@ Component for displaying stories. It looks like a carousel in a modal with given
items={[
{
title: 'Story title',
description: 'Story text',
content: <b>Story text</b>,
media: {
url: 'https://storage.yandexcloud.net/uikit-storybook-assets/story-picture-2.png',
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/Stories/__stories__/Stories.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
const items: StoriesItem[] = [
{
title: 'New navigation',
description:
content:
'At the top of the panel is the service navigation for each service. ' +
'Below are common navigation elements: a component for switching between accounts ' +
'and organizations, settings, help center, search, notifications, favorites.',
Expand All @@ -26,15 +26,15 @@ const items: StoriesItem[] = [
},
{
title: 'New navigation (2)',
description: 'A little more about the new navigation',
content: 'A little more about the new navigation',
media: {
url: 'https://storage.yandexcloud.net/uikit-storybook-assets/sample_960x400_ocean_with_audio.mp4',
type: 'video',
},
},
{
title: 'New navigation (3)',
description: 'Switch to the new navigation right now',
content: <b>Switch to the new navigation right now</b>,
media: {
url: 'https://storage.yandexcloud.net/uikit-storybook-assets/story-picture-4.png',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ export const StoriesLayout = (props: StoriesLayoutProps) => {
{currentStory.title && (
<div className={b('text-header')}>{currentStory.title}</div>
)}
{currentStory.description && (
{currentStory.content && (
<div className={b('text-content')}>
{currentStory.content}
</div>
)}
{!currentStory.content && currentStory.description && (
<div className={b('text-content')}>
{currentStory.description}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Stories/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type React from 'react';

export type StoriesItemMedia = {url: string} & (
| {
/** default 'image' */
Expand All @@ -12,7 +14,9 @@ export type StoriesItemMedia = {url: string} & (

export interface StoriesItem {
title?: string;
/** @deprecated use `content` property instead */
description?: string;
content?: React.ReactNode;
/** Url for link "more" */
url?: string;
media?: StoriesItemMedia;
Expand Down
Loading