code
stringlengths 26
124k
| docstring
stringlengths 23
125k
| func_name
stringlengths 1
98
| language
stringclasses 1
value | repo
stringlengths 5
53
| path
stringlengths 7
151
| url
stringlengths 50
211
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
def set_opts(opts)
opts.banner = <<END
Usage: #{default_syntax} [options] [INPUT] [OUTPUT]
Description:
Converts SCSS or Sass files to CSS.
END
common_options(opts)
watching_and_updating(opts)
input_and_output(opts)
miscellaneous(opts)
end
|
Tells optparse how to parse the arguments.
@param opts [OptionParser]
|
set_opts
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/exec/sass_scss.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/exec/sass_scss.rb
|
Apache-2.0
|
def process_result
require 'sass'
if !@options[:update] && !@options[:watch] &&
@args.first && colon_path?(@args.first)
if @args.size == 1
@args = split_colon_path(@args.first)
else
@fake_update = true
@options[:update] = true
end
end
load_compass if @options[:compass]
return interactive if @options[:interactive]
return watch_or_update if @options[:watch] || @options[:update]
super
if @options[:sourcemap] != :none && @options[:output_filename]
@options[:sourcemap_filename] = Sass::Util.sourcemap_name(@options[:output_filename])
end
@options[:for_engine][:filename] = @options[:filename]
@options[:for_engine][:css_filename] = @options[:output] if @options[:output].is_a?(String)
@options[:for_engine][:sourcemap_filename] = @options[:sourcemap_filename]
@options[:for_engine][:sourcemap] = @options[:sourcemap]
run
end
|
Processes the options set by the command-line arguments,
and runs the Sass compiler appropriately.
|
process_result
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/exec/sass_scss.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/exec/sass_scss.rb
|
Apache-2.0
|
def probably_dest_dir?(path)
return false unless path
return false if colon_path?(path)
Sass::Util.glob(File.join(path, "*.s[ca]ss")).empty?
end
|
Whether path is likely to be meant as the destination
in a source:dest pair.
|
probably_dest_dir?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/exec/sass_scss.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/exec/sass_scss.rb
|
Apache-2.0
|
def public_url(uri, sourcemap_directory)
return if @public_url_warning_issued
@public_url_warning_issued = true
Sass::Util.sass_warn <<WARNING
WARNING: #{self.class.name} should define the #public_url method.
WARNING
nil
end
|
Get the publicly-visible URL for an imported file. This URL is used by
source maps to link to the source stylesheet. This may return `nil` to
indicate that no public URL is available; however, this will cause
sourcemap generation to fail if any CSS is generated from files imported
from this importer.
If an absolute "file:" URI can be produced for an imported file, that
should be preferred to returning `nil`. However, a URL relative to
`sourcemap_directory` should be preferred over an absolute "file:" URI.
@param uri [String] A URI known to be valid for this importer.
@param sourcemap_directory [String, NilClass] The absolute path to a
directory on disk where the sourcemap will be saved. If uri refers to
a file on disk that's accessible relative to sourcemap_directory, this
may return a relative URL. This may be `nil` if the sourcemap's
eventual location is unknown.
@return [String?] The publicly-visible URL for this file, or `nil`
indicating that no publicly-visible URL exists. This should be
appropriately URL-escaped.
|
public_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/base.rb
|
Apache-2.0
|
def initialize(root)
@specified_root = root
@warning_given = false
super
end
|
@param root [String] The absolute, expanded path to the folder that is deprecated.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/deprecated_path.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/deprecated_path.rb
|
Apache-2.0
|
def deprecation_warning
path = @specified_root == "." ? "the current working directory" : @specified_root
<<WARNING
DEPRECATION WARNING: Importing from #{path} will not be
automatic in future versions of Sass. To avoid future errors, you can add it
to your environment explicitly by setting `SASS_PATH=#{@specified_root}`, by using the -I command
line option, or by changing your Sass configuration options.
WARNING
end
|
@return [String] The deprecation warning that will be printed the first
time an import occurs.
|
deprecation_warning
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/deprecated_path.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/deprecated_path.rb
|
Apache-2.0
|
def initialize(root)
@root = File.expand_path(root)
@real_root = Sass::Util.realpath(@root).to_s
@same_name_warnings = Set.new
end
|
Creates a new filesystem importer that imports files relative to a given path.
@param root [String] The root path.
This importer will import files relative to this path.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
Apache-2.0
|
def remove_root(name)
if name.index(@root + "/") == 0
name[(@root.length + 1)..-1]
else
name
end
end
|
If a full uri is passed, this removes the root from it
otherwise returns the name unchanged
|
remove_root
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
Apache-2.0
|
def extensions
{'sass' => :sass, 'scss' => :scss}
end
|
A hash from file extensions to the syntaxes for those extensions.
The syntaxes must be `:sass` or `:scss`.
This can be overridden by subclasses that want normal filesystem importing
with unusual extensions.
@return [{String => Symbol}]
|
extensions
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
Apache-2.0
|
def possible_files(name)
name = escape_glob_characters(name)
dirname, basename, extname = split(name)
sorted_exts = extensions.sort
syntax = extensions[extname]
if syntax
ret = [["#{dirname}/{_,}#{basename}.#{extensions.invert[syntax]}", syntax]]
else
ret = sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
end
# JRuby chokes when trying to import files from JARs when the path starts with './'.
ret.map {|f, s| [f.sub(%r{^\./}, ''), s]}
end
|
Given an `@import`ed path, returns an array of possible
on-disk filenames and their corresponding syntaxes for that path.
@param name [String] The filename.
@return [Array(String, Symbol)] An array of pairs.
The first element of each pair is a filename to look for;
the second element is the syntax that file would be in (`:sass` or `:scss`).
|
possible_files
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
Apache-2.0
|
def find_real_file(dir, name, options)
# On windows 'dir' or 'name' can be in native File::ALT_SEPARATOR form.
dir = dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
name = name.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
found = possible_files(remove_root(name)).map do |f, s|
path = if dir == "." || Sass::Util.pathname(f).absolute?
f
else
"#{escape_glob_characters(dir)}/#{f}"
end
Dir[path].map do |full_path|
full_path.gsub!(REDUNDANT_DIRECTORY, File::SEPARATOR)
[Sass::Util.cleanpath(full_path).to_s, s]
end
end.flatten(1)
if found.empty? && split(name)[2].nil? && File.directory?("#{dir}/#{name}")
return find_real_file("#{dir}/#{name}", "index", options)
end
if found.size > 1 && !@same_name_warnings.include?(found.first.first)
found.each {|(f, _)| @same_name_warnings << f}
relative_to = Sass::Util.pathname(dir)
if options[:_from_import_node]
# If _line exists, we're here due to an actual import in an
# import_node and we want to print a warning for a user writing an
# ambiguous import.
candidates = found.map do |(f, _)|
" " + Sass::Util.pathname(f).relative_path_from(relative_to).to_s
end.join("\n")
raise Sass::SyntaxError.new(<<MESSAGE)
It's not clear which file to import for '@import "#{name}"'.
Candidates:
#{candidates}
Please delete or rename all but one of these files.
MESSAGE
else
# Otherwise, we're here via StalenessChecker, and we want to print a
# warning for a user running `sass --watch` with two ambiguous files.
candidates = found.map {|(f, _)| " " + File.basename(f)}.join("\n")
Sass::Util.sass_warn <<WARNING
WARNING: In #{File.dirname(name)}:
There are multiple files that match the name "#{File.basename(name)}":
#{candidates}
WARNING
end
end
found.first
end
|
Given a base directory and an `@import`ed name,
finds an existent file that matches the name.
@param dir [String] The directory relative to which to search.
@param name [String] The filename to search for.
@return [(String, Symbol)] A filename-syntax pair.
|
find_real_file
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
Apache-2.0
|
def split(name)
extension = nil
dirname, basename = File.dirname(name), File.basename(name)
if basename =~ /^(.*)\.(#{extensions.keys.map {|e| Regexp.escape(e)}.join('|')})$/
basename = $1
extension = $2
end
[dirname, basename, extension]
end
|
Splits a filename into three parts, a directory part, a basename, and an extension
Only the known extensions returned from the extensions method will be recognized as such.
|
split
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/importers/filesystem.rb
|
Apache-2.0
|
def initialize(inner)
self.log_level = inner.log_level
@inner = inner
@messages = []
end
|
Creates a delayed logger wrapping `inner`.
@param inner [Sass::Logger::Base] The wrapped logger.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/logger/delayed.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/logger/delayed.rb
|
Apache-2.0
|
def flush
@messages.each {|(l, m)| @inner.log(l, m)}
end
|
Flushes all queued logs to the wrapped logger.
|
flush
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/logger/delayed.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/logger/delayed.rb
|
Apache-2.0
|
def uninstall!
if Sass.logger != self
throw Exception.new("Can't uninstall a logger that's not currently installed.")
end
@inner.log_level = log_level
Sass.logger = @inner
end
|
Uninstalls this logger from \{Sass.logger\}. This should only be called if
the logger was installed using \{#install!}
|
uninstall!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/logger/delayed.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/logger/delayed.rb
|
Apache-2.0
|
def initialize(opts = {})
@watched_files = Set.new
options.merge!(opts)
end
|
Creates a new compiler.
@param opts [{Symbol => Object}]
See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
Apache-2.0
|
def update_stylesheets(individual_files = [])
Sass::Plugin.checked_for_updates = true
staleness_checker = StalenessChecker.new(engine_options)
files = file_list(individual_files)
run_updating_stylesheets(files)
updated_stylesheets = []
files.each do |file, css, sourcemap|
# TODO: Does staleness_checker need to check the sourcemap file as well?
if options[:always_update] || staleness_checker.stylesheet_needs_update?(css, file)
# XXX For consistency, this should return the sourcemap too, but it would
# XXX be an API change.
updated_stylesheets << [file, css]
update_stylesheet(file, css, sourcemap)
else
run_not_updating_stylesheet(file, css, sourcemap)
end
end
run_updated_stylesheets(updated_stylesheets)
end
|
Updates out-of-date stylesheets.
Checks each Sass/SCSS file in
{file:SASS_REFERENCE.md#template_location-option `:template_location`}
to see if it's been modified more recently than the corresponding CSS file
in {file:SASS_REFERENCE.md#css_location-option `:css_location`}.
If it has, it updates the CSS file.
@param individual_files [Array<(String, String[, String])>]
A list of files to check for updates
**in addition to those specified by the
{file:SASS_REFERENCE.md#template_location-option `:template_location` option}.**
The first string in each pair is the location of the Sass/SCSS file,
the second is the location of the CSS file that it should be compiled to.
The third string, if provided, is the location of the Sourcemap file.
|
update_stylesheets
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
Apache-2.0
|
def file_list(individual_files = [])
files = individual_files.map do |tuple|
if engine_options[:sourcemap] == :none
tuple[0..1]
elsif tuple.size < 3
[tuple[0], tuple[1], Sass::Util.sourcemap_name(tuple[1])]
else
tuple.dup
end
end
template_location_array.each do |template_location, css_location|
Sass::Util.glob(File.join(template_location, "**", "[^_]*.s[ca]ss")).sort.each do |file|
# Get the relative path to the file
name = Sass::Util.relative_path_from(file, template_location).to_s
css = css_filename(name, css_location)
sourcemap = Sass::Util.sourcemap_name(css) unless engine_options[:sourcemap] == :none
files << [file, css, sourcemap]
end
end
files
end
|
Construct a list of files that might need to be compiled
from the provided individual_files and the template_locations.
Note: this method does not cache the results as they can change
across invocations when sass files are added or removed.
@param individual_files [Array<(String, String[, String])>]
A list of files to check for updates
**in addition to those specified by the
{file:SASS_REFERENCE.md#template_location-option `:template_location` option}.**
The first string in each pair is the location of the Sass/SCSS file,
the second is the location of the CSS file that it should be compiled to.
The third string, if provided, is the location of the Sourcemap file.
@return [Array<(String, String, String)>]
A list of [sass_file, css_file, sourcemap_file] tuples similar
to what was passed in, but expanded to include the current state
of the directories being updated.
|
file_list
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
Apache-2.0
|
def watch(individual_files = [], options = {})
@inferred_directories = []
options, individual_files = individual_files, [] if individual_files.is_a?(Hash)
update_stylesheets(individual_files) unless options[:skip_initial_update]
directories = watched_paths
individual_files.each do |(source, _, _)|
source = File.expand_path(source)
@watched_files << Sass::Util.realpath(source).to_s
@inferred_directories << File.dirname(source)
end
directories += @inferred_directories
directories = remove_redundant_directories(directories)
# TODO: Keep better track of what depends on what
# so we don't have to run a global update every time anything changes.
# XXX The :additional_watch_paths option exists for Compass to use until
# a deprecated feature is removed. It may be removed without warning.
directories += Array(options[:additional_watch_paths])
options = {
:relative_paths => false,
# The native windows listener is much slower than the polling option, according to
# https://github.com/nex3/sass/commit/a3031856b22bc834a5417dedecb038b7be9b9e3e
:force_polling => @options[:poll] || Sass::Util.windows?
}
listener = create_listener(*directories, options) do |modified, added, removed|
on_file_changed(individual_files, modified, added, removed)
yield(modified, added, removed) if block_given?
end
begin
listener.start
sleep
rescue Interrupt
# Squelch Interrupt for clean exit from Listen::Listener
end
end
|
Watches the template directory (or directories)
and updates the CSS files whenever the related Sass/SCSS files change.
`watch` never returns.
Whenever a change is detected to a Sass/SCSS file in
{file:SASS_REFERENCE.md#template_location-option `:template_location`},
the corresponding CSS file in {file:SASS_REFERENCE.md#css_location-option `:css_location`}
will be recompiled.
The CSS files of any Sass/SCSS files that import the changed file will also be recompiled.
Before the watching starts in earnest, `watch` calls \{#update\_stylesheets}.
Note that `watch` uses the [Listen](http://github.com/guard/listen) library
to monitor the filesystem for changes.
Listen isn't loaded until `watch` is run.
The version of Listen distributed with Sass is loaded by default,
but if another version has already been loaded that will be used instead.
@param individual_files [Array<(String, String[, String])>]
A list of files to check for updates
**in addition to those specified by the
{file:SASS_REFERENCE.md#template_location-option `:template_location` option}.**
The first string in each pair is the location of the Sass/SCSS file,
the second is the location of the CSS file that it should be compiled to.
The third string, if provided, is the location of the Sourcemap file.
@param options [Hash] The options that control how watching works.
@option options [Boolean] :skip_initial_update
Don't do an initial update when starting the watcher when true
|
watch
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
Apache-2.0
|
def engine_options(additional_options = {})
opts = options.merge(additional_options)
opts[:load_paths] = load_paths(opts)
options[:sourcemap] = :auto if options[:sourcemap] == true
options[:sourcemap] = :none if options[:sourcemap] == false
opts
end
|
Non-destructively modifies \{#options} so that default values are properly set,
and returns the result.
@param additional_options [{Symbol => Object}] An options hash with which to merge \{#options}
@return [{Symbol => Object}] The modified options hash
|
engine_options
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
Apache-2.0
|
def clean(individual_files = [])
file_list(individual_files).each do |(_, css_file, sourcemap_file)|
if File.exist?(css_file)
run_deleting_css css_file
File.delete(css_file)
end
if sourcemap_file && File.exist?(sourcemap_file)
run_deleting_sourcemap sourcemap_file
File.delete(sourcemap_file)
end
end
nil
end
|
Remove all output files that would be created by calling update_stylesheets, if they exist.
This method runs the deleting_css and deleting_sourcemap callbacks for
the files that are deleted.
@param individual_files [Array<(String, String[, String])>]
A list of files to check for updates
**in addition to those specified by the
{file:SASS_REFERENCE.md#template_location-option `:template_location` option}.**
The first string in each pair is the location of the Sass/SCSS file,
the second is the location of the CSS file that it should be compiled to.
The third string, if provided, is the location of the Sourcemap file.
|
clean
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
Apache-2.0
|
def create_listener(*args, &block)
require 'sass-listen'
SassListen.to(*args, &block)
end
|
This is mocked out in compiler_test.rb.
|
create_listener
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/compiler.rb
|
Apache-2.0
|
def default_options
@default_options ||= {
:css_location => './public/stylesheets',
:always_update => false,
:always_check => true,
:full_exception => true,
:cache_location => ".sass-cache"
}.freeze
end
|
Returns the default options for a {Sass::Plugin::Compiler}.
@return [{Symbol => Object}]
|
default_options
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
Apache-2.0
|
def reset!
@options = nil
clear_callbacks!
end
|
Resets the options and
{Sass::Callbacks::InstanceMethods#clear_callbacks! clears all callbacks}.
|
reset!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
Apache-2.0
|
def options
@options ||= default_options.dup
end
|
An options hash. See {file:SASS_REFERENCE.md#Options the Sass options
documentation}.
@return [{Symbol => Object}]
|
options
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
Apache-2.0
|
def add_template_location(template_location, css_location = options[:css_location])
normalize_template_location!
template_location_array << [template_location, css_location]
end
|
Adds a new template-location/css-location mapping.
This means that Sass/SCSS files in `template_location`
will be compiled to CSS files in `css_location`.
This is preferred over manually manipulating the
{file:SASS_REFERENCE.md#template_location-option `:template_location` option}
since the option can be in multiple formats.
Note that this method will change `options[:template_location]`
to be in the Array format.
This means that even if `options[:template_location]`
had previously been a Hash or a String,
it will now be an Array.
@param template_location [String] The location where Sass/SCSS files will be.
@param css_location [String] The location where compiled CSS files will go.
|
add_template_location
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
Apache-2.0
|
def remove_template_location(template_location, css_location = options[:css_location])
normalize_template_location!
template_location_array.delete([template_location, css_location])
end
|
Removes a template-location/css-location mapping.
This means that Sass/SCSS files in `template_location`
will no longer be compiled to CSS files in `css_location`.
This is preferred over manually manipulating the
{file:SASS_REFERENCE.md#template_location-option `:template_location` option}
since the option can be in multiple formats.
Note that this method will change `options[:template_location]`
to be in the Array format.
This means that even if `options[:template_location]`
had previously been a Hash or a String,
it will now be an Array.
@param template_location [String]
The location where Sass/SCSS files were,
which is now going to be ignored.
@param css_location [String]
The location where compiled CSS files went, but will no longer go.
@return [Boolean]
Non-`nil` if the given mapping already existed and was removed,
or `nil` if nothing was changed.
|
remove_template_location
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
Apache-2.0
|
def template_location_array
convert_template_location(options[:template_location], options[:css_location])
end
|
Returns the template locations configured for Sass
as an array of `[template_location, css_location]` pairs.
See the {file:SASS_REFERENCE.md#template_location-option `:template_location` option}
for details.
Modifications to the returned array may not be persistent. Use {#add_template_location}
and {#remove_template_location} instead.
@return [Array<(String, String)>]
An array of `[template_location, css_location]` pairs.
|
template_location_array
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
Apache-2.0
|
def convert_template_location(template_location, css_location)
return template_location if template_location.is_a?(Array)
case template_location
when nil
if css_location
[[File.join(css_location, 'sass'), css_location]]
else
[]
end
when String
[[template_location, css_location]]
else
template_location.to_a
end
end
|
Returns the given template location, as an array. If it's already an array,
it is returned unmodified. Otherwise, a new array is created and returned.
@param template_location [String, Array<(String, String)>]
A single template location, or a pre-normalized array of template
locations and CSS locations.
@param css_location [String?]
The location for compiled CSS files.
@return [Array<(String, String)>]
An array of `[template_location, css_location]` pairs.
|
convert_template_location
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/configuration.rb
|
Apache-2.0
|
def initialize(app, dwell = 1.0)
@app = app
@dwell = dwell
@check_after = Time.now.to_f
end
|
Initialize the middleware.
@param app [#call] The Rack application
@param dwell [Float] See \{#dwell}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/rack.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/rack.rb
|
Apache-2.0
|
def call(env)
if @dwell.nil? || Time.now.to_f > @check_after
Sass::Plugin.check_for_updates
@check_after = Time.now.to_f + @dwell if @dwell
end
@app.call(env)
end
|
Process a request, checking the Sass stylesheets for changes
and updating them if necessary.
@param env The Rack request environment
@return [(#to_i, {String => String}, Object)] The Rack response
|
call
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/rack.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/rack.rb
|
Apache-2.0
|
def default_options
return @default_options if @default_options
opts = {
:quiet => Sass::Util.rails_env != "production",
:full_exception => Sass::Util.rails_env != "production",
:cache_location => Sass::Util.rails_root + '/tmp/sass-cache'
}
opts.merge!(
:always_update => false,
:template_location => Sass::Util.rails_root + '/public/stylesheets/sass',
:css_location => Sass::Util.rails_root + '/public/stylesheets',
:always_check => Sass::Util.rails_env == "development")
@default_options = opts.freeze
end
|
Different default options in a rails environment.
|
default_options
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/rails.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/rails.rb
|
Apache-2.0
|
def initialize(options)
# URIs that are being actively checked for staleness. Protects against
# import loops.
@actively_checking = Set.new
# Entries in the following instance-level caches are never explicitly expired.
# Instead they are supposed to automatically go out of scope when a series of staleness
# checks (this instance of StalenessChecker was created for) is finished.
@mtimes, @dependencies_stale, @parse_trees = {}, {}, {}
@options = Sass::Engine.normalize_options(options)
end
|
Creates a new StalenessChecker
for checking the staleness of several stylesheets at once.
@param options [{Symbol => Object}]
See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
Apache-2.0
|
def stylesheet_needs_update?(css_file, template_file, importer = nil)
template_file = File.expand_path(template_file)
begin
css_mtime = File.mtime(css_file)
rescue Errno::ENOENT
return true
end
stylesheet_modified_since?(template_file, css_mtime, importer)
end
|
Returns whether or not a given CSS file is out of date
and needs to be regenerated.
@param css_file [String] The location of the CSS file to check.
@param template_file [String] The location of the Sass or SCSS template
that is compiled to `css_file`.
@return [Boolean] Whether the stylesheet needs to be updated.
|
stylesheet_needs_update?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
Apache-2.0
|
def stylesheet_modified_since?(template_file, mtime, importer = nil)
importer ||= @options[:filesystem_importer].new(".")
dependency_updated?(mtime).call(template_file, importer)
end
|
Returns whether a Sass or SCSS stylesheet has been modified since a given time.
@param template_file [String] The location of the Sass or SCSS template.
@param mtime [Time] The modification time to check against.
@param importer [Sass::Importers::Base] The importer used to locate the stylesheet.
Defaults to the filesystem importer.
@return [Boolean] Whether the stylesheet has been modified.
|
stylesheet_modified_since?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
Apache-2.0
|
def with_dependency_cache
StalenessChecker.dependency_cache_mutex.synchronize do
yield StalenessChecker.dependencies_cache
end
end
|
Get access to the global dependency cache in a threadsafe manner.
Inside the block, no other thread can access the dependency cache.
@yieldparam cache [Hash] The hash that is the global dependency cache
@return The value returned by the block to which this method yields
|
with_dependency_cache
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/plugin/staleness_checker.rb
|
Apache-2.0
|
def interpolation(first: nil, inner: :space)
first || send(inner)
end
|
Short-circuit all the SassScript-only productions
|
interpolation
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/css_parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/css_parser.rb
|
Apache-2.0
|
def assert_type(value, type, name = nil)
valid_types = Array(type)
found_type = valid_types.find do |t|
value.is_a?(Sass::Script::Value.const_get(t)) ||
t == :Map && value.is_a?(Sass::Script::Value::List) && value.value.empty?
end
if found_type
value.check_deprecated_interp if found_type == :String
return
end
err = if valid_types.size == 1
"#{value.inspect} is not a #{TYPE_NAMES[type] || type.to_s.downcase}"
else
type_names = valid_types.map {|t| TYPE_NAMES[t] || t.to_s.downcase}
"#{value.inspect} is not any of #{type_names.join(', ')}"
end
err = "$#{name.to_s.tr('_', '-')}: " + err if name
raise ArgumentError.new(err)
end
|
Asserts that the type of a given SassScript value
is the expected type (designated by a symbol).
Valid types are `:Bool`, `:Color`, `:Number`, and `:String`.
Note that `:String` will match both double-quoted strings
and unquoted identifiers.
@example
assert_type value, :String
assert_type value, :Number
@param value [Sass::Script::Value::Base] A SassScript value
@param type [Symbol, Array<Symbol>] The name(s) of the type the value is expected to be
@param name [String, Symbol, nil] The name of the argument.
@raise [ArgumentError] if value is not of the correct type.
|
assert_type
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def assert_unit(number, unit, name = nil)
assert_type number, :Number, name
return if number.is_unit?(unit)
expectation = unit ? "have a unit of #{unit}" : "be unitless"
if name
raise ArgumentError.new("Expected $#{name} to #{expectation} but got #{number}")
else
raise ArgumentError.new("Expected #{number} to #{expectation}")
end
end
|
Asserts that the unit of the number is as expected.
@example
assert_unit number, "px"
assert_unit number, nil
@param number [Sass::Script::Value::Number] The number to be validated.
@param unit [::String]
The unit that the number must have.
If nil, the number must be unitless.
@param name [::String] The name of the parameter being validated.
@raise [ArgumentError] if number is not of the correct unit or is not a number.
|
assert_unit
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def assert_integer(number, name = nil)
assert_type number, :Number, name
return if number.int?
if name
raise ArgumentError.new("Expected $#{name} to be an integer but got #{number}")
else
raise ArgumentError.new("Expected #{number} to be an integer")
end
end
|
Asserts that the value is an integer.
@example
assert_integer 2px
assert_integer 2.5px
=> SyntaxError: "Expected 2.5px to be an integer"
assert_integer 2.5px, "width"
=> SyntaxError: "Expected width to be an integer but got 2.5px"
@param number [Sass::Script::Value::Base] The value to be validated.
@param name [::String] The name of the parameter being validated.
@raise [ArgumentError] if number is not an integer or is not a number.
|
assert_integer
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def perform(node, env = environment.caller)
if node.is_a?(Sass::Script::Value::Base)
node
else
node.perform(env)
end
end
|
Performs a node that has been delayed for execution.
@private
@param node [Sass::Script::Tree::Node,
Sass::Script::Value::Base] When this is a tree node, it's
performed in the caller's environment. When it's a value
(which can happen when the value had to be performed already
-- like for a splat), it's returned as-is.
@param env [Sass::Environment] The environment within which to perform the node.
Defaults to the (read-only) environment of the caller.
|
perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def rgb(red, green = nil, blue = nil)
if green.nil?
return unquoted_string("rgb(#{red})") if var?(red)
raise ArgumentError.new("wrong number of arguments (1 for 3)")
elsif blue.nil?
return unquoted_string("rgb(#{red}, #{green})") if var?(red) || var?(green)
raise ArgumentError.new("wrong number of arguments (2 for 3)")
end
if special_number?(red) || special_number?(green) || special_number?(blue)
return unquoted_string("rgb(#{red}, #{green}, #{blue})")
end
assert_type red, :Number, :red
assert_type green, :Number, :green
assert_type blue, :Number, :blue
color_attrs = [
percentage_or_unitless(red, 255, "red"),
percentage_or_unitless(green, 255, "green"),
percentage_or_unitless(blue, 255, "blue")
]
# Don't store the string representation for function-created colors, both
# because it's not very useful and because some functions aren't supported
# on older browsers.
Sass::Script::Value::Color.new(color_attrs)
end
|
Creates a {Sass::Script::Value::Color Color} object from red, green, and
blue values.
@see #rgba
@overload rgb($red, $green, $blue)
@param $red [Sass::Script::Value::Number] The amount of red in the color.
Must be between 0 and 255 inclusive, or between `0%` and `100%`
inclusive
@param $green [Sass::Script::Value::Number] The amount of green in the
color. Must be between 0 and 255 inclusive, or between `0%` and `100%`
inclusive
@param $blue [Sass::Script::Value::Number] The amount of blue in the
color. Must be between 0 and 255 inclusive, or between `0%` and `100%`
inclusive
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if any parameter is the wrong type or out of bounds
|
rgb
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def rgba(*args)
case args.size
when 1
return unquoted_string("rgba(#{args.first})") if var?(args.first)
raise ArgumentError.new("wrong number of arguments (1 for 4)")
when 2
color, alpha = args
if var?(color)
return unquoted_string("rgba(#{color}, #{alpha})")
elsif var?(alpha)
if color.is_a?(Sass::Script::Value::Color)
return unquoted_string("rgba(#{color.red}, #{color.green}, #{color.blue}, #{alpha})")
else
return unquoted_string("rgba(#{color}, #{alpha})")
end
end
assert_type color, :Color, :color
if special_number?(alpha)
unquoted_string("rgba(#{color.red}, #{color.green}, #{color.blue}, #{alpha})")
else
assert_type alpha, :Number, :alpha
color.with(:alpha => percentage_or_unitless(alpha, 1, "alpha"))
end
when 3
if var?(args[0]) || var?(args[1]) || var?(args[2])
unquoted_string("rgba(#{args.join(', ')})")
else
raise ArgumentError.new("wrong number of arguments (3 for 4)")
end
when 4
red, green, blue, alpha = args
if special_number?(red) || special_number?(green) ||
special_number?(blue) || special_number?(alpha)
unquoted_string("rgba(#{red}, #{green}, #{blue}, #{alpha})")
else
rgba(rgb(red, green, blue), alpha)
end
else
raise ArgumentError.new("wrong number of arguments (#{args.size} for 4)")
end
end
|
Creates a {Sass::Script::Value::Color Color} from red, green, blue, and
alpha values.
@see #rgb
@overload rgba($red, $green, $blue, $alpha)
@param $red [Sass::Script::Value::Number] The amount of red in the
color. Must be between 0 and 255 inclusive or 0% and 100% inclusive
@param $green [Sass::Script::Value::Number] The amount of green in the
color. Must be between 0 and 255 inclusive or 0% and 100% inclusive
@param $blue [Sass::Script::Value::Number] The amount of blue in the
color. Must be between 0 and 255 inclusive or 0% and 100% inclusive
@param $alpha [Sass::Script::Value::Number] The opacity of the color.
Must be between 0 and 1 inclusive
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if any parameter is the wrong type or out of
bounds
@overload rgba($color, $alpha)
Sets the opacity of an existing color.
@example
rgba(#102030, 0.5) => rgba(16, 32, 48, 0.5)
rgba(blue, 0.2) => rgba(0, 0, 255, 0.2)
@param $color [Sass::Script::Value::Color] The color whose opacity will
be changed.
@param $alpha [Sass::Script::Value::Number] The new opacity of the
color. Must be between 0 and 1 inclusive
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$alpha` is out of bounds or either parameter
is the wrong type
|
rgba
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def hsl(hue, saturation = nil, lightness = nil)
if saturation.nil?
return unquoted_string("hsl(#{hue})") if var?(hue)
raise ArgumentError.new("wrong number of arguments (1 for 3)")
elsif lightness.nil?
return unquoted_string("hsl(#{hue}, #{saturation})") if var?(hue) || var?(saturation)
raise ArgumentError.new("wrong number of arguments (2 for 3)")
end
if special_number?(hue) || special_number?(saturation) || special_number?(lightness)
unquoted_string("hsl(#{hue}, #{saturation}, #{lightness})")
else
hsla(hue, saturation, lightness, number(1))
end
end
|
Creates a {Sass::Script::Value::Color Color} from hue, saturation, and
lightness values. Uses the algorithm from the [CSS3 spec][].
[CSS3 spec]: http://www.w3.org/TR/css3-color/#hsl-color
@see #hsla
@overload hsl($hue, $saturation, $lightness)
@param $hue [Sass::Script::Value::Number] The hue of the color. Should be
between 0 and 360 degrees, inclusive
@param $saturation [Sass::Script::Value::Number] The saturation of the
color. Must be between `0%` and `100%`, inclusive
@param $lightness [Sass::Script::Value::Number] The lightness of the
color. Must be between `0%` and `100%`, inclusive
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$saturation` or `$lightness` are out of bounds
or any parameter is the wrong type
|
hsl
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def hsla(hue, saturation = nil, lightness = nil, alpha = nil)
if saturation.nil?
return unquoted_string("hsla(#{hue})") if var?(hue)
raise ArgumentError.new("wrong number of arguments (1 for 4)")
elsif lightness.nil?
return unquoted_string("hsla(#{hue}, #{saturation})") if var?(hue) || var?(saturation)
raise ArgumentError.new("wrong number of arguments (2 for 4)")
elsif alpha.nil?
if var?(hue) || var?(saturation) || var?(lightness)
return unquoted_string("hsla(#{hue}, #{saturation}, #{lightness})")
else
raise ArgumentError.new("wrong number of arguments (2 for 4)")
end
end
if special_number?(hue) || special_number?(saturation) ||
special_number?(lightness) || special_number?(alpha)
return unquoted_string("hsla(#{hue}, #{saturation}, #{lightness}, #{alpha})")
end
assert_type hue, :Number, :hue
assert_type saturation, :Number, :saturation
assert_type lightness, :Number, :lightness
assert_type alpha, :Number, :alpha
h = hue.value
s = saturation.value
l = lightness.value
# Don't store the string representation for function-created colors, both
# because it's not very useful and because some functions aren't supported
# on older browsers.
Sass::Script::Value::Color.new(
:hue => h, :saturation => s, :lightness => l,
:alpha => percentage_or_unitless(alpha, 1, "alpha"))
end
|
Creates a {Sass::Script::Value::Color Color} from hue,
saturation, lightness, and alpha values. Uses the algorithm from
the [CSS3 spec][].
[CSS3 spec]: http://www.w3.org/TR/css3-color/#hsl-color
@see #hsl
@overload hsla($hue, $saturation, $lightness, $alpha)
@param $hue [Sass::Script::Value::Number] The hue of the color. Should be
between 0 and 360 degrees, inclusive
@param $saturation [Sass::Script::Value::Number] The saturation of the
color. Must be between `0%` and `100%`, inclusive
@param $lightness [Sass::Script::Value::Number] The lightness of the
color. Must be between `0%` and `100%`, inclusive
@param $alpha [Sass::Script::Value::Number] The opacity of the color. Must
be between 0 and 1, inclusive
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$saturation`, `$lightness`, or `$alpha` are out
of bounds or any parameter is the wrong type
|
hsla
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def red(color)
assert_type color, :Color, :color
number(color.red)
end
|
Gets the red component of a color. Calculated from HSL where necessary via
[this algorithm][hsl-to-rgb].
[hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
@overload red($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The red component, between 0 and 255
inclusive
@raise [ArgumentError] if `$color` isn't a color
|
red
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def green(color)
assert_type color, :Color, :color
number(color.green)
end
|
Gets the green component of a color. Calculated from HSL where necessary
via [this algorithm][hsl-to-rgb].
[hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
@overload green($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The green component, between 0 and
255 inclusive
@raise [ArgumentError] if `$color` isn't a color
|
green
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def blue(color)
assert_type color, :Color, :color
number(color.blue)
end
|
Gets the blue component of a color. Calculated from HSL where necessary
via [this algorithm][hsl-to-rgb].
[hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
@overload blue($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The blue component, between 0 and
255 inclusive
@raise [ArgumentError] if `$color` isn't a color
|
blue
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def hue(color)
assert_type color, :Color, :color
number(color.hue, "deg")
end
|
Returns the hue component of a color. See [the CSS3 HSL
specification][hsl]. Calculated from RGB where necessary via [this
algorithm][rgb-to-hsl].
[hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
[rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
@overload hue($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The hue component, between 0deg and
360deg
@raise [ArgumentError] if `$color` isn't a color
|
hue
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def saturation(color)
assert_type color, :Color, :color
number(color.saturation, "%")
end
|
Returns the saturation component of a color. See [the CSS3 HSL
specification][hsl]. Calculated from RGB where necessary via [this
algorithm][rgb-to-hsl].
[hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
[rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
@overload saturation($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The saturation component, between 0%
and 100%
@raise [ArgumentError] if `$color` isn't a color
|
saturation
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def lightness(color)
assert_type color, :Color, :color
number(color.lightness, "%")
end
|
Returns the lightness component of a color. See [the CSS3 HSL
specification][hsl]. Calculated from RGB where necessary via [this
algorithm][rgb-to-hsl].
[hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
[rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
@overload lightness($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The lightness component, between 0%
and 100%
@raise [ArgumentError] if `$color` isn't a color
|
lightness
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def alpha(*args)
if args.all? do |a|
a.is_a?(Sass::Script::Value::String) && a.type == :identifier &&
a.value =~ /^[a-zA-Z]+\s*=/
end
# Support the proprietary MS alpha() function
return identifier("alpha(#{args.map {|a| a.to_s}.join(', ')})")
end
raise ArgumentError.new("wrong number of arguments (#{args.size} for 1)") if args.size != 1
assert_type args.first, :Color, :color
number(args.first.alpha)
end
|
Returns the alpha component (opacity) of a color. This is 1 unless
otherwise specified.
This function also supports the proprietary Microsoft `alpha(opacity=20)`
syntax as a special case.
@overload alpha($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The alpha component, between 0 and 1
@raise [ArgumentError] if `$color` isn't a color
|
alpha
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def opacity(color)
if color.is_a?(Sass::Script::Value::Number)
return identifier("opacity(#{color})")
end
assert_type color, :Color, :color
number(color.alpha)
end
|
Returns the alpha component (opacity) of a color. This is 1 unless
otherwise specified.
@overload opacity($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Number] The alpha component, between 0 and 1
@raise [ArgumentError] if `$color` isn't a color
|
opacity
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def opacify(color, amount)
_adjust(color, amount, :alpha, 0..1, :+)
end
|
Makes a color more opaque. Takes a color and a number between 0 and 1, and
returns a color with the opacity increased by that amount.
@see #transparentize
@example
opacify(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.6)
opacify(rgba(0, 0, 17, 0.8), 0.2) => #001
@overload opacify($color, $amount)
@param $color [Sass::Script::Value::Color]
@param $amount [Sass::Script::Value::Number] The amount to increase the
opacity by, between 0 and 1
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$amount` is out of bounds, or either parameter
is the wrong type
|
opacify
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def transparentize(color, amount)
_adjust(color, amount, :alpha, 0..1, :-)
end
|
Makes a color more transparent. Takes a color and a number between 0 and
1, and returns a color with the opacity decreased by that amount.
@see #opacify
@example
transparentize(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.4)
transparentize(rgba(0, 0, 0, 0.8), 0.2) => rgba(0, 0, 0, 0.6)
@overload transparentize($color, $amount)
@param $color [Sass::Script::Value::Color]
@param $amount [Sass::Script::Value::Number] The amount to decrease the
opacity by, between 0 and 1
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$amount` is out of bounds, or either parameter
is the wrong type
|
transparentize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def lighten(color, amount)
_adjust(color, amount, :lightness, 0..100, :+, "%")
end
|
Makes a color lighter. Takes a color and a number between `0%` and `100%`,
and returns a color with the lightness increased by that amount.
@see #darken
@example
lighten(hsl(0, 0%, 0%), 30%) => hsl(0, 0, 30)
lighten(#800, 20%) => #e00
@overload lighten($color, $amount)
@param $color [Sass::Script::Value::Color]
@param $amount [Sass::Script::Value::Number] The amount to increase the
lightness by, between `0%` and `100%`
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$amount` is out of bounds, or either parameter
is the wrong type
|
lighten
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def darken(color, amount)
_adjust(color, amount, :lightness, 0..100, :-, "%")
end
|
Makes a color darker. Takes a color and a number between 0% and 100%, and
returns a color with the lightness decreased by that amount.
@see #lighten
@example
darken(hsl(25, 100%, 80%), 30%) => hsl(25, 100%, 50%)
darken(#800, 20%) => #200
@overload darken($color, $amount)
@param $color [Sass::Script::Value::Color]
@param $amount [Sass::Script::Value::Number] The amount to decrease the
lightness by, between `0%` and `100%`
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$amount` is out of bounds, or either parameter
is the wrong type
|
darken
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def saturate(color, amount = nil)
# Support the filter effects definition of saturate.
# https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html
return identifier("saturate(#{color})") if amount.nil?
_adjust(color, amount, :saturation, 0..100, :+, "%")
end
|
Makes a color more saturated. Takes a color and a number between 0% and
100%, and returns a color with the saturation increased by that amount.
@see #desaturate
@example
saturate(hsl(120, 30%, 90%), 20%) => hsl(120, 50%, 90%)
saturate(#855, 20%) => #9e3f3f
@overload saturate($color, $amount)
@param $color [Sass::Script::Value::Color]
@param $amount [Sass::Script::Value::Number] The amount to increase the
saturation by, between `0%` and `100%`
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$amount` is out of bounds, or either parameter
is the wrong type
|
saturate
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def desaturate(color, amount)
_adjust(color, amount, :saturation, 0..100, :-, "%")
end
|
Makes a color less saturated. Takes a color and a number between 0% and
100%, and returns a color with the saturation decreased by that value.
@see #saturate
@example
desaturate(hsl(120, 30%, 90%), 20%) => hsl(120, 10%, 90%)
desaturate(#855, 20%) => #726b6b
@overload desaturate($color, $amount)
@param $color [Sass::Script::Value::Color]
@param $amount [Sass::Script::Value::Number] The amount to decrease the
saturation by, between `0%` and `100%`
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$amount` is out of bounds, or either parameter
is the wrong type
|
desaturate
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def adjust_hue(color, degrees)
assert_type color, :Color, :color
assert_type degrees, :Number, :degrees
color.with(:hue => color.hue + degrees.value)
end
|
Changes the hue of a color. Takes a color and a number of degrees (usually
between `-360deg` and `360deg`), and returns a color with the hue rotated
along the color wheel by that amount.
@example
adjust-hue(hsl(120, 30%, 90%), 60deg) => hsl(180, 30%, 90%)
adjust-hue(hsl(120, 30%, 90%), -60deg) => hsl(60, 30%, 90%)
adjust-hue(#811, 45deg) => #886a11
@overload adjust_hue($color, $degrees)
@param $color [Sass::Script::Value::Color]
@param $degrees [Sass::Script::Value::Number] The number of degrees to
rotate the hue
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if either parameter is the wrong type
|
adjust_hue
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def ie_hex_str(color)
assert_type color, :Color, :color
alpha = Sass::Util.round(color.alpha * 255).to_s(16).rjust(2, '0')
identifier("##{alpha}#{color.send(:hex_str)[1..-1]}".upcase)
end
|
Converts a color into the format understood by IE filters.
@example
ie-hex-str(#abc) => #FFAABBCC
ie-hex-str(#3322BB) => #FF3322BB
ie-hex-str(rgba(0, 255, 0, 0.5)) => #8000FF00
@overload ie_hex_str($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::String] The IE-formatted string
representation of the color
@raise [ArgumentError] if `$color` isn't a color
|
ie_hex_str
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def adjust_color(color, kwargs)
assert_type color, :Color, :color
with = Sass::Util.map_hash(
"red" => [-255..255, ""],
"green" => [-255..255, ""],
"blue" => [-255..255, ""],
"hue" => nil,
"saturation" => [-100..100, "%"],
"lightness" => [-100..100, "%"],
"alpha" => [-1..1, ""]
) do |name, (range, units)|
val = kwargs.delete(name)
next unless val
assert_type val, :Number, name
Sass::Util.check_range("$#{name}: Amount", range, val, units) if range
adjusted = color.send(name) + val.value
adjusted = [0, Sass::Util.restrict(adjusted, range)].max if range
[name.to_sym, adjusted]
end
unless kwargs.empty?
name, val = kwargs.to_a.first
raise ArgumentError.new("Unknown argument $#{name} (#{val})")
end
color.with(with)
end
|
Increases or decreases one or more properties of a color. This can change
the red, green, blue, hue, saturation, value, and alpha properties. The
properties are specified as keyword arguments, and are added to or
subtracted from the color's current value for that property.
All properties are optional. You can't specify both RGB properties
(`$red`, `$green`, `$blue`) and HSL properties (`$hue`, `$saturation`,
`$value`) at the same time.
@example
adjust-color(#102030, $blue: 5) => #102035
adjust-color(#102030, $red: -5, $blue: 5) => #0b2035
adjust-color(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
@overload adjust_color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])
@param $color [Sass::Script::Value::Color]
@param $red [Sass::Script::Value::Number] The adjustment to make on the
red component, between -255 and 255 inclusive
@param $green [Sass::Script::Value::Number] The adjustment to make on the
green component, between -255 and 255 inclusive
@param $blue [Sass::Script::Value::Number] The adjustment to make on the
blue component, between -255 and 255 inclusive
@param $hue [Sass::Script::Value::Number] The adjustment to make on the
hue component, in degrees
@param $saturation [Sass::Script::Value::Number] The adjustment to make on
the saturation component, between `-100%` and `100%` inclusive
@param $lightness [Sass::Script::Value::Number] The adjustment to make on
the lightness component, between `-100%` and `100%` inclusive
@param $alpha [Sass::Script::Value::Number] The adjustment to make on the
alpha component, between -1 and 1 inclusive
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if any parameter is the wrong type or out-of
bounds, or if RGB properties and HSL properties are adjusted at the
same time
|
adjust_color
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def scale_color(color, kwargs)
assert_type color, :Color, :color
with = Sass::Util.map_hash(
"red" => 255,
"green" => 255,
"blue" => 255,
"saturation" => 100,
"lightness" => 100,
"alpha" => 1
) do |name, max|
val = kwargs.delete(name)
next unless val
assert_type val, :Number, name
assert_unit val, '%', name
Sass::Util.check_range("$#{name}: Amount", -100..100, val, '%')
current = color.send(name)
scale = val.value / 100.0
diff = scale > 0 ? max - current : current
[name.to_sym, current + diff * scale]
end
unless kwargs.empty?
name, val = kwargs.to_a.first
raise ArgumentError.new("Unknown argument $#{name} (#{val})")
end
color.with(with)
end
|
Fluidly scales one or more properties of a color. Unlike
\{#adjust_color adjust-color}, which changes a color's properties by fixed
amounts, \{#scale_color scale-color} fluidly changes them based on how
high or low they already are. That means that lightening an already-light
color with \{#scale_color scale-color} won't change the lightness much,
but lightening a dark color by the same amount will change it more
dramatically. This has the benefit of making `scale-color($color, ...)`
have a similar effect regardless of what `$color` is.
For example, the lightness of a color can be anywhere between `0%` and
`100%`. If `scale-color($color, $lightness: 40%)` is called, the resulting
color's lightness will be 40% of the way between its original lightness
and 100. If `scale-color($color, $lightness: -40%)` is called instead, the
lightness will be 40% of the way between the original and 0.
This can change the red, green, blue, saturation, value, and alpha
properties. The properties are specified as keyword arguments. All
arguments should be percentages between `0%` and `100%`.
All properties are optional. You can't specify both RGB properties
(`$red`, `$green`, `$blue`) and HSL properties (`$saturation`, `$value`)
at the same time.
@example
scale-color(hsl(120, 70%, 80%), $lightness: 50%) => hsl(120, 70%, 90%)
scale-color(rgb(200, 150%, 170%), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
scale-color(hsl(200, 70%, 80%), $saturation: -90%, $alpha: -30%) => hsla(200, 7%, 80%, 0.7)
@overload scale_color($color, [$red], [$green], [$blue], [$saturation], [$lightness], [$alpha])
@param $color [Sass::Script::Value::Color]
@param $red [Sass::Script::Value::Number]
@param $green [Sass::Script::Value::Number]
@param $blue [Sass::Script::Value::Number]
@param $saturation [Sass::Script::Value::Number]
@param $lightness [Sass::Script::Value::Number]
@param $alpha [Sass::Script::Value::Number]
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if any parameter is the wrong type or out-of
bounds, or if RGB properties and HSL properties are adjusted at the
same time
|
scale_color
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def change_color(color, kwargs)
assert_type color, :Color, :color
with = Sass::Util.map_hash(
'red' => ['Red value', 0..255],
'green' => ['Green value', 0..255],
'blue' => ['Blue value', 0..255],
'hue' => [],
'saturation' => ['Saturation', 0..100, '%'],
'lightness' => ['Lightness', 0..100, '%'],
'alpha' => ['Alpha channel', 0..1]
) do |name, (desc, range, unit)|
val = kwargs.delete(name)
next unless val
assert_type val, :Number, name
if range
val = Sass::Util.check_range(desc, range, val, unit)
else
val = val.value
end
[name.to_sym, val]
end
unless kwargs.empty?
name, val = kwargs.to_a.first
raise ArgumentError.new("Unknown argument $#{name} (#{val})")
end
color.with(with)
end
|
Changes one or more properties of a color. This can change the red, green,
blue, hue, saturation, value, and alpha properties. The properties are
specified as keyword arguments, and replace the color's current value for
that property.
All properties are optional. You can't specify both RGB properties
(`$red`, `$green`, `$blue`) and HSL properties (`$hue`, `$saturation`,
`$value`) at the same time.
@example
change-color(#102030, $blue: 5) => #102005
change-color(#102030, $red: 120, $blue: 5) => #782005
change-color(hsl(25, 100%, 80%), $lightness: 40%, $alpha: 0.8) => hsla(25, 100%, 40%, 0.8)
@overload change_color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])
@param $color [Sass::Script::Value::Color]
@param $red [Sass::Script::Value::Number] The new red component for the
color, within 0 and 255 inclusive
@param $green [Sass::Script::Value::Number] The new green component for
the color, within 0 and 255 inclusive
@param $blue [Sass::Script::Value::Number] The new blue component for the
color, within 0 and 255 inclusive
@param $hue [Sass::Script::Value::Number] The new hue component for the
color, in degrees
@param $saturation [Sass::Script::Value::Number] The new saturation
component for the color, between `0%` and `100%` inclusive
@param $lightness [Sass::Script::Value::Number] The new lightness
component for the color, within `0%` and `100%` inclusive
@param $alpha [Sass::Script::Value::Number] The new alpha component for
the color, within 0 and 1 inclusive
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if any parameter is the wrong type or out-of
bounds, or if RGB properties and HSL properties are adjusted at the
same time
|
change_color
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def mix(color1, color2, weight = number(50))
assert_type color1, :Color, :color1
assert_type color2, :Color, :color2
assert_type weight, :Number, :weight
Sass::Util.check_range("Weight", 0..100, weight, '%')
# This algorithm factors in both the user-provided weight (w) and the
# difference between the alpha values of the two colors (a) to decide how
# to perform the weighted average of the two RGB values.
#
# It works by first normalizing both parameters to be within [-1, 1],
# where 1 indicates "only use color1", -1 indicates "only use color2", and
# all values in between indicated a proportionately weighted average.
#
# Once we have the normalized variables w and a, we apply the formula
# (w + a)/(1 + w*a) to get the combined weight (in [-1, 1]) of color1.
# This formula has two especially nice properties:
#
# * When either w or a are -1 or 1, the combined weight is also that number
# (cases where w * a == -1 are undefined, and handled as a special case).
#
# * When a is 0, the combined weight is w, and vice versa.
#
# Finally, the weight of color1 is renormalized to be within [0, 1]
# and the weight of color2 is given by 1 minus the weight of color1.
p = (weight.value / 100.0).to_f
w = p * 2 - 1
a = color1.alpha - color2.alpha
w1 = ((w * a == -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0
w2 = 1 - w1
rgba = color1.rgb.zip(color2.rgb).map {|v1, v2| v1 * w1 + v2 * w2}
rgba << color1.alpha * p + color2.alpha * (1 - p)
rgb_color(*rgba)
end
|
Mixes two colors together. Specifically, takes the average of each of the
RGB components, optionally weighted by the given percentage. The opacity
of the colors is also considered when weighting the components.
The weight specifies the amount of the first color that should be included
in the returned color. The default, `50%`, means that half the first color
and half the second color should be used. `25%` means that a quarter of
the first color and three quarters of the second color should be used.
@example
mix(#f00, #00f) => #7f007f
mix(#f00, #00f, 25%) => #3f00bf
mix(rgba(255, 0, 0, 0.5), #00f) => rgba(63, 0, 191, 0.75)
@overload mix($color1, $color2, $weight: 50%)
@param $color1 [Sass::Script::Value::Color]
@param $color2 [Sass::Script::Value::Color]
@param $weight [Sass::Script::Value::Number] The relative weight of each
color. Closer to `100%` gives more weight to `$color1`, closer to `0%`
gives more weight to `$color2`
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$weight` is out of bounds or any parameter is
the wrong type
|
mix
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def grayscale(color)
if color.is_a?(Sass::Script::Value::Number)
return identifier("grayscale(#{color})")
end
desaturate color, number(100)
end
|
Converts a color to grayscale. This is identical to `desaturate(color,
100%)`.
@see #desaturate
@overload grayscale($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$color` isn't a color
|
grayscale
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def complement(color)
adjust_hue color, number(180)
end
|
Returns the complement of a color. This is identical to `adjust-hue(color,
180deg)`.
@see #adjust_hue #adjust-hue
@overload complement($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$color` isn't a color
|
complement
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def invert(color, weight = number(100))
if color.is_a?(Sass::Script::Value::Number)
return identifier("invert(#{color})")
end
assert_type color, :Color, :color
inv = color.with(
:red => (255 - color.red),
:green => (255 - color.green),
:blue => (255 - color.blue))
mix(inv, color, weight)
end
|
Returns the inverse (negative) of a color. The red, green, and blue values
are inverted, while the opacity is left alone.
@overload invert($color)
@param $color [Sass::Script::Value::Color]
@overload invert($color, $weight: 100%)
@param $color [Sass::Script::Value::Color]
@param $weight [Sass::Script::Value::Number] The relative weight of the
color color's inverse
@return [Sass::Script::Value::Color]
@raise [ArgumentError] if `$color` isn't a color or `$weight`
isn't a percentage between 0% and 100%
|
invert
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def unquote(string)
unless string.is_a?(Sass::Script::Value::String)
# Don't warn multiple times for the same source line.
$_sass_warned_for_unquote ||= Set.new
frame = environment.stack.frames.last
key = [frame.filename, frame.line] if frame
return string if frame && $_sass_warned_for_unquote.include?(key)
$_sass_warned_for_unquote << key if frame
Sass::Util.sass_warn(<<MESSAGE.strip)
DEPRECATION WARNING: Passing #{string.to_sass}, a non-string value, to unquote()
will be an error in future versions of Sass.
#{environment.stack.to_s.gsub(/^/, ' ' * 8)}
MESSAGE
return string
end
string.check_deprecated_interp
return string if string.type == :identifier
identifier(string.value)
end
|
Removes quotes from a string. If the string is already unquoted, this will
return it unmodified.
@see #quote
@example
unquote("foo") => foo
unquote(foo) => foo
@overload unquote($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::String]
@raise [ArgumentError] if `$string` isn't a string
|
unquote
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def quote(string)
assert_type string, :String, :string
if string.type != :string
quoted_string(string.value)
else
string
end
end
|
Add quotes to a string if the string isn't quoted,
or returns the same string if it is.
@see #unquote
@example
quote("foo") => "foo"
quote(foo) => "foo"
@overload quote($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::String]
@raise [ArgumentError] if `$string` isn't a string
|
quote
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def str_length(string)
assert_type string, :String, :string
number(string.value.size)
end
|
Returns the number of characters in a string.
@example
str-length("foo") => 3
@overload str_length($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if `$string` isn't a string
|
str_length
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def str_insert(original, insert, index)
assert_type original, :String, :string
assert_type insert, :String, :insert
assert_integer index, :index
assert_unit index, nil, :index
insertion_point = if index.to_i > 0
[index.to_i - 1, original.value.size].min
else
[index.to_i, -original.value.size - 1].max
end
result = original.value.dup.insert(insertion_point, insert.value)
Sass::Script::Value::String.new(result, original.type)
end
|
Inserts `$insert` into `$string` at `$index`.
Note that unlike some languages, the first character in a Sass string is
number 1, the second number 2, and so forth.
@example
str-insert("abcd", "X", 1) => "Xabcd"
str-insert("abcd", "X", 4) => "abcXd"
str-insert("abcd", "X", 5) => "abcdX"
@overload str_insert($string, $insert, $index)
@param $string [Sass::Script::Value::String]
@param $insert [Sass::Script::Value::String]
@param $index [Sass::Script::Value::Number] The position at which
`$insert` will be inserted. Negative indices count from the end of
`$string`. An index that's outside the bounds of the string will insert
`$insert` at the front or back of the string
@return [Sass::Script::Value::String] The result string. This will be
quoted if and only if `$string` was quoted
@raise [ArgumentError] if any parameter is the wrong type
|
str_insert
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def str_index(string, substring)
assert_type string, :String, :string
assert_type substring, :String, :substring
index = string.value.index(substring.value)
index ? number(index + 1) : null
end
|
Returns the index of the first occurrence of `$substring` in `$string`. If
there is no such occurrence, returns `null`.
Note that unlike some languages, the first character in a Sass string is
number 1, the second number 2, and so forth.
@example
str-index(abcd, a) => 1
str-index(abcd, ab) => 1
str-index(abcd, X) => null
str-index(abcd, c) => 3
@overload str_index($string, $substring)
@param $string [Sass::Script::Value::String]
@param $substring [Sass::Script::Value::String]
@return [Sass::Script::Value::Number, Sass::Script::Value::Null]
@raise [ArgumentError] if any parameter is the wrong type
|
str_index
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def str_slice(string, start_at, end_at = nil)
assert_type string, :String, :string
assert_unit start_at, nil, "start-at"
end_at = number(-1) if end_at.nil?
assert_unit end_at, nil, "end-at"
return Sass::Script::Value::String.new("", string.type) if end_at.value == 0
s = start_at.value > 0 ? start_at.value - 1 : start_at.value
e = end_at.value > 0 ? end_at.value - 1 : end_at.value
s = string.value.length + s if s < 0
s = 0 if s < 0
e = string.value.length + e if e < 0
return Sass::Script::Value::String.new("", string.type) if e < 0
extracted = string.value.slice(s..e)
Sass::Script::Value::String.new(extracted || "", string.type)
end
|
Extracts a substring from `$string`. The substring will begin at index
`$start-at` and ends at index `$end-at`.
Note that unlike some languages, the first character in a Sass string is
number 1, the second number 2, and so forth.
@example
str-slice("abcd", 2, 3) => "bc"
str-slice("abcd", 2) => "bcd"
str-slice("abcd", -3, -2) => "bc"
str-slice("abcd", 2, -2) => "bc"
@overload str_slice($string, $start-at, $end-at: -1)
@param $start-at [Sass::Script::Value::Number] The index of the first
character of the substring. If this is negative, it counts from the end
of `$string`
@param $end-at [Sass::Script::Value::Number] The index of the last
character of the substring. If this is negative, it counts from the end
of `$string`. Defaults to -1
@return [Sass::Script::Value::String] The substring. This will be quoted
if and only if `$string` was quoted
@raise [ArgumentError] if any parameter is the wrong type
|
str_slice
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def to_upper_case(string)
assert_type string, :String, :string
Sass::Script::Value::String.new(Sass::Util.upcase(string.value), string.type)
end
|
Converts a string to upper case.
@example
to-upper-case(abcd) => ABCD
@overload to_upper_case($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::String]
@raise [ArgumentError] if `$string` isn't a string
|
to_upper_case
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def to_lower_case(string)
assert_type string, :String, :string
Sass::Script::Value::String.new(Sass::Util.downcase(string.value), string.type)
end
|
Convert a string to lower case,
@example
to-lower-case(ABCD) => abcd
@overload to_lower_case($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::String]
@raise [ArgumentError] if `$string` isn't a string
|
to_lower_case
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def type_of(value)
value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
identifier(value.class.name.gsub(/Sass::Script::Value::/, '').downcase)
end
|
Returns the type of a value.
@example
type-of(100px) => number
type-of(asdf) => string
type-of("asdf") => string
type-of(true) => bool
type-of(#fff) => color
type-of(blue) => color
type-of(null) => null
type-of(a b c) => list
type-of((a: 1, b: 2)) => map
type-of(get-function("foo")) => function
@overload type_of($value)
@param $value [Sass::Script::Value::Base] The value to inspect
@return [Sass::Script::Value::String] The unquoted string name of the
value's type
|
type_of
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def feature_exists(feature)
assert_type feature, :String, :feature
bool(Sass.has_feature?(feature.value))
end
|
Returns whether a feature exists in the current Sass runtime.
The following features are supported:
* `global-variable-shadowing` indicates that a local variable will shadow
a global variable unless `!global` is used.
* `extend-selector-pseudoclass` indicates that `@extend` will reach into
selector pseudoclasses like `:not`.
* `units-level-3` indicates full support for unit arithmetic using units
defined in the [Values and Units Level 3][] spec.
[Values and Units Level 3]: http://www.w3.org/TR/css3-values/
* `at-error` indicates that the Sass `@error` directive is supported.
* `custom-property` indicates that the [Custom Properties Level 1][] spec
is supported. This means that custom properties are parsed statically,
with only interpolation treated as SassScript.
[Custom Properties Level 1]: https://www.w3.org/TR/css-variables-1/
@example
feature-exists(some-feature-that-exists) => true
feature-exists(what-is-this-i-dont-know) => false
@overload feature_exists($feature)
@param $feature [Sass::Script::Value::String] The name of the feature
@return [Sass::Script::Value::Bool] Whether the feature is supported in this version of Sass
@raise [ArgumentError] if `$feature` isn't a string
|
feature_exists
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def get_function(name, kwargs = {})
assert_type name, :String, :name
css = if kwargs.has_key?("css")
v = kwargs.delete("css")
assert_type v, :Bool, :css
v.value
else
false
end
if kwargs.any?
raise ArgumentError.new("Illegal keyword argument '#{kwargs.keys.first}'")
end
if css
return Sass::Script::Value::Function.new(
Sass::Callable.new(name.value, nil, nil, nil, nil, nil, "function", :css))
end
callable = environment.caller.function(name.value) ||
(Sass::Script::Functions.callable?(name.value.tr("-", "_")) &&
Sass::Callable.new(name.value, nil, nil, nil, nil, nil, "function", :builtin))
if callable
Sass::Script::Value::Function.new(callable)
else
raise Sass::SyntaxError.new("Function not found: #{name}")
end
end
|
Returns a reference to a function for later invocation with the `call()` function.
If `$css` is `false`, the function reference may refer to a function
defined in your stylesheet or built-in to the host environment. If it's
`true` it will refer to a plain-CSS function.
@example
get-function("rgb")
@function myfunc { @return "something"; }
get-function("myfunc")
@overload get_function($name, $css: false)
@param name [Sass::Script::Value::String] The name of the function being referenced.
@param css [Sass::Script::Value::Bool] Whether to get a plain CSS function.
@return [Sass::Script::Value::Function] A function reference.
|
get_function
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def unit(number)
assert_type number, :Number, :number
quoted_string(number.unit_str)
end
|
Returns the unit(s) associated with a number. Complex units are sorted in
alphabetical order by numerator and denominator.
@example
unit(100) => ""
unit(100px) => "px"
unit(3em) => "em"
unit(10px * 5em) => "em*px"
unit(10px * 5em / 30cm / 1rem) => "em*px/cm*rem"
@overload unit($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::String] The unit(s) of the number, as a
quoted string
@raise [ArgumentError] if `$number` isn't a number
|
unit
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def unitless(number)
assert_type number, :Number, :number
bool(number.unitless?)
end
|
Returns whether a number has units.
@example
unitless(100) => true
unitless(100px) => false
@overload unitless($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::Bool]
@raise [ArgumentError] if `$number` isn't a number
|
unitless
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def comparable(number1, number2)
assert_type number1, :Number, :number1
assert_type number2, :Number, :number2
bool(number1.comparable_to?(number2))
end
|
Returns whether two numbers can added, subtracted, or compared.
@example
comparable(2px, 1px) => true
comparable(100px, 3em) => false
comparable(10cm, 3mm) => true
@overload comparable($number1, $number2)
@param $number1 [Sass::Script::Value::Number]
@param $number2 [Sass::Script::Value::Number]
@return [Sass::Script::Value::Bool]
@raise [ArgumentError] if either parameter is the wrong type
|
comparable
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def percentage(number)
unless number.is_a?(Sass::Script::Value::Number) && number.unitless?
raise ArgumentError.new("$number: #{number.inspect} is not a unitless number")
end
number(number.value * 100, '%')
end
|
Converts a unitless number to a percentage.
@example
percentage(0.2) => 20%
percentage(100px / 50px) => 200%
@overload percentage($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if `$number` isn't a unitless number
|
percentage
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def round(number)
numeric_transformation(number) {|n| Sass::Util.round(n)}
end
|
Rounds a number to the nearest whole number.
@example
round(10.4px) => 10px
round(10.6px) => 11px
@overload round($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if `$number` isn't a number
|
round
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def ceil(number)
numeric_transformation(number) {|n| n.ceil}
end
|
Rounds a number up to the next whole number.
@example
ceil(10.4px) => 11px
ceil(10.6px) => 11px
@overload ceil($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if `$number` isn't a number
|
ceil
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def floor(number)
numeric_transformation(number) {|n| n.floor}
end
|
Rounds a number down to the previous whole number.
@example
floor(10.4px) => 10px
floor(10.6px) => 10px
@overload floor($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if `$number` isn't a number
|
floor
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def abs(number)
numeric_transformation(number) {|n| n.abs}
end
|
Returns the absolute value of a number.
@example
abs(10px) => 10px
abs(-10px) => 10px
@overload abs($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if `$number` isn't a number
|
abs
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def min(*numbers)
numbers.each {|n| assert_type n, :Number}
numbers.inject {|min, num| min.lt(num).to_bool ? min : num}
end
|
Finds the minimum of several numbers. This function takes any number of
arguments.
@example
min(1px, 4px) => 1px
min(5em, 3em, 4em) => 3em
@overload min($numbers...)
@param $numbers [[Sass::Script::Value::Number]]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if any argument isn't a number, or if not all of
the arguments have comparable units
|
min
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def max(*values)
values.each {|v| assert_type v, :Number}
values.inject {|max, val| max.gt(val).to_bool ? max : val}
end
|
Finds the maximum of several numbers. This function takes any number of
arguments.
@example
max(1px, 4px) => 4px
max(5em, 3em, 4em) => 5em
@overload max($numbers...)
@param $numbers [[Sass::Script::Value::Number]]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if any argument isn't a number, or if not all of
the arguments have comparable units
|
max
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def set_nth(list, n, value)
assert_type n, :Number, :n
Sass::Script::Value::List.assert_valid_index(list, n)
index = n.to_i > 0 ? n.to_i - 1 : n.to_i
new_list = list.to_a.dup
new_list[index] = value
list.with_contents(new_list)
end
|
Return a new list, based on the list provided, but with the nth
element changed to the value given.
Note that unlike some languages, the first item in a Sass list is number
1, the second number 2, and so forth.
Negative index values address elements in reverse order, starting with the last element
in the list.
@example
set-nth($list: 10px 20px 30px, $n: 2, $value: -20px) => 10px -20px 30px
@overload set-nth($list, $n, $value)
@param $list [Sass::Script::Value::Base] The list that will be copied, having the element
at index `$n` changed.
@param $n [Sass::Script::Value::Number] The index of the item to set.
Negative indices count from the end of the list.
@param $value [Sass::Script::Value::Base] The new value at index `$n`.
@return [Sass::Script::Value::List]
@raise [ArgumentError] if `$n` isn't an integer between 1 and the length
of `$list`
|
set_nth
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def nth(list, n)
assert_type n, :Number, :n
Sass::Script::Value::List.assert_valid_index(list, n)
index = n.to_i > 0 ? n.to_i - 1 : n.to_i
list.to_a[index]
end
|
Gets the nth item in a list.
Note that unlike some languages, the first item in a Sass list is number
1, the second number 2, and so forth.
This can return the nth pair in a map as well.
Negative index values address elements in reverse order, starting with the last element in
the list.
@example
nth(10px 20px 30px, 1) => 10px
nth((Helvetica, Arial, sans-serif), 3) => sans-serif
nth((width: 10px, length: 20px), 2) => length, 20px
@overload nth($list, $n)
@param $list [Sass::Script::Value::Base]
@param $n [Sass::Script::Value::Number] The index of the item to get.
Negative indices count from the end of the list.
@return [Sass::Script::Value::Base]
@raise [ArgumentError] if `$n` isn't an integer between 1 and the length
of `$list`
|
nth
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def join(list1, list2,
separator = identifier("auto"), bracketed = identifier("auto"),
kwargs = nil, *rest)
if separator.is_a?(Hash)
kwargs = separator
separator = identifier("auto")
elsif bracketed.is_a?(Hash)
kwargs = bracketed
bracketed = identifier("auto")
elsif rest.last.is_a?(Hash)
rest.unshift kwargs
kwargs = rest.pop
end
unless rest.empty?
# Add 4 to rest.length because we don't want to count the kwargs hash,
# which is always passed.
raise ArgumentError.new("wrong number of arguments (#{rest.length + 4} for 2..4)")
end
if kwargs
separator = kwargs.delete("separator") || separator
bracketed = kwargs.delete("bracketed") || bracketed
unless kwargs.empty?
name, val = kwargs.to_a.first
raise ArgumentError.new("Unknown argument $#{name} (#{val})")
end
end
assert_type separator, :String, :separator
unless %w(auto space comma).include?(separator.value)
raise ArgumentError.new("Separator name must be space, comma, or auto")
end
list(list1.to_a + list2.to_a,
separator:
if separator.value == 'auto'
list1.separator || list2.separator || :space
else
separator.value.to_sym
end,
bracketed:
if bracketed.is_a?(Sass::Script::Value::String) && bracketed.value == 'auto'
list1.bracketed
else
bracketed.to_bool
end)
end
|
Joins together two lists into one.
Unless `$separator` is passed, if one list is comma-separated and one is
space-separated, the first parameter's separator is used for the resulting
list. If both lists have fewer than two items, spaces are used for the
resulting list.
Unless `$bracketed` is passed, the resulting list is bracketed if the
first parameter is.
Like all list functions, `join()` returns a new list rather than modifying
its arguments in place.
@example
join(10px 20px, 30px 40px) => 10px 20px 30px 40px
join((blue, red), (#abc, #def)) => blue, red, #abc, #def
join(10px, 20px) => 10px 20px
join(10px, 20px, comma) => 10px, 20px
join((blue, red), (#abc, #def), space) => blue red #abc #def
join([10px], 20px) => [10px 20px]
@overload join($list1, $list2, $separator: auto, $bracketed: auto)
@param $list1 [Sass::Script::Value::Base]
@param $list2 [Sass::Script::Value::Base]
@param $separator [Sass::Script::Value::String] The list separator to use.
If this is `comma` or `space`, that separator will be used. If this is
`auto` (the default), the separator is determined as explained above.
@param $bracketed [Sass::Script::Value::Base] Whether the resulting list
will be bracketed. If this is `auto` (the default), the separator is
determined as explained above.
@return [Sass::Script::Value::List]
|
join
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def append(list, val, separator = identifier("auto"))
assert_type separator, :String, :separator
unless %w(auto space comma).include?(separator.value)
raise ArgumentError.new("Separator name must be space, comma, or auto")
end
list.with_contents(list.to_a + [val],
separator:
if separator.value == 'auto'
list.separator || :space
else
separator.value.to_sym
end)
end
|
Appends a single value onto the end of a list.
Unless the `$separator` argument is passed, if the list had only one item,
the resulting list will be space-separated.
Like all list functions, `append()` returns a new list rather than
modifying its argument in place.
@example
append(10px 20px, 30px) => 10px 20px 30px
append((blue, red), green) => blue, red, green
append(10px 20px, 30px 40px) => 10px 20px (30px 40px)
append(10px, 20px, comma) => 10px, 20px
append((blue, red), green, space) => blue red green
@overload append($list, $val, $separator: auto)
@param $list [Sass::Script::Value::Base]
@param $val [Sass::Script::Value::Base]
@param $separator [Sass::Script::Value::String] The list separator to use.
If this is `comma` or `space`, that separator will be used. If this is
`auto` (the default), the separator is determined as explained above.
@return [Sass::Script::Value::List]
|
append
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def zip(*lists)
length = nil
values = []
lists.each do |list|
array = list.to_a
values << array.dup
length = length.nil? ? array.length : [length, array.length].min
end
values.each do |value|
value.slice!(length)
end
new_list_value = values.first.zip(*values[1..-1])
list(new_list_value.map {|list| list(list, :space)}, :comma)
end
|
Combines several lists into a single multidimensional list. The nth value
of the resulting list is a space separated list of the source lists' nth
values.
The length of the resulting list is the length of the
shortest list.
@example
zip(1px 1px 3px, solid dashed solid, red green blue)
=> 1px solid red, 1px dashed green, 3px solid blue
@overload zip($lists...)
@param $lists [[Sass::Script::Value::Base]]
@return [Sass::Script::Value::List]
|
zip
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def index(list, value)
index = list.to_a.index {|e| e.eq(value).to_bool}
index ? number(index + 1) : null
end
|
Returns the position of a value within a list. If the value isn't found,
returns `null` instead.
Note that unlike some languages, the first item in a Sass list is number
1, the second number 2, and so forth.
This can return the position of a pair in a map as well.
@example
index(1px solid red, solid) => 2
index(1px solid red, dashed) => null
index((width: 10px, height: 20px), (height 20px)) => 2
@overload index($list, $value)
@param $list [Sass::Script::Value::Base]
@param $value [Sass::Script::Value::Base]
@return [Sass::Script::Value::Number, Sass::Script::Value::Null] The
1-based index of `$value` in `$list`, or `null`
|
index
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def list_separator(list)
identifier((list.separator || :space).to_s)
end
|
Returns the separator of a list. If the list doesn't have a separator due
to having fewer than two elements, returns `space`.
@example
list-separator(1px 2px 3px) => space
list-separator(1px, 2px, 3px) => comma
list-separator('foo') => space
@overload list_separator($list)
@param $list [Sass::Script::Value::Base]
@return [Sass::Script::Value::String] `comma` or `space`
|
list_separator
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def map_get(map, key)
assert_type map, :Map, :map
map.to_h[key] || null
end
|
Returns the value in a map associated with the given key. If the map
doesn't have such a key, returns `null`.
@example
map-get(("foo": 1, "bar": 2), "foo") => 1
map-get(("foo": 1, "bar": 2), "bar") => 2
map-get(("foo": 1, "bar": 2), "baz") => null
@overload map_get($map, $key)
@param $map [Sass::Script::Value::Map]
@param $key [Sass::Script::Value::Base]
@return [Sass::Script::Value::Base] The value indexed by `$key`, or `null`
if the map doesn't contain the given key
@raise [ArgumentError] if `$map` is not a map
|
map_get
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def map_merge(map1, map2)
assert_type map1, :Map, :map1
assert_type map2, :Map, :map2
map(map1.to_h.merge(map2.to_h))
end
|
Merges two maps together into a new map. Keys in `$map2` will take
precedence over keys in `$map1`.
This is the best way to add new values to a map.
All keys in the returned map that also appear in `$map1` will have the
same order as in `$map1`. New keys from `$map2` will be placed at the end
of the map.
Like all map functions, `map-merge()` returns a new map rather than
modifying its arguments in place.
@example
map-merge(("foo": 1), ("bar": 2)) => ("foo": 1, "bar": 2)
map-merge(("foo": 1, "bar": 2), ("bar": 3)) => ("foo": 1, "bar": 3)
@overload map_merge($map1, $map2)
@param $map1 [Sass::Script::Value::Map]
@param $map2 [Sass::Script::Value::Map]
@return [Sass::Script::Value::Map]
@raise [ArgumentError] if either parameter is not a map
|
map_merge
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def map_remove(map, *keys)
assert_type map, :Map, :map
hash = map.to_h.dup
hash.delete_if {|key, _| keys.include?(key)}
map(hash)
end
|
Returns a new map with keys removed.
Like all map functions, `map-merge()` returns a new map rather than
modifying its arguments in place.
@example
map-remove(("foo": 1, "bar": 2), "bar") => ("foo": 1)
map-remove(("foo": 1, "bar": 2, "baz": 3), "bar", "baz") => ("foo": 1)
map-remove(("foo": 1, "bar": 2), "baz") => ("foo": 1, "bar": 2)
@overload map_remove($map, $keys...)
@param $map [Sass::Script::Value::Map]
@param $keys [[Sass::Script::Value::Base]]
@return [Sass::Script::Value::Map]
@raise [ArgumentError] if `$map` is not a map
|
map_remove
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def map_keys(map)
assert_type map, :Map, :map
list(map.to_h.keys, :comma)
end
|
Returns a list of all keys in a map.
@example
map-keys(("foo": 1, "bar": 2)) => "foo", "bar"
@overload map_keys($map)
@param $map [Map]
@return [List] the list of keys, comma-separated
@raise [ArgumentError] if `$map` is not a map
|
map_keys
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.