Add theme support using environment variable#145
Merged
httpjamesm merged 6 commits intomainfrom Jul 25, 2024
Merged
Conversation
Propagate the `theme` variable from the environment to the template in `src/routes/options.go`
* Retrieve the `theme` variable from the environment using `os.Getenv("THEME")`
* Set the `theme` variable in the `gin.H` map when rendering the `home.html` template
---
For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/httpjamesm/AnonymousOverflow/pull/145?shareId=6397c9b4-9450-425c-bbbe-019425965d2b).
Owner
Author
|
Propagate the
For more details, open the Copilot Workspace session. |
Move theme environment variable logic to a utils function and update routes to use it. * Add `GetThemeFromEnv` function in `src/utils/theme.go` to derive the theme from environment variables and default to "auto" if not set. * Update `src/routes/home.go` to import and use `GetThemeFromEnv` in the `GetHome` function. * Update `src/routes/options.go` to import and use `GetThemeFromEnv` in the `ChangeOptions` function. * Update `src/routes/question.go` to import and use `GetThemeFromEnv` in the `ViewQuestion` function. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/httpjamesm/AnonymousOverflow/pull/145?shareId=a0dab6f3-027c-4f6e-85fe-60e7675d0e70).
Owner
Author
|
Move theme environment variable logic to a utils function and update routes to use it.
For more details, open the Copilot Workspace session. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #140
Add support for theme environment variable and update theme switching logic.
public/globals.cssto handle thedata-themeattribute for light and dark themes while keeping theprefers-color-schememedia query.src/routes/home.goto read theTHEMEenvironment variable and pass it to the template.src/routes/question.goto read theTHEMEenvironment variable and pass it to the template.templates/home.htmlto add adata-themeattribute to thehtmltag and set its value based on theTHEMEenvironment variable.templates/question.htmlto add adata-themeattribute to thehtmltag and set its value based on theTHEMEenvironment variable.For more details, open the Copilot Workspace session.