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

@mantine/notifications Allow global notifications auto close customization #5329

Conversation

dillonstreator
Copy link

@dillonstreator dillonstreator commented Nov 26, 2023

This PR proposes extending the autoClose functionality by allowing a callback to be specified (in addition to the existing number | false) that receives the NotificationData and returns number | false. This enables creating a "global" default ruleset/config on the Notifications component.

import { Notifications, NotificationData, DEFAULT_AUTO_CLOSE_DURATION_MS } from '@mantine/notifications';

// red notifications will require manual close while all others close in the default auto close duration (4000ms)
function Demo() {
  return <Notifications autoClose={(data: NotificationData) => {
    if (data.color === 'red') return false;

    return DEFAULT_AUTO_CLOSE_DURATION_MS;
  }} />;
}

This global config can be overridden at the time of calling showNotification by specifying autoClose.

@dillonstreator dillonstreator changed the title Allow global notifications auto close customization @mantine/notifications Allow global notifications auto close customization Nov 26, 2023
@dillonstreator dillonstreator force-pushed the global-notifications-auto-close-customization branch from c89a7a0 to d3872e9 Compare November 26, 2023 06:36
@rtivital
Copy link
Member

rtivital commented Dec 7, 2023

Thanks for showing interest in contributing to Mantine! Unfortunatelly, this contribution cannot be accepted as it does not align with the project roadmap. Be sure to discuss changes that you are planning to implement with the maintainer before submitting a PR like it is described in the contributing guideline – https://mantine.dev/contribute/#contributing-workflow

@rtivital rtivital closed this Dec 7, 2023
@dillonstreator
Copy link
Author

Sounds good! Getting the conversation started here https://github.com/orgs/mantinedev/discussions/5383

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.

2 participants