![httpjamesm](/assets/img/avatar_default.png)
* Add theme support using environment variable * Propagate theme variable to template in options.go 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). * Move all theme environment variable logic to a utils function 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). * fix: imports removed by copilot * fix: override theme in posthome * style: reduced repetition in themes with common vars
94 lines
1.5 KiB
CSS
94 lines
1.5 KiB
CSS
:root {
|
|
--code-bg: #36383d;
|
|
--code-fg: #ffffff;
|
|
}
|
|
|
|
:root,
|
|
[data-theme="dark"] {
|
|
--main-bg: #1b1f26;
|
|
--text-color: #fff;
|
|
--muted-text-color: #b3b3b3;
|
|
--input-bg: #2b303b;
|
|
--input-bg-hover: #3b404b;
|
|
--meta-bg: #525262;
|
|
--divider-color: #42464e;
|
|
--link-color: #92adff;
|
|
}
|
|
|
|
@media (prefers-color-scheme: light) {
|
|
:root:not([data-theme="dark"]) {
|
|
--main-bg: #dbdbdb;
|
|
--text-color: #000;
|
|
--muted-text-color: #636363;
|
|
--input-bg: #bcbcbc;
|
|
--input-bg-hover: #a8a8a8;
|
|
--meta-bg: #aaa8a8;
|
|
--divider-color: #b5b5b5;
|
|
--link-color: #335ad0;
|
|
}
|
|
}
|
|
|
|
[data-theme="light"] {
|
|
--main-bg: #dbdbdb;
|
|
--text-color: #000;
|
|
--muted-text-color: #636363;
|
|
--input-bg: #bcbcbc;
|
|
--input-bg-hover: #a8a8a8;
|
|
--meta-bg: #aaa8a8;
|
|
--divider-color: #b5b5b5;
|
|
--link-color: #335ad0;
|
|
}
|
|
|
|
a {
|
|
color: var(--link-color);
|
|
}
|
|
|
|
html {
|
|
margin: auto;
|
|
max-width: 40rem;
|
|
}
|
|
|
|
@media only screen and (max-width: calc(40rem + 2rem)) {
|
|
body {
|
|
padding-left: 1rem;
|
|
padding-right: 1rem;
|
|
}
|
|
}
|
|
|
|
body {
|
|
background-color: var(--main-bg);
|
|
color: var(--text-color);
|
|
font-family: sans-serif;
|
|
|
|
margin: 0;
|
|
}
|
|
|
|
.icon {
|
|
width: 2rem;
|
|
min-width: 2rem;
|
|
height: 2rem;
|
|
min-height: 2rem;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.icon img {
|
|
background: white;
|
|
border-radius: 50%;
|
|
padding: 0.25rem;
|
|
}
|
|
|
|
details {
|
|
cursor: pointer;
|
|
}
|
|
|
|
.d-flex {
|
|
display: flex;
|
|
}
|
|
|
|
.fd-column {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.fw-nowrap {
|
|
flex-wrap: nowrap;
|
|
} |