mirror of
https://github.com/flarum/framework.git
synced 2025-04-27 23:24:03 +08:00
Replace ColorPreviewInput preview box with 'color' input (#3271)
This commit is contained in:
parent
fa45db3c45
commit
904deda6b9
framework/core
@ -5,23 +5,20 @@ import classList from '../utils/classList';
|
|||||||
import icon from '../helpers/icon';
|
import icon from '../helpers/icon';
|
||||||
|
|
||||||
export default class ColorPreviewInput extends Component {
|
export default class ColorPreviewInput extends Component {
|
||||||
value?: string;
|
|
||||||
|
|
||||||
view(vnode: Mithril.Vnode<ComponentAttrs, this>) {
|
view(vnode: Mithril.Vnode<ComponentAttrs, this>) {
|
||||||
const { className, ...attrs } = this.attrs;
|
const { className, id, ...attrs } = this.attrs;
|
||||||
const value = attrs.bidi?.() || attrs.value;
|
|
||||||
|
|
||||||
attrs.type ||= 'text';
|
attrs.type ||= 'text';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ColorInput">
|
<div className="ColorInput">
|
||||||
<input className={classList('FormControl', className)} {...attrs} />
|
<input className={classList('FormControl', className)} id={id} {...attrs} />
|
||||||
|
|
||||||
<span className="ColorInput-icon" role="presentation">
|
<span className="ColorInput-icon" role="presentation">
|
||||||
{icon('fas fa-exclamation-circle')}
|
{icon('fas fa-exclamation-circle')}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div className="ColorInput-preview" style={{ '--input-value': value }} role="presentation" />
|
<input className="ColorInput-preview" {...attrs} type="color" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,26 @@
|
|||||||
bottom: 8px;
|
bottom: 8px;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-preview {
|
&-preview {
|
||||||
background-color: var(--input-value);
|
display: inline-block;
|
||||||
border-radius: 15%;
|
border-radius: 15%;
|
||||||
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
// Match both the wrapper div and the div with the background color
|
||||||
|
&, &::-webkit-color-swatch-wrapper, &::-webkit-color-swatch {
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This has to be a separate entry so other browsers
|
||||||
|
// don't ignore the entire CSS rule. Thanks Firefox.
|
||||||
|
&::-moz-color-swatch {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-icon {
|
&-icon {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user