Git Product home page Git Product logo

stylesheet.js's Introduction

stylesheet.js Build Status

Generate and edit a dynamic Cascading Style Sheet using JavaScript.

Getting Started

npm

Install the script via npm:

npm install stylesheet.js --save

Require it in your app:

var Stylesheet = require('stylesheet.js');

Bower

Install the script via bower:

bower install stylesheet.js --save

Include it in the head of your page:

<head><script src="/bower_components/stylesheet.js/dist/stylesheet.min.js"></script></head>

You are now ready to go!

Documentation

Generate a new Instance:

var stylesheet = new Stylesheet();

#addRule

You can add new rules to that created stylesheet. It takes 3 parameters:

  • required String selector The CSS selector.
  • required String rules The CSS rules.
  • optional Number index An index, where to insert the rule at in the new stylesheet.

#deleteRule

To delete a rule, pass in the selector of that rule.

  • required String selector The CSS selector.

#clear

This will clear the whole stylesheet, leaving it empty without any rules.

Examples

var stylesheet = new Stylesheet();

stylesheet.addRule('.ninja', 'visibility: hidden;'); // Add a new rule
stylesheet.addRule('.bear', 'color: white;'); // Add a second rule
stylesheet.addRule('.bear', 'color: brown;', 0); // Add as first rule

stylesheet.deleteRule('.ninja'); // Delete the .ninja rule

stylesheet.clear(); // Clear all rules

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2014 Robert Katzki. Licensed under the MIT license.

stylesheet.js's People

Contributors

ro-ka avatar

Stargazers

Paul Clark avatar

Watchers

 avatar James Cloos 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.