Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#750): add themestore and usetheme #881

Merged
merged 6 commits into from Jun 28, 2023

Conversation

Jshen123
Copy link
Contributor

No description provided.

@ergomake
Copy link

ergomake bot commented Jun 28, 2023

Hi 👋

Here's a preview environment 🚀

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

Environment Summary 📑

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

Questions? Comments? Suggestions? Join Discord.

Click here to disable Ergomake.

@vercel
Copy link

vercel bot commented Jun 28, 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 28, 2023 10:49pm
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2023 10:49pm

return theme === PREFERRED_THEME || (theme === "system" && preferredThemeMatches);
}

export function handleTheme(theme, matchObj?) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use arrow syntax. Also, should we have type params for these functions

@@ -0,0 +1,41 @@
import { type Theme, THEMES } from "../types";
import { useEffect } from "react";
const PREFERRED_THEME = "dark"; // preferred theme must be dark for Tailwind
Copy link
Contributor

Choose a reason for hiding this comment

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

How come?

Comment on lines 34 to 35
useEffect(() => {
const preferredTheme = window.matchMedia(`(prefers-color-scheme: ${PREFERRED_THEME})`);
Copy link
Contributor

Choose a reason for hiding this comment

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

What's going on here? What if their preferred theme isn't dark?

Comment on lines 22 to 28
const classList = document.documentElement.classList;

if (isPreferredTheme(theme, matchObj)) {
classList.add(PREFERRED_THEME);
} else {
classList.remove(PREFERRED_THEME);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats going on here, worth some comments?

Comment on lines +43 to +50
onRehydrateStorage: () => {
return (state, error) => {
if (error) {
console.error("an error happened during hydration. ", error);
} else {
handleTheme(state ? state.theme : "system");
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat, so this way even if we have local storage we won't run into rehydration issues with SSR? If so, could also use these in the other stores (Had to use a separate hook for them to ensure there were no issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants