compass 0.10.0.pre6 → 0.10.0.pre7

Sign up to get free protection for your applications and to get access to all the features.
data/REVISION CHANGED
@@ -1 +1 @@
1
- 9503512782eba7e387ba0dec14e5cfe1f3c0f22b
1
+ e3b0b06eda29c0fe179797f0f47d05d47cb0702c
@@ -2,4 +2,4 @@
2
2
  :patch: 0
3
3
  :major: 0
4
4
  :minor: 10
5
- :build: pre6
5
+ :build: pre7
@@ -6,10 +6,10 @@ module Compass::SassExtensions::Functions::GradientSupport
6
6
  self.values = values
7
7
  end
8
8
  def inspect
9
- to_s
9
+ values.map{|v| v.inspect}.join(", ")
10
10
  end
11
11
  def to_s
12
- values.map{|v| v.to_s}.join(", ")
12
+ inspect
13
13
  end
14
14
  end
15
15
 
@@ -22,13 +22,13 @@ module Compass::SassExtensions::Functions::GradientSupport
22
22
  to_s
23
23
  end
24
24
  def to_s
25
- s = "#{color}"
25
+ s = color.inspect.dup
26
26
  if stop
27
27
  s << " "
28
28
  if stop.unitless?
29
- s << stop.times(Sass::Script::Number.new(100, ["%"])).to_s
29
+ s << stop.times(Sass::Script::Number.new(100, ["%"])).inspect
30
30
  else
31
- s << stop.to_s
31
+ s << stop.inspect
32
32
  end
33
33
  end
34
34
  s
@@ -54,24 +54,27 @@ module Compass::SassExtensions::Functions::GradientSupport
54
54
 
55
55
  # returns color-stop() calls for use in webkit.
56
56
  def grad_color_stops(color_list)
57
+ assert_list(color_list)
57
58
  normalize_stops!(color_list)
58
59
  max = color_list.values.last.stop
59
60
  color_stops = color_list.values.map do |pos|
60
61
  # have to convert absolute units to percentages for use in color stop functions.
61
62
  stop = pos.stop
62
63
  stop = stop.div(max).times(Sass::Script::Number.new(100,["%"])) if stop.numerator_units == max.numerator_units
63
- "color-stop(#{stop}, #{pos.color})"
64
+ "color-stop(#{stop.inspect}, #{pos.color.inspect})"
64
65
  end
65
66
  Sass::Script::String.new(color_stops.join(", "))
66
67
  end
67
-
68
+
68
69
  # returns the end position of the gradient from the color stop
69
70
  def grad_end_position(color_list, radial = Sass::Script::Bool.new(false))
71
+ assert_list(color_list)
70
72
  default = Sass::Script::Number.new(100)
71
73
  grad_position(color_list, Sass::Script::Number.new(color_list.values.size), default, radial)
72
74
  end
73
75
 
74
76
  def grad_position(color_list, index, default, radial = Sass::Script::Bool.new(false))
77
+ assert_list(color_list)
75
78
  stop = color_list.values[index.value - 1].stop
76
79
  if stop && radial.to_bool
77
80
  orig_stop = stop
@@ -129,26 +132,28 @@ module Compass::SassExtensions::Functions::GradientSupport
129
132
  when Sass::Script::Color
130
133
  ColorStop.new(arg)
131
134
  when Sass::Script::String
132
- color, stop = arg.value.split(/ +/, 2)
133
- color = Sass::Script::Parser.parse(color, 0, 0)
134
- if stop =~ /^(\d+)?(?:\.(\d+))?(%)?$/
135
- integral, decimal, percent = $1, $2, $3
136
- number = "#{integral || 0}.#{decimal || 0}".to_f
137
- number = number / 100 if percent
138
- if number > 1
139
- raise Sass::SyntaxError, "A color stop location must be between 0#{"%" if percent} and 1#{"00%" if percent}. Got: #{stop}"
140
- end
141
- stop = Sass::Script::Number.new(number)
142
- elsif !stop.nil?
143
- number = Sass::Script::Parser.parse(stop, 0, 0)
144
- unless number.is_a?(Sass::Script::Number)
145
- raise Sass::SyntaxError, "A color stop location must be a number. Got: #{stop}"
135
+ # We get a string as the result of concatenation
136
+ # So we have to reparse the expression
137
+ color = stop = nil
138
+ expr = Sass::Script::Parser.parse(arg.value, 0, 0)
139
+ case expr
140
+ when Sass::Script::Color
141
+ color = expr
142
+ when Sass::Script::Funcall
143
+ color = expr
144
+ when Sass::Script::Operation
145
+ unless expr.instance_variable_get("@operator") == :concat
146
+ # This should never happen.
147
+ raise Sass::SyntaxError, "Couldn't parse a color stop from: #{arg.value}"
146
148
  end
147
- stop = number
149
+ color = expr.instance_variable_get("@operand1")
150
+ stop = expr.instance_variable_get("@operand2")
151
+ else
152
+ raise Sass::SyntaxError, "Couldn't parse a color stop from: #{arg.value}"
148
153
  end
149
154
  ColorStop.new(color, stop)
150
155
  else
151
- raise Sass::SyntaxError, "Not a valid color stop: #{arg}"
156
+ raise Sass::SyntaxError, "Not a valid color stop: #{arg}"
152
157
  end
153
158
  end)
154
159
  end
@@ -182,5 +187,9 @@ module Compass::SassExtensions::Functions::GradientSupport
182
187
  end
183
188
  nil
184
189
  end
190
+ def assert_list(value)
191
+ return if value.is_a?(List)
192
+ raise ArgumentError.new("#{value.inspect} is not a list of color stops. Expected: color_stops(<color> <number>?, ...)")
193
+ end
185
194
  end
186
195
  end
@@ -23,8 +23,8 @@
23
23
  background-image: -moz-linear-gradient(top, #dddddd 0%, #cccccc 20%, #aaaaaa 100%); }
24
24
 
25
25
  .linear-7 {
26
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #dddddd), color-stop(20%, #cccccc), color-stop(50.1%, #eeeeee), color-stop(100%, #aaaaaa));
27
- background-image: -moz-linear-gradient(top, #dddddd 0%, #cccccc 20%, #eeeeee 50.1%, #aaaaaa 100%); }
26
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #dddddd), color-stop(20%, #cccccc), color-stop(60%, #eeeeee), color-stop(100%, #aaaaaa));
27
+ background-image: -moz-linear-gradient(top, #dddddd 0%, #cccccc 20%, #eeeeee 60%, #aaaaaa 100%); }
28
28
 
29
29
  .linear-8 {
30
30
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(80%, #dddddd), color-stop(100%, #aaaaaa));
@@ -69,3 +69,7 @@
69
69
  .radial-7 {
70
70
  background-image: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 50, color-stop(20%, #dddddd), color-stop(100%, #aaaaaa));
71
71
  background-image: -moz-radial-gradient(center center, circle, #dddddd 20%, #aaaaaa 50px); }
72
+
73
+ .alpha-linear {
74
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(80%, rgba(255, 255, 255, 0)), color-stop(90%, rgba(255, 127, 127, 0.5)), color-stop(100%, rgba(255, 255, 255, 1)));
75
+ background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0) 40%, rgba(255, 127, 127, 0.5) 45%, rgba(255, 255, 255, 1) 50%); }
@@ -46,3 +46,6 @@
46
46
  // A centered elliptical gradient with color stops
47
47
  // The color stops must be relative units
48
48
  +radial-gradient(color_stops(#ddd 20%, #aaa 50px))
49
+
50
+ .alpha-linear
51
+ +linear-gradient(color_stops(rgba(255, 255, 255, 0) 40%, rgba(255, 127, 127, 0.5), rgba(255, 255, 255, 1) 50%))
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 10
8
8
  - 0
9
- - pre6
10
- version: 0.10.0.pre6
9
+ - pre7
10
+ version: 0.10.0.pre7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Eppstein
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-02-22 00:00:00 -08:00
18
+ date: 2010-02-23 00:00:00 -08:00
19
19
  default_executable: compass
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency