diff --git a/client/components/main/uiFont.css b/client/components/main/uiFont.css index f6b80dae83..26344b20a0 100644 --- a/client/components/main/uiFont.css +++ b/client/components/main/uiFont.css @@ -65,30 +65,11 @@ body.has-ui-text-color *:not(.fa) { color: var(--wekan-ui-text-color) !important; } -/* Text background color (#4759): behind the TEXT, not behind the page. - * - * This was on , so choosing orange painted the whole window orange - the - * board canvas, the empty space under the lists, everything - which is a page - * background, not a text background. It is a marker pen: it goes on the - * elements that carry text, and never on the boxes that carry elements (body, - * div, section, the board canvas, a minicard). */ -body.has-ui-bg-color span, -body.has-ui-bg-color a, -body.has-ui-bg-color p, -body.has-ui-bg-color h1, -body.has-ui-bg-color h2, -body.has-ui-bg-color h3, -body.has-ui-bg-color h4, -body.has-ui-bg-color h5, -body.has-ui-bg-color h6, -body.has-ui-bg-color li, -body.has-ui-bg-color td, -body.has-ui-bg-color th, -body.has-ui-bg-color label, -body.has-ui-bg-color .viewer, -body.has-ui-bg-color input, -body.has-ui-bg-color textarea, -body.has-ui-bg-color select, -body.has-ui-bg-color .wekan-form-control { - background-color: var(--wekan-ui-bg-color) !important; -} +/* There was a "text background color" here (#4759), a colour painted behind the + * text. It is REMOVED. A background needs elements to sit on, and neither choice + * of them looks right: on the boxes (its first form, `body`) it painted the whole + * window - the board canvas, the space under the lists - which is a page + * background and not a text one; on the elements that carry text it striped every + * heading, menu row and paragraph with a full-width band. A setting that cannot be + * made to look good is worse than no setting, so it is gone rather than tuned + * again. The text COLOUR above stays. */ diff --git a/client/components/main/uiFont.js b/client/components/main/uiFont.js index 69c6c73232..a1a8767241 100644 --- a/client/components/main/uiFont.js +++ b/client/components/main/uiFont.js @@ -51,6 +51,11 @@ Meteor.startup(() => { // variable that is not set falls back to 1 in the calc itself. toggle('--wekan-ui-font-scale', null, fontScaleValue(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)); + // There was a `--wekan-ui-bg-color` here, for "text background color". It is + // removed: a colour behind the text needs elements to sit on, and there is no + // set of them that looks right - on the boxes it painted the page, on the text + // carriers it striped headings and menu rows with bands. Nothing reads + // `profile.uiTextBgColor` any more, and setUiColors unsets it, so a value + // stored before this is gone rather than dormant. }); }); diff --git a/client/components/users/userHeader.jade b/client/components/users/userHeader.jade index 8287638b49..e48f47a01a 100644 --- a/client/components/users/userHeader.jade +++ b/client/components/users/userHeader.jade @@ -215,16 +215,17 @@ template(name="changeFontPopup") .ui-font-size-buttons each fontSizes a.ui-font-size-btn.js-ui-font-size-btn(data-size="{{key}}" class="{{#if selected}}active{{/if}}") {{label}} - //- #4759: text + text-background color from a color wheel, each unsettable. - //- Applied immediately when the wheel is committed / reset. + //- #4759: the text colour, from a colour wheel, unsettable. Applied + immediately when the wheel is committed / reset. + There was a "text background color" beside it. It painted a colour behind + the text of every element that carries text, and there is no choice of + elements that looks right: on the boxes it painted the page, and on the + text carriers it striped headings and menu rows with bands. It is removed + rather than left in as a setting nobody can make look good. label {{_ 'text-color'}} .color-wheel-wrap input.js-ui-text-color(type="color" value=textColorHex title="{{_ 'text-color'}}") a.js-reset-text-color(class="{{#unless hasTextColor}}disabled{{/unless}}") {{_ 'unset-color'}} - label {{_ 'text-background-color'}} - .color-wheel-wrap - input.js-ui-bg-color(type="color" value=bgColorHex title="{{_ 'text-background-color'}}") - a.js-reset-bg-color(class="{{#unless hasBgColor}}disabled{{/unless}}") {{_ 'unset-color'}} template(name="changeSettingsPopup") ul.pop-over-list diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js index f6ff0f97b7..132386c58f 100644 --- a/client/components/users/userHeader.js +++ b/client/components/users/userHeader.js @@ -452,7 +452,6 @@ Template.changeFontPopup.onCreated(function () { this.selectedSize = new ReactiveVar((user && user.getUiFontSize && user.getUiFontSize()) || 'default'); // null = use default (unset); a hex string = custom color. this.textColor = new ReactiveVar((user && user.getUiTextColor && user.getUiTextColor()) || null); - this.bgColor = new ReactiveVar((user && user.getUiTextBgColor && user.getUiTextBgColor()) || null); }); Template.changeFontPopup.helpers({ @@ -482,34 +481,29 @@ Template.changeFontPopup.helpers({ textColorHex() { return Template.instance().textColor.get() || '#000000'; }, - bgColorHex() { - return Template.instance().bgColor.get() || '#ffffff'; - }, hasTextColor() { return !!Template.instance().textColor.get(); }, - hasBgColor() { - return !!Template.instance().bgColor.get(); - }, - // Preview reflects the chosen font, size, text color and background color. + // Preview reflects the chosen font, size and text color. previewStyle() { const tpl = Template.instance(); const family = fontFamilyValue(tpl.selected.get()); const size = fontSizeValue(tpl.selectedSize.get()); const color = colorValue(tpl.textColor.get()); - const bg = colorValue(tpl.bgColor.get()); return [ family && `font-family: ${family};`, size && `font-size: ${size};`, color && `color: ${color};`, - bg && `background-color: ${bg};`, ].filter(Boolean).join(''); }, }); -// Apply the current text/background colors immediately (no Save button). +// Apply the chosen text colour immediately (no Save button). The second +// argument is the removed text-background colour: the method still takes it so +// an older client cannot fail, and it UNSETS it whatever is passed, so a value +// stored before the feature was removed is cleared the next time this runs. function applyUiColors(tpl) { - Meteor.call('setUiColors', tpl.textColor.get(), tpl.bgColor.get(), err => { + Meteor.call('setUiColors', tpl.textColor.get(), null, err => { if (err && process.env.DEBUG === 'true') console.error('setUiColors error', err); }); } @@ -538,29 +532,15 @@ Template.changeFontPopup.events({ const v = event.currentTarget.value; if (isHexColor6(v)) tpl.textColor.set(v); }, - 'input .js-ui-bg-color'(event, tpl) { - const v = event.currentTarget.value; - if (isHexColor6(v)) tpl.bgColor.set(v); - }, // ...and apply the color when the wheel is committed. 'change .js-ui-text-color'(event, tpl) { const v = event.currentTarget.value; if (isHexColor6(v)) tpl.textColor.set(v); applyUiColors(tpl); }, - 'change .js-ui-bg-color'(event, tpl) { - const v = event.currentTarget.value; - if (isHexColor6(v)) tpl.bgColor.set(v); - applyUiColors(tpl); - }, 'click .js-reset-text-color'(event, tpl) { event.preventDefault(); tpl.textColor.set(null); // back to default applyUiColors(tpl); }, - 'click .js-reset-bg-color'(event, tpl) { - event.preventDefault(); - tpl.bgColor.set(null); - applyUiColors(tpl); - }, }); diff --git a/models/users.js b/models/users.js index fc06afca0e..48d4d84b02 100644 --- a/models/users.js +++ b/models/users.js @@ -462,8 +462,12 @@ Users.attachSchema( }, 'profile.uiTextBgColor': { /** - * Member Settings / Font / Color (#4759): custom UI text background color. - * A validated #rrggbb hex; absent = default (transparent) background. + * REMOVED feature (#4759 "text background color"): nothing sets or reads + * this any more, and `setUiColors` unsets it on every call. The key stays + * in the schema ONLY so that $unset validates against it for the users who + * stored a colour before it was removed - a modifier touching a key the + * schema does not know is rejected, which would leave exactly those + * profiles unable to be cleaned. */ type: String, optional: true, @@ -2284,13 +2288,11 @@ Users.helpers({ return (this.profile && this.profile.uiFontSize) || null; }, - // #4759: custom UI text color / text background color (hex), or null when unset. + // #4759: custom UI text color (hex), or null when unset. There was a + // getUiTextBgColor() beside it, for the removed "text background color". getUiTextColor() { return (this.profile && this.profile.uiTextColor) || null; }, - getUiTextBgColor() { - return (this.profile && this.profile.uiTextBgColor) || null; - }, // The CSS class the global override maps to, or '' when unset. Used by the header // template on non-board pages and by the autorun. diff --git a/server/models/users.js b/server/models/users.js index bbd5229dca..6c508e91af 100644 --- a/server/models/users.js +++ b/server/models/users.js @@ -586,9 +586,16 @@ Meteor.methods({ return null; }, - // #4759: set (or clear) the caller's custom UI text color and text background - // color. Each is validated as #rrggbb hex; a null/empty/invalid value unsets that - // color (back to default). Only strict hex ever reaches a CSS value. + // #4759: set (or clear) the caller's custom UI text color. Validated as + // #rrggbb hex; a null/empty/invalid value unsets it (back to default). Only + // strict hex ever reaches a CSS value. + // + // `bgColor` was the "text background color", which is REMOVED - no choice of + // elements to paint it on looked good. The parameter is still accepted, so an + // older client calling this cannot fail, and it is IGNORED: the field is + // unset on every call whatever is passed, so a colour stored before the + // removal is cleared the next time somebody touches this popup rather than + // sitting in the profile for ever. async setUiColors(textColor, bgColor) { if (!this.userId) throw new Meteor.Error('not-logged-in', 'User must be logged in'); check(textColor, Match.OneOf(String, null, undefined)); @@ -601,8 +608,7 @@ Meteor.methods({ const $unset = {}; if (isHexColor6(textColor)) $set['profile.uiTextColor'] = textColor; else $unset['profile.uiTextColor'] = ''; - if (isHexColor6(bgColor)) $set['profile.uiTextBgColor'] = bgColor; - else $unset['profile.uiTextBgColor'] = ''; + $unset['profile.uiTextBgColor'] = ''; const modifier = {}; if (Object.keys($set).length) modifier.$set = $set; @@ -610,7 +616,7 @@ Meteor.methods({ await Users.updateAsync(this.userId, modifier); return { textColor: $set['profile.uiTextColor'] || null, - bgColor: $set['profile.uiTextBgColor'] || null, + bgColor: null, }; }, diff --git a/tests/uiFonts.test.cjs b/tests/uiFonts.test.cjs index 0243d1f6d7..0b41438894 100644 --- a/tests/uiFonts.test.cjs +++ b/tests/uiFonts.test.cjs @@ -140,34 +140,64 @@ test('server setUiFontSize validates presets + supports unset', () => { assert.ok(/\$unset:\s*{\s*'profile\.uiFontSize'/.test(body), "default/null unsets size"); }); -test('text/bg color schema custom() skips unset values (regression: user insert)', () => { +test('color schema custom() skips unset values (regression: user insert)', () => { // The optional-field custom() runs on EVERY user insert; without an unset guard, // /regex/.test(undefined) rejects every user with no color set (SyncedCron fatal - // ValidationError). Both validators must short-circuit when the value is absent. + // ValidationError). It must short-circuit when the value is absent. const users = read('models/users.js'); const guards = users.match(/custom\(\)\s*{\s*\n\s*(?:\/\/[^\n]*\n\s*)*if \(this\.value === undefined \|\| this\.value === null \|\| this\.value === ''\) return undefined;/g) || []; - assert.ok(guards.length >= 2, 'uiTextColor + uiTextBgColor custom() both guard the unset case'); + assert.ok(guards.length >= 2, 'the colour validators guard the unset case'); }); -test('text/bg color: schema, wheels+reset, validated setter, applied as CSS vars', () => { +test('text color: schema, wheel+reset, validated setter, applied as a CSS var', () => { const users = read('models/users.js'); - assert.ok(/'profile\.uiTextColor'/.test(users) && /'profile\.uiTextBgColor'/.test(users), 'schema fields'); - assert.ok(/getUiTextColor\(\)/.test(users) && /getUiTextBgColor\(\)/.test(users), 'getters'); + assert.ok(/'profile\.uiTextColor'/.test(users), 'schema field'); + assert.ok(/getUiTextColor\(\)/.test(users), 'getter'); const jade = read('client/components/users/userHeader.jade'); - assert.ok(/js-ui-text-color\(type="color"/.test(jade) && /js-ui-bg-color\(type="color"/.test(jade), 'color wheels'); - assert.ok(/js-reset-text-color/.test(jade) && /js-reset-bg-color/.test(jade), 'unset buttons'); + assert.ok(/js-ui-text-color\(type="color"/.test(jade), 'colour wheel'); + assert.ok(/js-reset-text-color/.test(jade), 'unset button'); const js = read('client/components/users/userHeader.js'); - assert.ok(/Meteor\.call\('setUiColors', tpl\.textColor\.get\(\), tpl\.bgColor\.get\(\)/.test(js), 'saves both colors'); - assert.ok(/textColor\.set\(null\)/.test(js) && /bgColor\.set\(null\)/.test(js), 'reset unsets'); + assert.ok(/Meteor\.call\('setUiColors', tpl\.textColor\.get\(\), null/.test(js), 'saves it'); + assert.ok(/textColor\.set\(null\)/.test(js), 'reset unsets'); const s = read('server/models/users.js'); const i = s.indexOf('setUiColors(textColor, bgColor)'); assert.ok(i !== -1, 'server method'); - assert.ok(/isHexColor6\(textColor\)/.test(s.slice(i, i + 700)), 'validates hex'); + assert.ok(/isHexColor6\(textColor\)/.test(s.slice(i, i + 900)), 'validates hex'); const jj = read('client/components/main/uiFont.js'); - assert.ok(/--wekan-ui-text-color/.test(jj) && /--wekan-ui-bg-color/.test(jj), 'applies color vars'); + assert.ok(/--wekan-ui-text-color/.test(jj), 'applies the colour var'); const css = read('client/components/main/uiFont.css'); - assert.ok(/color: var\(--wekan-ui-text-color\)/.test(css) && /background-color: var\(--wekan-ui-bg-color\)/.test(css), - 'css consumes color vars'); + assert.ok(/color: var\(--wekan-ui-text-color\)/.test(css), 'css consumes it'); +}); + +test('"text background color" is gone, and a stored one is cleared (negative)', () => { + // Removed on purpose: a colour behind the text needs elements to sit on, and + // neither choice looked good - on the boxes it painted the whole window, on + // the elements that carry text it striped headings and menu rows with bands. + const css = read('client/components/main/uiFont.css'); + assert.ok(!/--wekan-ui-bg-color/.test(css.replace(/\/\*[\s\S]*?\*\//g, '')), + 'no stylesheet rule paints it'); + const jj = read('client/components/main/uiFont.js'); + assert.ok(!/toggle\('--wekan-ui-bg-color'/.test(jj), 'nothing publishes the variable'); + assert.ok(!/uiTextBgColor/.test(jj.replace(/\/\/[^\n]*/g, '')), 'and nothing reads the profile field'); + const jade = read('client/components/users/userHeader.jade'); + assert.ok(!/js-ui-bg-color/.test(jade) && !/js-reset-bg-color/.test(jade), + 'the popup does not offer it'); + const js = read('client/components/users/userHeader.js'); + assert.ok(!/bgColor/.test(js.replace(/\/\/[^\n]*/g, '')), 'and the popup keeps no state for it'); + + // A profile that HAS one is cleaned rather than left dormant: the setter + // unsets the field on every call, whatever it is passed. + const s = read('server/models/users.js'); + const i = s.indexOf('setUiColors(textColor, bgColor)'); + assert.ok(/\$unset\['profile\.uiTextBgColor'\] = '';/.test(s.slice(i, i + 900)), + 'the setter always unsets it'); + assert.ok(!/\$set\['profile\.uiTextBgColor'\]/.test(s), 'and never sets it'); + // The schema key stays: a modifier touching a key SimpleSchema does not know + // is rejected, which would leave exactly those profiles uncleanable. + const users = read('models/users.js'); + assert.ok(/'profile\.uiTextBgColor'/.test(users), 'the key is still declared'); + assert.ok(/REMOVED feature/.test(users), 'and says why it is only still declared'); + assert.ok(!/getUiTextBgColor\(\) \{/.test(users), 'with no getter left'); }); test('font detector uses the whitelist + canvas width comparison', () => { @@ -273,21 +303,4 @@ test('an icon keeps meaning what it means (negative)', () => { 'and the ones that follow their label still say so'); }); -test('the text BACKGROUND goes behind text, not behind the page (negative)', () => { - // It was on , so choosing orange painted the whole window - the board - // canvas, the empty space under the lists - which is a page background. - const css = read('client/components/main/uiFont.css'); - const at = css.indexOf('body.has-ui-bg-color span,'); - assert.ok(at > 0, 'the rule lists the elements that carry text'); - const selectors = css.slice(at, css.indexOf('{', at)); - assert.ok(!/^body\.has-ui-bg-color,$/m.test(css), 'the body itself is not one of them'); - for (const el of ['span', 'a', 'p', 'li', 'td', 'label', '.viewer', 'input', 'textarea']) { - assert.ok(selectors.includes(`body.has-ui-bg-color ${el},`), `${el} carries text`); - } - for (const box of ['div', 'section', '.board-canvas', '.minicard']) { - assert.ok(!selectors.includes(`body.has-ui-bg-color ${box}`), - `${box} is a box that carries elements, not text`); - } -}); - console.log(`\nAll ${passed} ui-font tests passed`);