Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save YonathanMeguira/6e626c7f0d718e46065f455de24d7765 to your computer and use it in GitHub Desktop.
Save YonathanMeguira/6e626c7f0d718e46065f455de24d7765 to your computer and use it in GitHub Desktop.
const siteHeaderElement = .nativeElement;
const customClasses = localStorage.getItem('custom');
.brand-name{color: blue}
// regex to get array of classname
const classNames = ['NP1', 'NP2', 'LC'];
function getElement(className): ElementRef {
return siteHeaderElement.find(className);
}
// array of elements inside the site header that have custom css
const elements = classNames.map(c => getElement(c));
// regex
elements.forEach(e => e.style=doRegexGetStyle);
// second solution
const styleTag = document.createElement("style") //localStorage;
styleTag.innerHTML = cssTemplateString ;
document.head.insertAdjacentElement('beforeend', styleTag);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment