Skip to content

feat(Gallery): add a hook for opening the gallery from the custom content #275

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kseniya57
Copy link
Contributor

A hook for opening the gallery from the custom content

@kseniya57 kseniya57 self-assigned this Apr 3, 2025
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@kseniya57 kseniya57 force-pushed the open-gallery-hook branch from ac0cb65 to 156b01e Compare April 3, 2025 06:52
@kseniya57 kseniya57 force-pushed the open-gallery-hook branch 2 times, most recently from 06cd44a to 1e4d437 Compare April 24, 2025 13:15
@kseniya57 kseniya57 requested a review from amje April 28, 2025 04:51
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's name this file AsyncGallery.tsx to distinguish from normal Gallery component on search

import * as React from 'react';

export const Gallery = React.lazy(() =>
import('../../components/Gallery/Gallery').then((module) => ({default: module.Gallery})),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is default export necessary? We only use named exports through the codebase.


The hook for opening the gallery

### PropTypes
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep this section at the end of readme, and name it Properties


| Property | Type | Required | Values | Default | Description |
| :----------- | :---------------------------- | :------- | :----- | :------ | :------------------ |
| theme | `ThemeProviderProps['theme']` | | | `dark` | The gallery theme |
Copy link
Contributor

Choose a reason for hiding this comment

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

dark is no longer default, let's keep it blank, since it's inherited from the root ThemeProvider

| theme | `ThemeProviderProps['theme']` | | | `dark` | The gallery theme |
| className | `String` | | | | The modal class |
| container | `HTMLElement` | | | | The modal container |
| emptyMessage | `String` | | | No data | No data message |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| emptyMessage | `String` | | | No data | No data message |
| emptyMessage | `String` | | | "No data" | No data message |


_GalleryContextProvider_:

| Property | Type | Required | Values | Default | Description |
Copy link
Contributor

Choose a reason for hiding this comment

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

Values column seems to be unnecessary

> &
Pick<ThemeProviderProps, 'theme'>;

export const GalleryContextProvider = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's omit Context from the name, just GalleryProvider

import {GalleryContext} from './GalleryContext';

export function useGallery() {
return React.useContext(GalleryContext).openGallery;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe return whole context value here in case of extending API in the future?

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.

3 participants