Skip to content

Instantly share code, notes, and snippets.

@anotheremily
Last active December 14, 2015 22:19
Show Gist options
  • Save anotheremily/5157932 to your computer and use it in GitHub Desktop.
Save anotheremily/5157932 to your computer and use it in GitHub Desktop.
CoffeeSheets Example - Literate Example

Stylesheet for [name of project]

These are the main styles for the home page

class CoffeeSheetsExampleBaseClass extends CoffeeSheetStyleSheet {

This will execute on every page load generating beautiful styles for all!

   public void main () {

First we need to begin by setting up a style for the body.

      Selector body = new Selector("body");

The BackgroundColorFactory provides an elegant way for us to generate new colors with very few keystrokes! Parameter is a color provided by the ColorBuilder.

    BackgroundColor bodyBackgroundColor = BackgroundColorFactory.createBackgroundColor(ColorBuilder.generateBackgroundColorFromHexadecimalColor("#FFFFFF")); 

Create a selector attribute so we can attach this color to something!

    SelectorAttribute bodyBackgroundColorAttribute = new SelectorAttribute("background-color");
    bodyBackgroundColorAttribute.addValue(bodyBackgroundColor);

Add the attribute to the new selector and you're done!

    body.addCSSAttribute(bodyBackgroundColorAttribute);

Continue on for every other attribute, selector, etc!

    return;
  }
}

What could be easier? Clean, elegant, simple to use. Want more? Checkout CSUnit and CSDoc coming soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment