compass-core-sass37 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 748eccd29e4e0f853f2de750f8ba0edcae4237f3dcb79e8d3b3ae03f040ff4cd
4
- data.tar.gz: d9bebeaae9d5fb5bb134924dbf372a6f3ad571380bd9f9dfcdc5c5aa937cb57e
3
+ metadata.gz: 6548a79fd2ab2d4e719c8c963d32f587f0cd367fac1297d4bd544d3398feabec
4
+ data.tar.gz: 05fefb87bc381284b4e4cc24c194bf81b345a4a83e581418dd729369006efbe3
5
5
  SHA512:
6
- metadata.gz: af6c275f3879f3f60af79c2e021469909c050d3b3a2132e987da82e278bd2daa851967e1bb9325b37782c6f16a382aceffa5ae512ca572b38524c31949ece4d5
7
- data.tar.gz: da00e60ab7f22ddf07ba300fd7453a92c346f41e13d63b763c589d9863fe3ca604063259e77690ed8b2f2fafa62b56be628bb88eacb3e0de1f786b0618838eb6
6
+ metadata.gz: 973b443d162d545c1febe876f44196daceef6cf3cd537933140c6e0a2dbc41cca41d200280de52fffa16a795a88899382eefe57c8995698efa439df43a09d59e
7
+ data.tar.gz: efe5f9913680aa983ea75660ec9ef3c76720ae4a4de3e4fdca6e0a845810d805c020858fd75374a6821fc9ad1895906a6952572e45ecf89e33eb314e1918b669
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -145,14 +145,19 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
145
145
 
146
146
  class ColorStop < Sass::Script::Value::Base
147
147
  include Sass::Script::Value::Helpers
148
- attr_accessor :color, :stop
148
+ attr_accessor :color, :stop, :stop2
149
+ # Rightmost stop position (for CSS color hint / double-position syntax).
150
+ def outer_stop
151
+ stop2 || stop
152
+ end
149
153
  def children
150
- [color, stop].compact
154
+ [color, stop, stop2].compact
151
155
  end
152
- def initialize(color, stop = nil)
156
+ def initialize(color, stop = nil, stop2 = nil)
153
157
  assert_legal_color! color
154
158
  assert_legal_color_stop! stop if stop
155
- self.color, self.stop = color, stop
159
+ assert_legal_color_stop! stop2 if stop2
160
+ self.color, self.stop, self.stop2 = color, stop, stop2
156
161
  end
157
162
  def inspect
158
163
  to_s
@@ -212,10 +217,10 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
212
217
  s = self.class.color_to_s(color)
213
218
  if stop
214
219
  s << " "
215
- if stop.respond_to?(:unitless?) && stop.unitless?
216
- s << stop.times(number(100, "%")).inspect
217
- else
218
- s << stop.to_s
220
+ s << format_stop_for_css(stop)
221
+ if stop2
222
+ s << " "
223
+ s << format_stop_for_css(stop2)
219
224
  end
220
225
  end
221
226
  s
@@ -224,6 +229,16 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
224
229
  def to_sass(options = nil)
225
230
  identifier("color-stop(#{color.to_sass rescue nil}, #{stop.to_sass rescue nil})")
226
231
  end
232
+
233
+ private
234
+
235
+ def format_stop_for_css(stop)
236
+ if stop.respond_to?(:unitless?) && stop.unitless?
237
+ stop.times(number(100, "%")).inspect
238
+ else
239
+ stop.to_s
240
+ end
241
+ end
227
242
  end
228
243
 
229
244
  module Gradient
@@ -427,7 +442,10 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
427
442
  # I don't know how to support degree-based gradients in old webkit gradients (owg) or svg so we just disable them.
428
443
  if %w(owg).include?(aspect) && position_or_angle.is_a?(Sass::Script::Value::Number) && position_or_angle.numerator_units.include?("deg")
429
444
  false
430
- elsif %w(owg svg).include?(aspect) && color_stops.value.any?{|cs| cs.stop.is_a?(Sass::Script::Value::String) }
445
+ elsif %w(owg svg).include?(aspect) && color_stops.value.any?{|cs|
446
+ cs.stop.is_a?(Sass::Script::Value::String) ||
447
+ (cs.stop2 && cs.stop2.is_a?(Sass::Script::Value::String))
448
+ }
431
449
  # calc expressions cannot be represented in svg or owg
432
450
  false
433
451
  else
@@ -442,7 +460,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
442
460
  start_point = grad_point(position_list)
443
461
  args = []
444
462
  args << start_point
445
- args << linear_end_position(position_list, start_point, color_stops.value.last.stop)
463
+ args << linear_end_position(position_list, start_point, color_stops.value.last.outer_stop)
446
464
  args << grad_color_stops(color_stops)
447
465
  args.each{|a| a.options = options}
448
466
  Sass::Script::String.new("-webkit-gradient(linear, #{args.join(', ')})")
@@ -546,7 +564,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
546
564
  elsif Sass::Script::Value::Color === arg
547
565
  ColorStop.new(arg)
548
566
  elsif Sass::Script::Value::List === arg
549
- ColorStop.new(*arg.value)
567
+ color_stop_from_list(arg)
550
568
  elsif Sass::Script::Value::String === arg && arg.value == "transparent"
551
569
  ColorStop.new(arg)
552
570
  elsif Sass::Script::Value::String === arg && arg.value == "currentColor"
@@ -630,19 +648,29 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
630
648
  def color_stops_in_percentages(color_list)
631
649
  assert_type color_list, :List
632
650
  color_list = normalize_stops(color_list)
633
- max = color_list.value.last.stop
651
+ last_cs = color_list.value.last
652
+ max = last_cs.outer_stop
634
653
  last_value = nil
635
- color_list.value.map do |pos|
636
- next [pos.stop, pos.color] if pos.stop.is_a?(Sass::Script::Value::String)
654
+ pairs = color_list.value.flat_map do |pos|
655
+ if pos.stop2
656
+ [[pos.stop, pos.color], [pos.stop2, pos.color]]
657
+ else
658
+ [[pos.stop, pos.color]]
659
+ end
660
+ end
661
+ pairs.map do |stop, color|
662
+ next [stop, color] if stop.is_a?(Sass::Script::Value::String)
637
663
  # have to convert absolute units to percentages for use in color stop functions.
638
- stop = pos.stop
639
- stop = stop.div(max).times(number(100, "%")) if stop.numerator_units == max.numerator_units && max.numerator_units != ["%"]
664
+ if max.is_a?(Sass::Script::Value::Number) &&
665
+ stop.numerator_units == max.numerator_units && max.numerator_units != ["%"]
666
+ stop = stop.div(max).times(number(100, "%"))
667
+ end
640
668
  # Make sure the color stops are specified in the right order.
641
669
  if last_value && stop.numerator_units == last_value.numerator_units && stop.denominator_units == last_value.denominator_units && (stop.value * 1000).round < (last_value.value * 1000).round
642
670
  raise Sass::SyntaxError.new("Color stops must be specified in increasing order. #{stop.value} came after #{last_value.value}.")
643
671
  end
644
672
  last_value = stop
645
- [stop, pos.color]
673
+ [stop, color]
646
674
  end
647
675
  end
648
676
 
@@ -678,7 +706,8 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
678
706
 
679
707
  def grad_position(color_list, index, default, radial = bool(false))
680
708
  assert_type color_list, :List
681
- stop = color_list.value[index.value - 1].stop
709
+ # Use outermost position so double-position stops (e.g. transparent 0 25%) extend the radial correctly.
710
+ stop = color_list.value[index.value - 1].outer_stop
682
711
  if stop && radial.to_bool
683
712
  orig_stop = stop
684
713
  if stop.unitless?
@@ -690,8 +719,9 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
690
719
  stop = stop.times(number(1, "px"))
691
720
  end
692
721
  end
693
- if stop.numerator_units == ["%"] && color_list.value.last.stop && color_list.value.last.stop.numerator_units == ["px"]
694
- stop = stop.times(color_list.value.last.stop).div(number(100, "%"))
722
+ last_outer = color_list.value.last.outer_stop
723
+ if stop.numerator_units == ["%"] && last_outer && last_outer.numerator_units == ["px"]
724
+ stop = stop.times(last_outer).div(number(100, "%"))
695
725
  end
696
726
  Compass::Logger.new.record(:warning, "Webkit only supports pixels for the start and end stops for radial gradients. Got: #{orig_stop}") if stop.numerator_units != ["px"]
697
727
  stop.div(Sass::Script::Value::Number.new(1, stop.numerator_units, stop.denominator_units))
@@ -723,12 +753,36 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
723
753
 
724
754
  def color_stop?(arg)
725
755
  arg.is_a?(ColorStop) ||
726
- (arg.is_a?(Sass::Script::Value::List) && ColorStop.new(*arg.value)) ||
756
+ (arg.is_a?(Sass::Script::Value::List) && color_stop_from_list(arg)) ||
727
757
  ColorStop.new(arg)
728
758
  rescue
729
759
  nil
730
760
  end
731
761
 
762
+ # True for values that may appear as gradient stop positions in Sass lists.
763
+ def legal_color_stop?(stop)
764
+ return false unless stop
765
+ case stop
766
+ when Sass::Script::Value::String
767
+ stop.value.start_with?("calc(")
768
+ when Sass::Script::Value::Number
769
+ true
770
+ else
771
+ false
772
+ end
773
+ end
774
+
775
+ # Parses a space- or comma-separated stop list; supports CSS Color Module 4
776
+ # double-position stops, e.g. (transparent 0 25%).
777
+ def color_stop_from_list(list)
778
+ v = list.value
779
+ if v.size == 3 && legal_color_stop?(v[1]) && legal_color_stop?(v[2])
780
+ ColorStop.new(v[0], v[1], v[2])
781
+ else
782
+ ColorStop.new(*v)
783
+ end
784
+ end
785
+
732
786
  def normalize_stops(color_list)
733
787
  positions = color_list.value.map{|obj| obj.dup}
734
788
  # fill in the start and end positions, if unspecified
@@ -750,18 +804,23 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
750
804
  end
751
805
  # normalize unitless numbers
752
806
  positions.each do |pos|
753
- next pos if pos.stop.is_a?(Sass::Script::Value::String)
754
- if pos.stop.unitless? && pos.stop.value <= 1
755
- pos.stop = pos.stop.times(number(100, "%"))
756
- elsif pos.stop.unitless?
757
- pos.stop = pos.stop.times(number(1, "px"))
807
+ [:stop, :stop2].each do |attr|
808
+ st = pos.send(attr)
809
+ next unless st
810
+ next if st.is_a?(Sass::Script::Value::String)
811
+ if st.unitless? && st.value <= 1
812
+ pos.send("#{attr}=", st.times(number(100, "%")))
813
+ elsif st.unitless?
814
+ pos.send("#{attr}=", st.times(number(1, "px")))
815
+ end
758
816
  end
759
817
  end
760
- if (positions.last.stop.eq(number(0, "px")).to_bool ||
761
- positions.last.stop.eq(number(0, "%")).to_bool)
762
- raise Sass::SyntaxError.new("Color stops must be specified in increasing order")
763
- end
764
- opts(list(positions, color_list.separator))
818
+ last_outer = positions.last.outer_stop
819
+ if (last_outer.eq(number(0, "px")).to_bool ||
820
+ last_outer.eq(number(0, "%")).to_bool)
821
+ raise Sass::SyntaxError.new("Color stops must be specified in increasing order")
822
+ end
823
+ opts(list(positions, color_list.separator))
765
824
  end
766
825
 
767
826
  def parse_color_stop(arg)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-core-sass37
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Ivanin
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2025-10-13 00:00:00.000000000 Z
15
+ date: 2026-04-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: sass