Skip to content

feat: dark mode #4394

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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
77f25d2
Bootstrap `4.0.0-alpha.6` -> `5.3.3`
eth2353 Jan 14, 2025
652290c
Regenerate assets
eth2353 Jan 14, 2025
b75fc14
Update NavBar for BS5
eth2353 Jan 14, 2025
959fc2b
Update AlertList for BS5
eth2353 Jan 14, 2025
d95473c
Update FilterBar for BS5
eth2353 Jan 14, 2025
6ed5074
Update GroupBar for BS5
eth2353 Jan 14, 2025
8066030
Update ReceiverBar for BS5
eth2353 Jan 14, 2025
dccef96
Update Settings for BS5
eth2353 Jan 14, 2025
83d75d5
Update Shared for BS5
eth2353 Jan 14, 2025
0f2c0fa
Update Utils/Views for BS5
eth2353 Jan 14, 2025
919de46
Update SilenceForm for BS5
eth2353 Jan 14, 2025
8156242
Update SilenceList for BS5
eth2353 Jan 14, 2025
2f4d0f6
Update SilenceView for BS5
eth2353 Jan 14, 2025
5ee144d
Update Shared/Alert for BS5
eth2353 Jan 14, 2025
cee3362
Update Status for BS5
eth2353 Jan 14, 2025
97090ec
Fix AlertList checkbox label
eth2353 Jan 14, 2025
7d7d993
Get rid of datepicker custom CSS
eth2353 Jan 14, 2025
875605e
WIP datepicker
eth2353 Jan 14, 2025
43cebf4
elm format
eth2353 Jan 14, 2025
ad7461e
Dark mode
eth2353 Jan 15, 2025
903ad9d
Set data-bs-theme attribute on entire document, not just body
eth2353 Jan 15, 2025
d321313
A few dark mode fixes
eth2353 Jan 15, 2025
460fb38
Datepicker adjustments
eth2353 Jan 15, 2025
00f00eb
Remove custom datepicker CSS again
eth2353 Jan 15, 2025
dded901
Minor layout fixes
eth2353 Jan 15, 2025
62478e2
Minor DateTimePicker UI improvements
eth2353 Jan 22, 2025
a6e4ccb
Update close button in Dialog.elm
eth2353 Apr 21, 2025
49c727f
Add TODO for DateTimePicker responsiveness
eth2353 May 8, 2025
ae7559d
Add last successfully compiled assets file
eth2353 May 8, 2025
1509026
Remove unused imported variables
eth2353 May 8, 2025
48bfb55
Update assets_vfsdata.go
eth2353 May 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 19 additions & 41 deletions asset/assets_vfsdata.go

Large diffs are not rendered by default.

28 changes: 27 additions & 1 deletion ui/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,40 @@
<script>
// If there is no trailing slash at the end of the path in the url,
// add one. This ensures assets like script.js are loaded properly
if (location.pathname.substr(-1) != '/') {
if (location.pathname.slice(-1) !== '/') {
location.pathname = location.pathname + '/';
console.log('added slash');
}

function setAndPersistTheme(requestedBootstrapTheme) {
let themeToSet = requestedBootstrapTheme;

// Handle "auto" by detecting system preference
if (requestedBootstrapTheme === 'auto') {
themeToSet = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}

// Apply the theme to the body
document.documentElement.setAttribute('data-bs-theme', themeToSet);

// Persist the requested theme back to localStorage
localStorage.setItem('bootstrapTheme', requestedBootstrapTheme);
}

// Initialize theme on app launch
window.addEventListener("DOMContentLoaded", function () {
let persistedBootstrapTheme = localStorage.getItem('bootstrapTheme');
if (persistedBootstrapTheme === null) { persistedBootstrapTheme = "auto"; }
setAndPersistTheme(persistedBootstrapTheme);
});
</script>
<script src="script.js"></script>
<script>
var app = Elm.Main.init({
flags: {
production: true,
firstDayOfWeek: JSON.parse(localStorage.getItem('firstDayOfWeek')),
bootstrapTheme: localStorage.getItem('bootstrapTheme'),
defaultCreator: localStorage.getItem('defaultCreator'),
groupExpandAll: JSON.parse(localStorage.getItem('groupExpandAll'))
}
Expand All @@ -34,6 +57,9 @@
app.ports.persistFirstDayOfWeek.subscribe(function(firstDayOfWeek) {
localStorage.setItem('firstDayOfWeek', JSON.stringify(firstDayOfWeek));
});
app.ports.setAndPersistBootstrapTheme.subscribe(function(bootstrapTheme) {
setAndPersistTheme(bootstrapTheme);
});
</script>
</body>
</html>
6 changes: 0 additions & 6 deletions ui/app/lib/bootstrap-4.0.0-alpha.6-dist/css/bootstrap.min.css

This file was deleted.

This file was deleted.

6 changes: 6 additions & 0 deletions ui/app/lib/bootstrap-5.3.3-dist/css/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ui/app/lib/bootstrap-5.3.3-dist/css/bootstrap.min.css.map

Large diffs are not rendered by default.

140 changes: 0 additions & 140 deletions ui/app/lib/elm-datepicker/css/elm-datepicker.css

This file was deleted.

14 changes: 11 additions & 3 deletions ui/app/src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ init flags url key =
_ ->
Monday
)

bootstrapTheme =
flags
|> Json.decodeValue (Json.field "bootstrapTheme" Json.string)
|> Result.withDefault "auto"

settings =
{ firstDayOfWeek = firstDayOfWeek
, bootstrapTheme = bootstrapTheme
}
in
update (urlUpdate url)
(Model
Expand All @@ -115,12 +125,10 @@ init flags url key =
libUrl
Loading
Loading
Loading
defaultCreator
groupExpandAll
key
{ firstDayOfWeek = firstDayOfWeek
}
settings
)


Expand Down
3 changes: 1 addition & 2 deletions ui/app/src/Types.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type alias Model =
, libUrl : String
, bootstrapCSS : ApiData String
, fontAwesomeCSS : ApiData String
, elmDatepickerCSS : ApiData String
, defaultCreator : String
, expandAll : Bool
, key : Key
Expand Down Expand Up @@ -52,9 +51,9 @@ type Msg
| RedirectAlerts
| BootstrapCSSLoaded (ApiData String)
| FontAwesomeCSSLoaded (ApiData String)
| ElmDatepickerCSSLoaded (ApiData String)
| SetDefaultCreator String
| SetGroupExpandAll Bool
| SetAndPersistBootstrapTheme String


type Route
Expand Down
11 changes: 7 additions & 4 deletions ui/app/src/Updates.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Updates exposing (update)
port module Updates exposing (update)

import Browser.Navigation as Navigation
import Task
Expand Down Expand Up @@ -114,11 +114,14 @@ update msg ({ basePath, apiUrl } as model) =
FontAwesomeCSSLoaded css ->
( { model | fontAwesomeCSS = css }, Cmd.none )

ElmDatepickerCSSLoaded css ->
( { model | elmDatepickerCSS = css }, Cmd.none )

SetDefaultCreator name ->
( { model | defaultCreator = name }, Cmd.none )

SetGroupExpandAll expanded ->
( { model | expandAll = expanded }, Cmd.none )

SetAndPersistBootstrapTheme theme ->
( model, setAndPersistBootstrapTheme theme )


port setAndPersistBootstrapTheme : String -> Cmd msg
Loading
Loading