diff --git a/doc-src/content/CHANGELOG.markdown b/doc-src/content/CHANGELOG.markdown index 254549cb..205a12f0 100644 --- a/doc-src/content/CHANGELOG.markdown +++ b/doc-src/content/CHANGELOG.markdown @@ -79,7 +79,13 @@ gem to integrate with compass. Please read the [README](https://github.com/Compa `generated-image-url()` helper function. These should rarely be needed and will default to your corresponding image directories and paths. -0.11.7 (UNRELEASED) +0.11.8 (02/26/2012) +------------------- + +* Fix a bug in gradients that used the transparent keyword +* Add filesize to the `compass stats` output. + +0.11.7 (01/05/2012) ------------------- * Update to font-face mixin to make it work on IE8. diff --git a/doc-src/content/help/tutorials/configuration-reference.markdown b/doc-src/content/help/tutorials/configuration-reference.markdown index e078ba49..b6c49a3f 100644 --- a/doc-src/content/help/tutorials/configuration-reference.markdown +++ b/doc-src/content/help/tutorials/configuration-reference.markdown @@ -412,7 +412,7 @@ to avoid crashing the watcher in the case where the file has been removed. on_stylesheet_saved do |filename| Growl.notify { - self.message "#{File.basename(filename)} updated!" + self.message = "#{File.basename(filename)} updated!" self.icon = '/path/to/success.jpg' } end diff --git a/doc-src/content/help/tutorials/contributing.markdown b/doc-src/content/help/tutorials/contributing.markdown index ebe98a6c..e58465b3 100644 --- a/doc-src/content/help/tutorials/contributing.markdown +++ b/doc-src/content/help/tutorials/contributing.markdown @@ -89,12 +89,12 @@ If the tests fail, fix the tests or the stylesheets accordingly. If the tests, d fail, that means this aspect was not well enough tested. Please [add or augment a test](#writing-tests). -You're done. Please [submit your changes](#patches) +You're done. Please [submit your changes](#patches).

Making Stylesheet Changes

It is a good idea to discuss new features ideas with the compass users and developers -before building something. Please don't by shy; send an email to the [compass mailing +before building something. Please don't be shy; send an email to the [compass mailing list](http://groups.google.com/group/compass-users). Many feature ideas are good but not obviously a good fit for the compass core library. @@ -112,7 +112,7 @@ making extensions.][extensions] **Step 6**: Documentation - Add or update the reference documentation. Add an example of using the feature. See the [doc readme for details][documentation]. -You're done. Please [submit your changes](#patches) +You're done. Please [submit your changes](#patches).

Making Ruby Changes

diff --git a/frameworks/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss b/frameworks/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss index f669c85d..5d4a1298 100644 --- a/frameworks/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss +++ b/frameworks/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss @@ -1,3 +1,3 @@ @warn "This import is deprecated. Use 'compass/typography/lists/inline-block-list' instead."; -@import "../../typography/lists/inline-block-link"; +@import "../../typography/lists/inline-block-list"; diff --git a/lib/compass/commands/project_stats.rb b/lib/compass/commands/project_stats.rb index 42ab579e..7da2e227 100644 --- a/lib/compass/commands/project_stats.rb +++ b/lib/compass/commands/project_stats.rb @@ -34,13 +34,16 @@ module Compass compiler = new_compiler_instance sass_files = sorted_sass_files(compiler) total_label = "Total (#{sass_files.size} files):" - rows = [[ :-, :-, :-, :-, :-, :-, :- ], - [ 'Filename', 'Rules', 'Properties', 'Mixins Defs', 'Mixins Used', 'CSS Selectors', 'CSS Properties' ], - [ :-, :-, :-, :-, :-, :-, :- ]] - maximums = [ total_label.length, 5, 10, 14, 11, 13, 14 ] - alignments = [ :left, :right, :right, :right, :right, :right, :right ] - delimiters = [ ['| ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'] ] - totals = [ total_label, 0, 0, 0, 0, 0, 0 ] + rows = [[ :-, :-, :-, :-, :-, :-, :-, :-, :- ], + [ 'Filename', 'Rules', 'Properties', 'Mixins Defs', 'Mixins Used', 'Filesize', 'CSS Selectors', 'CSS Properties', 'CSS Filesize' ], + [ :-, :-, :-, :-, :-, :-, :-, :-, :- ]] + maximums = [ total_label.length, 5, 10, 14, 11, 13, 13, 14, 14 ] + alignments = [ :left, :right, :right, :right, :right, :right, :right, :right, :right ] + delimiters = [ ['| ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'] ] + formatters = [ nil, nil, nil, nil, nil, :kb, nil, nil, :kb ] + totals = [ total_label, 0, 0, 0, 0, 0, 0, 0, 0 ] + + columns = rows.first.size sass_files.each do |sass_file| css_file = compiler.corresponding_css_file(sass_file) unless sass_file[0..0] == '_' @@ -53,12 +56,12 @@ module Compass end rows << row end - rows << [:-] * 7 + rows << [:-] * columns rows << totals.map{|t| t.to_s} - rows << [:-] * 7 + rows << [:-] * columns rows.each do |row| row.each_with_index do |col, i| - print pad(col, maximums[i], :align => alignments[i], :left => delimiters[i].first, :right => delimiters[i].last) + print pad(col, maximums[i], :align => alignments[i], :left => delimiters[i].first, :right => delimiters[i].last, :formatter => formatters[i]) end print "\n" end @@ -75,11 +78,23 @@ module Compass else filler = ' ' end + c = send(:"format_#{options[:formatter]}", c) if options[:formatter] spaces = max - c.size filled = filler * [spaces,0].max "#{options[:left]}#{filled if options[:align] == :right}#{c}#{filled if options[:align] == :left}#{options[:right]}" end + def format_kb(v) + return v unless v =~ /^\d+$/ + v = Integer(v) + if v < 1024 + "#{v} B" + else + v = v / 1024.0 + "#{v.ceil} KB" + end + end + def sorted_sass_files(compiler) sass_files = compiler.sass_files(:exclude_partials => false) sass_files.map! do |s| @@ -100,7 +115,7 @@ module Compass def sass_columns(sass_file) sf = Compass::Stats::SassFile.new(sass_file) sf.analyze! - %w(rule_count prop_count mixin_def_count mixin_count).map do |t| + %w(rule_count prop_count mixin_def_count mixin_count file_size).map do |t| sf.send(t).to_s end end @@ -109,11 +124,11 @@ module Compass if File.exists?(css_file) cf = Compass::Stats::CssFile.new(css_file) cf.analyze! - %w(selector_count prop_count).map do |t| + %w(selector_count prop_count file_size).map do |t| cf.send(t).to_s end else - return [ '--', '--' ] + return [ '--', '--' , '--'] end rescue LoadError @missing_css_parser = true diff --git a/lib/compass/sass_extensions/functions/gradient_support.rb b/lib/compass/sass_extensions/functions/gradient_support.rb index a08b1c9d..c1fe1073 100644 --- a/lib/compass/sass_extensions/functions/gradient_support.rb +++ b/lib/compass/sass_extensions/functions/gradient_support.rb @@ -8,7 +8,9 @@ module Compass::SassExtensions::Functions::GradientSupport [color, stop].compact end def initialize(color, stop = nil) - unless Sass::Script::Color === color || Sass::Script::Funcall === color + unless Sass::Script::Color === color || + Sass::Script::Funcall === color || + (Sass::Script::String === color && color.value == "transparent") raise Sass::SyntaxError, "Expected a color. Got: #{color}" end if stop && !stop.is_a?(Sass::Script::Number) @@ -19,8 +21,16 @@ module Compass::SassExtensions::Functions::GradientSupport def inspect to_s end + def self.color_to_s(c) + if c.is_a?(Sass::Script::String) + c.value.dup + else + c.inspect.dup + end + end + def to_s(options = self.options) - s = color.inspect.dup + s = self.class.color_to_s(color) if stop s << " " if stop.unitless? @@ -227,13 +237,14 @@ module Compass::SassExtensions::Functions::GradientSupport def color_stops(*args) Sass::Script::List.new(args.map do |arg| - case arg - when ColorStop + if ColorStop === arg arg - when Sass::Script::Color + elsif Sass::Script::Color === arg ColorStop.new(arg) - when Sass::Script::List + elsif Sass::Script::List === arg ColorStop.new(*arg.value) + elsif Sass::Script::String === arg && arg.value == "transparent" + ColorStop.new(arg) else raise Sass::SyntaxError, "Not a valid color stop: #{arg.class.name}: #{arg}" end @@ -288,7 +299,7 @@ module Compass::SassExtensions::Functions::GradientSupport # returns color-stop() calls for use in webkit. def grad_color_stops(color_list) stops = color_stops_in_percentages(color_list).map do |stop, color| - "color-stop(#{stop.inspect}, #{color.inspect})" + "color-stop(#{stop.inspect}, #{ColorStop.color_to_s(color)})" end Sass::Script::String.new(stops.join(", ")) end diff --git a/lib/compass/stats.rb b/lib/compass/stats.rb index 243b42af..28de86e4 100644 --- a/lib/compass/stats.rb +++ b/lib/compass/stats.rb @@ -29,6 +29,7 @@ module Compass class CssFile attr_accessor :path, :css attr_accessor :selector_count, :prop_count + attr_accessor :file_size def initialize(path) require 'css_parser' self.path = path @@ -44,6 +45,7 @@ module Compass contents.inject(0){|m,c| m + 1 } end def analyze! + self.file_size = File.size(path) css.each_selector do |selector, declarations, specificity| sels = selector.split(/,/).size props = declarations.split(/;/).size @@ -55,6 +57,8 @@ module Compass class SassFile attr_accessor :path attr_reader :visitor + attr_accessor :file_size + def initialize(path) self.path = path end @@ -72,6 +76,7 @@ module Compass @visitor end def analyze! + self.file_size = File.size(path) visit_tree! end def lines diff --git a/test/fixtures/stylesheets/compass/css/gradients.css b/test/fixtures/stylesheets/compass/css/gradients.css index 384db492..73e1d13c 100644 --- a/test/fixtures/stylesheets/compass/css/gradients.css +++ b/test/fixtures/stylesheets/compass/css/gradients.css @@ -82,15 +82,25 @@ background-image: -ms-linear-gradient(left, #dddddd 10px, #aaaaaa 40px); background-image: linear-gradient(left, #dddddd 10px, #aaaaaa 40px); } -.bg-radial-gradient { - background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iMTAwIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZGRkZGRkIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjYWFhYWFhIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g'); +.transparent-in-linear-gradient { + background-image: white url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iInRyYW5zcGFyZW50IiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2FhYWFhYSIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='); background-size: 100%; - background-image: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 100, color-stop(0%, #dddddd), color-stop(100%, #aaaaaa)); - background-image: -webkit-radial-gradient(center center, #dddddd, #aaaaaa 100px); - background-image: -moz-radial-gradient(center center, #dddddd, #aaaaaa 100px); - background-image: -o-radial-gradient(center center, #dddddd, #aaaaaa 100px); - background-image: -ms-radial-gradient(center center, #dddddd, #aaaaaa 100px); - background-image: radial-gradient(center center, #dddddd, #aaaaaa 100px); } + background-image: white -webkit-gradient(linear, 0% 0%, 100% 100%, color-stop(0%, transparent), color-stop(100%, #aaaaaa)); + background-image: white -webkit-linear-gradient(top left, transparent, #aaaaaa); + background-image: white -moz-linear-gradient(top left, transparent, #aaaaaa); + background-image: white -o-linear-gradient(top left, transparent, #aaaaaa); + background-image: white -ms-linear-gradient(top left, transparent, #aaaaaa); + background-image: white linear-gradient(top left, transparent, #aaaaaa); } + +.transparent-in-linear-gradient { + background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iMTAwIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZGRkZGRkIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIidHJhbnNwYXJlbnQiIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g'); + background-size: 100%; + background-image: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 100, color-stop(0%, #dddddd), color-stop(100%, transparent)); + background-image: -webkit-radial-gradient(center center, #dddddd, transparent 100px); + background-image: -moz-radial-gradient(center center, #dddddd, transparent 100px); + background-image: -o-radial-gradient(center center, #dddddd, transparent 100px); + background-image: -ms-radial-gradient(center center, #dddddd, transparent 100px); + background-image: radial-gradient(center center, #dddddd, transparent 100px); } .bg-linear-gradient-with-angle { background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9Ii00NSIgeTE9IiIgeDI9Ii00NSIgeTI9IiIgZ3JhZGllbnRUcmFuc2Zvcm0gPSAicm90YXRlKC00NSkiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNkZGRkZGQiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNhYWFhYWEiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSJ1cmwoI2dyYWQpIiAvPjwvc3ZnPiA='); diff --git a/test/fixtures/stylesheets/compass/sass/gradients.sass b/test/fixtures/stylesheets/compass/sass/gradients.sass index dc915aa4..8251e9ce 100644 --- a/test/fixtures/stylesheets/compass/sass/gradients.sass +++ b/test/fixtures/stylesheets/compass/sass/gradients.sass @@ -31,8 +31,13 @@ $experimental-support-for-svg: true .bg-linear-gradient-pixel-stop-from-left +background-image(linear-gradient(left, #ddd 10px, #aaa 40px)) +.transparent-in-linear-gradient + +background-image(#fff linear-gradient(top left, transparent, #aaa)) + +.transparent-in-linear-gradient + +background-image(radial-gradient(center center, #ddd, transparent 100px)) + .bg-radial-gradient - +background-image(radial-gradient(center center, #ddd, #aaa 100px)) .bg-linear-gradient-with-angle +background-image(linear-gradient(-45deg, #ddd, #aaa)) @@ -231,3 +236,4 @@ $experimental-support-for-svg: true .ie-alpha-filter +filter-gradient(rgba(#fff, 1), rgba(#fff, 0)) +