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

fix: dark-mode for scalar API docs when appearance is system settings #11085

Closed
wants to merge 2 commits into from

Conversation

Nabhag8848
Copy link
Contributor

Issue

Demo

Screen.Recording.2025-03-21.at.3.23.06.PM.mov

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added dark mode support for the Scalar API documentation in the RestPlayground component, ensuring proper theme synchronization with system settings.

  • Added useColorMode hook import from @scalar/use-hooks in packages/twenty-front/src/modules/settings/playground/components/RestPlayground.tsx
  • Configured darkMode and forceDarkModeState properties in ApiReferenceReact based on theme context
  • Implemented lazy loading of color mode hook to ensure proper theme initialization

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +21 to +23
import('@scalar/use-hooks/useColorMode').then((colorMode) =>
colorMode.useColorMode(),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The useColorMode() hook is called immediately without being used, which may cause unnecessary re-renders

Comment on lines +69 to 71
darkMode: theme.name === 'dark',
baseServerURL: REACT_APP_SERVER_BASE_URL + '/' + schema,
forceDarkModeState: theme.name === 'dark' ? 'dark' : 'light',
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Redundant dark mode configuration - darkMode and forceDarkModeState properties serve the same purpose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • when using anyone of them: changing from dark to light mode works but from light to dark doesn't work as expected.

@FelixMalfait FelixMalfait self-assigned this Mar 21, 2025
@FelixMalfait
Copy link
Member

I cannot reproduce the original issue on main 🤔

@FelixMalfait
Copy link
Member

I get the opposite behavior with this PR:

Image

IMO we should just close the original issue if it happens only when you change the system specifically on that page, and that we don't have a good/clean fix

@FelixMalfait
Copy link
Member

Screenshot 2025-03-21 at 18 09 55

Seems to be a bigger issue, if I play around I can get similar behaviors in the app

@FelixMalfait
Copy link
Member

So I'm sorry @Nabhag8848 I will just close this and this original issue. Thanks for digging into this!

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.

Enable Dark-Mode for API documentation when Theme == System Settings
2 participants