juliancwirko / react-s-alert

Alerts / Notifications for React with rich configuration options
https://www.npmjs.com/package/react-s-alert
MIT License
649 stars 69 forks source link

Different global configs for different alert types #68

Open Venugopal46 opened 6 years ago

Venugopal46 commented 6 years ago

Is there a way to set different global configuration for different types of alert? like this

<Alert
    config={{
      success: {
        position: 'bottom-right',
        timeout: 5000
      },
      error: {
        position: 'top-right',
        timeout: 'none'
      }
   }}
/>

remaining options will be set to defaults.

juliancwirko commented 6 years ago

Not for now. But you can always prepare some of the configuration objects and just use them in Alert calls like:

export const alertError = {
  position: 'top-right',
  timeout: 'none'
};
import { alertError } from './alertError';

Alert.error('Error msg', alertError);

But maybe this could be a good improvement, so let's leave it here for now.

Valerika commented 5 years ago

Hi! Сan I do this?


export const Notification = {
  success: (msg, params) => {
    Alert.success(msg, { ...params });
  },
  info: (msg, params) => {
    Alert.info(msg, { ...params });
  },
  error: (msg, params) => {
    Alert.info(msg, { ...params });
  },
  warning: (msg, params) => {
    Alert.warning(msg, { ...params });
  }
};

 and  then 

Notification.success("test", {
    position: "top-right",
    beep: false,
    timeout: "none",
    offset: 100
  });