@JS() library main; import 'dart:html'; import 'package:js/js.dart'; import './cookie.dart'; void main() { reorganizeHtml(); createThemeSwitcher(); themeSwitch(isThemeDark()); querySelector('.themeBtn').onClick.listen(themeSwitchMouse); } String cookieThemeName = 'theme'; void createThemeSwitcher() { // set the correct CSS depending on the cookie, dark is enabled by default var isDark = isThemeDark(); // Set the correct symbol in the theme switcher button querySelector('body').append(DivElement()..className = 'themeBtn'); querySelector('.themeBtn') .children .add(Element.tag('i')..className = 'fas fa-' + (isDark ? 'sun' : 'moon')); } bool isThemeDark() { if (Cookies.get(cookieThemeName) == 'light') { return false; } Cookies.set(cookieThemeName, 'dark'); return true; } void reorganizeHtml() { // Add a