2020-04-19 00:59:18 +02:00
|
|
|
class Theme < ApplicationRecord
|
2015-08-25 10:26:36 +02:00
|
|
|
include ThemeHelper
|
|
|
|
|
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
validates_numericality_of :primary_color, :primary_text,
|
|
|
|
:danger_color, :danger_text,
|
|
|
|
:success_color, :success_text,
|
|
|
|
:warning_color, :warning_text,
|
|
|
|
:info_color, :info_text,
|
2020-05-05 02:02:16 +02:00
|
|
|
:dark_color, :dark_text,
|
|
|
|
:light_color, :light_text,
|
|
|
|
:raised_background, :raised_accent,
|
|
|
|
:background_color, :body_text,
|
|
|
|
:muted_text, :input_color,
|
|
|
|
:input_text,
|
2015-08-25 10:26:36 +02:00
|
|
|
greater_than_or_equal_to: 0, less_than_or_equal_to: 0xFFFFFF,
|
|
|
|
allow_nil: true, only_integer: true
|
|
|
|
|
2015-08-27 01:56:07 +02:00
|
|
|
def theme_color
|
|
|
|
('#' + ('0000000' + primary_color.to_s(16))[-6, 6])
|
|
|
|
end
|
2021-08-06 00:36:20 +02:00
|
|
|
|
|
|
|
def mobile_theme_color
|
|
|
|
('#' + ('0000000' + background_color.to_s(16))[-6, 6])
|
|
|
|
end
|
2015-08-25 10:26:36 +02:00
|
|
|
end
|