5.0.26 • Published 11 months ago

@sweetalert2/theme-wordpress-admin v5.0.26

Weekly downloads
18
License
MIT
Repository
github
Last release
11 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.19

12 months ago

5.0.20

12 months ago

5.0.21

11 months ago

5.0.22

11 months ago

5.0.23

11 months ago

5.0.24

11 months ago

5.0.25

11 months ago

5.0.26

11 months ago

5.0.17

1 year ago

5.0.18

1 year ago

5.0.16

2 years ago

5.0.13

3 years ago

5.0.14

3 years ago

5.0.15

3 years ago

5.0.12

3 years ago

5.0.11

4 years ago

5.0.10

4 years ago

0.0.1

4 years ago

5.0.9

4 years ago

5.0.8

4 years ago

5.0.6

4 years ago

5.0.7

4 years ago

5.0.5

4 years ago

5.0.4

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.2.0

5 years ago

3.1.3

6 years ago

3.1.4

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago