Module: Sass::Script::Functions

Defined in:
lib/flat-ui-sass/sass_functions.rb

Instance Method Summary collapse

Instance Method Details

#fade(color, amount) ⇒ Object



41
42
43
44
45
46
# File 'lib/flat-ui-sass/sass_functions.rb', line 41

def fade(color, amount)
  if amount.is_a?(Sass::Script::Number) && amount.unit_str == "%"
    amount = Sass::Script::Number.new(1 - amount.value / 100.0)
  end
  fade_out(color, amount)
end

#flat_ui_asset_path(source, type) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/flat-ui-sass/sass_functions.rb', line 17

def flat_ui_asset_path(source, type)
  return Sass::Script::String.new('', :string) if source.to_s.empty?
  url = if FlatUI.asset_pipeline? && (context = sprockets_context)
          context.send(:"#{type}_path", source.value)
        elsif FlatUI.compass?
          send(:"#{type}_url", source, Sass::Script::Bool.new(true)).value.sub /url\((.*)\)$/, '\1'
        end

  # sass-only
  url ||= source.value.gsub('"', '')
  Sass::Script::String.new(url, :string)
end

#flat_ui_font_path(source) ⇒ Object



7
8
9
# File 'lib/flat-ui-sass/sass_functions.rb', line 7

def flat_ui_font_path(source)
  flat_ui_asset_path source, :font
end

#flat_ui_image_path(source) ⇒ Object



12
13
14
# File 'lib/flat-ui-sass/sass_functions.rb', line 12

def flat_ui_image_path(source)
  flat_ui_asset_path source, :image
end

#interpolate_variable(name) ⇒ Object

Based on github.com/edwardoriordan/sass-utilities/blob/master/lib/sass-utilities.rb For Sass < 3.3.0, just echo back the variable since we can’t interpolate it



52
53
54
55
# File 'lib/flat-ui-sass/sass_functions.rb', line 52

def interpolate_variable(name)
  assert_type name, :String
  ::Sass::VERSION >= '3.3.0' ? environment.var(name.value) : name
end

#tint(color, percentage) ⇒ Object



32
33
34
35
36
37
# File 'lib/flat-ui-sass/sass_functions.rb', line 32

def tint(color, percentage)
  assert_type color, :Color
  assert_type percentage, :Number
  white = Sass::Script::Color.new([255, 255, 255])
  mix(white, color, percentage)
end