Skip to content

Commit

Permalink
move widget to header
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisnsns committed Jan 18, 2024
1 parent 99e1c70 commit 152bfcc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
12 changes: 1 addition & 11 deletions ui/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,16 @@ import "./styles.css";
import "./sakura.css";
import "./tokyoNight.css";
import { useTheme } from "./ThemeContext";
import { Button, SelectMenu } from "evergreen-ui";

function App() {
const { theme, setTheme } = useTheme();
const themes = ["sakura", "tokyoNight", "nord"]; // All your themes
const { theme } = useTheme();

return (
<>
<div className={`app ${theme}`}>
<div className="header header-app">
<ConnectButton />
</div>
<SelectMenu
title="Select Theme"
options={themes.map((t) => ({ label: t, value: t }))}
selected={theme}
onSelect={(item) => setTheme(String(item.value))}
>
<Button className="theme-toggle-button">{theme}</Button>
</SelectMenu>

<div className="list-stream-managers">
<h2> Stream Managers </h2>
Expand Down
13 changes: 11 additions & 2 deletions ui/app/src/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import { Button, ArrowLeftIcon } from "evergreen-ui";
import { useTheme } from "./ThemeContext";
import { Button, SelectMenu, ArrowLeftIcon } from "evergreen-ui";

const Header = () => {
const { theme } = useTheme();
const { theme, setTheme } = useTheme();
const navigate = useNavigate();
const themes = ["sakura", "tokyoNight", "nord"];

return (
<div className={`app ${theme}`}>
Expand All @@ -19,6 +20,14 @@ const Header = () => {
<Button className="theme-header-button" onClick={() => navigate("/")}>
Homepage
</Button>
<SelectMenu
title="Select Theme"
options={themes.map((t) => ({ label: t, value: t }))}
selected={theme}
onSelect={(item) => setTheme(String(item.value))}
>
<Button className="theme-toggle-button">{theme}</Button>
</SelectMenu>
</div>
);
};
Expand Down
12 changes: 4 additions & 8 deletions ui/app/src/ThemeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import React, {
} from "react";

type ThemeContextType = {
theme: string; // The current theme
setTheme: (theme: string) => void; // Function to update the theme
theme: string;
setTheme: (theme: string) => void;
};



const ThemeContext = createContext<ThemeContextType>({
theme: "sakura", // Default value
setTheme: () => {}, // Default function
theme: "sakura",
setTheme: () => {},
});

type ThemeProviderProps = {
Expand All @@ -30,8 +28,6 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
localStorage.setItem("theme", theme);
}, [theme]);

// No need for toggleTheme if it's not being used

return (
<ThemeContext.Provider value={{ theme, setTheme }}>
{children}
Expand Down

0 comments on commit 152bfcc

Please sign in to comment.