-
Notifications
You must be signed in to change notification settings - Fork 47
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
HDS::CodeEditor with Code Mirror 6 #2573
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
e91b5a5
to
672f756
Compare
3399f55
to
6aae2e5
Compare
495c0e7
to
16df6ff
Compare
packages/components/src/styles/components/code-editor/index.scss
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three minor things I caught. Let me know when you address them so I can approve the PR 👍
packages/components/src/styles/components/code-editor/index.scss
Outdated
Show resolved
Hide resolved
packages/components/src/modifiers/hds-code-editor/themes/hds-dark-theme.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the functionality again. One thing I noticed is that in full-screen mode the border-radius is preserved (not sure if it was intentional or not). Otherwise all looks good! Happy to get it in, and if anything comes up in testing we can address separately.
&:active { | ||
background-color: var(--hds-code-editor-color-surface-interactive-active) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Active still isn't showing up properly. I believe this needs to be moved below the hover pseudo class so it will show up properly on mouse click.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adressing in a followup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving because there is one last minor thing with the active state (in CSS) and I don't want to block entirely. I'd move the active state below the hover state in CSS so it will show up properly on mouse click.
📌 Summary
This PR adds a code editor utilizing Code Mirror 6 to the HDS component library. The code editor can be instantiated via:
hds-code-editor
modifier, which can be added to any element to transform that element into a code editor instanceHds::CodeEditor
component, which uses thehds-code-editor
modifier under the hood, but adds support for title, description, and various tools.Details
hds-code-editor
modifierThis modifier will instantiate a Code Mirror editor on the element that it's added to. In order to reduce the up-front cost of loading the editor, we only load the CodeMirror package when the editor is scrolled into view. Because of this, there may be an exceptionally brief loading state before the editor is ready when it is viewed by the user.
value
: The initial value of the editorlanguage
: optional, one of 4 possible supported languages (json, sql, go, hcl)onInput
: callback function when the code editor changesonSetup
: callback function when the modifier has completed loading dependencies and instantiating the editor, receives CodeMirror Editor instance.This editor features support for:
cmd+z
and other history commands)Hds::CodeEditor
componentThis component uses the
hds-code-editor
modifier in combination with a customizable header and support for a fullscreen mode.value
: The initial value of the editorhasExpandButton
: Whether the editor can be expanded into fullscreen modehasCopyButton
: Whether the editor has a button that adds the current value to the clipboardlanguage
: optional, one of 4 possible supported languages (json, sql, go, hcl)onInput
: callback function when the code editor changesonSetup
: callback function when the component has completed loading dependencies and instantiating the editor, receives CodeMirror Editor instance.📸 Screenshots
🔗 External links
Jira ticket: HDS-4016
Figma
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.