vocascan / vocascan-frontend

A highly configurable vocabulary trainer
https://vocascan.com
Apache License 2.0
29 stars 8 forks source link

Theme system #111

Closed Tracer1337 closed 2 years ago

Tracer1337 commented 2 years ago
Status Type
Feature

Description

Successor of https://github.com/vocascan/vocascan-frontend/pull/101

Also includes changes from https://github.com/vocascan/vocascan-frontend/pull/110, cause I messed up my git history.

Theme-System through CSS variables. The SCSS variables are references to the css variables now.

Themes are stored in the folder public/themes. The current theme is stored in Redux and can be changed through a Redux action. Additional themes can also be mounted into the docker container.

Screenshots / GIFs (if appropriate):

Without additional themes:

Screenshot 2022-04-20 213025

With additional "amber" theme:

# docker-compose.yml
# ...
volumes:
      - ../public/themes:/usr/share/nginx/html/themes

Screenshot 2022-04-20 213049

Resolves

frontend/projects/1#card-51929616

Tracer1337 commented 2 years ago

What needs to be done:

2 instead of an dark/light theming system we could maybe consider about multiple and also an extendable theme system like vscode have. My thoughts for the future are:

2.1 an key/value store for user settings on the backend where we store which theme a user prefers which can be overwritten per device on localstorage 2.2 . It would also be cool, if we could somehow select a custom css in the desktop app or mount custom themes into the frontend nginx docker container to select. 2.3 Maybe we could consider about dark/light implementation of each theme

luwol03 commented 2 years ago

I would say that first a good start is to allow custom themes by just adding a css file into the themes folder (could be mounted into the frontend docker container or an dialog to import for the electron app). Then save the users preference in local storage. If nothing is selected, use the machines default for the default light/dark theme. So you need to:

@noctera or what is your opinion?

noctera commented 2 years ago

I think implementing the basic dark and light theme with an select option is a good start. If you have some time left you can add the functionality to add custom themes to the frontend container.

However I wouldn't just replace the toggle with a select menu. I would outsource this option to the settings page.

Tracer1337 commented 2 years ago

I think implementing the basic dark and light theme with an select option is a good start. If you have some time left you can add the functionality to add custom themes to the frontend container.

However I wouldn't just replace the toggle with a select menu. I would outsource this option to the settings page.

We could keep both the switch and the theme-selector.

2.3 Maybe we could consider about dark/light implementation of each theme

How will the FE know, which themes are mounted into the container? My first naive approaches are:

luwol03 commented 2 years ago

How will the FE know, which themes are mounted into the container? My first naive approaches are

Read my message carefully. My idea was to set that as config option in the Frontend like the base url.

Tracer1337 commented 2 years ago

How should we handle the translations for mounted themes? Fallback to the key of the theme?

luwol03 commented 2 years ago

Can we somehow include translations if available in the themes file via comments in css at the top of the file?

Maybe the generate config script can extract them and add them to the config object.

Tracer1337 commented 2 years ago

Can we somehow include translations if available in the themes file via comments in css at the top of the file?

Maybe the generate config script can extract them and add them to the config object.

I don't think that we need translations at all. Someone who mounts his own themes, knows what they are. So only displaying the key may be enough.

Tracer1337 commented 2 years ago

Note to myself: Move default themes into a different directory. That way the mounting doesn't override the default themes.

luwol03 commented 2 years ago

I don't think that we need translations at all. Someone who mounts his own themes, knows what they are. So only displaying the key may be enough.

Good point.

luwol03 commented 2 years ago
  1. Can you also add a bg color to the select component? image

  2. What about choosing a bit darker color as the primary color? image

Tracer1337 commented 2 years ago
  1. Can you also add a bg color to the select component? image
  2. What about choosing a bit darker color as the primary color? image

Done and Done:

Screenshot 2022-04-22 210853

Screenshot 2022-04-22 210905

We should be cautious with using a primary color as the background color for large surfaces. This may look weird with some themes (like the dark-theme now)

noctera commented 2 years ago

What about using a slightly darker color than showed on the other side. I think this variant would work in every theme

luwol03 commented 2 years ago

Can you please resolve conflicts.

Tracer1337 commented 2 years ago

Can you please resolve conflicts.

Done

Tracer1337 commented 2 years ago

@luwol03 I think we can merge this

Tracer1337 commented 2 years ago

Selects now look like this: Screenshot 2022-05-27 105959