Skip to content

Commit

Permalink
fix(Overlay.stories): codestyle/docs fixes + remove unnecessary story
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladeeg committed Jun 13, 2024
1 parent 5cc62a8 commit 207be73
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 70 deletions.
12 changes: 6 additions & 6 deletions src/components/Overlay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ You can use `base` or `float` background colors.

## Properties

| Name | Type | Required | Default | Description |
| :--------- | :----------------- | :------: | :------ | :---------------------------------- |
| className | `String` | | | CSS class name of the root element |
| visible | `Boolean` | | `false` | Overlay visibility state |
| background | `"base"` `"float"` | | `base` | Overlay background style |
| children | `React.ReactNode` | | | Content, usually a Loader component |
| Name | Description | Type | Default |
| :--------- | :---------------------------------- | :----------------: | :-----: |
| className | CSS class name of the root element | `String` | |
| visible | Overlay visibility state | `Boolean` | `false` |
| background | Overlay background style | `"base"` `"float"` | `base` |
| children | Content, usually a Loader component | `React.ReactNode` | |
2 changes: 1 addition & 1 deletion src/components/Overlay/__stories__/Docs.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Meta, Markdown} from '@storybook/addon-docs';
import * as Stories from './OverlayShowcase.stories';
import * as Stories from './Overlay.stories';
import Readme from '../README.md?raw';

<Meta of={Stories} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@use '../../variables';

$block: '.#{variables.$ns}overlay-showcase';
$block: '.#{variables.$ns}overlay-stories';

#{$block} {
&__content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ import React from 'react';
import {ArrowsRotateRight} from '@gravity-ui/icons';
import type {Meta, StoryObj} from '@storybook/react';

import {Showcase} from '../../../demo/Showcase';
import {ShowcaseItem} from '../../../demo/ShowcaseItem';
import {Button} from '../../Button';
import {Dialog as DialogComponent} from '../../Dialog';
import {Icon} from '../../Icon';
import {Loader} from '../../Loader';
import {Table as TableComponent} from '../../Table';
import {Box, Flex} from '../../layout';
import {Box} from '../../layout';
import {block} from '../../utils/cn';
import {Overlay} from '../Overlay';
import type {OverlayProps} from '../Overlay';

import {columns, data} from './data';
import type {DataItem} from './data';

import './OverlayShowcase.scss';
import './Overlay.stories.scss';

const b = block('overlay-showcase');
const b = block('overlay-stories');

type Story = StoryObj<typeof Overlay>;

Expand All @@ -33,7 +34,7 @@ export const Default: Story = {
},
render: (args) => {
return (
<div className={b()}>
<Showcase>
<Box position="relative" className={b('content')}>
<div>Example of overlay</div>
<div>with loader</div>
Expand All @@ -58,7 +59,7 @@ export const Default: Story = {
<div>without children</div>
<Overlay {...args} />
</Box>
</div>
</Showcase>
);
},
};
Expand All @@ -69,66 +70,27 @@ export const Background: Story = {
},
render: (args) => {
return (
<div className={b()}>
<Box position="relative" className={b('content')}>
<div>I am an example</div>
<div>content</div>
<Overlay {...args} background="base" />
</Box>
<span style={{margin: '16px'}} />
<Box position="relative" className={b('content')}>
<div>I am an example</div>
<div>content</div>
<Overlay {...args} background="float" />
</Box>
</div>
);
},
};

export const DialogTemplate: Story = {
args: {
visible: true,
},
render: (args) => {
const dialogTitleId = 'app-dialog-title';
return (
<DialogComponent
open
onClose={() => {}}
onEnterKeyDown={() => {
alert('onEnterKeyDown');
}}
aria-labelledby={dialogTitleId}
>
<DialogComponent.Header caption="Caption" id={dialogTitleId} />
<DialogComponent.Body>
<Box position="relative" width={480} height={212}>
<Flex direction="column" gap={2}>
Some text to show in dialog body
<Button>Some interaction</Button>
</Flex>
<Overlay {...args}>
<Flex direction="column" centerContent>
<Loader size="m" />
<Box style={{textAlign: 'center'}} spacing={{mt: 3}}>
Loading text about process with long description to show
<br /> max content-width
</Box>
</Flex>
</Overlay>
<Showcase>
<ShowcaseItem title="base">
<Box position="relative" className={b('content')}>
<div>I am an example</div>
<div>content</div>
<Overlay {...args} background="base" />
</Box>
</ShowcaseItem>
<ShowcaseItem title="float">
<Box position="relative" className={b('content')}>
<div>I am an example</div>
<div>content</div>
<Overlay {...args} background="float" />
</Box>
</DialogComponent.Body>
<DialogComponent.Footer
onClickButtonApply={() => alert('onApply')}
textButtonApply="Apply"
/>
</DialogComponent>
</ShowcaseItem>
</Showcase>
);
},
};

const TableShowcase = (args: OverlayProps) => {
const TableView = (args: OverlayProps) => {
const [loading, setLoading] = React.useState(false);
const [loadedData, setData] = React.useState<DataItem[]>([]);

Expand Down Expand Up @@ -162,5 +124,5 @@ const TableShowcase = (args: OverlayProps) => {

export const Table: Story = {
args: {},
render: TableShowcase,
render: TableView,
};

0 comments on commit 207be73

Please sign in to comment.