compass-core-sass37 1.1.0
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 +7 -0
- data/LICENSE.txt +22 -0
- data/VERSION +1 -0
- data/data/caniuse.json +1 -0
- data/data/caniuse_extras/css-placeholder.json +171 -0
- data/lib/compass/browser_support.rb +64 -0
- data/lib/compass/configuration/adapters.rb +109 -0
- data/lib/compass/configuration/data.rb +199 -0
- data/lib/compass/configuration/defaults.rb +207 -0
- data/lib/compass/configuration/inheritance.rb +307 -0
- data/lib/compass/configuration/paths.rb +19 -0
- data/lib/compass/configuration/watch.rb +38 -0
- data/lib/compass/configuration.rb +175 -0
- data/lib/compass/core/caniuse.rb +314 -0
- data/lib/compass/core/generated_version.rb +6 -0
- data/lib/compass/core/sass_extensions/functions/colors.rb +67 -0
- data/lib/compass/core/sass_extensions/functions/configuration.rb +173 -0
- data/lib/compass/core/sass_extensions/functions/constants.rb +56 -0
- data/lib/compass/core/sass_extensions/functions/cross_browser_support.rb +270 -0
- data/lib/compass/core/sass_extensions/functions/display.rb +32 -0
- data/lib/compass/core/sass_extensions/functions/enumerate.rb +7 -0
- data/lib/compass/core/sass_extensions/functions/env.rb +72 -0
- data/lib/compass/core/sass_extensions/functions/files.rb +33 -0
- data/lib/compass/core/sass_extensions/functions/font_files.rb +65 -0
- data/lib/compass/core/sass_extensions/functions/gradient_support.rb +859 -0
- data/lib/compass/core/sass_extensions/functions/image_size.rb +117 -0
- data/lib/compass/core/sass_extensions/functions/inline_image.rb +63 -0
- data/lib/compass/core/sass_extensions/functions/lists.rb +102 -0
- data/lib/compass/core/sass_extensions/functions/math.rb +105 -0
- data/lib/compass/core/sass_extensions/functions/selectors.rb +79 -0
- data/lib/compass/core/sass_extensions/functions/urls.rb +315 -0
- data/lib/compass/core/sass_extensions/functions.rb +41 -0
- data/lib/compass/core/sass_extensions/monkey_patches/browser_support.rb +119 -0
- data/lib/compass/core/sass_extensions/monkey_patches/traversal.rb +23 -0
- data/lib/compass/core/sass_extensions/monkey_patches.rb +3 -0
- data/lib/compass/core/sass_extensions.rb +10 -0
- data/lib/compass/core/version.rb +13 -0
- data/lib/compass/core.rb +78 -0
- data/lib/compass/error.rb +5 -0
- data/lib/compass/frameworks.rb +181 -0
- data/lib/compass/util.rb +19 -0
- data/lib/compass-core.rb +1 -0
- data/stylesheets/_compass.scss +3 -0
- data/stylesheets/_lemonade.scss +38 -0
- data/stylesheets/compass/_configuration.scss +54 -0
- data/stylesheets/compass/_css3.scss +21 -0
- data/stylesheets/compass/_layout.scss +3 -0
- data/stylesheets/compass/_reset-legacy.scss +3 -0
- data/stylesheets/compass/_reset.scss +3 -0
- data/stylesheets/compass/_support.scss +447 -0
- data/stylesheets/compass/_typography.scss +4 -0
- data/stylesheets/compass/_utilities.scss +9 -0
- data/stylesheets/compass/css3/_animation.scss +122 -0
- data/stylesheets/compass/css3/_appearance.scss +17 -0
- data/stylesheets/compass/css3/_background-clip.scss +35 -0
- data/stylesheets/compass/css3/_background-origin.scss +37 -0
- data/stylesheets/compass/css3/_background-size.scss +19 -0
- data/stylesheets/compass/css3/_border-radius.scss +107 -0
- data/stylesheets/compass/css3/_box-shadow.scss +88 -0
- data/stylesheets/compass/css3/_box-sizing.scss +21 -0
- data/stylesheets/compass/css3/_box.scss +85 -0
- data/stylesheets/compass/css3/_columns.scss +212 -0
- data/stylesheets/compass/css3/_deprecated-support.scss +272 -0
- data/stylesheets/compass/css3/_filter.scss +50 -0
- data/stylesheets/compass/css3/_flexbox.scss +156 -0
- data/stylesheets/compass/css3/_font-face.scss +48 -0
- data/stylesheets/compass/css3/_hyphenation.scss +71 -0
- data/stylesheets/compass/css3/_images.scss +152 -0
- data/stylesheets/compass/css3/_inline-block.scss +31 -0
- data/stylesheets/compass/css3/_opacity.scss +27 -0
- data/stylesheets/compass/css3/_pie.scss +1 -0
- data/stylesheets/compass/css3/_regions.scss +27 -0
- data/stylesheets/compass/css3/_selection.scss +59 -0
- data/stylesheets/compass/css3/_shared.scss +5 -0
- data/stylesheets/compass/css3/_text-shadow.scss +82 -0
- data/stylesheets/compass/css3/_transform.scss +590 -0
- data/stylesheets/compass/css3/_transition.scss +190 -0
- data/stylesheets/compass/css3/_user-interface.scss +71 -0
- data/stylesheets/compass/layout/_grid-background.scss +178 -0
- data/stylesheets/compass/layout/_sticky-footer.scss +23 -0
- data/stylesheets/compass/layout/_stretching.scss +24 -0
- data/stylesheets/compass/reset/_utilities-legacy.scss +135 -0
- data/stylesheets/compass/reset/_utilities.scss +142 -0
- data/stylesheets/compass/typography/_links.scss +3 -0
- data/stylesheets/compass/typography/_lists.scss +4 -0
- data/stylesheets/compass/typography/_text.scss +4 -0
- data/stylesheets/compass/typography/_units.scss +183 -0
- data/stylesheets/compass/typography/_vertical_rhythm.scss +300 -0
- data/stylesheets/compass/typography/links/_hover-link.scss +5 -0
- data/stylesheets/compass/typography/links/_link-colors.scss +28 -0
- data/stylesheets/compass/typography/links/_unstyled-link.scss +7 -0
- data/stylesheets/compass/typography/lists/_bullets.scss +34 -0
- data/stylesheets/compass/typography/lists/_horizontal-list.scss +63 -0
- data/stylesheets/compass/typography/lists/_inline-block-list.scss +50 -0
- data/stylesheets/compass/typography/lists/_inline-list.scss +47 -0
- data/stylesheets/compass/typography/text/_ellipsis.scss +25 -0
- data/stylesheets/compass/typography/text/_force-wrap.scss +12 -0
- data/stylesheets/compass/typography/text/_nowrap.scss +2 -0
- data/stylesheets/compass/typography/text/_replacement.scss +74 -0
- data/stylesheets/compass/utilities/_color.scss +1 -0
- data/stylesheets/compass/utilities/_general.scss +6 -0
- data/stylesheets/compass/utilities/_links.scss +5 -0
- data/stylesheets/compass/utilities/_lists.scss +6 -0
- data/stylesheets/compass/utilities/_print.scss +17 -0
- data/stylesheets/compass/utilities/_sass.scss +2 -0
- data/stylesheets/compass/utilities/_sprites.scss +2 -0
- data/stylesheets/compass/utilities/_tables.scss +3 -0
- data/stylesheets/compass/utilities/_text.scss +5 -0
- data/stylesheets/compass/utilities/color/_brightness.scss +20 -0
- data/stylesheets/compass/utilities/color/_contrast.scss +52 -0
- data/stylesheets/compass/utilities/general/_clearfix.scss +44 -0
- data/stylesheets/compass/utilities/general/_float.scss +38 -0
- data/stylesheets/compass/utilities/general/_hacks.scss +65 -0
- data/stylesheets/compass/utilities/general/_min.scss +16 -0
- data/stylesheets/compass/utilities/general/_reset.scss +2 -0
- data/stylesheets/compass/utilities/general/_tabs.scss +1 -0
- data/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
- data/stylesheets/compass/utilities/links/_hover-link.scss +3 -0
- data/stylesheets/compass/utilities/links/_link-colors.scss +3 -0
- data/stylesheets/compass/utilities/links/_unstyled-link.scss +3 -0
- data/stylesheets/compass/utilities/lists/_bullets.scss +3 -0
- data/stylesheets/compass/utilities/lists/_horizontal-list.scss +3 -0
- data/stylesheets/compass/utilities/lists/_inline-block-list.scss +3 -0
- data/stylesheets/compass/utilities/lists/_inline-list.scss +3 -0
- data/stylesheets/compass/utilities/sass/_lists.scss +16 -0
- data/stylesheets/compass/utilities/sass/_maps.scss +19 -0
- data/stylesheets/compass/utilities/sprites/_base.scss +92 -0
- data/stylesheets/compass/utilities/sprites/_sprite-img.scss +81 -0
- data/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +22 -0
- data/stylesheets/compass/utilities/tables/_borders.scss +38 -0
- data/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
- data/stylesheets/compass/utilities/text/_ellipsis.scss +3 -0
- data/stylesheets/compass/utilities/text/_nowrap.scss +3 -0
- data/stylesheets/compass/utilities/text/_replacement.scss +3 -0
- data/templates/ellipsis/ellipsis.sass +9 -0
- data/templates/ellipsis/manifest.rb +27 -0
- data/templates/ellipsis/xml/ellipsis.xml +14 -0
- data/templates/extension/manifest.rb +26 -0
- data/templates/extension/stylesheets/main.sass +1 -0
- data/templates/extension/templates/project/manifest.rb +2 -0
- data/templates/extension/templates/project/screen.sass +2 -0
- data/templates/project/USAGE.markdown +32 -0
- data/templates/project/ie.sass +6 -0
- data/templates/project/manifest.rb +4 -0
- data/templates/project/print.sass +6 -0
- data/templates/project/screen.sass +7 -0
- metadata +257 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
module Compass::Core::SassExtensions::Functions::ImageSize
|
2
|
+
KNOWN_TYPES = %w(png gif jpg jpeg)
|
3
|
+
|
4
|
+
# Returns the width of the image relative to the images directory
|
5
|
+
def image_width(image_file)
|
6
|
+
width, _ = image_dimensions(image_file)
|
7
|
+
number(width, "px")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns the height of the image relative to the images directory
|
11
|
+
def image_height(image_file)
|
12
|
+
_, height = image_dimensions(image_file)
|
13
|
+
number(height, "px")
|
14
|
+
end
|
15
|
+
|
16
|
+
class ImageProperties
|
17
|
+
def initialize(file)
|
18
|
+
@file = (file.respond_to?(:to_path) ? file.to_path : file)
|
19
|
+
@file_type = File.extname(@file)[1..-1].downcase
|
20
|
+
unless KNOWN_TYPES.include?(@file_type)
|
21
|
+
raise Sass::SyntaxError, "Unrecognized file type: #{@file_type}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def size
|
26
|
+
@dimensions ||= send(:"get_size_for_#{@file_type}")
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def get_size_for_png
|
31
|
+
File.open(@file, "rb") {|io| io.read}[0x10..0x18].unpack('NN')
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_size_for_gif
|
35
|
+
File.open(@file, "rb") {|io| io.read}[6..10].unpack('SS')
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_size_for_jpg
|
39
|
+
get_size_for_jpeg
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_size_for_jpeg
|
43
|
+
jpeg = JPEG.new(@file)
|
44
|
+
[jpeg.width, jpeg.height]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def image_dimensions(image_file)
|
51
|
+
image_file = image_file.respond_to?(:value) ? image_file.value : image_file
|
52
|
+
options[:compass] ||= {}
|
53
|
+
options[:compass][:image_dimensions] ||= {}
|
54
|
+
options[:compass][:image_dimensions][image_file] = ImageProperties.new(image_path_for_size(image_file)).size
|
55
|
+
end
|
56
|
+
|
57
|
+
def image_path_for_size(image_file)
|
58
|
+
if File.exist?(image_file)
|
59
|
+
return image_file
|
60
|
+
end
|
61
|
+
real_path(image_file)
|
62
|
+
end
|
63
|
+
|
64
|
+
def real_path(image_file)
|
65
|
+
# Compute the real path to the image on the file stystem if the images_dir is set.
|
66
|
+
if Compass.configuration.images_path
|
67
|
+
File.join(Compass.configuration.images_path, image_file)
|
68
|
+
else
|
69
|
+
File.join(Compass.configuration.project_path, image_file)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class JPEG
|
74
|
+
attr_reader :width, :height, :bits
|
75
|
+
|
76
|
+
def initialize(file)
|
77
|
+
if file.kind_of? IO
|
78
|
+
examine(file)
|
79
|
+
else
|
80
|
+
File.open(file, 'rb') { |io| examine(io) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def examine(io)
|
86
|
+
class << io
|
87
|
+
unless method_defined?(:readbyte)
|
88
|
+
def readbyte
|
89
|
+
getc
|
90
|
+
end
|
91
|
+
end
|
92
|
+
def readint; (readbyte << 8) + readbyte; end
|
93
|
+
def readframe; read(readint - 2); end
|
94
|
+
def readsof; [readint, readbyte, readint, readint, readbyte]; end
|
95
|
+
def next
|
96
|
+
c = readbyte while c != 0xFF
|
97
|
+
c = readbyte while c == 0xFF
|
98
|
+
c
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
raise 'malformed JPEG!' unless io.readbyte == 0xFF && io.readbyte == 0xD8 # SOI
|
103
|
+
|
104
|
+
while marker = io.next
|
105
|
+
case marker
|
106
|
+
when 0xC0..0xC3, 0xC5..0xC7, 0xC9..0xCB, 0xCD..0xCF # SOF markers
|
107
|
+
length, @bits, @height, @width, components = io.readsof
|
108
|
+
raise 'malformed JPEG' unless length == 8 + components * 3
|
109
|
+
when 0xD9, 0xDA then break # EOI, SOS
|
110
|
+
when 0xFE then @comment = io.readframe # COM
|
111
|
+
when 0xE1 then io.readframe # APP1, contains EXIF tag
|
112
|
+
else io.readframe # ignore frame
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Compass::Core::SassExtensions::Functions::InlineImage
|
2
|
+
|
3
|
+
def inline_image(path, mime_type = nil)
|
4
|
+
path = path.value
|
5
|
+
real_path = File.join(Compass.configuration.images_path, path)
|
6
|
+
inline_image_string(data(real_path), compute_mime_type(path, mime_type))
|
7
|
+
end
|
8
|
+
|
9
|
+
def inline_font_files(*args)
|
10
|
+
files = []
|
11
|
+
with_each_font_file(*args) do |path, type|
|
12
|
+
path = path.value
|
13
|
+
real_path = File.join(Compass.configuration.fonts_path, path)
|
14
|
+
data = inline_image_string(data(real_path), compute_mime_type(path))
|
15
|
+
files << list(data, unquoted_string("format('#{type}')"), :space)
|
16
|
+
end
|
17
|
+
list(files, :comma)
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
def inline_image_string(data, mime_type)
|
22
|
+
data = [data].flatten.pack('m').gsub("\n","")
|
23
|
+
url = "url('data:#{mime_type};base64,#{data}')"
|
24
|
+
unquoted_string(url)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def compute_mime_type(path, mime_type = nil)
|
29
|
+
return mime_type.value if mime_type
|
30
|
+
case path
|
31
|
+
when /\.png$/i
|
32
|
+
'image/png'
|
33
|
+
when /\.jpe?g$/i
|
34
|
+
'image/jpeg'
|
35
|
+
when /\.gif$/i
|
36
|
+
'image/gif'
|
37
|
+
when /\.svg$/i
|
38
|
+
'image/svg+xml'
|
39
|
+
when /\.otf$/i
|
40
|
+
'font/opentype'
|
41
|
+
when /\.eot$/i
|
42
|
+
'application/vnd.ms-fontobject'
|
43
|
+
when /\.ttf$/i
|
44
|
+
'font/truetype'
|
45
|
+
when /\.woff$/i
|
46
|
+
'application/font-woff'
|
47
|
+
when /\.off$/i
|
48
|
+
'font/openfont'
|
49
|
+
when /\.([a-zA-Z]+)$/
|
50
|
+
"image/#{Regexp.last_match(1).downcase}"
|
51
|
+
else
|
52
|
+
raise Compass::Error, "A mime type could not be determined for #{path}, please specify one explicitly."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def data(real_path)
|
57
|
+
if File.readable?(real_path)
|
58
|
+
File.open(real_path, "rb") {|io| io.read}
|
59
|
+
else
|
60
|
+
raise Compass::Error, "File not found or cannot be read: #{real_path}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Compass::Core::SassExtensions::Functions::Lists
|
2
|
+
|
3
|
+
# Returns true when the object is false, an empty string, or an empty list
|
4
|
+
def blank(obj)
|
5
|
+
case obj
|
6
|
+
when Sass::Script::Value::Bool, Sass::Script::Value::Null
|
7
|
+
bool(!obj.to_bool)
|
8
|
+
when Sass::Script::Value::String
|
9
|
+
bool(obj.value.strip.size == 0)
|
10
|
+
when Sass::Script::Value::List
|
11
|
+
bool(obj.value.size == 0 || obj.value.all?{|el| blank(el).to_bool})
|
12
|
+
else
|
13
|
+
bool(false)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns a new list after removing any non-true values
|
18
|
+
def compact(*args)
|
19
|
+
sep = :comma
|
20
|
+
if args.size == 1 && args.first.is_a?(Sass::Script::Value::List)
|
21
|
+
list = args.first
|
22
|
+
args = list.value
|
23
|
+
sep = list.separator
|
24
|
+
end
|
25
|
+
list(args.reject{|a| !a.to_bool}, sep)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get the nth value from a list
|
29
|
+
def _compass_nth(list, place)
|
30
|
+
assert_type list, :List
|
31
|
+
if place.value == "first"
|
32
|
+
list.value.first
|
33
|
+
elsif place.value == "last"
|
34
|
+
list.value.last
|
35
|
+
else
|
36
|
+
list.value[place.value - 1]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns a list object from a value that was passed.
|
41
|
+
# This can be used to unpack a space separated list that got turned
|
42
|
+
# into a string by sass before it was passed to a mixin.
|
43
|
+
def _compass_list(arg)
|
44
|
+
if arg.is_a?(Sass::Script::Value::List)
|
45
|
+
list(arg.value.dup, arg.separator)
|
46
|
+
else
|
47
|
+
list(arg, :space)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# If the argument is a list, it will return a new list that is space delimited
|
52
|
+
# Otherwise it returns a new, single element, space-delimited list.
|
53
|
+
def _compass_space_list(list)
|
54
|
+
if list.is_a?(Sass::Script::Value::List)
|
55
|
+
list(list.value.dup, :space)
|
56
|
+
else
|
57
|
+
list(list, :space)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns the size of the list.
|
62
|
+
def _compass_list_size(list)
|
63
|
+
assert_list list
|
64
|
+
number(list.value.size)
|
65
|
+
end
|
66
|
+
|
67
|
+
# slice a sublist from a list
|
68
|
+
def _compass_slice(list, start_index, end_index = nil)
|
69
|
+
end_index ||= number(-1)
|
70
|
+
start_index = start_index.value
|
71
|
+
end_index = end_index.value
|
72
|
+
start_index -= 1 unless start_index < 0
|
73
|
+
end_index -= 1 unless end_index < 0
|
74
|
+
list(list.values[start_index..end_index], list.separator)
|
75
|
+
end
|
76
|
+
|
77
|
+
# removes the given values from the list.
|
78
|
+
def reject(list, *values)
|
79
|
+
list(list.value.reject{|v| values.any?{|o| v == o}}, list.separator)
|
80
|
+
end
|
81
|
+
|
82
|
+
# returns the first value of a space delimited list.
|
83
|
+
def first_value_of(list)
|
84
|
+
if list.is_a?(Sass::Script::Value::String)
|
85
|
+
r = list.value.split(/\s+/).first
|
86
|
+
list.type == :identifier ? identifier(r) : quoted_string(r)
|
87
|
+
elsif list.is_a?(Sass::Script::Value::List)
|
88
|
+
list.value.first
|
89
|
+
else
|
90
|
+
list
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
protected
|
95
|
+
|
96
|
+
def assert_list(value)
|
97
|
+
unless value.is_a?(Sass::Script::Value::List)
|
98
|
+
raise ArgumentError.new("#{value.inspect} is not a list")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Compass::Core::SassExtensions::Functions::Math
|
2
|
+
extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
|
3
|
+
extend Sass::Script::Value::Helpers
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
if base == Sass::Script::Functions
|
7
|
+
base.send :alias_method, :sass_random, :random
|
8
|
+
base.send :alias_method, :random, :deprecated_random
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
PI = number(Math::PI)
|
13
|
+
E = number(Math::E)
|
14
|
+
|
15
|
+
def pi()
|
16
|
+
PI
|
17
|
+
end
|
18
|
+
declare :pi, []
|
19
|
+
|
20
|
+
def deprecated_random(*args)
|
21
|
+
if args.length == 2
|
22
|
+
Compass::Util.compass_warn <<WARNING
|
23
|
+
WARNING: The $start value for random(#{args.first}, #{args.last}) is not supported by Sass and is now
|
24
|
+
deprecated in Compass and will be removed in a future release.
|
25
|
+
Use `#{args.first} + random(#{args.last.minus(args.first)})` instead.
|
26
|
+
WARNING
|
27
|
+
range = (args.first.value..args.last.value).to_a
|
28
|
+
number(range[rand(range.length)])
|
29
|
+
else
|
30
|
+
sass_random(*args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
declare :random, [:start, :limit]
|
34
|
+
|
35
|
+
def sin(number)
|
36
|
+
trig(:sin, number)
|
37
|
+
end
|
38
|
+
declare :sin, [:number]
|
39
|
+
|
40
|
+
def asin(number)
|
41
|
+
trig(:asin, number)
|
42
|
+
end
|
43
|
+
declare :asin, [:number]
|
44
|
+
|
45
|
+
def cos(number)
|
46
|
+
trig(:cos, number)
|
47
|
+
end
|
48
|
+
declare :cos, [:number]
|
49
|
+
|
50
|
+
def acos(number)
|
51
|
+
trig(:acos, number)
|
52
|
+
end
|
53
|
+
declare :acos, [:number]
|
54
|
+
|
55
|
+
def tan(number)
|
56
|
+
trig(:tan, number)
|
57
|
+
end
|
58
|
+
declare :tan, [:number]
|
59
|
+
|
60
|
+
def atan(number)
|
61
|
+
trig(:atan, number)
|
62
|
+
end
|
63
|
+
declare :atan, [:number]
|
64
|
+
|
65
|
+
def e
|
66
|
+
E
|
67
|
+
end
|
68
|
+
declare :e, []
|
69
|
+
|
70
|
+
def logarithm(number, base = e )
|
71
|
+
assert_type number, :Number
|
72
|
+
assert_type base, :Number
|
73
|
+
raise Sass::SyntaxError, "base to logarithm must be unitless." unless base.unitless?
|
74
|
+
|
75
|
+
result = Math.log(number.value, base.value) rescue Math.log(number.value) / Math.log(base.value)
|
76
|
+
number(result, number.unit_str)
|
77
|
+
end
|
78
|
+
declare :logarithm, [:number]
|
79
|
+
declare :logarithm, [:number, :base]
|
80
|
+
|
81
|
+
def sqrt(number)
|
82
|
+
numeric_transformation(number) { |n| Math.sqrt(n) }
|
83
|
+
end
|
84
|
+
declare :sqrt, [:number]
|
85
|
+
|
86
|
+
alias square_root sqrt
|
87
|
+
declare :square_root, [:number]
|
88
|
+
|
89
|
+
def pow(number, exponent)
|
90
|
+
assert_type number, :Number
|
91
|
+
assert_type exponent, :Number
|
92
|
+
raise Sass::SyntaxError, "exponent to pow must be unitless." unless exponent.unitless?
|
93
|
+
number(number.value**exponent.value, number.unit_str)
|
94
|
+
end
|
95
|
+
declare :pow, [:number, :exponent]
|
96
|
+
|
97
|
+
private
|
98
|
+
def trig(operation, number)
|
99
|
+
if number.unit_str == "deg"
|
100
|
+
number(Math.send(operation, Math::PI * number.value / 180))
|
101
|
+
else
|
102
|
+
number(Math.send(operation, number.value), number.unit_str)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Compass::Core::SassExtensions::Functions::Selectors
|
2
|
+
COMMA_SEPARATOR = /\s*,\s*/
|
3
|
+
|
4
|
+
# Permute multiple selectors each of which may be comma delimited, the end result is
|
5
|
+
# a new selector that is the equivalent of nesting each under the previous selector.
|
6
|
+
# To illustrate, the following mixins are equivalent:
|
7
|
+
#
|
8
|
+
# @include mixin-a($selector1, $selector2, $selector3) {
|
9
|
+
# #{$selector1} {
|
10
|
+
# #{$selector2} {
|
11
|
+
# #{$selector3} {
|
12
|
+
# width: 2px
|
13
|
+
# }
|
14
|
+
# }
|
15
|
+
# }
|
16
|
+
# }
|
17
|
+
# @include mixin-b($selector1, $selector2, $selector3) {
|
18
|
+
# #{nest($selector, $selector2, $selector3)} {
|
19
|
+
# width: 2px
|
20
|
+
# }
|
21
|
+
# }
|
22
|
+
def nest(*arguments)
|
23
|
+
nested = arguments.map{|a| a.value}.inject do |memo,arg|
|
24
|
+
ancestors = memo.split(COMMA_SEPARATOR)
|
25
|
+
descendants = arg.split(COMMA_SEPARATOR)
|
26
|
+
ancestors.map{|a| descendants.map{|d| "#{a} #{d}"}.join(", ")}.join(", ")
|
27
|
+
end
|
28
|
+
unquoted_string(nested)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Permute two selectors, the first may be comma delimited.
|
32
|
+
# The end result is a new selector that is the equivalent of nesting the second
|
33
|
+
# selector under the first one in a sass file and preceding it with an &.
|
34
|
+
# To illustrate, the following mixins are equivalent, except the second
|
35
|
+
# mixin handles:
|
36
|
+
#
|
37
|
+
# @include mixin-a($selector, $to-append) {
|
38
|
+
# #{$selector} {
|
39
|
+
# &#{$to-append} {
|
40
|
+
# width: 2px
|
41
|
+
# }
|
42
|
+
# }
|
43
|
+
# }
|
44
|
+
#
|
45
|
+
# @include mixin-b($selector, $to-append) {
|
46
|
+
# #{append_selector($selector, $to-append)} {
|
47
|
+
# width: 2px
|
48
|
+
# }
|
49
|
+
# }
|
50
|
+
def append_selector(selector, to_append)
|
51
|
+
ancestors = selector.value.split(COMMA_SEPARATOR)
|
52
|
+
descendants = to_append.value.split(COMMA_SEPARATOR)
|
53
|
+
nested = ancestors.map{|a| descendants.map{|d| "#{a}#{d}"}.join(", ")}.join(", ")
|
54
|
+
unquoted_string(nested)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Return the header selectors for the levels indicated
|
58
|
+
# Defaults to all headers h1 through h6
|
59
|
+
# For example:
|
60
|
+
# headers(all) => h1, h2, h3, h4, h5, h6
|
61
|
+
# headers(4) => h1, h2, h3, h4
|
62
|
+
# headers(2,4) => h2, h3, h4
|
63
|
+
def headers(from = nil, to = nil)
|
64
|
+
if from && !to
|
65
|
+
if from.is_a?(Sass::Script::Value::String) && from.value == "all"
|
66
|
+
from = number(1)
|
67
|
+
to = number(6)
|
68
|
+
else
|
69
|
+
to = from
|
70
|
+
from = number(1)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
from ||= number(1)
|
74
|
+
to ||= number(6)
|
75
|
+
end
|
76
|
+
list((from.value..to.value).map{|n| identifier("h#{n}")}, :comma)
|
77
|
+
end
|
78
|
+
alias headings headers
|
79
|
+
end
|