mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
The Font popup now has a color wheel for the text color and one for the text background color, each with an Unset button to go back to default. Values are free choices (native <input type=color>), validated server-side as #rrggbb hex (models/lib/uiFonts isHexColor6) so only a strict hex ever reaches a CSS value — no injection surface. An unset/invalid value clears that color. - profile.uiTextColor / profile.uiTextBgColor schema (hex-validated) + getters; setUiColors(textColor, bgColor) method ($set valid hex, $unset otherwise). - changeFontPopup: two color wheels + reset buttons; live preview reflects font, size, text color and background color. - Applied UI-wide via --wekan-ui-text-color / --wekan-ui-bg-color CSS variables + has-ui-text-color / has-ui-bg-color body classes (uiFont.js + uiFont.css). - i18n text-color / text-background-color; tests extended (hex + negatives + source guards). Part of #4759.
35 lines
1.5 KiB
JavaScript
35 lines
1.5 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Tracker } from 'meteor/tracker';
|
|
import { fontFamilyValue, fontSizeValue, colorValue } from '/models/lib/uiFonts';
|
|
|
|
// #4759: apply the user's chosen UI font AND font-size preset to the whole UI by
|
|
// setting CSS variables on :root and toggling marker classes on <body> (uiFont.css
|
|
// consumes them). fontFamilyValue()/fontSizeValue() return '' for anything not on the
|
|
// curated whitelist/presets, so only known, safe values can ever reach the DOM — the
|
|
// saved values are also validated server-side. Unset => nothing applied (defaults).
|
|
|
|
Meteor.startup(() => {
|
|
function toggle(varName, className, value) {
|
|
try {
|
|
if (value) {
|
|
document.documentElement.style.setProperty(varName, value);
|
|
document.body.classList.add(className);
|
|
} else {
|
|
document.documentElement.style.removeProperty(varName);
|
|
document.body.classList.remove(className);
|
|
}
|
|
} catch (_) {
|
|
// document not ready in exotic embeddings; ignore.
|
|
}
|
|
}
|
|
|
|
Tracker.autorun(() => {
|
|
const user = Meteor.user();
|
|
const profile = (user && user.profile) || {};
|
|
toggle('--wekan-ui-font', 'has-ui-font', fontFamilyValue(profile.uiFont));
|
|
toggle('--wekan-ui-font-size', 'has-ui-font-size', fontSizeValue(profile.uiFontSize));
|
|
toggle('--wekan-ui-text-color', 'has-ui-text-color', colorValue(profile.uiTextColor));
|
|
toggle('--wekan-ui-bg-color', 'has-ui-bg-color', colorValue(profile.uiTextBgColor));
|
|
});
|
|
});
|