GithubHelp home page GithubHelp logo

adam-singer / spritely Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danschultz/stitch

0.0 2.0 0.0 70 KB

A Dart package that uses transformers to generate CSS sprite sheets

License: MIT License

spritely's Introduction

Spritely

Spritely is a Dart package that uses transformers to generate CSS sprite sheets.

Configuration

Add Spritely to your pubspec.yaml.

name: my_app
description: A web application
dependencies:
  browser: any
  spritely: any
transformers:
- spritely

Usage

Spritely looks for links to a sprite sheet's CSS file. If one is found, it'll generate a CSS file and sprite sheet with all the PNGs that are contained within the directory of the same name as the sprite sheet.

For example, lets say you have a Dart application with the following folder structure:

my_app/
  lib/
  web/
    images/
      icons/
        star.png
        info.png
    index.html

To tell Spritely to generate a sprite sheet for all PNGs in web/images/icons, reference web/images/icons.css from an HTML file.

The generated CSS file contains classes that reference each sprite within the sheet. For each image, a class with the naming convention {folder-name}-{image-name} will be generated. Each class sets the element's background-image, background-position, width and height.

Using the star.png and info.png sprites in index.html:

<html>
  <head>
    <title>My App</title>
    <link rel="stylesheet" href="images/icons.css">
  </head>
  <body>
  	<div class="icons-star"></div>
  	<div class="icons-info"></div>
  </body>
</html>

Running pub build will compile your application and any referenced sprite sheets. Using the previous example, pub build would generate the following directory structure:

my_app/
  build/
    web/
      images/
        icons/
          star.png
          plus.png
        icons.css
        icons.png
      index.html
  ...

Todo

  • Add support for SASS
  • Add support for LESS
  • Customization options: padding, sprite layout, etc.

spritely's People

Contributors

danschultz avatar

Watchers

 avatar  avatar

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.