dalexhd/SteamSpeak

View on GitHub
packages/client/src/assets/utils/theme.js

Summary

Maintainability
A
45 mins
Test Coverage
import color from './color';

export default {
    name: 'theme',
    vsfunction(json) {
        for (const clave in json) {
            if (Object.prototype.hasOwnProperty.call(json, clave)) {
                let colorx;
                if (/^[rgb(]/g.test(json[clave])) {
                    colorx = json[clave].replace(/[rgb()]/g, '');
                } else if (/[#]/g.test(json[clave])) {
                    const rgbx = color.hexToRgb(json[clave]);
                    colorx = `${rgbx.r},${rgbx.g},${rgbx.b}`;
                } else {
                    colorx = json[clave];
                }
                color.setCssVariable(`--vs-${clave}`, colorx);
            }
        }
    }
};