about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-12 10:09:27 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-12 11:30:35 +0100
commit6a96b17a2de3fe6d7e24014d1dcc1ad5f54050d8 (patch)
treea66ac6f6eb5440e235ddef670e8c42052657db18
parentc813df2ebb0483236d95797d1bb840b48b95d290 (diff)
Add “Glitch-only” label to glitch-specific settings
-rw-r--r--app/javascript/flavours/glitch/styles/accounts.scss9
-rw-r--r--app/javascript/flavours/glitch/styles/forms.scss3
-rw-r--r--app/views/admin/settings/discovery/show.html.haml2
-rw-r--r--app/views/admin/settings/registrations/show.html.haml2
-rw-r--r--app/views/settings/preferences/appearance/show.html.haml4
-rw-r--r--app/views/settings/preferences/other/show.html.haml4
-rw-r--r--config/initializers/simple_form.rb10
-rw-r--r--config/locales-glitch/simple_form.en.yml1
8 files changed, 27 insertions, 8 deletions
diff --git a/app/javascript/flavours/glitch/styles/accounts.scss b/app/javascript/flavours/glitch/styles/accounts.scss
index ffe5de262..cdc506cf4 100644
--- a/app/javascript/flavours/glitch/styles/accounts.scss
+++ b/app/javascript/flavours/glitch/styles/accounts.scss
@@ -205,7 +205,8 @@
 
 .account-role,
 .simple_form .recommended,
-.simple_form .not_recommended {
+.simple_form .not_recommended,
+.simple_form .glitch_only {
   display: inline-block;
   padding: 4px 6px;
   cursor: default;
@@ -236,6 +237,12 @@
   border-color: rgba(lighten($error-red, 12%), 0.5);
 }
 
+.simple_form .glitch_only {
+  color: lighten($warning-red, 12%);
+  background-color: rgba(lighten($warning-red, 12%), 0.1);
+  border-color: rgba(lighten($warning-red, 12%), 0.5);
+}
+
 .account__header__fields {
   max-width: 100vw;
   padding: 0;
diff --git a/app/javascript/flavours/glitch/styles/forms.scss b/app/javascript/flavours/glitch/styles/forms.scss
index cddf42dac..8eecee4e9 100644
--- a/app/javascript/flavours/glitch/styles/forms.scss
+++ b/app/javascript/flavours/glitch/styles/forms.scss
@@ -104,7 +104,8 @@ code {
       }
 
       .recommended,
-      .not_recommended {
+      .not_recommended,
+      .glitch_only {
         position: absolute;
         margin: 0 4px;
         margin-top: -2px;
diff --git a/app/views/admin/settings/discovery/show.html.haml b/app/views/admin/settings/discovery/show.html.haml
index 9b6424c79..3983b563b 100644
--- a/app/views/admin/settings/discovery/show.html.haml
+++ b/app/views/admin/settings/discovery/show.html.haml
@@ -19,7 +19,7 @@
     = f.input :trendable_by_default, as: :boolean, wrapper: :with_label, recommended: :not_recommended
 
   .fields-group
-    = f.input :trending_status_cw, as: :boolean, wrapper: :with_label, label: t('admin.settings.trending_status_cw.title'), hint: t('admin.settings.trending_status_cw.desc_html')
+    = f.input :trending_status_cw, as: :boolean, wrapper: :with_label, label: t('admin.settings.trending_status_cw.title'), hint: t('admin.settings.trending_status_cw.desc_html'), glitch_only: true
 
   %h4= t('admin.settings.discovery.public_timelines')
 
diff --git a/app/views/admin/settings/registrations/show.html.haml b/app/views/admin/settings/registrations/show.html.haml
index f5e448125..0d7d49dc8 100644
--- a/app/views/admin/settings/registrations/show.html.haml
+++ b/app/views/admin/settings/registrations/show.html.haml
@@ -19,7 +19,7 @@
 
   - if captcha_available?
     .fields-group
-      = f.input :captcha_enabled, as: :boolean, wrapper: :with_label, label: t('admin.settings.captcha_enabled.title'), hint: t('admin.settings.captcha_enabled.desc_html')
+      = f.input :captcha_enabled, as: :boolean, wrapper: :with_label, label: t('admin.settings.captcha_enabled.title'), hint: t('admin.settings.captcha_enabled.desc_html'), glitch_only: true
 
   .fields-group
     = f.input :closed_registrations_message, as: :text, wrapper: :with_block_label, input_html: { rows: 2 }
diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml
index 89bd4f459..a252289b0 100644
--- a/app/views/settings/preferences/appearance/show.html.haml
+++ b/app/views/settings/preferences/appearance/show.html.haml
@@ -29,7 +29,7 @@
     = f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
     = f.input :setting_disable_swiping, as: :boolean, wrapper: :with_label
     = f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
-    = f.input :setting_system_emoji_font, as: :boolean, wrapper: :with_label
+    = f.input :setting_system_emoji_font, as: :boolean, wrapper: :with_label, glitch_only: true
 
   %h4= t 'appearance.toot_layout'
 
@@ -46,7 +46,7 @@
   .fields-group
     = f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label
     = f.input :setting_boost_modal, as: :boolean, wrapper: :with_label
-    = f.input :setting_favourite_modal, as: :boolean, wrapper: :with_label
+    = f.input :setting_favourite_modal, as: :boolean, wrapper: :with_label, glitch_only: true
     = f.input :setting_delete_modal, as: :boolean, wrapper: :with_label
 
   %h4= t 'appearance.sensitive_content'
diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml
index cf604d043..fb3d21060 100644
--- a/app/views/settings/preferences/other/show.html.haml
+++ b/app/views/settings/preferences/other/show.html.haml
@@ -15,7 +15,7 @@
 
   - unless Setting.hide_followers_count
     .fields-group
-      = f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label
+      = f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label, glitch_only: true
 
   %h4= t 'preferences.posting_defaults'
 
@@ -33,7 +33,7 @@
     = f.input :setting_show_application, as: :boolean, wrapper: :with_label, recommended: true
 
   .fields-group
-    = f.input :setting_default_content_type, collection: ['text/plain', 'text/markdown', 'text/html'], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_default_content_type_#{item.split('/')[1]}"), content_tag(:span, t("simple_form.hints.defaults.setting_default_content_type_#{item.split('/')[1]}"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
+    = f.input :setting_default_content_type, collection: ['text/plain', 'text/markdown', 'text/html'], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_default_content_type_#{item.split('/')[1]}"), content_tag(:span, t("simple_form.hints.defaults.setting_default_content_type_#{item.split('/')[1]}"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', glitch_only: true
 
   %h4= t 'preferences.public_timelines'
 
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
index 92cffc5a2..d167a1600 100644
--- a/config/initializers/simple_form.rb
+++ b/config/initializers/simple_form.rb
@@ -19,8 +19,17 @@ module RecommendedComponent
   end
 end
 
+module GlitchOnlyComponent
+  def glitch_only(_wrapper_options = nil)
+    return unless options[:glitch_only]
+    options[:label_text] = ->(raw_label_text, _required_label_text, _label_present) { safe_join([raw_label_text, ' ', content_tag(:span, I18n.t('simple_form.glitch_only'), class: 'glitch_only')]) }
+    nil
+  end
+end
+
 SimpleForm.include_component(AppendComponent)
 SimpleForm.include_component(RecommendedComponent)
+SimpleForm.include_component(GlitchOnlyComponent)
 
 SimpleForm.setup do |config|
   # Wrappers are used by the form builder to generate a
@@ -78,6 +87,7 @@ SimpleForm.setup do |config|
 
     b.wrapper tag: :div, class: :label_input do |ba|
       ba.optional :recommended
+      ba.optional :glitch_only
       ba.use :label
 
       ba.wrapper tag: :div, class: :label_input__wrapper do |bb|
diff --git a/config/locales-glitch/simple_form.en.yml b/config/locales-glitch/simple_form.en.yml
index fd1c64bbb..0ad39886f 100644
--- a/config/locales-glitch/simple_form.en.yml
+++ b/config/locales-glitch/simple_form.en.yml
@@ -1,6 +1,7 @@
 ---
 en:
   simple_form:
+    glitch_only: glitch-soc
     hints:
       defaults:
         fields: You can have up to %{count} items displayed as a table on your profile