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