Merge pull request #1017 from Retrospring/feature/raised-texts
Add new raised text and raised accent text theme fields
This commit is contained in:
commit
2517b1330a
|
@ -125,6 +125,8 @@ $spacers: map-merge($rs-spacers, $spacers);
|
||||||
--muted-text: 108, 117, 125;
|
--muted-text: 108, 117, 125;
|
||||||
--input-text: 0, 0, 0;
|
--input-text: 0, 0, 0;
|
||||||
--input-placeholder: 108, 117, 125;
|
--input-placeholder: 108, 117, 125;
|
||||||
|
--raised-text: 0, 0, 0;
|
||||||
|
--raised-accent-text: 0, 0, 0;
|
||||||
|
|
||||||
--turbolinks-progress-color: #a58adc; // --primary lightened by 25%
|
--turbolinks-progress-color: #a58adc; // --primary lightened by 25%
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
& .dropdown-item:hover,
|
& .dropdown-item:hover,
|
||||||
& .dropdown-item:active {
|
& .dropdown-item:active {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: RGB(var(--body-text));
|
color: RGB(var(--raised-text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
margin-bottom: map.get($spacers, 3);
|
margin-bottom: map.get($spacers, 3);
|
||||||
box-shadow: $box-shadow-sm;
|
box-shadow: $box-shadow-sm;
|
||||||
background-color: var(--raised-bg);
|
background-color: var(--raised-bg);
|
||||||
|
color: RGB(var(--raised-text));
|
||||||
|
|
||||||
p:last-child {
|
p:last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
@ -17,4 +18,5 @@
|
||||||
.card-header,
|
.card-header,
|
||||||
.card-footer {
|
.card-footer {
|
||||||
background-color: var(--raised-accent);
|
background-color: var(--raised-accent);
|
||||||
|
color: RGB(var(--raised-accent-text));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
.dropdown-menu {
|
.dropdown-menu {
|
||||||
color: RGB(var(--body-text));
|
color: RGB(var(--raised-text));
|
||||||
background-color: var(--raised-bg);
|
background-color: var(--raised-bg);
|
||||||
box-shadow: $box-shadow-lg;
|
box-shadow: $box-shadow-lg;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-item {
|
.dropdown-item {
|
||||||
color: RGB(var(--body-text));
|
color: RGB(var(--raised-text));
|
||||||
|
|
||||||
&.active,
|
&.active,
|
||||||
&:active,
|
&:active,
|
||||||
&:active:hover {
|
&:active:hover {
|
||||||
color: RGB(var(--primary-text));
|
color: RGB(var(--primary-text));
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
color: RGB(var(--raised-accent-text));
|
||||||
background-color: var(--raised-accent);
|
background-color: var(--raised-accent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,4 +33,4 @@
|
||||||
.dropdown-menu--lists {
|
.dropdown-menu--lists {
|
||||||
max-width: 275px;
|
max-width: 275px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-group-item-action {
|
.list-group-item-action {
|
||||||
color: RGB(var(--body-text));
|
color: RGB(var(--raised-text));
|
||||||
|
|
||||||
&:hover, &:focus {
|
&:hover, &:focus {
|
||||||
|
color: RGB(var(--raised-accent-text));
|
||||||
background-color: var(--raised-accent);
|
background-color: var(--raised-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,22 +8,8 @@ class Settings::ThemeController < ApplicationController
|
||||||
def edit; end
|
def edit; end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
update_attributes = params.require(:theme).permit(%i[
|
|
||||||
primary_color primary_text
|
|
||||||
danger_color danger_text
|
|
||||||
success_color success_text
|
|
||||||
warning_color warning_text
|
|
||||||
info_color info_text
|
|
||||||
dark_color dark_text
|
|
||||||
light_color light_text
|
|
||||||
raised_background raised_accent
|
|
||||||
background_color body_text
|
|
||||||
muted_text input_color
|
|
||||||
input_text input_placeholder
|
|
||||||
])
|
|
||||||
|
|
||||||
if current_user.theme.nil?
|
if current_user.theme.nil?
|
||||||
current_user.theme = Theme.new update_attributes
|
current_user.theme = Theme.new theme_attributes
|
||||||
current_user.theme.user_id = current_user.id
|
current_user.theme.user_id = current_user.id
|
||||||
|
|
||||||
if current_user.theme.save
|
if current_user.theme.save
|
||||||
|
@ -31,7 +17,7 @@ class Settings::ThemeController < ApplicationController
|
||||||
else
|
else
|
||||||
flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" "))
|
flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" "))
|
||||||
end
|
end
|
||||||
elsif current_user.theme.update(update_attributes)
|
elsif current_user.theme.update(theme_attributes)
|
||||||
flash[:success] = t(".success")
|
flash[:success] = t(".success")
|
||||||
else
|
else
|
||||||
flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" "))
|
flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" "))
|
||||||
|
@ -43,4 +29,23 @@ class Settings::ThemeController < ApplicationController
|
||||||
current_user.theme.destroy!
|
current_user.theme.destroy!
|
||||||
redirect_to edit_settings_theme_path
|
redirect_to edit_settings_theme_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def theme_attributes
|
||||||
|
params.require(:theme).permit(%i[
|
||||||
|
primary_color primary_text
|
||||||
|
danger_color danger_text
|
||||||
|
success_color success_text
|
||||||
|
warning_color warning_text
|
||||||
|
info_color info_text
|
||||||
|
dark_color dark_text
|
||||||
|
light_color light_text
|
||||||
|
raised_background raised_accent
|
||||||
|
raised_text raised_accent_text
|
||||||
|
background_color body_text
|
||||||
|
muted_text input_color
|
||||||
|
input_text input_placeholder
|
||||||
|
])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,28 +2,30 @@
|
||||||
|
|
||||||
module ThemeHelper
|
module ThemeHelper
|
||||||
ATTRIBUTE_MAP = {
|
ATTRIBUTE_MAP = {
|
||||||
"primary_color" => %w[primary primary-rgb],
|
"primary_color" => %w[primary primary-rgb],
|
||||||
"primary_text" => "primary-text",
|
"primary_text" => "primary-text",
|
||||||
"danger_color" => "danger",
|
"danger_color" => "danger",
|
||||||
"danger_text" => "danger-text",
|
"danger_text" => "danger-text",
|
||||||
"warning_color" => "warning",
|
"warning_color" => "warning",
|
||||||
"warning_text" => "warning-text",
|
"warning_text" => "warning-text",
|
||||||
"info_color" => "info",
|
"info_color" => "info",
|
||||||
"info_text" => "info-text",
|
"info_text" => "info-text",
|
||||||
"success_color" => "success",
|
"success_color" => "success",
|
||||||
"success_text" => "success-text",
|
"success_text" => "success-text",
|
||||||
"dark_color" => "dark",
|
"dark_color" => "dark",
|
||||||
"dark_text" => "dark-text",
|
"dark_text" => "dark-text",
|
||||||
"light_color" => "light",
|
"light_color" => "light",
|
||||||
"light_text" => "light-text",
|
"light_text" => "light-text",
|
||||||
"raised_background" => %w[raised-bg raised-bg-rgb],
|
"raised_background" => %w[raised-bg raised-bg-rgb],
|
||||||
"raised_accent" => %w[raised-accent raised-accent-rgb],
|
"raised_text" => "raised-text",
|
||||||
"background_color" => "background",
|
"raised_accent" => %w[raised-accent raised-accent-rgb],
|
||||||
"body_text" => "body-text",
|
"raised_accent_text" => "raised-accent-text",
|
||||||
"input_color" => "input-bg",
|
"background_color" => "background",
|
||||||
"input_text" => "input-text",
|
"body_text" => "body-text",
|
||||||
"input_placeholder" => "input-placeholder",
|
"input_color" => "input-bg",
|
||||||
"muted_text" => "muted-text"
|
"input_text" => "input-text",
|
||||||
|
"input_placeholder" => "input-placeholder",
|
||||||
|
"muted_text" => "muted-text"
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
def render_theme
|
def render_theme
|
||||||
|
|
|
@ -14,7 +14,9 @@ export const THEME_MAPPING = {
|
||||||
'light_color': 'light',
|
'light_color': 'light',
|
||||||
'light_text': 'light-text',
|
'light_text': 'light-text',
|
||||||
'raised_background': 'raised-bg',
|
'raised_background': 'raised-bg',
|
||||||
|
'raised_text': 'raised-text',
|
||||||
'raised_accent': 'raised-accent',
|
'raised_accent': 'raised-accent',
|
||||||
|
'raised_accent_text': 'raised-accent-text',
|
||||||
'background_color': 'background',
|
'background_color': 'background',
|
||||||
'body_text': 'body-text',
|
'body_text': 'body-text',
|
||||||
'input_color': 'input-bg',
|
'input_color': 'input-bg',
|
||||||
|
|
|
@ -21,6 +21,23 @@
|
||||||
= f.text_field :background_color, class: "color", data: { default: 0xF0EDF4, theme_target: "color", action: "theme#updatePreview" }
|
= f.text_field :background_color, class: "color", data: { default: 0xF0EDF4, theme_target: "color", action: "theme#updatePreview" }
|
||||||
.col-sm-6
|
.col-sm-6
|
||||||
= f.text_field :body_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" }
|
= f.text_field :body_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" }
|
||||||
|
.card
|
||||||
|
.card-body
|
||||||
|
%h2= t(".raised.heading")
|
||||||
|
%p= t(".raised.body")
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
= f.text_field :raised_background, class: "color", data: { default: 0xFFFFFF, theme_target: "color", action: "theme#updatePreview" }
|
||||||
|
.col-sm-6
|
||||||
|
= f.text_field :raised_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" }
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
= f.text_field :raised_accent, class: "color", data: { default: 0xF7F7F7, theme_target: "color", action: "theme#updatePreview" }
|
||||||
|
.col-sm-6
|
||||||
|
= f.text_field :raised_accent_text, class: "color", data: { default: 0x000000, theme_target: "color", action: "theme#updatePreview" }
|
||||||
|
.card-footer
|
||||||
|
%p= t(".raised.accent.example")
|
||||||
.card
|
.card
|
||||||
.card-body
|
.card-body
|
||||||
%h2= t(".colors.heading")
|
%h2= t(".colors.heading")
|
||||||
|
@ -93,23 +110,11 @@
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-sm-6
|
.col-sm-6
|
||||||
= f.text_field :input_placeholder, class: "color", data: { default: 0x6C757D, theme_target: "color" }
|
= f.text_field :input_placeholder, class: "color", data: { default: 0x6C757D, theme_target: "color", action: "theme#updatePreview" }
|
||||||
.col-sm-6
|
.col-sm-6
|
||||||
.form-group
|
.form-group
|
||||||
%label.form-label Example Input
|
%label.form-label Example Input
|
||||||
%input.form-control{ placeholder: "A test placeholder" }
|
%input.form-control{ placeholder: "A test placeholder" }
|
||||||
.card
|
|
||||||
.card-body
|
|
||||||
%h2= t(".raised.heading")
|
|
||||||
%p= t(".raised.body")
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-sm-6
|
|
||||||
= f.text_field :raised_background, class: "color", data: { default: 0xFFFFFF, theme_target: "color" }
|
|
||||||
.col-sm-6
|
|
||||||
= f.text_field :raised_accent, class: "color", data: { default: 0xF7F7F7, theme_target: "color" }
|
|
||||||
.card-footer
|
|
||||||
%p= t(".raised.accent.example")
|
|
||||||
.card
|
.card
|
||||||
.card-body
|
.card-body
|
||||||
.pull-left
|
.pull-left
|
||||||
|
|
|
@ -49,7 +49,9 @@ en:
|
||||||
primary_color: "Primary colour"
|
primary_color: "Primary colour"
|
||||||
primary_text: "Primary text colour"
|
primary_text: "Primary text colour"
|
||||||
raised_accent: "Raised accent colour"
|
raised_accent: "Raised accent colour"
|
||||||
|
raised_accent_text: "Raised accent text colour"
|
||||||
raised_background: "Raised background colour"
|
raised_background: "Raised background colour"
|
||||||
|
raised_text: "Raised text colour"
|
||||||
success_color: "Success colour"
|
success_color: "Success colour"
|
||||||
success_text: "Success text colour"
|
success_text: "Success text colour"
|
||||||
warning_color: "Warning colour"
|
warning_color: "Warning colour"
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddRaisedAndAccentTextToThemes < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
add_column :themes, :raised_text, :integer, default: 0x000000, null: false
|
||||||
|
add_column :themes, :raised_accent_text, :integer, default: 0x000000, null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :themes, :raised_text
|
||||||
|
remove_column :themes, :raised_accent_text
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class UseBodyTextForRaisedTextsInThemes < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
execute <<~SQUIRREL
|
||||||
|
UPDATE themes
|
||||||
|
SET raised_text = body_text,
|
||||||
|
raised_accent_text = body_text
|
||||||
|
WHERE body_text != 0;
|
||||||
|
SQUIRREL
|
||||||
|
end
|
||||||
|
|
||||||
|
def down; end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_01_08_114333) do
|
ActiveRecord::Schema.define(version: 2023_01_29_194809) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -181,7 +181,7 @@ ActiveRecord::Schema.define(version: 2023_01_08_114333) do
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
||||||
t.index ["resource_type", "resource_id"], name: "index_roles_on_resource"
|
t.index ["resource_type", "resource_id"], name: "index_roles_on_resource_type_and_resource_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "rpush_apps", force: :cascade do |t|
|
create_table "rpush_apps", force: :cascade do |t|
|
||||||
|
@ -301,6 +301,8 @@ ActiveRecord::Schema.define(version: 2023_01_08_114333) do
|
||||||
t.integer "light_color", default: 16316922
|
t.integer "light_color", default: 16316922
|
||||||
t.integer "light_text", default: 0
|
t.integer "light_text", default: 0
|
||||||
t.integer "input_placeholder", default: 7107965, null: false
|
t.integer "input_placeholder", default: 7107965, null: false
|
||||||
|
t.integer "raised_text", default: 0, null: false
|
||||||
|
t.integer "raised_accent_text", default: 0, null: false
|
||||||
t.index ["user_id", "created_at"], name: "index_themes_on_user_id_and_created_at"
|
t.index ["user_id", "created_at"], name: "index_themes_on_user_id_and_created_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,14 @@ FactoryBot.define do
|
||||||
dark_color { 6_710_886 }
|
dark_color { 6_710_886 }
|
||||||
dark_text { 15_658_734 }
|
dark_text { 15_658_734 }
|
||||||
raised_background { 16_777_215 }
|
raised_background { 16_777_215 }
|
||||||
|
raised_text { 3_355_443 }
|
||||||
background_color { 13_026_795 }
|
background_color { 13_026_795 }
|
||||||
body_text { 3_355_443 }
|
body_text { 3_355_443 }
|
||||||
muted_text { 3_355_443 }
|
muted_text { 3_355_443 }
|
||||||
input_color { 15_789_556 }
|
input_color { 15_789_556 }
|
||||||
input_text { 6_710_886 }
|
input_text { 6_710_886 }
|
||||||
raised_accent { 16_250_871 }
|
raised_accent { 16_250_871 }
|
||||||
|
raised_accent_text { 3_355_443 }
|
||||||
light_color { 16_316_922 }
|
light_color { 16_316_922 }
|
||||||
light_text { 0 }
|
light_text { 0 }
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,32 +22,34 @@ 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,
|
id: theme.id,
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
primary_color: 9342168,
|
primary_color: 9342168,
|
||||||
primary_text: 16777215,
|
primary_text: 16777215,
|
||||||
danger_color: 14257035,
|
danger_color: 14257035,
|
||||||
danger_text: 16777215,
|
danger_text: 16777215,
|
||||||
success_color: 12573067,
|
success_color: 12573067,
|
||||||
success_text: 16777215,
|
success_text: 16777215,
|
||||||
warning_color: 14261899,
|
warning_color: 14261899,
|
||||||
warning_text: 16777215,
|
warning_text: 16777215,
|
||||||
info_color: 9165273,
|
info_color: 9165273,
|
||||||
info_text: 16777215,
|
info_text: 16777215,
|
||||||
dark_color: 6710886,
|
dark_color: 6710886,
|
||||||
dark_text: 15658734,
|
dark_text: 15658734,
|
||||||
raised_background: 16777215,
|
raised_background: 16777215,
|
||||||
background_color: 13026795,
|
raised_text: 3355443,
|
||||||
body_text: 3355443,
|
background_color: 13026795,
|
||||||
muted_text: 3355443,
|
body_text: 3355443,
|
||||||
created_at: "2022-12-10T13:37:42.000Z",
|
muted_text: 3355443,
|
||||||
updated_at: "2022-12-10T13:37:42.000Z",
|
created_at: "2022-12-10T13:37:42.000Z",
|
||||||
input_color: 15789556,
|
updated_at: "2022-12-10T13:37:42.000Z",
|
||||||
input_text: 6710886,
|
input_color: 15789556,
|
||||||
raised_accent: 16250871,
|
input_text: 6710886,
|
||||||
light_color: 16316922,
|
raised_accent: 16250871,
|
||||||
light_text: 0,
|
raised_accent_text: 3355443,
|
||||||
input_placeholder: 7107965
|
light_color: 16316922,
|
||||||
|
light_text: 0,
|
||||||
|
input_placeholder: 7107965
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue