Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

feat(#750): implement toggle for light/dark mode#894

Merged
asim-shrestha merged 7 commits intomainfrom
feat/750_add_theme_toggle_button
Jul 1, 2023
Merged

feat(#750): implement toggle for light/dark mode#894
asim-shrestha merged 7 commits intomainfrom
feat/750_add_theme_toggle_button

Conversation

@Jshen123
Copy link
Copy Markdown
Contributor

@Jshen123 Jshen123 commented Jun 29, 2023

Description
Add Theme Toggle
image

Other changes:
refactored useTheme hook

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
agent-gpt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2023 7:21pm
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2023 7:21pm

@ergomake
Copy link
Copy Markdown

ergomake Bot commented Jun 29, 2023

Hi 👋

Here's a preview environment 🚀

https://next-reworkd-agentgpt-894.env.ergomake.link

Environment Summary 📑

Container Source URL
next Dockerfile https://next-reworkd-agentgpt-894.env.ergomake.link
docs Dockerfile https://docs-reworkd-agentgpt-894.env.ergomake.link
platform Dockerfile https://platform-reworkd-agentgpt-894.env.ergomake.link
db Dockerfile [not exposed - internal service]
weaviate semitechnologies/weaviate:1.19.6 https://weaviate-reworkd-agentgpt-894.env.ergomake.link

Questions? Comments? Suggestions? Join Discord.

Click here to disable Ergomake.

Comment thread next/src/components/Menu.tsx Outdated
icon?: ReactNode;
chevron?: boolean;
name?: string;
className?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to manually pass these in anymore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread next/src/components/Menu.tsx Outdated
<div className="relative">
<MenuPrimitive.Button className="flex h-8 items-center gap-1 rounded-lg border border-white/30 bg-[#3a3a3a] p-2 font-bold hover:border-[#1E88E5]/40 hover:bg-[#6b6b6b]">
<MenuPrimitive.Button
className={`neutral-button-primary flex h-8 items-center gap-1 rounded-lg border p-2 font-bold`}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove the {} and use double quotes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread next/src/components/Menu.tsx Outdated
Comment on lines +34 to +36
className={`absolute right-0 ${
buttonPosition === "top" ? "top-full mt-1" : "bottom-full mb-9"
} background-color-3 z-20 max-h-48 w-fit overflow-hidden rounded-xl border-2 border-white/10 shadow-xl`}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use clsx instead of template strings. Easier to maintain that way

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import React from "react";
import Menu from "./Menu";

export const ThemeMenu = () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Much easier to understand / maintain

Comment thread next/src/hooks/useTheme.ts Outdated
export const useTheme = (theme: Theme) => {
theme = THEMES.includes(theme) ? theme : "system";
export const useTheme = () => {
// theme = THEMES.includes(theme) ? theme : "system";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +31 to +32
useTheme();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have this here? Does this just ensure the theme is updated at somepoint?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, can we leave a comment?

background-image: radial-gradient(
circle,
hsla(240, 11%, 85%, 0.75) 2px,
rgba(58, 58, 58, 0.75) 2px,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change from rgba to hsla?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Asim, this is actually reverting back to rgba.

In terms of HSL, it's a bit easier for me to work with.

Comment thread next/src/ui/toggleButton.tsx Outdated
Comment on lines +1 to +24
import React from "react";

type ToggleButtonProps = {
className?: string;
setChecked: (checked: boolean) => void;
onIcon: React.ReactNode;
offIcon: React.ReactNode;
checked: boolean;
};

const ToggleButton = ({ ...props }: ToggleButtonProps) => {
const handleClick = () => {
props.setChecked(!props.checked);
};

const icon = props.checked ? props.onIcon : props.offIcon;
return (
<button type="button" className={props.className} onClick={handleClick}>
{icon}
</button>
);
};

export default ToggleButton;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we delete this? Also we have ax existing toggle right? Is this from TailwindUI components?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel vercel Bot temporarily deployed to Preview – docs June 30, 2023 19:09 Inactive
@vercel vercel Bot temporarily deployed to Preview – docs June 30, 2023 19:20 Inactive
@asim-shrestha asim-shrestha merged commit 7acc3ec into main Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants