Code Monkey home page Code Monkey logo

gcss's Introduction

GCSS - Pure Go CSS Preprocessor

wercker status Build status Coverage Status GoDoc ![Gitter](https://badges.gitter.im/Join Chat.svg)

Overview

GCSS is a pure Go CSS preprocessor. This is inspired by Sass and Stylus.

Syntax

Variables

$base-font: Helvetica, sans-serif
$main-color: blue

body
  font: 100% $base-font
  color: $main-color

Nesting

nav
  ul
    margin: 0
    padding: 0

a
  color: blue
  &:hover
    color: red

Mixins

$border-radius($radius)
  -webkit-border-radius: $radius
  -moz-border-radius: $radius
  -ms-border-radius: $radius
  border-radius: $radius

.box
  $border-radius(10px)

Installation

$ go get -u github.com/yosssi/gcss/...

Compile from the Command-Line

$ gcss /path/to/gcss/file

or

$ cat /path/to/gcss/file | gcss > /path/to/css/file

Compile from Go programs

You can compile a GCSS file from Go programs by invoking the gcss.CompileFile function.

cssPath, err := gcss.CompileFile("path_to_gcss_file")

if err != nil {
	http.Error(w, err.Error(), http.StatusInternalServerError)
	return
}

http.ServeFile(w, r, cssPath)

You can invoke the gcss.Compile function instead of the gcss.CompileFile function. The gcss.Compile function takes io.Writer and io.Reader as a parameter, compiles the GCSS data which is read from the io.Reader and writes the result CSS data to the io.Writer. Please see the GoDoc for the details.

f, err := os.Open("path_to_gcss_file")

if err != nil {
	panic(err)
}

defer func() {
	if err := f.Close(); err != nil {
		panic(err)
	}
}()

n, err := gcss.Compile(os.Stdout, f)

Documentation

Syntax Highlightings

  • vim-gcss - Vim syntax highlighting for GCSS

gcss's People

Contributors

mattn avatar yosssi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gcss's Issues

include using text/templates.

Hello,

Thanks for the great work. I have been using it for production for a while. However, I was wondering if you would consider introducing a way to import/include other gcss files, it will come extremely handy with Mixins specially.

I think compiling/preprocessing* every gcss file first as text/template would be a good solution, so you can just basically do {{ template "mixinCollection" }}.

Of course, using text/template would allow not only just including other templates but brings the complete power of Go templates in gcss. A bit of a madness be extremely powerful nonetheless.

Preprocessing before preprocessing

Can't use media queries?!

Has anyone gotten media queries working with gcss? Any '@' rules I try to use just get striped.

I've tried it with variables, nesting, and even just good'ol css.

Allow use of @apply in gcss

I'm trying to use Gcss with polymer and some of the components require the use @apply in the CSS. Currently gcss strips these tags out when compiled. It would be helpful if when compiling gcss would ignore such tags.

To see an example of how these are used see https://github.com/PolymerElements/iron-flex-layout/blob/master/demo/x-app.html

Example gcss file

html, body
  height: 100%

body
  margin: 0

:host
  @apply(--layout-horizontal)
  @apply(--paper-font-body2)

[nav]
  @apply(--layout-vertical)
  width: 200px
  background-color: var(--paper-grey-300)

Generated css

html,body{height:100%;}body{margin:0;}[nav]{width:200px;background-color:var(--paper-grey-300);}

Various parsing bugs.

max-width: 100% will not parse and produces: max-width: 100%! (MISSING).

display:block will not parse and produces no output. spaces should not necessarily be required between rules but if they are, surely this should throw an error.

Allow variables within parenthesis

Without space padding variables don't work within parentheses. If I pad them with spaces like this ( $url ) they work though.

GCSS:

$image-url: ../image/svg/footer.svg

$background-mixin($url)
  background-image: url($url)

#background
  $background-mixin($image-url)

EXPECTED:
#background{background-image:url(../image/svg/footer.svg);}

ACTUAL:
#background{background-image:url($url);}

But why...?

I don't get it... is this some project to show that Go can be used to do such things or was this really solving a pain point...? Why not just use execute an external program like lessc? Usually compiling from the sever side is done just once.. so am I missing something?

Allow variables in the middle of a statement

Using the following GCSS I have a $base-fonts variable I have some common fonts defined, and I have custom fonts before and after the variable. The problem is when the variable is surrounded by static items the variable seems to get skipped.

GCSS file (surrounded variable)

$color1: #2e6580
$color2: #3a83a7
$color3: #509ec4
$color4: #75b3d2
$color5: #9bc9df
$base-fonts: 'Helvetica Neue', Helvetica, Arial

h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6
  font-family: 'Droid Serif', $base-fonts, serif
  color: $color1
  a,a:hover,u
    color: $color1
    text-decoration: none
  small
    color: $color2

body
  font-family: 'Roboto', $base-fonts, sans-serif

footer
  margin-top: 10px

Produces

h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6 {
    font-family: 'Droid Serif', serif;
    color: #2e6580;
}

h1 a,h1 a:hover,h1 u,h2 a,h2 a:hover,h2 u,h3 a,h3 a:hover,h3 u,h4 a,h4 a:hover,h4 u,h5 a,h5 a:hover,h5 u,h6 a,h6 a:hover,h6 u,.h1 a,.h1 a:hover,.h1 u,.h2 a,.h2 a:hover,.h2 u,.h3 a,.h3 a:hover,.h3 u,.h4 a,.h4 a:hover,.h4 u,.h5 a,.h5 a:hover,.h5 u,.h6 a,.h6 a:hover,.h6 u {
    color: #2e6580;
    text-decoration: none;
}

h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small {
    color: #3a83a7;
}

body {
    font-family: 'Roboto', sans-serif;
}

footer {
    margin-top: 10px;
}

Removing the serif and sans-serif the $base-fonts works as expected.

4 spaces indenting

Is there an option to indent with 4 spaces instead of 2? Getting invalid indents while compiling:

indent is invalid [line: 2]

dead?

The last commit was 2014. Issues do not seem to get answered.
Is it safe to assume that this project can be considered unmaintained?

@import external stylesheets

Hi,

I'm trying to reference an external stylesheet from GCSS. Can it be done? Is there a way?

$font: 'Lato'
@import url("//fonts.googleapis.com/css?family=" + $font)

body
  font-family: $font, sans-serif

Best regards,
Aleander Rødseth

Todo

  • Create the command-line tool
  • Create the syntax highlighters
    • Vim
    • TextMate & SublimeText //-> put off
  • Create the website of GCSS //-> put off
  • Implement the selector
  • Implement the declaration
  • Implement the at-rule
  • Implement the mixin
  • Implement the assignment
  • Edit CompileBytes & check its comment
  • Handling of the error return by bytes.Buffer.WriteString()
  • Check the Sass's functions
  • Comment
  • GCSS for a Web server //-> canceled
  • Add the race detector to the test
  • Add e2e tests
  • Return an error if a selector has a suffix of "{", "}" or a declaration has a suffix of ";"
  • assign a variable to a mixin parameter
  • selector has a single mixin
  • font: 100% $font-stack
  • at-rule, mixin
  • Fix Compile: See http://www.reddit.com/r/golang/comments/2gkofb/yosssigcss_pure_go_css_preprocessor/
  • CI which runs tests on Windows

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.