From f8d23f70b9e5658b109a0180881fb272fccc28ca Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Thu, 30 Jul 2020 15:08:05 -0500 Subject: [UI, Accessibility] Make underlining hyperlinks optional --- app/controllers/settings/preferences_controller.rb | 1 + .../styles/monsterfork/components/formatting.scss | 4 ++-- app/lib/user_settings_decorator.rb | 5 +++++ app/models/user.rb | 2 +- app/views/layouts/application.html.haml | 18 ++++++++++++++++++ .../settings/preferences/appearance/show.html.haml | 1 + config/locales/simple_form.en-MP.yml | 1 + 7 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index cc3b38dad..b189b394f 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -63,6 +63,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_crop_images, :setting_manual_publish, :setting_style_dashed_nest, + :setting_style_underline_a, notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account trending_tag), interactions: %i(must_be_follower must_be_following must_be_following_dm) ) diff --git a/app/javascript/flavours/glitch/styles/monsterfork/components/formatting.scss b/app/javascript/flavours/glitch/styles/monsterfork/components/formatting.scss index 2b822fdec..0d8a42211 100644 --- a/app/javascript/flavours/glitch/styles/monsterfork/components/formatting.scss +++ b/app/javascript/flavours/glitch/styles/monsterfork/components/formatting.scss @@ -79,10 +79,10 @@ a { color: $secondary-text-color; - text-decoration: underline; + text-decoration: none; &:hover { - text-decoration: none; + text-decoration: underline; .fa { color: lighten($dark-text-color, 7%); diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index cd84d42e8..0d6d150fa 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -46,6 +46,7 @@ class UserSettingsDecorator user.settings['manual_publish'] = manual_publish_preference if change?('setting_manual_publish') user.settings['style_dashed_nest'] = style_dashed_nest_preference if change?('setting_style_dashed_nest') + user.settings['style_underline_a'] = style_underline_a_preference if change?('setting_style_underline_a') end def merged_notification_emails @@ -168,6 +169,10 @@ class UserSettingsDecorator boolean_cast_setting 'setting_style_dashed_nest' end + def style_underline_a_preference + boolean_cast_setting 'setting_style_underline_a' + end + def boolean_cast_setting(key) ActiveModel::Type::Boolean.new.cast(settings[key]) end diff --git a/app/models/user.rb b/app/models/user.rb index 23c0f232b..129cb822d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,7 +114,7 @@ class User < ApplicationRecord :expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images, :default_content_type, :system_emoji_font, - :manual_publish, :style_dashed_nest, + :manual_publish, :style_dashed_nest, :style_underline_a, to: :settings, prefix: :setting, allow_nil: false attr_reader :invite_code, :sign_in_token_attempt diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 98ee041c1..aa3c560cb 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -46,6 +46,24 @@ border-style: dashed; } + - if current_account&.user&.setting_style_underline_a + :css + .status__content__text a, + .reply-indicator__content a, + .composer--reply > .content a, + .account__header__content a + { + text-decoration: underline; + } + + .status__content__text a:hover, + .reply-indicator__content a:hover, + .composer--reply > .content a:hover, + .account__header__content a:hover + { + text-decoration: none; + } + %body{ class: body_classes } = content_for?(:content) ? yield(:content) : yield diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index c2cff5ca4..8d4c182c3 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -32,6 +32,7 @@ .fields-group = f.input :setting_style_dashed_nest, as: :boolean, wrapper: :with_label + = f.input :setting_style_underline_a, as: :boolean, wrapper: :with_label %h4= t 'appearance.toot_layout' diff --git a/config/locales/simple_form.en-MP.yml b/config/locales/simple_form.en-MP.yml index 671cbda0c..71f498c68 100644 --- a/config/locales/simple_form.en-MP.yml +++ b/config/locales/simple_form.en-MP.yml @@ -54,6 +54,7 @@ en-MP: setting_manual_publish: Manually publish roars setting_show_application: Disclose application used to send roars setting_style_dashed_nest: Use dashed nest level indicators + setting_style_underline_a: Underline hyperlinks setting_use_pending_items: Relax mode show_replies: Show replies on profile show_unlisted: Show unlisted roars to anonymous visitors -- cgit