27
loading...
This website collects cookies to deliver better user experience
body
element has a CSS class name including "dark". import React, {useContext} from "react";
import ThemeContext from "../ThemeContext";
import {FlexCenter} from "../styles/Grid";
import darkMode from "../images/darkMode.svg";
import lightMode from "../images/lightMode.svg";
import themeAuto from "../images/themeAuto.svg";
function ThemeButtonGroup() {
const [theme, setTheme] = useContext(ThemeContext);
return (
<FlexCenter style={{marginRight:"0.5rem"}}>
<a
style={{margin:"0 .5rem"}}
disabled={theme === "dark"}
onClick={(event) => {
event.preventDefault();
setTheme("dark");
}}>
<img
src={darkMode}
alt="dark mode"
style={{
backgroundColor:(theme === "dark")
? "#ccc"
: "transparent"
}}/>
</a>
// ...
</FlexCenter>
);
}
<img alt="open sauced" className="svg" src={mortarBoard} />
), the coloring of these is controlled using the filter
CSS property. On the other hand, we also make use of @primer/octicons-react. import {SearchIcon} from "@primer/octicons-react";
// ...
<SearchIcon size="large" verticalAlign="middle" className="svg" />
<svg>...</svg>
, requiring use of CSS property fill
.<img>
and <svg>
tags are handled differently.body.dark img.svg {
filter: invert();
}
body.dark svg.svg {
fill: var(--lightestGrey);
}
body.dark .react-loading-skeleton {
background-color: var(--backgroundGrey);
background-image: linear-gradient(
90deg,
var(--backgroundGrey),
var(--grey),
var(--backgroundGrey)
);
}