Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theming #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kristofzerbe
Copy link
Contributor

Some prefer light themes to be easier on the eyes. The current change completes the work on theming of the last pull requests by me.

Features:

  • set a prefered theme (dark or light) in meta.json to render as default
  • switch themes in UI

@kristofzerbe
Copy link
Contributor Author

Just for you to know. Just discovered two errors, I'm working on right now:

  • Theme is not saved on page change (naah, stupid)
  • Sparklines have fixed color #FFF

@maxboeck
Copy link
Owner

@kristofzerbe sparklines are instantiated from .js-sparkline elements. these could have a data-theme attribute to pass the theme definition to JS. the stroke color could then be set accordingly in sparkline.js.

@kristofzerbe
Copy link
Contributor Author

Yeah, got this, but I have currently now idea how to recolor (or redraw) the lines in the client. I want to make it possible, that the user switch themes on-the-fly.

@maxboeck
Copy link
Owner

hmm - just spitballing here, but whatever method toggles the theme client-side could emit a custom Event, like:

const event = new CustomEvent('toggleTheme', { detail: "dark" });
window. dispatchEvent(event);

The sparkline script can listen for that event and then call drawSparkline again, with a color property that matches the theme:

window.addEventListener('toggleTheme', (e) => {
    const color = e.detail === 'dark' : '#FFF' : '#000'
    drawSparkline(canvas, data, true, color)
})

@kristofzerbe
Copy link
Contributor Author

Events, yeah. Let me do a rewrite of the theming JS tomorrow...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants