= The Forgotten Child: Powerful CSS with Rails by Geoffrey Grosenbach
Working title:
Deplyoing scalable thread-safe rails-generated css in jruby, with agiity (please mention on Twitter)
Like to start with a little humor:
- When americans think of Berlin they think of: "Ich bin ein Berliner"
- Was meaningful to Germans
- "Ich bin ein Chunky Bacon"
The internet scale of humor:
- heh
- hah
- lol
- LOL
- rofl lmao
Jokes about Recursion is always funny for us developers
But CSS is NOT funny
Why not:
CSS = Type.new "text/css", :css
There is stylesheets directory, but it is up to you to put together a stylesheet
For many people it works, and that's a good way to do it
There are still benefits in generating CSS dynamically
== Why generate CSS?
* Repetition: The same color is written multiple places in the stylesheet
* If you are a programmer wanting to write some css, you are stuck with these things
* Have to report e.g.
element three times in the stylesheet
* Information about the width is usually in the stylesheet, and only there (pnn.com example)
== Stylesheet elements
* Colors
* Layouts
* Typography
* Compatibility
* Devices
Each one of these can be split out, and be dynamically generated, and the rest can just be static
== How?
=== ERB
Already built into Rails:
* Generate stylesheets controller
* Add a Mimetype of type "text/css"
* In controller:
caches_page :application
def application
respond_to do |format|
format.css
end
end
===== Advantages
* DB Driven
* Familiar
* No plugins needed
=== HAML
HAML: No angle brackets!
=== SASS
SASS is meant to be a very descriptive, css-targeted template
- Very nice way to write CSS
/public/stylesheets/sass/[...].sass
- Will generate css files in the parent directory
A graphic designer who is familiar with CSS can easily use SASS - even based on an existing CSS file
You can set some values:
!pink = #ff43a7
#sidebar
color= !pink
You can actually do math:
!darker_pink = !pink - #333333
@import colors.sass
- Reuse of colors across various sass (css) files
dl.stat
clear: both
margin:
left: 2em
bottom: 1em
==== Features
* Not DB-driven
* Just an effiecent way to write CSS syntax
* In development mode it only reload with controllers
* Benefit: Very CSS-like
=== merb
Can also utilize the Sass Engine