swup / astro

Astro integration for swup 🚀
94 stars 2 forks source link

Theme configuration object #11

Closed Tanguy-Magnaudet closed 1 year ago

Tanguy-Magnaudet commented 1 year ago

Describe the problem

When using a built in theme, we cannot pass a configuration object. this makes it impossible to change the direction of the overlay theme easely.

Describe the proposed solution

adding a themeConfig object that can be passed to the new SwupOverlayTheme() class, like so :

SwupOverlayTheme({
  direction: 'to-right'
});

How important is this feature to you?

daun commented 1 year ago

Good point. We're trying to get away from theme options, towards CSS custom properties for customizing themes. The direction option of overlays is the one single option that couldn't be converted easily.

We'll think of a way of making this configurable from the Astro integration.

In the meantime, this should do the trick when run after swup was initialized:

document.querySelector('.swup-transition-overlay').dataset.direction = 'to-right';
daun commented 1 year ago

We've released version 1.2.0 of the integration that allows customizing theme options:

{
  theme: ['overlay', { direction: 'to-right' }]
}