From 195cc9cee0284b5f940123b8a7aa8973437c82a4 Mon Sep 17 00:00:00 2001 From: Erb3 <49862976+Erb3@users.noreply.github.com> Date: Fri, 21 Feb 2025 19:43:49 +0100 Subject: [PATCH] refactor(ui): move Toggle component to Composition API + TS (#3281) * refactor(frontend): move Toggle component to Composition API + TS **Toggle.vue**: - Enable composition API and TS - Added `disabled` to props - Remove redundant `checked` - Replace `modelValue` and `emits` with `defineModel` compiler macro **Others**: - Replace emit handling and `model-value` with `v-model` where simple logic was used - Not `FeatureFlagSettings.vue` (contained custom code on receiving emit) - Not `Mods.vue` (contained custom code on receiving emit) - Remove redundant `checked` attribute * fix(app): toggles not updating value --- .../ui/instance_settings/WindowSettings.vue | 3 +- .../ui/settings/AppearanceSettings.vue | 28 +++------------ .../ui/settings/DefaultInstanceSettings.vue | 11 +----- .../ui/settings/FeatureFlagSettings.vue | 1 - .../ui/settings/PrivacySettings.vue | 28 ++------------- apps/app-frontend/src/pages/instance/Mods.vue | 1 - .../frontend/src/pages/admin/billing/[id].vue | 9 ++--- .../ui/src/components/base/MarkdownEditor.vue | 28 +++++++-------- packages/ui/src/components/base/Toggle.vue | 36 ++++++------------- 9 files changed, 35 insertions(+), 110 deletions(-) diff --git a/apps/app-frontend/src/components/ui/instance_settings/WindowSettings.vue b/apps/app-frontend/src/components/ui/instance_settings/WindowSettings.vue index 735d6c08..53820da6 100644 --- a/apps/app-frontend/src/components/ui/instance_settings/WindowSettings.vue +++ b/apps/app-frontend/src/components/ui/instance_settings/WindowSettings.vue @@ -5,7 +5,7 @@ import { handleError } from '@/store/notifications' import { defineMessages, useVIntl } from '@vintl/vintl' import { get } from '@/helpers/settings' import { edit } from '@/helpers/profile' -import type { InstanceSettingsTabProps, AppSettings } from '../../../helpers/types' +import type { AppSettings, InstanceSettingsTabProps } from '../../../helpers/types' const { formatMessage } = useVIntl() @@ -114,7 +114,6 @@ const messages = defineMessages({ -import { Toggle, ThemeSelector, TeleportDropdownMenu } from '@modrinth/ui' +import { TeleportDropdownMenu, ThemeSelector, Toggle } from '@modrinth/ui' import { useTheming } from '@/store/state' import { get, set } from '@/helpers/settings' -import { watch, ref } from 'vue' +import { ref, watch } from 'vue' import { getOS } from '@/helpers/utils' const themeStore = useTheming() @@ -46,7 +46,6 @@ watch( Native Decorations

Use system window frame (app restart required).

- +
@@ -78,16 +68,7 @@ watch(

Minimize launcher

Minimize the launcher when a Minecraft process starts.

- +
@@ -111,7 +92,6 @@ watch( +
diff --git a/apps/app-frontend/src/components/ui/settings/FeatureFlagSettings.vue b/apps/app-frontend/src/components/ui/settings/FeatureFlagSettings.vue index fde4a5c1..24d27feb 100644 --- a/apps/app-frontend/src/components/ui/settings/FeatureFlagSettings.vue +++ b/apps/app-frontend/src/components/ui/settings/FeatureFlagSettings.vue @@ -37,7 +37,6 @@ watch(
diff --git a/apps/app-frontend/src/components/ui/settings/PrivacySettings.vue b/apps/app-frontend/src/components/ui/settings/PrivacySettings.vue index 5bb4deac..69eea98f 100644 --- a/apps/app-frontend/src/components/ui/settings/PrivacySettings.vue +++ b/apps/app-frontend/src/components/ui/settings/PrivacySettings.vue @@ -30,16 +30,7 @@ watch( option, you opt out and ads will no longer be shown based on your interests.

- +
@@ -51,16 +42,7 @@ watch( longer be collected.

- +
@@ -75,10 +57,6 @@ watch( as those added by mods. (app restart required to take effect)

- + diff --git a/apps/app-frontend/src/pages/instance/Mods.vue b/apps/app-frontend/src/pages/instance/Mods.vue index 45ef2372..e49f2d9c 100644 --- a/apps/app-frontend/src/pages/instance/Mods.vue +++ b/apps/app-frontend/src/pages/instance/Mods.vue @@ -179,7 +179,6 @@ diff --git a/apps/frontend/src/pages/admin/billing/[id].vue b/apps/frontend/src/pages/admin/billing/[id].vue index db7f9b41..60ac7681 100644 --- a/apps/frontend/src/pages/admin/billing/[id].vue +++ b/apps/frontend/src/pages/admin/billing/[id].vue @@ -40,12 +40,7 @@ Whether or not the subscription should be unprovisioned on refund. - +
@@ -114,7 +109,7 @@