Add a settings section component to reduce duplicate code (#2609)

This commit is contained in:
absidue 2022-09-24 11:12:11 +02:00 committed by GitHub
parent 1512178489
commit 63946f7561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 140 additions and 194 deletions

View File

@ -1,4 +1,5 @@
import Vue from 'vue'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import { mapActions, mapMutations } from 'vuex'
import FtCard from '../ft-card/ft-card.vue'
import FtButton from '../ft-button/ft-button.vue'
@ -16,6 +17,7 @@ import ytch from 'yt-channel-info'
export default Vue.extend({
name: 'DataSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-button': FtButton,
'ft-toggle-switch': FtToggleSwitch,

View File

@ -1 +0,0 @@
@use "../../sass-partials/settings"

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Data Settings.Data Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.Data Settings.Data Settings')"
>
<ft-flex-box>
<ft-button
:label="$t('Settings.Data Settings.Import Subscriptions')"
@ -69,8 +65,7 @@
:option-values="subscriptionsPromptValues"
@click="exportSubscriptions"
/>
</details>
</ft-settings-section>
</template>
<script src="./data-settings.js" />
<style scoped lang="sass" src="./data-settings.sass" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtButton from '../ft-button/ft-button.vue'
@ -9,6 +10,7 @@ import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
export default Vue.extend({
name: 'PlayerSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-toggle-switch': FtToggleSwitch,
'ft-button': FtButton,

View File

@ -1 +0,0 @@
@use "../../sass-partials/settings"

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Distraction Free Settings.Distraction Free Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.Distraction Free Settings.Distraction Free Settings')"
>
<div class="switchColumnGrid">
<div class="switchColumn">
<ft-toggle-switch
@ -96,25 +92,7 @@
/>
</div>
</div>
<br>
<ft-flex-box>
<ft-select
v-if="false"
placeholder="Distraction View Type"
:value="viewValues[0]"
:select-names="viewNames"
:select-values="viewValues"
/>
</ft-flex-box>
<br>
<ft-flex-box>
<ft-button
v-if="false"
label="Manage My Distractions"
/>
</ft-flex-box>
</details>
</ft-settings-section>
</template>
<script src="./distraction-settings.js" />
<style scoped lang="sass" src="./distraction-settings.sass" />

View File

@ -1,4 +1,5 @@
import Vue from 'vue'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtSelect from '../ft-select/ft-select.vue'
@ -11,6 +12,7 @@ import { IpcChannels } from '../../../constants'
export default Vue.extend({
name: 'DownloadSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-toggle-switch': FtToggleSwitch,
'ft-flex-box': FtFlexBox,
'ft-select': FtSelect,

View File

@ -1,8 +1,2 @@
@use "../../sass-partials/settings"
@media only screen and (max-width: 500px)
.downloadSettingsFlexBox
justify-content: flex-start
.folderDisplay
width: 50vh

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Download Settings.Download Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.Download Settings.Download Settings')"
>
<ft-flex-box>
<ft-select
:placeholder="$t('Settings.Download Settings.Download Behavior')"
@ -17,7 +13,7 @@
</ft-flex-box>
<ft-flex-box
v-if="downloadBehavior === 'download'"
class="downloadSettingsFlexBox"
class="settingsFlexStart500px"
>
<ft-toggle-switch
:label="$t('Settings.Download Settings.Ask Download Path')"
@ -44,7 +40,7 @@
@click="chooseDownloadingFolder"
/>
</ft-flex-box>
</details>
</ft-settings-section>
</template>
<script src="./download-settings.js" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtSelect from '../ft-select/ft-select.vue'
import FtInput from '../ft-input/ft-input.vue'
@ -9,6 +10,7 @@ import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
export default Vue.extend({
name: 'ExternalPlayerSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-select': FtSelect,
'ft-input': FtInput,

View File

@ -1 +0,0 @@
@use "../../sass-partials/settings"

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.External Player Settings.External Player Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.External Player Settings.External Player Settings')"
>
<div class="switchColumnGrid">
<div class="switchColumn">
<ft-select
@ -30,7 +26,7 @@
</div>
<ft-flex-box
v-if="externalPlayer !== ''"
class="externalPlayerSettingsFlexBox"
class="settingsFlexStart460px"
>
<ft-input
:placeholder="$t('Settings.External Player Settings.Custom External Player Executable')"
@ -49,8 +45,7 @@
@input="updateExternalPlayerCustomArgs"
/>
</ft-flex-box>
</details>
</ft-settings-section>
</template>
<script src="./external-player-settings.js" />
<style scoped lang="sass" src="./external-player-settings.sass" />

View File

@ -0,0 +1,11 @@
import Vue from 'vue'
export default Vue.extend({
name: 'FtSettingsSection',
props: {
title: {
type: String,
required: true
}
}
})

View File

@ -1,4 +1,30 @@
.switchGrid
.settingsSection
background-color: var(--card-bg-color)
width: 85%
margin: 0 auto
&[open]
padding-bottom: 15px
@media only screen and (max-width: 680px)
width: 90%
.sectionLine
width: 100%
height: 2px
border: 0
margin-top: -1px
background-color: var(--primary-color)
.sectionHeader
display: block
cursor: pointer
padding: 1px
.sectionTitle
margin-left: 2%
:deep(.switchGrid)
display: grid
grid-template-columns: auto auto
justify-content: space-evenly
@ -7,44 +33,22 @@
@media only screen and (max-width: 680px)
grid-template-columns: auto
.switchColumnGrid
@extend .switchGrid
:deep(.switchColumnGrid)
@extend :deep(.switchGrid)
align-items: start
.switchColumn
:deep(.switchColumn)
display: flex
flex-direction: column
justify-items: start
details
background-color: var(--card-bg-color)
width: 85%
margin: 0 auto
&[open]
padding-bottom: 15px
hr
width: 100%
height: 2px
border: 0
margin-top: -1px
background-color: var(--primary-color)
summary
display: block
cursor: pointer
padding: 1px 1px 1px 1px
h3
margin-left: 2%
@media only screen and (max-width: 680px)
width: 90%
.center
:deep(.center)
text-align: center
@media only screen and (max-width: 460px)
.generalSettingsFlexBox, .playerSettingsFlexBox, .externalPlayerSettingsFlexBox
:deep(.settingsFlexStart460px)
justify-content: flex-start
@media only screen and (max-width: 500px)
:deep(.settingsFlexStart500px)
justify-content: flex-start

View File

@ -0,0 +1,14 @@
<template>
<details class="settingsSection">
<summary class="sectionHeader">
<h3 class="sectionTitle">
{{ title }}
</h3>
</summary>
<hr class="sectionLine">
<slot />
</details>
</template>
<script src="./ft-settings-section.js" />
<style scoped src="./ft-settings-section.sass" lang="sass" />

View File

@ -1,4 +1,3 @@
@use "../../sass-partials/settings"
.sponsorBlockCategory
margin-top: 30px
padding: 0 10px

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions, mapMutations } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtSelect from '../ft-select/ft-select.vue'
import FtInput from '../ft-input/ft-input.vue'
@ -12,6 +13,7 @@ import debounce from 'lodash.debounce'
export default Vue.extend({
name: 'GeneralSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-select': FtSelect,
'ft-input': FtInput,

View File

@ -1,5 +1,3 @@
@use "../../sass-partials/settings"
.select
min-width: 240px
width: auto

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.General Settings.General Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.General Settings.General Settings')"
>
<div class="switchColumnGrid">
<div class="switchColumn">
<ft-toggle-switch
@ -96,7 +92,7 @@
<div
v-if="backendPreference === 'invidious' || backendFallback"
>
<ft-flex-box class="generalSettingsFlexBox">
<ft-flex-box class="settingsFlexStart460px">
<ft-input
:placeholder="$t('Settings.General Settings.Current Invidious Instance')"
:show-action-button="false"
@ -141,7 +137,7 @@
/>
</ft-flex-box>
</div>
</details>
</ft-settings-section>
</template>
<script src="./general-settings.js" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtButton from '../ft-button/ft-button.vue'
@ -9,6 +10,7 @@ import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
export default Vue.extend({
name: 'ParentalControlSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-toggle-switch': FtToggleSwitch,
'ft-button': FtButton,

View File

@ -1 +0,0 @@
@use "../../sass-partials/settings"

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Parental Control Settings.Parental Control Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.Parental Control Settings.Parental Control Settings')"
>
<div class="switchColumnGrid">
<div class="switchColumn">
<ft-toggle-switch
@ -30,8 +26,7 @@
/>
</div>
</div>
</details>
</ft-settings-section>
</template>
<script src="./parental-control-settings.js" />
<style scoped lang="sass" src="./parental-control-settings.sass" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtSelect from '../ft-select/ft-select.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
@ -15,6 +16,7 @@ import path from 'path'
export default Vue.extend({
name: 'PlayerSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-select': FtSelect,
'ft-toggle-switch': FtToggleSwitch,

View File

@ -1,5 +1,3 @@
@use "../../sass-partials/settings"
.screenshotFolderContainer
width: 95%
margin: 0 auto

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Player Settings.Player Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.Player Settings.Player Settings')"
>
<div class="switchColumnGrid">
<div class="switchColumn">
<ft-toggle-switch
@ -231,7 +227,7 @@
/>
</ft-flex-box>
</div>
</details>
</ft-settings-section>
</template>
<script src="./player-settings.js" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtButton from '../ft-button/ft-button.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
@ -10,6 +11,7 @@ import { MAIN_PROFILE_ID } from '../../../constants'
export default Vue.extend({
name: 'PrivacySettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-button': FtButton,
'ft-toggle-switch': FtToggleSwitch,

View File

@ -1 +0,0 @@
@use "../../sass-partials/settings"

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Privacy Settings.Privacy Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.Privacy Settings.Privacy Settings')"
>
<div class="switchColumnGrid">
<div class="switchColumn">
<ft-toggle-switch
@ -76,8 +72,7 @@
:option-values="promptValues"
@click="handleRemoveSubscriptions"
/>
</details>
</ft-settings-section>
</template>
<script src="./privacy-settings.js" />
<style scoped lang="sass" src="./privacy-settings.sass" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtButton from '../ft-button/ft-button.vue'
@ -18,6 +19,7 @@ import { IpcChannels } from '../../../constants'
export default Vue.extend({
name: 'ProxySettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-toggle-switch': FtToggleSwitch,
'ft-button': FtButton,

View File

@ -1,5 +0,0 @@
@use "../../sass-partials/settings"
@media only screen and (max-width: 500px)
.subscriptionSettingsFlexBox
justify-content: flex-start

View File

@ -1,12 +1,8 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Proxy Settings.Proxy Settings") }}
</h3>
</summary>
<hr>
<ft-flex-box class="subscriptionSettingsFlexBox">
<ft-settings-section
:title="$t('Settings.Proxy Settings.Proxy Settings')"
>
<ft-flex-box class="settingsFlexStart500px">
<ft-toggle-switch
:label="$t('Settings.Proxy Settings.Enable Tor / Proxy')"
:default-value="useProxy"
@ -77,8 +73,7 @@
</p>
</div>
</div>
</details>
</ft-settings-section>
</template>
<script src="./proxy-settings.js" />
<style scoped lang="sass" src="./proxy-settings.sass" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtInput from '../ft-input/ft-input.vue'
@ -9,6 +10,7 @@ import FtSponsorBlockCategory from '../ft-sponsor-block-category/ft-sponsor-bloc
export default Vue.extend({
name: 'SponsorBlockSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-toggle-switch': FtToggleSwitch,
'ft-input': FtInput,

View File

@ -1,5 +0,0 @@
@use "../../sass-partials/settings"
@media only screen and (max-width: 500px)
.sponsorBlockSettingsFlexBox
justify-content: flex-start

View File

@ -1,12 +1,8 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.SponsorBlock Settings.SponsorBlock Settings") }}
</h3>
</summary>
<hr>
<ft-flex-box class="sponsorBlockSettingsFlexBox">
<ft-settings-section
:title="$t('Settings.SponsorBlock Settings.SponsorBlock Settings')"
>
<ft-flex-box class="settingsFlexStart500px">
<ft-toggle-switch
:label="$t('Settings.SponsorBlock Settings.Enable SponsorBlock')"
:default-value="useSponsorBlock"
@ -16,7 +12,7 @@
<div
v-if="useSponsorBlock"
>
<ft-flex-box class="sponsorBlockSettingsFlexBox">
<ft-flex-box class="settingsFlexStart500px">
<ft-toggle-switch
:label="$t('Settings.SponsorBlock Settings.Notify when sponsor segment is skipped')"
:default-value="sponsorBlockShowSkippedToast"
@ -40,8 +36,7 @@
/>
</ft-flex-box>
</div>
</details>
</ft-settings-section>
</template>
<script src="./sponsor-block-settings.js" />
<style scoped lang="sass" src="./sponsor-block-settings.sass" />

View File

@ -1,11 +1,13 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
export default Vue.extend({
name: 'SubscriptionSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-toggle-switch': FtToggleSwitch,
'ft-flex-box': FtFlexBox
},

View File

@ -1,6 +0,0 @@
@use "../../sass-partials/settings"
@media only screen and (max-width: 500px)
.subscriptionSettingsFlexBox
justify-content: flex-start

View File

@ -1,12 +1,8 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Subscription Settings.Subscription Settings") }}
</h3>
</summary>
<hr>
<ft-flex-box class="subscriptionSettingsFlexBox">
<ft-settings-section
:title="$t('Settings.Subscription Settings.Subscription Settings')"
>
<ft-flex-box class="settingsFlexStart500px">
<ft-toggle-switch
:label="$t('Settings.Subscription Settings.Hide Videos on Watch')"
:default-value="hideWatchedSubs"
@ -19,8 +15,7 @@
@change="updateUseRssFeeds"
/>
</ft-flex-box>
</details>
</ft-settings-section>
</template>
<script src="./subscription-settings.js" />
<style scoped lang="sass" src="./subscription-settings.sass" />

View File

@ -1,5 +1,6 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtCard from '../ft-card/ft-card.vue'
import FtSelect from '../ft-select/ft-select.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
@ -10,6 +11,7 @@ import FtPrompt from '../ft-prompt/ft-prompt.vue'
export default Vue.extend({
name: 'ThemeSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-card': FtCard,
'ft-select': FtSelect,
'ft-toggle-switch': FtToggleSwitch,

View File

@ -1 +0,0 @@
@use "../../sass-partials/settings"

View File

@ -1,11 +1,7 @@
<template>
<details>
<summary>
<h3>
{{ $t("Settings.Theme Settings.Theme Settings") }}
</h3>
</summary>
<hr>
<ft-settings-section
:title="$t('Settings.Theme Settings.Theme Settings')"
>
<ft-flex-box>
<ft-toggle-switch
:label="$t('Settings.Theme Settings.Match Top Bar with Main Color')"
@ -70,8 +66,7 @@
:option-values="restartPromptValues"
@click="handleSmoothScrolling"
/>
</details>
</ft-settings-section>
</template>
<script src="./theme-settings.js" />
<style scoped lang="sass" src="./theme-settings.sass" />