We use texture atlassing to improve rendering and loading efficiency. This document explains how to generate the spritesheets used by the SpriteSystem and the page's css.
After installing the project dependencies, spritesheets can be generated with the command npm run spritesheet
. The exact parameters used by this script can be inspected in the package.json
where it is defined. More information about the tool we use, spritesheet-js
, can be found on the github page.
The steps to generate a spritesheet are :
- Move sprites you want in the sprite-system-spritesheet to
src/assets/images/sprites/
. - Move sprites you want in the css-spritesheet to
src/assets/images/css-sprites/
. - Type
npm run spritesheet
. This will generatesprite-system-spritesheet.json
withsprite-system-spritesheet.png
for the sprite system andcss-spritesheet.css
withcss-spritesheet.png
in the directorysrc/assets/images/spritesheets/
.
The name of the sprite that is used in the generated json
file is the same as its source filename; When a sprite component has the name foo.png
, the sprite system looks for that name in the json
file. It does not use the foo.png
source file.
The source images are exported from Figma. If you want to alter these images, it is probably best to do so in Figma, then re-export at the desired size. It is a good idea to stack all of the icons you want to export on top of one another in figma, because otherwise Figma produces surprisingly different results for similar icons when exporting at low resolution.