question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alert plugin improvements

See original GitHub issue

Hi,

I think the alert plugin is a little too opiniated. It would be great if we could customize it a little bit more.

For instance :

  • Being able not to have a header
  • Being able to add extra classes to the elements of the modal (buttons, etc)
  • Being able to prevent the modal from closing on onConfirm() and onCancel() events
  • Being able to target the button that was clicked on onConfirm() and onCancel() events

What I suggest is adding a few more options. Maybe an object for the buttons ?

confirm: {
  'text': 'Confirm',
  'classes': 'is-link'
}

cancel: {
  'text': 'Cancel',
  'classes': 'is-danger'
}

To prevent the modal from being destroyed on onConfirm() and onCancel(), I suggest adding two more options :

destroyOnCancel: true|false // defaulted to true
destroyOnConfirm: true|false // defaulted to true

To target the button that was clicked on onConfirm() and onCancel() events, I suggest adding the event as a parameter on the ‘click’ event listener callback of the cancel and confim buttons. Like so:

confirmButton.addEventListener('click', e => {
  this.onConfirm(e);
  this.destroyOnConfirm && this.destroy(); // related to previous suggestion
});

cancelButton.addEventListener('click', e => {
  this.onCancel(e);
  this.destroyOnCancel && this.destroy(); // related to previous suggestion
});

I have some of these features already coded, I can submit a PR if you’re OK with the suggestions.

Waiting for your feedback, thanks !

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
alexcananacommented, Mar 4, 2019

Not sure about the security thing, I’m no JS expert…

Awesome work, thank you!

1reaction
VizuaaLOGcommented, Mar 1, 2019

@alexcanana Thank you for your suggestions. These have been added to the master branch and the new 0.9 documentation.

It’s not on NPM yet, just want to test a little bit make sure everything is okay.

I’ve added the option for custom classes on the buttons, but do not feel like other elements require custom classes. The alert is using the modal behind the scenes so any style changes made to that via your application will automatically apply to the alert, keeping consistency etc.

Should your app require changing the styling of other model elements within the alert, a new .alert class has been added to alert popups allowing you to only target those in your CSS.

If you have any further suggestions, please open a new issue. BulmaJS will only get better with everyone’s feedback. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Better Notifications for WP – WordPress plugin
Supercharge your WordPress email notifications using a WYSIWYG editor and shortcodes. Default and new notifications available.
Read more >
50 Plugins for Alerts and Notifications - TechSlides
Here is a list of the top jQuery plugins for alerts and messages and the best JavaScript notification libraries. Some are enhancements to ......
Read more >
[Improvement][Alert] Dingtalk alert plugin supports markdown ...
Dingtalk alert plugin supports markdown message type to format alert content for easy viewing of specific content.
Read more >
The new unified alerting system for Grafana: Everything you ...
From here, you can expect the following enhancements: It's now possible to create a multi-dimensional Grafana alert rule that generates multiple ...
Read more >
Plugin Hub - RuneLite
These plugins are verified by RuneLite Developers to ensure they comply with ... Show the status of your kitten and gives alerts to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found