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

INN-3033: make code editor support tailwind/system color schema and overrides #1357

Merged
merged 13 commits into from
May 16, 2024

Conversation

jacobheric
Copy link
Contributor

@jacobheric jacobheric commented May 14, 2024

Description

Code editor was previously hard coded to use a dark theme. Now it will use the tailwind/system color scheme by default and also support the ability to override the color scheme per use. This is useful for things like the current function view in the dashboard that we still want dark despite the fact that the dashboard itself use a light color scheme.

Here the webhooks editor gets the default light:
Screenshot 2024-05-14 at 3 31 06 PM

And the function editor is overriden to dark
Screenshot 2024-05-14 at 12 47 51 PM

Motivation

Type of change (choose one)

  • [x ] Chore (refactors, upgrades, etc.)
  • Bug fix (non-breaking change that fixes an issue)
  • Security fix (non-breaking change that fixes a potential vulnerability)
  • Docs
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality not to work as expected)

Checklist

  • [ x] I've linked any associated issues to this PR.
  • [ x] I've tested my own changes.

https://linear.app/inngest/issue/INN-3033/add-light-theme-to-code-block

Check our Pull Request Guidelines

Copy link

linear bot commented May 14, 2024

Copy link

vercel bot commented May 14, 2024

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

Name Status Preview Comments Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 1:15pm

@jacobheric
Copy link
Contributor Author

There are a couple visual quirks to the editor that light mode exposed (see lower border corners). I'll clean those up.

@jacobheric
Copy link
Contributor Author

Do we want to make the editor toolbar light as well? I've left it dark for now as it more or less matches the rest of the current design.

@anafilipadealmeida
Copy link
Contributor

Do we want to make the editor toolbar light as well? I've left it dark for now as it more or less matches the rest of the current design.

It's a great question. Yes! In light mode, the border of the entire block should be border-slate-200, we should replace the backgrounds by bg-white, and text and description text-white by text-slate-700. We can ignore the button colors for now

@jacobheric
Copy link
Contributor Author

I believe I've addressed all the items we talked about in review with the exception of the transparent scrollbars. I couldn't find any easy way to do that via monaco options so I just let that be for now.

Updates are:

  1. use figma colors for all light theme attributes
  2. update header to respect light theme
  3. use outline buttons that support dark/light in header
  4. remove manual dark override and instead update helper dark detector to find any parent level tailwind dark class
  5. fixe broken border corners on all editors after the first

They now look like:
Screenshot 2024-05-15 at 2 19 37 PM
Screenshot 2024-05-15 at 2 19 57 PM

@@ -133,15 +196,6 @@ export function CodeBlock({ header, tabs, actions = [] }: CodeBlockProps) {
setActiveTab(index);
};

function handleEditorDidMount(editor: MonacoEditorType) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the cause of the broken borders as it was not adding this class when there were more than one editor on the page. So instead I just removed it and applied this globally via css, see above.

Copy link
Contributor

@anafilipadealmeida anafilipadealmeida left a comment

Choose a reason for hiding this comment

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

Looking good @jacobheric ! Left a few small comments 🙂

ui/packages/components/src/CodeBlock/CodeBlock.tsx Outdated Show resolved Hide resolved
ui/packages/components/src/CodeBlock/CodeBlock.tsx Outdated Show resolved Hide resolved
ui/packages/components/src/CodeBlock/CodeBlock.tsx Outdated Show resolved Hide resolved
ui/packages/components/src/CopyButton/CopyButton.tsx Outdated Show resolved Hide resolved
ui/packages/components/src/CodeBlock/CodeBlock.tsx Outdated Show resolved Hide resolved
ui/packages/components/src/utils/theme.ts Outdated Show resolved Hide resolved
ui/packages/components/src/CodeBlock/CodeBlock.tsx Outdated Show resolved Hide resolved
jacobheric and others added 6 commits May 16, 2024 08:18
Co-authored-by: Ana Filipa de Almeida <anafilipadealmeida@gmail.com>
Co-authored-by: Ana Filipa de Almeida <anafilipadealmeida@gmail.com>
Co-authored-by: Ana Filipa de Almeida <anafilipadealmeida@gmail.com>
Co-authored-by: Ana Filipa de Almeida <anafilipadealmeida@gmail.com>
Co-authored-by: Ana Filipa de Almeida <anafilipadealmeida@gmail.com>
Co-authored-by: Ana Filipa de Almeida <anafilipadealmeida@gmail.com>
@jacobheric
Copy link
Contributor Author

Thanks @anafilipadealmeida for the careful review, I think I've addressed all your comments! Let me know if you see anything else.

Also, I see I'm getting an invalid dom nesting error now that I've switched to the new buttons. I'll give that a look and fix before we merge.

@@ -134,7 +134,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps<string>>(functio
if (tooltip) {
return (
<Tooltip>
<TooltipTrigger>{Element}</TooltipTrigger>
<TooltipTrigger asChild>{Element}</TooltipTrigger>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anafilipadealmeida, the dom nesting error I was getting was because I added tooltips to our buttons. Rendering the tooltip trigger button as a child element prevents this nesting. I clicked around after making this change and all the tooltips seem to be working as expected.

Copy link
Contributor

@anafilipadealmeida anafilipadealmeida left a comment

Choose a reason for hiding this comment

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

Thank you for all the hard work, looking great! Left a final small comment, but approving this already!

ui/packages/components/src/CodeBlock/CodeBlock.tsx Outdated Show resolved Hide resolved
Co-authored-by: Ana Filipa de Almeida <anafilipadealmeida@gmail.com>
@jacobheric jacobheric merged commit b866476 into main May 16, 2024
13 checks passed
@jacobheric jacobheric deleted the jacob/dark-editor branch May 16, 2024 13:28
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