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

Dark mode activation #369

Open
Aenardhil opened this issue Aug 24, 2023 · 3 comments
Open

Dark mode activation #369

Aenardhil opened this issue Aug 24, 2023 · 3 comments

Comments

@Aenardhil
Copy link

Is your feature request related to a problem? Please describe.
no

Describe the solution you'd like
I want to a activate dark mode or any type of dark background with the atom and bound with light colour.

Describe alternatives you've considered
I have tried to change the background colour to a dark blue with backgroundColour but the problem is that the bounds are indistinguishable. I've tried then to use svg instead of canvas to modify the colours using css but the carbons are not selectable by css selectors.

@Aenardhil Aenardhil changed the title Activation of dark moder Dark mode activation Aug 25, 2023
@MichelML
Copy link
Collaborator

MichelML commented Sep 19, 2023

@Aenardhil maybe @ptosco has a better idea here, but here's a starter "hack", in svg mode, you can make most bonds white with css like this (but you'll probably have to hack other things in the image like atom numbers, etc):

/**
   * This means all path elements with a class starting with the word "bond"
   * (ideally be more specific than that in your css selection
   */
path[class^="bond"] {
    stroke: white !important;
    fill: white !important;
}

/* set the svg background to black (ideally be more specific than that in your css selection) */
svg {
    background-color: black;
}

example:

image

@sgoodrow-zymergen
Copy link

sgoodrow-zymergen commented Sep 29, 2023

Opened a similar discussion here: #390

I believe rdkit has support for darkmode in its draw options, but we aren't making that available currently? Are those draw options hard to expose? I have tried poking around the library code a bit but haven't identified the throughline from get_svg to those draw options.

I also played around with the approach shared above -- it has its limitations, but is possible. Need to narrow the overrides a bit to not recolor bonds that are colored from the atom color, e.g.:

const theme = useTheme();
  return (
    <Box
      aria-label="molecule image"
      display="flex"
      justifyContent="center"
      sx={
        theme.palette.mode === "dark"
          ? {
              // Override any black stroke to white
              '& path[style*="stroke:#000000;"]': {
                stroke: "white !important",
                fill: "white !important",
              },
            }
          : undefined
      }
      dangerouslySetInnerHTML={{
        __html: sanitize(svgHtml),
      }}
    />

@MichelML
Copy link
Collaborator

xref #325 (reply in thread)

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

No branches or pull requests

3 participants