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: refactor Stories component #216

Closed
wants to merge 1 commit into from
Closed
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
38 changes: 26 additions & 12 deletions src/components/Stories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,37 @@ Component for displaying stories. It looks like a carousel in a modal with given
| onNextClick | `Function` | | | Action when switching to next story |
| disableOutsideClick | `Boolean` | | true | If `true`, do not close stories on click outside |
| className | `string` | | | Stories modal class |
| action | `ButtonProps` | | | Custom action button props for the last step |

### StoriesItem object

| Field | Type | Required | Default | Description |
| ----------- | ------------------ | -------- | ------- | -------------------------------- |
| title | `String` | | | Title |
| description | `String` | | | Main text |
| url | `String` | | | Link to display more information |
| media | `StoriesItemMedia` | | | Media content |
| Field | Type | Required | Default | Description |
| --------------- | ------------------------ | -------- | ------- | ---------------------------------------- |
| title | `String` | | | Title |
| description | `String` | | | Main text |
| url | `String` | | | Link to display more information |
| media | `StoriesItemMedia` | | | Media content |
| firstAction | `ButtonProps` | | | Custom action button props |
| secondAction | `ButtonProps` | | | Custom action button props |
| textBlockStyle | `StoriesTextBlockStyle` | ✓ | | Props for styling text content in Story |
| mediaBlockStyle | `StoriesMediaBlockStyle` | ✓ | | Props for styling media content in Story |
| textColorStyles | `StoriesItemTextStyles` | | | Props for styling text color in Story |

### StoriesItemMedia object

| Field | Type | Required | Default | Description |
| --------- | -------- | -------- | ------- | --------------------------------- |
| type | `String` | | image | Content type (`image` or `video`) |
| url | `String` | ✓ | | File link |
| posterUrl | `String` | | | Poster URL (only used for video) |
| Field | Type | Required | Default | Description |
| --------- | -------- | -------- | ------- | -------------------------------------------------- |
| type | `String` | ✓ | | Content type (`image` or `video`) |
| url | `String` | ✓ | | File link |
| url2x | `String` | | | File link for Retina display (only used for image) |
| posterUrl | `String` | | | Poster URL (only used for video) |

### StoriesItemTextStyles object

| Field | Type | Required | Default | Description |
| ---------------- | -------- | -------- | ------- | -------------------------------- |
| titleColor | `String` | | | Apply color to Story title |
| descriptionColor | `String` | | | Apply color to Story description |
| counterColor | `String` | | | Apply color to Story counter |

#### Usage example

Expand All @@ -42,6 +55,7 @@ Component for displaying stories. It looks like a carousel in a modal with given
{
title: 'Story title',
description: 'Story text',
type: 'image',
media: {
url: 'https://storage.yandexcloud.net/uikit-storybook-assets/story-picture-2.png',
},
Expand Down
11 changes: 7 additions & 4 deletions src/components/Stories/Stories.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
@use '../variables';

$block: '.#{variables.$ns}stories';
$borderRadius: 20px;

#{$block} {
--g-modal-border-radius: #{$borderRadius};
--g-modal-margin: 20px;
--g-modal-border-radius: var(--g-spacing-5);
--g-modal-margin: var(--g-spacing-5);

& .g-modal__content-wrapper {
overflow-x: initial;
}

&__modal-content {
border-radius: $borderRadius;
border-radius: var(--g-spacing-5);
}
}
4 changes: 0 additions & 4 deletions src/components/Stories/Stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {Modal} from '@gravity-ui/uikit';

import {block} from '../utils/cn';

import type {StoriesLayoutProps} from './components/StoriesLayout/StoriesLayout';
import {IndexType, StoriesLayout} from './components/StoriesLayout/StoriesLayout';
import {useSyncWithLS} from './hooks';
import type {StoriesItem} from './types';
Expand All @@ -26,7 +25,6 @@ export interface StoriesProps {
onNextClick?: (storyIndex: number) => void;
disableOutsideClick?: boolean;
className?: string;
action?: StoriesLayoutProps['action'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking change

syncInTabsKey?: string;
}

Expand All @@ -39,7 +37,6 @@ export function Stories({
initialStoryIndex = 0,
disableOutsideClick = true,
className,
action,
syncInTabsKey,
}: StoriesProps) {
const [storyIndex, setStoryIndex] = React.useState(initialStoryIndex);
Expand Down Expand Up @@ -125,7 +122,6 @@ export function Stories({
handleButtonClose={handleButtonClose}
handleGotoNext={handleGotoNext}
handleGotoPrevious={handleGotoPrevious}
action={action}
/>
</Modal>
);
Expand Down
Loading
Loading