mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 01:26:23 +00:00
feat: Allow for adjustable alignment of main content on certain pages for content moderators (#7034)
* Add type safety and validation for moderation settings * Add ability for moderators to adjust page layout for discover, project, moderation pages Primarily for changes to have more tooling present without overlapping important info
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { SettingDefinitionBase } from '../types/settings.ts'
|
||||
import { isValidFor, type SettingDefinitionBase } from '../types/settings.ts'
|
||||
import { moderationSettings } from '../index.ts'
|
||||
|
||||
export class Settings {
|
||||
private readonly settings: { [id: string]: any }
|
||||
@@ -13,7 +14,9 @@ export class Settings {
|
||||
}
|
||||
|
||||
get<T>(definition: SettingDefinitionBase<T>): T {
|
||||
return this.settings[definition.id] ?? definition.default
|
||||
const value = this.settings[definition.id]
|
||||
|
||||
return (isValidFor(definition, value) ? value : undefined) ?? definition.default
|
||||
}
|
||||
|
||||
set<T>(definition: SettingDefinitionBase<T>, value?: T): void {
|
||||
@@ -23,3 +26,11 @@ export class Settings {
|
||||
this.onChange()
|
||||
}
|
||||
}
|
||||
|
||||
export function getMarginTarget(settings: Settings): string {
|
||||
return settings.get(moderationSettings.General.AdjustPageAlignment) == 'always'
|
||||
? settings.get(moderationSettings.General.ChecklistPosition) == 'right'
|
||||
? 'r'
|
||||
: 'l'
|
||||
: 'x'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user