<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Vanilla setup

Installing SWAN

If you are generating HTML pages using some template engines, installing SWAN will help with injecting styles and scripts.

Additionally, you may just want to reuse the design tokens that are exported within the SWAN package.

Configuring the .npmrc file for your project

SWAN is hosted in a private npm repository. To install the package, you need to ensure your project’s .npmrc file is correctly configured.

For detailed steps on configuring your npm client, see Install NPM Packages from Vistaprint Artifactory.

Install the latest version of SWAN

Configuring Page

Specifying the Locale (HTML Tag)

TheΒ htmlΒ tag must have aΒ langΒ attribute whose value is the language tag for that locale's language and region, using theΒ language and region subtags. For instance, the language tag for Irish English would beΒ en-IE, while the language tag for United States Spanish would beΒ es-US.

Configuring Head

Before you proceed with integrating SWAN on your page, it's advisable to refer to SWAN Assets Hosting and getSwanBaseUrl. SWAN exposes the utility getSwanAssetUrl which can be used to get appropriate asset URLs.

Add favicons

Add fonts and font faces

Most pages will need only the Graphik webfont.

Adding stylesheets

SWAN exports utility methods to retrieve the URLs for the hosted stylesheets, as shown below. Using these, you can add either hashed or versioned files.

If you are manually typing the URLs, it's advisable to use the versioned one.

Adding Scripts

Most of our components are CSS and HTML only and don't need any additional JavaScript. The components below require JavaScript, and we provide a vanilla JS implementation:

  • Accordion
  • Alert Box
  • core
  • Modal Dialog
  • Popover
  • Progress
  • Progressive Image
  • Tabs
  • Toggle Switch

Adding icons

Adding illustrations

SASS

There are separate instructions on how to use SWAN design tokens in your project's stylesheets.

If you’re using node-sass in your project, we recommend that you use sass instead of node-sass with SWAN. The sass project works with all the major bundlers and frameworks (eg. gatsby, webpack, snowpack, parcel, etc) without you needing to change anything in the configuration.

npm uninstall node-sass # if already installed
npm i sass -D


getSwanAssetUrl

Resolves the URL for a given SWAN asset (fonts, stylesheets, illustrations, icons, etc.) based on the asset type and key.


Configuring the Body

SWAN is built to be interoperable with other design systems to allow incremental adoption. To achieve this, everything related to swan must be within the swan class.

Page Structure

Pages need a single, consistent set of HTML tags and CSS classes for wrapping major elements of the page, to provide a standard layout, and to support any behaviors we want to be consistent across the site.