mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 10:29:53 +01:00
Represent theme colors as hexadecimal in export
This commit is contained in:
parent
ce69ec7cec
commit
5d38699ba6
2 changed files with 34 additions and 34 deletions
|
@ -3,20 +3,24 @@
|
|||
module UseCase
|
||||
module DataExport
|
||||
class Theme < UseCase::DataExport::Base
|
||||
include ThemeHelper
|
||||
|
||||
MODEL_FIELDS = %i[id user_id created_at updated_at].freeze
|
||||
|
||||
def files
|
||||
return {} unless user.theme
|
||||
|
||||
{
|
||||
"theme.json" => json_file!(
|
||||
theme: theme_data
|
||||
)
|
||||
theme: theme_data,
|
||||
),
|
||||
}
|
||||
end
|
||||
|
||||
def theme_data
|
||||
{}.tap do |obj|
|
||||
column_names(::Theme).each do |field|
|
||||
obj[field] = user.theme[field]
|
||||
(column_names(::Theme) - MODEL_FIELDS).each do |field|
|
||||
obj[field] = "##{get_hex_color_from_theme_value(user.theme[field])}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,36 +22,32 @@ describe UseCase::DataExport::Theme, :data_export do
|
|||
expect(json_file("theme.json")).to eq(
|
||||
{
|
||||
theme: {
|
||||
id: theme.id,
|
||||
user_id: user.id,
|
||||
primary_color: 9342168,
|
||||
primary_text: 16777215,
|
||||
danger_color: 14257035,
|
||||
danger_text: 16777215,
|
||||
success_color: 12573067,
|
||||
success_text: 16777215,
|
||||
warning_color: 14261899,
|
||||
warning_text: 16777215,
|
||||
info_color: 9165273,
|
||||
info_text: 16777215,
|
||||
dark_color: 6710886,
|
||||
dark_text: 15658734,
|
||||
raised_background: 16777215,
|
||||
raised_text: 3355443,
|
||||
background_color: 13026795,
|
||||
body_text: 3355443,
|
||||
muted_text: 3355443,
|
||||
created_at: "2022-12-10T13:37:42.000Z",
|
||||
updated_at: "2022-12-10T13:37:42.000Z",
|
||||
input_color: 15789556,
|
||||
input_text: 6710886,
|
||||
raised_accent: 16250871,
|
||||
raised_accent_text: 3355443,
|
||||
light_color: 16316922,
|
||||
light_text: 0,
|
||||
input_placeholder: 7107965
|
||||
}
|
||||
}
|
||||
background_color: "#f0edf4",
|
||||
body_text: "#000000",
|
||||
danger_color: "#dc3545",
|
||||
danger_text: "#ffffff",
|
||||
dark_color: "#343a40",
|
||||
dark_text: "#eeeeee",
|
||||
info_color: "#17a2b8",
|
||||
info_text: "#ffffff",
|
||||
input_color: "#f0edf4",
|
||||
input_placeholder: "#6c757d",
|
||||
input_text: "#000000",
|
||||
light_color: "#f8f9fa",
|
||||
light_text: "#000000",
|
||||
muted_text: "#6c757d",
|
||||
primary_color: "#5e35b1",
|
||||
primary_text: "#ffffff",
|
||||
raised_accent: "#f7f7f7",
|
||||
raised_accent_text: "#000000",
|
||||
raised_background: "#ffffff",
|
||||
raised_text: "#000000",
|
||||
success_color: "#28a745",
|
||||
success_text: "#ffffff",
|
||||
warning_color: "#ffc107",
|
||||
warning_text: "#292929",
|
||||
},
|
||||
},
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue