Completed
Branch master (ce2c9c)
by Jesus
04:32
created

Themer.color_lighten()   A

Complexity

Conditions 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 11
loc 11
rs 9.85
c 1
b 0
f 0
1
# frozen_string_literal: true
2
3
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
4
#
5
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
6
#
7
# This program is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU Lesser General Public License as published by the Free Software
9
# Foundation; either version 3.0 of the License, or (at your option) any later
10
# version.
11
#
12
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
#
16
# You should have received a copy of the GNU Lesser General Public License along
17
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
19
module Themer
20
  extend ActiveSupport::Concern
21
22
  # Lightens a color by 40%
23 View Code Duplication
  def color_lighten(color)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
24
    # Uses the built in Sass Engine to lighten the color
25
26
    dummy_scss = "h1 { color: $lighten; }"
27
    compiled = Sass::Engine.new("$lighten:lighten(#{color}, 40%);" + dummy_scss, syntax: :scss).render
28
29
    string_locater = 'color: '
30
    color_start = compiled.index(string_locater) + string_locater.length
31
32
    compiled[color_start..color_start + 6]
33
  end
34
35
  # Darkens a color by 10%
36 View Code Duplication
  def color_darken(color)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
37
    # Uses the built in Sass Engine to darken the color
38
39
    dummy_scss = "h1 { color: $darken; }"
40
    compiled = Sass::Engine.new("$darken:darken(#{color}, 10%);" + dummy_scss, syntax: :scss).render
41
42
    string_locater = 'color: '
43
    color_start = compiled.index(string_locater) + string_locater.length
44
45
    compiled[color_start..color_start + 6]
46
  end
47
end
48