Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ibm
GitHub Repository: ibm/watson-machine-learning-samples
Path: blob/master/cloud/ai-service-apps/nextjs-carbon-react-ui/src/components/ThemeToggle/ThemeButton.js
6408 views
1
import cx from "classnames";
2
import { useAppContext } from "@/contexts/app-context";
3
import { getThemeIcon } from "@/utils/theme-util";
4
5
const ThemeButton = ({ value, onClick, isExpanded }) => {
6
const { theme } = useAppContext();
7
const themeIcon = getThemeIcon(value, 18);
8
9
return (
10
<button
11
type="button"
12
value={value}
13
tabIndex={isExpanded ? "0" : "-1"}
14
className={cx("theme-toggle__btn", {
15
"theme-toggle__btn--selected": value === theme,
16
})}
17
onClick={onClick}
18
aria-label={`Theme button ${value}`}
19
>
20
{themeIcon}
21
</button>
22
);
23
};
24
25
export default ThemeButton;
26
27