diff --git a/doc-src/content/reference/blueprint/colors.haml b/doc-src/content/reference/blueprint/colors.haml new file mode 100644 index 00000000..fb04fc6c --- /dev/null +++ b/doc-src/content/reference/blueprint/colors.haml @@ -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" diff --git a/doc-src/content/reference/blueprint/colors.yaml b/doc-src/content/reference/blueprint/colors.yaml new file mode 100644 index 00000000..6741d19d --- /dev/null +++ b/doc-src/content/reference/blueprint/colors.yaml @@ -0,0 +1,6 @@ +--- +title: Blueprint Color Module +framework: blueprint +stylesheet: blueprint/_colors.sass +classnames: + - reference diff --git a/doc-src/content/stylesheets/main.sass b/doc-src/content/stylesheets/main.sass index 77e1d0ae..c2b8b638 100644 --- a/doc-src/content/stylesheets/main.sass +++ b/doc-src/content/stylesheets/main.sass @@ -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 + \ No newline at end of file diff --git a/doc-src/layouts/partials/reference/constants.haml b/doc-src/layouts/partials/reference/constants.haml new file mode 100644 index 00000000..22f9928d --- /dev/null +++ b/doc-src/layouts/partials/reference/constants.haml @@ -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! diff --git a/doc-src/layouts/partials/reference/constants.yaml b/doc-src/layouts/partials/reference/constants.yaml new file mode 100644 index 00000000..2fbf0ffd --- /dev/null +++ b/doc-src/layouts/partials/reference/constants.yaml @@ -0,0 +1 @@ +--- {} diff --git a/doc-src/lib/default.rb b/doc-src/lib/default.rb index f57ca67c..dd40a1a2 100644 --- a/doc-src/lib/default.rb +++ b/doc-src/lib/default.rb @@ -22,4 +22,26 @@ def body_attributes(item) :id => body_id(item), :class => body_class(item) } -end \ No newline at end of file +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 diff --git a/doc-src/lib/stylesheets/sass_extensions.rb b/doc-src/lib/stylesheets/sass_extensions.rb index 5243ba03..16f4dd1a 100644 --- a/doc-src/lib/stylesheets/sass_extensions.rb +++ b/doc-src/lib/stylesheets/sass_extensions.rb @@ -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 \ No newline at end of file