Clearer theme select labels

pull/4861/head
Chocobozzz 2022-03-15 15:19:41 +01:00
parent b46489f8e4
commit ff6a266e3f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 26 additions and 3 deletions

View File

@ -5,10 +5,10 @@
<div class="peertube-select-container">
<select formControlName="theme" id="theme" class="form-control">
<option i18n value="instance-default">instance default</option>
<option i18n value="default">peertube default</option>
<option i18n value="instance-default">Instance default theme ({{ getDefaultThemeLabel() }})</option>
<option i18n value="default">{{ defaultThemeLabel }}</option>
<option *ngFor="let theme of availableThemes" [value]="theme">{{ theme }}</option>
<option *ngFor="let theme of availableThemes" [value]="theme">{{ capitalizeFirstLetter(theme) }}</option>
</select>
</div>
</div>

View File

@ -2,6 +2,7 @@ import { Subject, Subscription } from 'rxjs'
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { AuthService, Notifier, ServerService, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { capitalizeFirstLetter } from '@root-helpers/string'
import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models'
@Component({
@ -17,6 +18,8 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
formValuesWatcher: Subscription
defaultThemeLabel = $localize`Light/Orange`
private serverConfig: HTMLServerConfig
constructor (
@ -57,6 +60,18 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
this.formValuesWatcher?.unsubscribe()
}
getDefaultThemeLabel () {
const theme = this.serverConfig.theme.default
if (theme === 'default') return this.defaultThemeLabel
return theme
}
capitalizeFirstLetter (str: string) {
return capitalizeFirstLetter(str)
}
updateInterfaceSettings () {
const theme = this.form.value['theme']

View File

@ -4,5 +4,6 @@ export * from './images'
export * from './local-storage-utils'
export * from './peertube-web-storage'
export * from './plugins-manager'
export * from './string'
export * from './utils'
export * from './video'

View File

@ -0,0 +1,7 @@
function capitalizeFirstLetter (str: string) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
export {
capitalizeFirstLetter
}