Skip to content

Commit

Permalink
dark mode for the grid
Browse files Browse the repository at this point in the history
  • Loading branch information
benlower committed Apr 16, 2024
1 parent cc8dd01 commit be29bbf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions website/src/components/DataGrid.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ import 'ag-grid-community/styles/ag-theme-quartz.css';
<style>
.ag-theme-quartz {
font-family: monospace;
--ag-background-color: rgb(245 245 244);
--ag-header-background-color: rgb(245 245 244);
}

.ag-theme-quartz-dark {
font-family: monospace;
--ag-background-color: rgb(28 25 23);
--ag-header-background-color: rgb(28 25 23);
}
</style>

Expand Down
13 changes: 12 additions & 1 deletion website/src/components/Navbar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@ const data = await fs.readFile(url, 'utf8');
el.checked = checked;
}
});
if (lightSwitch.checked) {
if (lightSwitch.checked) { // Dark mode
document.documentElement.classList.add('dark');
localStorage.setItem('dark-mode', 'true');

// Change the data grid
const myElement = document.getElementById('myGrid');
myElement.classList.remove('ag-theme-quartz');
myElement.classList.add('ag-theme-quartz-dark');

} else {
document.documentElement.classList.remove('dark');
localStorage.setItem('dark-mode', 'false');

// Change the data grid
const myElement = document.getElementById('myGrid');
myElement.classList.remove('ag-theme-quartz-dark');
myElement.classList.add('ag-theme-quartz');
}
});
});
Expand Down

0 comments on commit be29bbf

Please sign in to comment.