From d1c625df7cf68b30534d082bb4ae63d3f18d10ec Mon Sep 17 00:00:00 2001 From: KMY Date: Thu, 11 May 2023 11:16:53 +0900 Subject: [PATCH] Add kmyblue mark in config page --- app/javascript/styles/mastodon/accounts.scss | 9 ++++++++- app/javascript/styles/mastodon/variables.scss | 1 + .../settings/preferences/appearance/show.html.haml | 2 +- .../preferences/notifications/show.html.haml | 2 +- app/views/settings/preferences/other/show.html.haml | 12 ++++++------ app/views/settings/profiles/show.html.haml | 4 ++-- config/initializers/simple_form.rb | 13 +++++++++++++ config/locales/simple_form.en.yml | 1 + config/locales/simple_form.ja.yml | 1 + 9 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index 961f8a7f8b..5f1222fbf6 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -199,7 +199,8 @@ .account-role, .simple_form .recommended, -.simple_form .not_recommended { +.simple_form .not_recommended, +.simple_form .kmyblue { display: inline-block; padding: 4px 6px; cursor: default; @@ -230,6 +231,12 @@ border-color: rgba(lighten($error-red, 12%), 0.5); } +.simple_form .kmyblue { + color: lighten($kmyblue, 12%); + background-color: rgba(lighten($kmyblue, 12%), 0.1); + border-color: rgba(lighten($kmyblue, 12%), 0.5); +} + .account__header__fields { max-width: 100vw; padding: 0; diff --git a/app/javascript/styles/mastodon/variables.scss b/app/javascript/styles/mastodon/variables.scss index 7de25f8fd4..4cb93b18a4 100644 --- a/app/javascript/styles/mastodon/variables.scss +++ b/app/javascript/styles/mastodon/variables.scss @@ -5,6 +5,7 @@ $success-green: #79bd9a !default; // Padua $error-red: #df405a !default; // Cerise $warning-red: #ff5050 !default; // Sunset Orange $gold-star: #ca8f04 !default; // Dark Goldenrod +$kmyblue: #29a5f7 !default; $red-bookmark: $warning-red; diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index ca6a2e9775..e9613f8cff 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -57,7 +57,7 @@ = ff.input :'web.display_media', collection: ['default', 'show_all', 'hide_all'],label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label, label: I18n.t('simple_form.labels.defaults.setting_display_media') .fields-group - = ff.input :'web.display_media_expand', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_display_media_expand'), hint: I18n.t('simple_form.hints.defaults.setting_display_media_expand') + = ff.input :'web.display_media_expand', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_display_media_expand'), hint: I18n.t('simple_form.hints.defaults.setting_display_media_expand') .fields-group = ff.input :'web.use_blurhash', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_use_blurhash'), hint: I18n.t('simple_form.hints.defaults.setting_use_blurhash') diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml index 1f3a0538c3..2444e788ec 100644 --- a/app/views/settings/preferences/notifications/show.html.haml +++ b/app/views/settings/preferences/notifications/show.html.haml @@ -36,4 +36,4 @@ .fields-group = f.simple_fields_for :settings, current_user.settings do |ff| - = ff.input :stop_emoji_reaction_streaming, as: :boolean, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_stop_emoji_reaction_streaming'), hint: I18n.t('simple_form.hints.defaults.setting_stop_emoji_reaction_streaming') + = ff.input :stop_emoji_reaction_streaming, as: :boolean, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_stop_emoji_reaction_streaming'), hint: I18n.t('simple_form.hints.defaults.setting_stop_emoji_reaction_streaming') diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index c726c02e1f..69ca38e94a 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -12,7 +12,7 @@ = ff.input :noindex, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_noindex'), hint: I18n.t('simple_form.hints.defaults.setting_noindex') .fields-group - = ff.input :noai, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_noai'), hint: I18n.t('simple_form.hints.defaults.setting_noai') + = ff.input :noai, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_noai'), hint: I18n.t('simple_form.hints.defaults.setting_noai') .fields-group = ff.input :aggregate_reblogs, wrapper: :with_label, recommended: true, label: I18n.t('simple_form.labels.defaults.setting_aggregate_reblogs'), hint: I18n.t('simple_form.hints.defaults.setting_aggregate_reblogs') @@ -27,10 +27,10 @@ = ff.input :default_language, collection: [nil] + filterable_languages, wrapper: :with_label, label_method: lambda { |locale| locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) }, required: false, include_blank: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_language') .fields-group - = ff.input :default_searchability, collection: Status.selectable_searchabilities, wrapper: :with_label, include_blank: false, label_method: lambda { |searchability| safe_join([I18n.t("statuses.searchabilities.#{searchability}"), I18n.t("statuses.searchabilities.#{searchability}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_searchability') + = ff.input :default_searchability, collection: Status.selectable_searchabilities, wrapper: :with_label, kmyblue: true, include_blank: false, label_method: lambda { |searchability| safe_join([I18n.t("statuses.searchabilities.#{searchability}"), I18n.t("statuses.searchabilities.#{searchability}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_searchability') .fields-group - = ff.input :public_post_to_unlisted, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_public_post_to_unlisted'), hint: I18n.t('simple_form.hints.defaults.setting_public_post_to_unlisted') + = ff.input :public_post_to_unlisted, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_public_post_to_unlisted'), hint: I18n.t('simple_form.hints.defaults.setting_public_post_to_unlisted') .fields-group = ff.input :default_sensitive, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'), hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive') @@ -41,13 +41,13 @@ %h4= t 'preferences.stop_deliver' .fields-group - = f.input :setting_send_without_domain_blocks, as: :boolean, wrapper: :with_label + = f.input :setting_send_without_domain_blocks, kmyblue: true, recommended: :not_recommended, as: :boolean, wrapper: :with_label .fields-group - = f.input :setting_reject_public_unlisted_subscription, as: :boolean, wrapper: :with_label + = f.input :setting_reject_public_unlisted_subscription, kmyblue: true, as: :boolean, wrapper: :with_label .fields-group - = f.input :setting_reject_unlisted_subscription, as: :boolean, wrapper: :with_label + = f.input :setting_reject_unlisted_subscription, kmyblue: true, as: :boolean, wrapper: :with_label %h4= t 'preferences.public_timelines' diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index 3d7a4325da..3c0f030733 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -30,7 +30,7 @@ = f.input :my_actor_type, collection: ['person', 'bot', 'group'],label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.#{item}"), content_tag(:span, I18n.t("simple_form.hints.defaults.#{item}"), class: 'hint')]) }, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label .fields-group - = f.input :group_allow_private_message, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.group_allow_private_message') + = f.input :group_allow_private_message, as: :boolean, wrapper: :with_label, kmyblue: true, hint: t('simple_form.hints.defaults.group_allow_private_message') .fields-group = f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable'), recommended: true @@ -39,7 +39,7 @@ = f.input :hide_collections, as: :boolean, wrapper: :with_label, label: t('simple_form.labels.defaults.setting_hide_network'), hint: t('simple_form.hints.defaults.setting_hide_network') .fields-group - = f.input :dissubscribable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.dissubscribable') + = f.input :dissubscribable, as: :boolean, wrapper: :with_label, kmyblue: true, hint: t('simple_form.hints.defaults.dissubscribable') %hr.spacer/ diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index 92cffc5a2a..5e009c41ac 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -19,8 +19,20 @@ module RecommendedComponent end end +module KmyblueComponent + def kmyblue(_wrapper_options = nil) + return unless options[:kmyblue] + + key = options[:kmyblue].is_a?(Symbol) ? options[:kmyblue] : :kmyblue + options[:label_text] = ->(raw_label_text, _required_label_text, _label_present) { safe_join([raw_label_text, ' ', content_tag(:span, I18n.t(key, scope: 'simple_form'), class: key)]) } + + nil + end +end + SimpleForm.include_component(AppendComponent) SimpleForm.include_component(RecommendedComponent) +SimpleForm.include_component(KmyblueComponent) SimpleForm.setup do |config| # Wrappers are used by the form builder to generate a @@ -78,6 +90,7 @@ SimpleForm.setup do |config| b.wrapper tag: :div, class: :label_input do |ba| ba.optional :recommended + ba.optional :kmyblue ba.use :label ba.wrapper tag: :div, class: :label_input__wrapper do |bb| diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index ae4aacc8a7..9533ba6564 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -136,6 +136,7 @@ en: webhook: events: Select events to send url: Where events will be sent to + kmyblue: kmyblue labels: account: fields: diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index 3b8362c0d4..4ed20fe03c 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -142,6 +142,7 @@ ja: webhook: events: 送信するイベントを選択 url: イベントの送信先 + kmyblue: kmyblue labels: account: fields: