Fix color picker initial value bug

This commit is contained in:
Cory LaViska
2020-07-13 07:56:47 -04:00
parent 8db9f4cf69
commit a4e35375b5
2 changed files with 5 additions and 1 deletions

View File

@@ -25,7 +25,7 @@ Set the color picker's format with the `format` attribute. Valid options include
```html preview
<sl-color-picker format="hex" value="#4a90e2"></sl-color-picker>
<sl-color-picker format="rgb" value="rgb(80, 227, 194)"></sl-color-picker>
<sl-color-picker format="hsl" value="hsl(90, 69%, 72%)"></sl-color-picker>
<sl-color-picker format="hsl" value="hsl(290, 87%, 47%)"></sl-color-picker>
```
### Inline

View File

@@ -421,6 +421,8 @@ export class ColorPicker {
if (rgba[3] && rgba[3].indexOf('%') > -1) {
rgba[3] = (Number(rgba[3].replace(/%/g, '')) / 100).toString();
} else {
rgba[3] = '1';
}
return `rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3]})`;
@@ -435,6 +437,8 @@ export class ColorPicker {
if (hsla[3] && hsla[3].indexOf('%') > -1) {
hsla[3] = (Number(hsla[3].replace(/%/g, '')) / 100).toString();
} else {
hsla[3] = '1';
}
return `hsla(${hsla[0]}, ${hsla[1]}, ${hsla[2]}, ${hsla[3]})`;