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(Overlay): implement component #1474

Merged
merged 7 commits into from
Jun 25, 2024

Conversation

Vladeeg
Copy link
Contributor

@Vladeeg Vladeeg commented Apr 2, 2024

No description provided.

@Vladeeg Vladeeg requested a review from IsaevAlexandr April 2, 2024 15:43
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@gravity-ui-bot
Copy link
Contributor

Playwright Test Component is ready.

</div>
);
};
export const Default = DefaultTemplate.bind({});
Copy link
Contributor

Choose a reason for hiding this comment

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

pls add more examples in storybook.
I think overlay in dialog content and table overlay would be enough.
It is better to do an example with a table when there is no data at first and they are loaded worse to show how overlay min height work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👌 Added some additional examples

}

export function LoadingOverlay({
loaderProps,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we realy need override className in Loader component?
I think it's not worth giving the user this opportunity to mix class name.
instead of loaderProps let pass size prop only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the Loader from here after the discussion, so looks like it's no longer relevant :)

<Box className={b(null, className)} {...boxProps}>
<div className={b('overlay', {visible: loading})}>
<div className={b('background', {type: background})} />
<Loader {...loaderProps} />
Copy link
Contributor

Choose a reason for hiding this comment

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

how do you think, may be add ability to pass a component insted of hardcode Loader component?

const LoadingOverlay = ({
  loaderSlot,
  size = 'm',
}: {loader: React.ReactNode}) => {
  return (
     ...
     {typeof loaderSlot === 'undefined' ? <Loader size={size} /> : loaderSlot}
     ...
  )
}

it is important to make it possible to pass null so that the display can be completely redefined.

<div>I am an example</div>
<div>content</div>
</LoadingOverlay>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

need to add some info about override background by --g-color-base-background css custom property

and examples with loader overrides

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added examples for different loaders, as for overriding --g-color-base-background, as I remember, we've decided that it's not really appreciated by designers?

@Vladeeg Vladeeg force-pushed the feature/implement-loading-overlay-component branch from 0368a2c to 73868ac Compare April 18, 2024 14:58
@Vladeeg Vladeeg changed the title feat(LoadingOverlay): implement component feat(Overlay): implement component Apr 18, 2024
@Vladeeg Vladeeg force-pushed the feature/implement-loading-overlay-component branch 2 times, most recently from 9de529e to 792bbf6 Compare April 22, 2024 08:40
children,
}: OverlayProps) {
return (
<div className={b({visible: loading}, className)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use Flex component here and remove styles with centring from .scss file

### Basic usage

```jsx
<div style={{position: 'relative'}}>
Copy link
Contributor

Choose a reason for hiding this comment

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

When we discussed this component last time, we agreed to add the position property to the Box component and make an example with this application

| view | `"base"` `"float"` | | `base` | Overlay background style |
| children | `React.ReactNode` | | | Content, usually a Loader component |

### Basic usage
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use also add .msx docs for storybook?

import {Overlay} from '@gravity-ui/uikit';
```

The `Overlay` component renders an overlay over the parent element with relative position.
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be highlighted here that the component should be used with a parent with position: relative

children?: React.ReactNode;
}

export function Overlay({
Copy link
Contributor

Choose a reason for hiding this comment

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

@amje @korvin89 Do we want to name this component Overlay or Backdrop?

Copy link
Contributor

Choose a reason for hiding this comment

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

Backdrop is a special case of Overlay use. So I think Overlay name is ok

<div style={{position: 'relative'}}>
<div>Some content to hide under overlay</div>
<Overlay visible={loading}>
<Loader />
Copy link
Contributor

Choose a reason for hiding this comment

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

@amje @korvin89 are you sure that this use case is really convenient? Do I transfer the same component to the loader every time? It looks like 90% of all uses here will be such a <Loader /> component and it should be made default by default

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I believe it's better to be that way, Overlay is a utility component, it shouldn't have "default" look. The look will depend on the usage context. Also, turning off the default behaviour would look a bit wierd:

<Overlay visible children={null} />

src/components/Overlay/__stories__/utils.tsx Outdated Show resolved Hide resolved
src/components/Overlay/__stories__/Overlay.stories.tsx Outdated Show resolved Hide resolved
src/components/Overlay/__stories__/Overlay.stories.tsx Outdated Show resolved Hide resolved
src/components/Overlay/Overlay.scss Outdated Show resolved Hide resolved
src/components/Overlay/Overlay.scss Outdated Show resolved Hide resolved
src/components/Overlay/README.md Outdated Show resolved Hide resolved
src/components/Overlay/README.md Outdated Show resolved Hide resolved
src/components/Overlay/README.md Outdated Show resolved Hide resolved
src/components/Overlay/__stories__/Overlay.scss Outdated Show resolved Hide resolved
src/components/Overlay/__stories__/Overlay.stories.tsx Outdated Show resolved Hide resolved
@Vladeeg Vladeeg force-pushed the feature/implement-loading-overlay-component branch from 792bbf6 to 9fe109d Compare May 22, 2024 10:55
src/components/index.ts Outdated Show resolved Hide resolved
src/components/Overlay/Overlay.scss Outdated Show resolved Hide resolved
src/components/Overlay/__stories__/OverlayShowcase.scss Outdated Show resolved Hide resolved
src/components/Overlay/README.md Outdated Show resolved Hide resolved
@Vladeeg Vladeeg force-pushed the feature/implement-loading-overlay-component branch from 9fe109d to 207be73 Compare June 13, 2024 16:01
@gravity-ui-bot
Copy link
Contributor

Visual Tests Report is ready.

@Vladeeg Vladeeg requested a review from amje June 17, 2024 11:52
src/components/Overlay/README.md Show resolved Hide resolved
src/components/Overlay/README.md Outdated Show resolved Hide resolved
src/components/Overlay/README.md Outdated Show resolved Hide resolved
src/components/Overlay/Overlay.scss Outdated Show resolved Hide resolved
@Vladeeg Vladeeg force-pushed the feature/implement-loading-overlay-component branch from 97fcca7 to 336ec67 Compare June 25, 2024 09:06
@Vladeeg Vladeeg merged commit ef47354 into main Jun 25, 2024
5 checks passed
@Vladeeg Vladeeg deleted the feature/implement-loading-overlay-component branch June 25, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants