Skip to content
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

Improve Styles, including Dark Mode #258

Draft
wants to merge 29 commits into
base: dev
Choose a base branch
from
Draft

Improve Styles, including Dark Mode #258

wants to merge 29 commits into from

Conversation

crhallberg
Copy link
Collaborator

@crhallberg crhallberg commented Feb 8, 2023

Based off of the Global Context PR.

  • Map grays to palette
  • Implement dark theme
  • Touch up padding and margins
  • Add test coverage to new code
  • Close Dark mode #255 when merging

@crhallberg crhallberg changed the base branch from dev to global-context February 8, 2023 22:37
@crhallberg crhallberg marked this pull request as draft February 8, 2023 22:37
@crhallberg crhallberg mentioned this pull request Feb 14, 2023
6 tasks
@crhallberg crhallberg changed the title Dark Mode Improve Styles, including Dark Mode Jul 3, 2024
@demiankatz demiankatz mentioned this pull request Jul 5, 2024
Base automatically changed from global-context to dev July 5, 2024 15:50
Copy link
Collaborator

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crhallberg, now that #256 is merged, there are a ton of conflicts here (since this work was based on a very early version of #256). Can you resolve the conflicts (or, if it's easier, close this PR and port the relevant changes over to a new one)?

Copy link
Collaborator

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the progress made here, @crhallberg! There were a few small problems that were causing test failures, so I went ahead and fixed them. This seems to be functional now, though I couldn't find a way to actually try out dark mode. See below for more detailed comments and suggestions.

import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select, { SelectChangeEvent } from '@mui/material/Select';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're importing SelectChangeEvent but not using it.


import { useGlobalContext } from "../context/GlobalContext";

export default function ThemeMenu() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test for this component once it is finalized and before we merge this PR.

@@ -19,7 +19,7 @@ const ObjectButtonBar = ({ pid }: ObjectButtonBarProps): React.ReactElement => {
<ObjectStatus pid={pid} />
<EditParentsButton pid={pid} />
<button onClick={() => clearPidFromChildListStorage(pid)}>
<Refresh style={{ height: "14px" }} titleAccess="Refresh children" />
<Refresh style={{ height: "20px", verticalAlign: "sub" }} titleAccess="Refresh children" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we give this a class and move the styling to CSS? I'm pretty sure the direct style here was just my laziness, but if we're going to get fancier, maybe we should do things "the right way."


/* Editor */

--object-status-active: #bef264;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the status colors need to be more clearly defined -- the active/inactive need to be distinct from each other so you can tell them apart at a glance, but these new colors make them look too similar:

image

Is there a reason we can't keep the standard red/green/yellow?

return (
<FormControl className="user-theme__menu">
<InputLabel id="user-theme__label">Theme</InputLabel>
<Select
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it comes time to test this, take a look at the test for my bulk editor -- it's a bit tricky to test MUI select controls, but that test does it successfully. (You have to trigger a MouseUp action, if I remember correctly...)

function systemTheme(): ThemeOption {
let defaultTheme = "light" as ThemeOption;

if (typeof window != "undefined" && typeof window.matchMedia != "undefined") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watchMedia is not defined in server-side code, so I had to add the second part of this check to prevent test failures. We can mock the method if we want to actually test this logic (and we should, once it's ready).

return mediaTheme;
}

return "system" as ThemeOption;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you return ThemeOption.system instead of "system" as ThemeOption? If that works, it seems easier to understand. (And we should use that pattern for all the theme references).

import LogoutButton from "../components/LogoutButton";
import ThemeMenu from "../components/ThemeMenu";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You import the ThemeMenu, but you don't use it. Indeed, I don't see a theme menu anywhere in the application at this point, though I do notice that the "log out" button has moved from right-aligned to left-aligned for some reason.

/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should we remove this commented-out code? Or should we consider revising the JobPaginator to use the MUI grid so we don't need this file at all? (I'm pretty sure this is only being used in JobPaginator.tsx, though maybe there are some other references I'm missing.

@demiankatz
Copy link
Collaborator

I also merged a couple of small fixes from here into dev (whitespace adjustments, removing the stray semicolon in JobPaginator) to reduce the number of files in this PR.

@crhallberg crhallberg mentioned this pull request Oct 31, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dark mode
2 participants