This repo is used as a template for swup themes. Steps to publish your own swup theme:
- Make a copy of this repo.
- Update the name in package.json. Please, follow format
swup-[theme name]-theme. - Update the description, repository url and author in package.json.
- Write your theme in
src/index.js. Theme must be in a form of class, must extend@swup/themeand should have a property name defined (package.jsonname in a form PascalCase - swup-name-theme -> SwupNameTheme). - Update this documentation. Below is a documentation template where the SwupNameTheme needs to be replaced with your theme name from packages.json in PascalCase.
- Use
npm run buildto compile a standalone version of your theme (dist folder) and npm version of your theme (lib folder). Command is automatically executed before publishing. - Publish your theme to npm with
npm publishcommand. This assumes you have npm account and are logged in with your computers npm CLI.
- Checkout existing themes before creating one.
- Swup instance is automatically assigned to the theme instance and can be accessed under
this.swupinmount/unmountmethods.
- Swup theme automatically sets swup animationSelector option to
[class*="swup-transition-"]to prevent bugs related to other libraries using the same classes. Useswup-transition-*for your theme classes.
- Themes get a few special helper methods:
applyStylesto prepend style tag with defined content in the head tag.addClassNameto addswup-transition-[name]classname to an element.applyHTMLto append a DIV element with defined HTML content.
- If you feel like this should be an official swup theme (under npm
@swuporganization) and the world could use a thing like this, contact me at gmarcuk@gmail.com.
This is a theme for swup - complete, flexible, extensible and easy to use page transition library for your web.
This theme can be installed with npm
npm install swup-[theme-name]-themeand included with import
import Swup[ThemeName]Theme from 'swup-[theme-name]-theme';or included from the dist folder
<script src="./dist/SwupNameTheme.js"></script>To run this theme, include an instance in the swup options.
const swup = new Swup({
theme: [new SwupNameTheme()]
});