5.0.16 • Published 4 months ago

@sweetalert2/theme-wordpress-admin v5.0.16

Weekly downloads
18
License
MIT
Repository
github
Last release
4 months ago

Wordpress-admin Theme for SweetAlert2

npm version

npm.io

Installation

npm install --save sweetalert2 @sweetalert2/theme-wordpress-admin

Usage

With CSS:

<!-- Include the Wordpress-admin theme -->
<link rel="stylesheet" href="@sweetalert2/theme-wordpress-admin/wordpress-admin.css">

<script src="sweetalert2/dist/sweetalert2.min.js"></script>

With SASS:

your-app.js:

import Swal from 'sweetalert2/dist/sweetalert2.js'

your-app.scss:

@import '@sweetalert2/theme-wordpress-admin/wordpress-admin.scss';

Integration

To more closely match the WordPress style toast messages, use the following to get started:

const notify = Swal.mixin({
  toast: true,
  position: 'bottom-start',
  showConfirmButton: false,
  timer: 6000,
  willOpen: (toast) => {
    // Offset the toast message based on the admin menu size
    var dir = 'rtl' === document.dir ? 'right' : 'left'
    toast.parentElement.style[dir] = document.getElementById('adminmenu').offsetWidth + 'px'
  }
})

Further, when using icons you may wish to use WordPress Dashicons.

notify.fire({
  icon: 'success',
  iconHtml: '<div class="dashicons dashicons-yes" style="transform: scale(3);"></div>',
  title: 'Settings updated.',
})

Using modals as another example, you can add the Dashicon's megaphone icon.

Swal.fire({
  title: 'Hey, we have something to say!',
  confirmButtonText: 'Let\'s do this',
  showCancelButton: false,
  icon: 'info',
  iconHtml: '<div class="dashicons dashicons-megaphone" style="transform: scale(3.5);"></div>',
  text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.'
})

If you would like to use this theme outside of the WordPress admin area, you might want to set the font-family to use the font WordPress uses:

.swal2-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
5.0.16

4 months ago

5.0.13

2 years ago

5.0.14

2 years ago

5.0.15

1 year ago

5.0.12

2 years ago

5.0.11

2 years ago

5.0.10

2 years ago

0.0.1

2 years ago

5.0.9

2 years ago

5.0.8

2 years ago

5.0.6

3 years ago

5.0.7

3 years ago

5.0.5

3 years ago

5.0.4

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.5

3 years ago

4.0.4

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.2.0

4 years ago

3.1.3

4 years ago

3.1.4

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago