Styles, BlurNSFW: update Style["variables"] type to support number values

This commit is contained in:
Sqaaakoi 2025-01-24 16:30:21 +13:00
parent a2785628c6
commit 7948f943de
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -24,7 +24,7 @@ export interface Style {
name: string;
source: string;
enabled: boolean;
variables?: Record<string, string>;
variables?: Record<string, string | number>;
}
export function requireStyle(name: string) {
@ -177,7 +177,7 @@ export function updateStyleInDocument(style: Style, doc: Document) {
if (style.variables) {
Object.entries(style.variables).forEach(([key, value]) => {
const kebabCaseKey = key.replaceAll(/(?<=[a-z])[A-Z0-9]/g, v => `-${v}`).toLowerCase();
content = content.replaceAll(`[--${kebabCaseKey}]`, value);
content = content.replaceAll(`[--${kebabCaseKey}]`, value.toString());
});
}
styleElement.textContent = content;

View file

@ -44,13 +44,13 @@ export default definePlugin({
description: "Blur Amount",
default: 10,
onChange(v) {
setStyleVariables(style, { blurAmount: v.toString() });
setStyleVariables(style, { blurAmount: v });
}
}
}),
start() {
setStyleVariables(style, { blurAmount: this.settings.store.blurAmount.toString() });
setStyleVariables(style, { blurAmount: this.settings.store.blurAmount });
},
style