Add random color method

This commit is contained in:
trading_peter 2025-02-09 17:08:31 +01:00
parent 1dd10a2044
commit 8c26fe50e3
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@tp/tp-color-picker", "name": "@tp/tp-color-picker",
"version": "1.0.1", "version": "1.1.0",
"description": "", "description": "",
"main": "tp-color-picker.js", "main": "tp-color-picker.js",
"scripts": { "scripts": {

View File

@ -124,6 +124,12 @@ class TpColorPicker extends FormElement(DomQuery(LitElement)) {
]; ];
} }
randomColor() {
const randomColor = this.colorList[Math.floor(Math.random() * this.colorList.length)];
this.value = randomColor;
return randomColor;
}
_selectColor(e) { _selectColor(e) {
const target = e.composedPath()[0]; const target = e.composedPath()[0];
if (target.hasAttribute('color')) { if (target.hasAttribute('color')) {