Code Monkey home page Code Monkey logo

Comments (4)

KevinBatdorf avatar KevinBatdorf commented on May 28, 2024 1

Hi @limonte,

I'll work on a PR this week. Finally found the time. I'll probably have some questions but hopefully not many.

One question that doesn't seem possible, can a theme define default JS settings? For example, the default animation class if none is set (WordPress fades in from the bottom).

I'll share some code here as well in case someone ends up here looking how to make it look right inside WordPress. For the offset question above, it looks like I will use something like this (the left nav panel can be dynamic, so it should calculate each time):

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

from sweetalert2-themes.

limonte avatar limonte commented on May 28, 2024 1

I'll work on a PR this week. Finally found the time. I'll probably have some questions but hopefully not many.

I'm here to answer any of your questions!

One question that doesn't seem possible, can a theme define default JS settings? For example, the default animation class if none is set (WordPress fades in from the bottom).

Yes, just redefine $swal2-show-animation and $swal2-hide-animation variables, we did the same in Bootstrap theme: https://github.com/sweetalert2/sweetalert2-themes/blob/master/bootstrap-4/bootstrap-4.scss#L169

You can find the list of all SCSS vriables here: https://github.com/sweetalert2/sweetalert2/blob/master/src/variables.scss

For the offset question above, it looks like I will use something like this (the left nav panel can be dynamic, so it should calculate each time):

Yup, exactly. Except this line isn't needed:

position: 'rtl' === document.dir ? 'bottom-end' : 'bottom-start',

start and end are handled with the document direction in mind.

from sweetalert2-themes.

limonte avatar limonte commented on May 28, 2024

Hey @KevinBatdorf and thank you for opening this request!

WordPress has toast style notifications now that might be a useful theme to some. I can probably work on this if there is interest.

Totally agree. It looks quite similar to the existing Dark theme, take a look at its implementation: https://github.com/sweetalert2/sweetalert2-themes/blob/master/dark/dark.scss

Here's how to start a new theme: https://github.com/sweetalert2/sweetalert2-themes#contributing

Let me know if you're willing to send a PR.

Also, is it possible to provide a dynamic offset like in this photo?

This can be achieved by using customClass with a class with desired margins, something like this:

Swal.fire({
  ...
  position: 'bottom-left',
  customClass: {
    container: 'offset-left' 
  }
})
.offset-left {
  margn-left: 200px;
}

from sweetalert2-themes.

limonte avatar limonte commented on May 28, 2024

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from sweetalert2-themes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.