Sha256: 9843cc09b45a2549849c17890aa3153453170c7654633f79bc571697e7efc7e0

Contents?: true

Size: 1.22 KB

Versions: 31

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Admin
  # AppearanceService
  class AppearanceService
    def style_file
      stylesheets = 'app/assets/stylesheets/admin/utils'
      "#{Rails.root}/#{stylesheets}/_variables.scss"
    end

    def set_default
      appearance = Appearance.last
      appearance.remove_image_background!
      appearance.save
      get_apparience_color('#f44336')
    end

    def get_color(color)
      get_apparience_color(color) if color_exist(color)
    end

    def set_color
      variables_file = File.readlines(style_file)
      color = ''
      variables_file.each do |line|
        color = line[15..21] if line.include?('$keppler-color')
      end
    end

    private

    def get_apparience_color(color)
      variables_file = File.readlines(style_file)
      indx = 0
      variables_file.map do |line|
        include_attr = line.include?('$keppler-color')
        indx = variables_file.find_index(line) if include_attr
      end
      variables_file[indx] = "$keppler-color:#{color};\n"
      variables_file = variables_file.join('')
      File.write(style_file, variables_file)
    end

    def color_exist(color)
      colors = [color]
      !colors.include?('') && !colors.include?(nil)
    end
  end
end

Version data entries

31 entries across 30 versions & 1 rubygems

Version Path
keppler-2.1.22 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.21 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.20 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.19 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.18 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.18 testing-with-2.1.18/app/services/admin/appearance_service.rb
keppler-2.1.17 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.16 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.15 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.14 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.13 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.12 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.11 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.10 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.9 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.8 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.7 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.6 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.5 installer/core/app/services/admin/appearance_service.rb
keppler-2.1.4 installer/core/app/services/admin/appearance_service.rb