Closed marieflorescontact closed 3 years ago
Nice, the build is now green 👍🏻
The last step is to add an event listener on the removeCustomStyleSheet
element to actually remove the custom theme:
untested code
removeCustomStyleSheet.onclick = () => {
if (selectTheme.selectedOptions) {
// make sure that a custom theme is selected (i.e., the theme is _not_ in the "Default" option group)
if (selectTheme.selectedOptions[0].parentNode.label !== 'Default') {
const themeName = selectTheme.value
// remove the theme from the custom theme names list (saved in the local storage as an array)
const customThemeNames = JSON.parse(localStorage.CUSTOM_THEME_NAMES || '[]')
const customThemeFoundIndex = customThemeNames.indexOf(themeName)
if (customThemeFoundIndex > -1) {
customThemeNames.splice(customThemeFoundIndex, 1)
localStorage.CUSTOM_THEME_NAMES = JSON.stringify(customThemeNames)
}
// remove stylesheet content
localStorage.removeItem('CUSTOM_THEME_' + themeName)
// remove the selected option
selectTheme.selectedOptions[0].remove()
}
}
}
Merci 🙇🏻
Our linter (https://standardjs.com/) is unhappy. Could you please run
npm run lint -- --fix
? It should fix all the lint issues. You can then runnpm run lint
to make sure that every issue has been fixed. Thanks!