1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 15:37:51 +02:00

Replace ColorPreviewInput preview box with 'color' input (#3271)

This commit is contained in:
David Sevilla Martin
2022-03-09 19:56:25 -05:00
committed by GitHub
parent fa45db3c45
commit 904deda6b9
2 changed files with 19 additions and 8 deletions

View File

@@ -5,23 +5,20 @@ import classList from '../utils/classList';
import icon from '../helpers/icon';
export default class ColorPreviewInput extends Component {
value?: string;
view(vnode: Mithril.Vnode<ComponentAttrs, this>) {
const { className, ...attrs } = this.attrs;
const value = attrs.bidi?.() || attrs.value;
const { className, id, ...attrs } = this.attrs;
attrs.type ||= 'text';
return (
<div className="ColorInput">
<input className={classList('FormControl', className)} {...attrs} />
<input className={classList('FormControl', className)} id={id} {...attrs} />
<span className="ColorInput-icon" role="presentation">
{icon('fas fa-exclamation-circle')}
</span>
<div className="ColorInput-preview" style={{ '--input-value': value }} role="presentation" />
<input className="ColorInput-preview" {...attrs} type="color" />
</div>
);
}