This repository has been archived on 2023-11-06. You can view files and clone it, but cannot push or open issues or pull requests.
beatsaber-overlay/src/components/Settings.js

52 lines
993 B
JavaScript
Raw Normal View History

2022-10-19 14:53:27 +00:00
import {
Avatar as NextAvatar,
changeTheme,
Dropdown,
Text,
useTheme,
} from "@nextui-org/react";
const Avatar = (props) => {
const { isDark } = useTheme();
2022-12-13 12:06:16 +00:00
const avatarUrl = props.avatarUrl || "https://cdn.fascinated.cc/yb4fgdc1.jpg";
2022-10-19 14:53:27 +00:00
const handleChange = () => {
const nextTheme = isDark ? "light" : "dark";
window.localStorage.setItem("theme", nextTheme); // you can use any storage
changeTheme(nextTheme);
};
return (
<>
<Dropdown>
<Dropdown.Trigger>
<NextAvatar
bordered
size="lg"
as="button"
color="primary"
src={avatarUrl}
/>
</Dropdown.Trigger>
<Dropdown.Menu aria-label="Static Actions">
<Dropdown.Item>
<div
style={{
display: "flex",
flexDirection: "column",
}}
>
<Text b onClick={() => handleChange()}>
Toggle Dark Mode
</Text>
</div>
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</>
);
};
export default Avatar;