index.coffee 692 B

123456789101112131415161718
  1. # app/shared/ThemeToggle/index.coffee
  2. document.head.insertAdjacentHTML('beforeend','<style type="text/tailwindcss" component="ThemeToggle">'+stylFns['app/shared/ThemeToggle/index.styl']+'</style>')
  3. module.exports =
  4. name: 'ThemeToggle'
  5. render: (new Function '_ctx', '_cache', renderFns['app/shared/ThemeToggle/index.pug'])()
  6. data: ->
  7. theme: 'light'
  8. beforeUnmount: ->
  9. debug.log "slider start"
  10. mounted: ->
  11. @theme = localStorage.theme || 'light'
  12. methods:
  13. toggleTheme: ->
  14. @theme = if @theme == 'light' then 'dark' else 'light'
  15. localStorage.setItem 'theme', @theme
  16. document.documentElement.classList.toggle 'dark'
  17. @$emit 'theme-changed', @theme