Code Monkey home page Code Monkey logo

flair's Introduction

Flair

Flair is a little "language" that "compiles" into CSS.

Compile a flair script: (an example is provided in /bin)

./flair /example/code.flair
=> creates code.css

This project is just getting started, if you have any ideas or suggestions please open an issue here.

Examples that work: (for right now)

CSS class selectors:

class Wrapper:
    background = "rgb(255, 255, 255)"
    padding = 1

compiles to:

.wrapper {
    background: rgb(255, 255, 255);
    padding: 1em;
}

CSS id selectors:

id Navigation:
    background = "rgb(40, 40, 40)"
    float = "left"

compiles to:

#navigation {
   background: rgb(40, 40, 40);
   float: left;
}

Author:

Jarod Luebbert

More About Flair:

Flair was inspired by Coffee-Script and the book "Create Your Own Freaking Awesome Programming Language". It is meant for developers who do not enjoy writing CSS.

Future of Flair:

  • allow classes and identifiers to 'inherit' from each other
  • access class and indentifier attributes from other classes/identifiers
  • should be able to set attributes on condition (active, hover, etc)
  • python like import of other files
  • mixins for repetitive css blocks
  • some way to template common styles

A simple example showing inheritance and attribute accessors:

import 'fonts'
import 'reset'

# variables for storing a color or path to file
@body_bg = "rgb(120, 125, 10)"
@link_img = "/images/link_bg.png"

class Header:
    background = "rgb(255, 255, 255)"
    margins = { right => 0.5, bottom => 0.5 }
    padding = 1

    if parent == div:
        # do something
    elsif parent == ul:
        # do something specific to ul

class Footer < Header:
    min-height = 15
    border = "1px solid blue"

class Button:
    color = "blue"

    if hover:
        color = "red"
    elsif active:
        color = "green"

id Featured:
    background = Header.background
    border = Footer.border

would compile to:

.header, .footer {
  background: rgb(255, 255, 255);
  margin-right: 0.5em;
  margin-bottom: 0.5em;
  padding: 1em;
}

.footer {
  min-height: 15em;
  border: 1px solid blue;
}

.button {
  color: blue;
}

.button:hover {
  color: red;
}

#featured {
  background: rgb(255, 255, 255);
  border: 1px solid blue;
}

Don't like whitespace?

I have gone back and forth between using whitespace or begin..end blocks like Ruby. I think I will stick with whitespace for now unless I find a good reason to do otherwise. The only reason I can think of is to also change the syntax of assignment from using = to using : like coffee-script and CSS.

class Header
  background: "rgb(240, 240, 240)"
  height: 20
end

id Footer < Header
  color: red
end

flair's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

marksands

flair's Issues

flair doesn't behave well with no returns in textmate

it appears vim doesn't care, but in textmate if you don't have a carriage return at the end of a statement, it won't compile:
class Foo:
width = 9001

id Bar:
    background = "#fff"

Without an explicit newline, it parses the code as a nil string.

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.