1
0
mirror of https://github.com/flarum/core.git synced 2025-07-26 11:10:41 +02:00

feat: remove color validation in appearance admin page & add color indicator (#3140)

* Remove color validation in basics admin page & add color indicator

* Create ColorInput common component

* Revert 'formGroupAttrs' addition

* Rename component CSS classes

* Fix input type in ColorInput from AdminPage#buildSettingComponent

* Rename component to ColorPreviewInput, remove aliases in admin & export in compat

* Remove leftovers from rebase on master

* feat: add global type definition for a vnode element tag

* fix(a11y): add aria roles to color input

* chore: use new type

* chore: format

Co-authored-by: David Wheatley <hi@davwheat.dev>
This commit is contained in:
David Sevilla Martin
2021-11-23 16:38:46 -05:00
committed by GitHub
parent c96fa49853
commit 94c4f266e3
8 changed files with 77 additions and 25 deletions

View File

@@ -25,12 +25,12 @@ export default class AppearancePage extends AdminPage {
<div className="AppearancePage-colors-input">
{this.buildSettingComponent({
type: 'text',
type: 'color-preview',
setting: 'theme_primary_color',
placeholder: '#aaaaaa',
})}
{this.buildSettingComponent({
type: 'text',
type: 'color-preview',
setting: 'theme_secondary_color',
placeholder: '#aaaaaa',
})}
@@ -105,17 +105,4 @@ export default class AppearancePage extends AdminPage {
onsaved() {
window.location.reload();
}
saveSettings(e) {
e.preventDefault();
const hex = /^#[0-9a-f]{3}([0-9a-f]{3})?$/i;
if (!hex.test(this.settings['theme_primary_color']()) || !hex.test(this.settings['theme_secondary_color']())) {
alert(app.translator.trans('core.admin.appearance.enter_hex_message'));
return;
}
super.saveSettings(e);
}
}