A module documentation for blueprint/colors and a constants partial.

This commit is contained in:
Chris Eppstein 2010-01-23 19:48:25 -08:00
parent 769e9c0c8e
commit 0fd292b776
7 changed files with 140 additions and 1 deletions

View File

@ -0,0 +1,11 @@
%h1= item[:title]
%p
The blueprint colors module defines the default colors that are used by the blueprint
framework.
= render "partials/reference/imports"
= render "partials/reference/constants"
= render "partials/reference/mixins"

View File

@ -0,0 +1,6 @@
---
title: Blueprint Color Module
framework: blueprint
stylesheet: blueprint/_colors.sass
classnames:
- reference

View File

@ -35,4 +35,13 @@ body.reference
a.view-source
float: right
margin: 1.25em
table.constants
width: 100%
+alternating-rows-and-columns(#eee, #bbb, #191919)
+outer-table-borders(2px)
+inner-table-borders(1px)
td, th
padding: 0.25em 0.5em

View File

@ -0,0 +1,21 @@
- if (constant_defs = constants(@item)).any?
%h2 Constants
- cycle 'even', 'odd' do |row_classes|
- cycle 'even', 'odd' do |col_classes|
%table.constants{:cellspacing => "0", :cellpadding=>"0", :border => "0"}
%thead
%tr{:class => row_classes.next}
%th{:class => col_classes.next} Constant
%th{:class => col_classes.next} Value
%th{:class => col_classes.next} Overridable?
- col_classes.reset!
- constant_defs.each do |constant_def|
%tr{:class => row_classes.next}
%td{:class => col_classes.next}
%code= "!"+constant_def.name
%td{:class => col_classes.next}
%code= constant_def.expr.to_sass
%td{:class => col_classes.next}
%code= constant_def.guarded ? "Y" : "N"
- col_classes.reset!

View File

@ -0,0 +1 @@
--- {}

View File

@ -22,4 +22,26 @@ def body_attributes(item)
:id => body_id(item),
:class => body_class(item)
}
end
end
class Recycler
attr_accessor :values
attr_accessor :index
def initialize *values
self.values = values
self.index = 0
end
def next
values[index]
ensure
self.index += 1
self.index = 0 if self.index >= self.values.size
end
def reset!
self.index = 0
end
end
def cycle(*args)
yield Recycler.new *args
end

View File

@ -25,6 +25,9 @@ module Sass
end
class VariableNode < Node
attr_accessor :name unless method_defined? :name
attr_accessor :expr unless method_defined? :expr
attr_accessor :guarded unless method_defined? :guarded
attr_accessor :comment unless method_defined? :comment
end
class IfNode < Node
def to_sass
@ -55,6 +58,9 @@ module Sass
sass_str
end
end
class VariableNode < Node
attr_accessor :comment unless method_defined? :comment
end
class MixinDefNode < Node
attr_accessor :name unless method_defined? :name
attr_accessor :args unless method_defined? :args
@ -108,4 +114,67 @@ module Sass
end
end
end
module Script
class Bool < Literal; alias to_sass to_s; end
class Color < Literal; alias to_sass to_s; end
class Funcall < Node
def to_sass
"#{name}(#{args.map {|a| a.to_sass}.join(', ')})"
end
end
class Number < Literal
def to_sass
value = if self.value.is_a?(Float) && (self.value.infinite? || self.value.nan?)
self.value
elsif int?
self.value.to_i
else
(self.value * PRECISION).round / PRECISION
end
value = "#{value}#{numerator_units.first}"
if (nu = numerator_units[1..-1]).any?
value << " * " + nu.map{|u| "1#{u}"}.join(" * ")
end
if (du = denominator_units).any?
value << " / " + du.map{|u| "1#{u}"}.join(" / ")
end
value
end
end
class Operation < Node
OPERATORS_TO_SASS = {
:plus => '+',
:minus => '-',
:div => '/',
:mult => '*',
:comma => ',',
:concat => ' ',
:neq => '!=',
:eq => '==',
:or => 'or',
:and => 'and'
}
def to_sass
"#{operand_to_sass(@operand1)} #{OPERATORS_TO_SASS[@operator]} #{operand_to_sass(@operand2)}"
end
def operand_to_sass(operand)
if operand.is_a? Operation
"(#{operand.to_sass})"
else
operand.to_sass
end
end
end
class String < Literal
def to_sass
value.inspect
end
end
class UnaryOperation < Node
def to_sass
"#{@operator}#{@operand}"
end
end
class Variable < Node; alias to_sass inspect; end
end
end