Open Event Web app generator provides an option to event organizers to choose the theme for their event website. Previously it supported the default light theme for the websites, but now it supports a customized dark-theme as well inspired from the twitter dark-mode. Adding this new feature to the User Interface of the generated website, Open Event Web app provides a stylish view for the website of an event.
How we enabled multiple theme support?
The client is provided an option to choose the theme, either ‘light’ or ‘dark’ from the generator. Depending on the option selected, the data is sent to the server, the server extracts the data and while compiling the stylesheet for the pages takes into the account which theme is chosen by the client.
Adding option to choose theme
A drop-down menu is added on the generator page which lets the client choose either of the light or dark themes. The default theme is light.
Defining the color schema
The color schema is set different for both the themes, this is achieved by making two different stylesheets for the light and dark themes. The style or color of an element is assigned a variable in main css file(application.scss). Those variables are overwritten while compiling these specific files depending upon the theme chosen.
Defines the values of variables for light theme.
Defines the values of variables for dark theme.
Setting up theme field in json data
The json data to be used for compiling the templates, sets or unsets the theme field according to the theme selected by the client.
Rendering style in template files
Now we have the value for theme selected by the client, the data used for rendering the CSS file is chosen accordingly. If the theme is light, the file containing color-scheme for light proposition is selected else the dark one. The output file contains the values for color variables according to the theme.
The output file is schedule.css which contains the style for different pages according to the theme chosen while web app generation.
- Open Event Webapp Repository: https://github.com/fossasia/open-event-webapp
- Pull Request: https://github.com/fossasia/open-event-webapp/pull/1940
- Issue : https://github.com/fossasia/open-event-webapp/issues/1713