nuxt-rating
Version:
Display or retrieve a score on a fully customisable scale.
18 lines (17 loc) • 398 B
JavaScript
export default class AlphaColor {
color;
opacity;
constructor(color) {
this.color = color;
this.opacity = 1;
}
parseAlphaColor() {
const match = this.color.match(/rgba?\(([^)]+)\)/);
if (match) {
const [r, g, b, a] = match[1].split(",").map(Number);
this.color = `rgb(${r}, ${g}, ${b})`;
this.opacity = a !== void 0 ? a : 1;
}
return this;
}
}