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

Hds::CodeEditor Website updates #2626

Draft
wants to merge 101 commits into
base: alex-ju/code-editor-codemirror-spike
Choose a base branch
from

Conversation

zamoore
Copy link
Contributor

@zamoore zamoore commented Dec 24, 2024

πŸ“Œ Summary

If merged, this PR will add Website documentation for the new Hds::CodeEditor component added in #2573.

πŸ› οΈ Detailed description

TBD

πŸ“Έ Screenshots

TBD

πŸ”— External links

Jira ticket: HDS-4311


πŸ’¬ Please consider using conventional comments when reviewing this PR.

Copy link
Contributor

@heatherlarsen heatherlarsen left a comment

Choose a reason for hiding this comment

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

@majedelass Looking good! Left a few notes.

One thing that caught me off guard, though, was the sections for "Active line highlighting" and "Bracket highlighting." I don't know that they're necessary. They aren't guidelines the consumer should follow or options they can choose from, but examples of styling for functional embedded features. Do others think this should be documented within the guidelines?

.changeset/long-poets-wonder.md Outdated Show resolved Hide resolved
website/docs/components/code-editor/index.md Outdated Show resolved Hide resolved
description: A code editor with syntax highlighting, change history, and keyboard navigation.
caption: A code editor with syntax highlighting, change history, and keyboard navigation.
links:
figma: https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?node-id=67166-37020&t=w8xQlWxzH7bwXLe2-1
Copy link
Contributor

Choose a reason for hiding this comment

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

@majedelass This will also need to be updated. It currently links to the CodeBlock page.

website/docs/components/code-editor/index.md Outdated Show resolved Hide resolved
website/docs/components/code-editor/index.md Outdated Show resolved Hide resolved
Copy link
Contributor

@jorytindall jorytindall left a comment

Choose a reason for hiding this comment

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

Left mainly grammatical suggestions, but there are a couple of references to the component and some other cleanup items that should be consistent. LMK if you want to pair on the Code Block syntax highlighting color preview in the table.

website/docs/components/code-editor/index.md Outdated Show resolved Hide resolved

### Contextual components

#### [CB].Title
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the contextual component be this instead? Maybe this is a result of copy-pasta from the CodeBlock?

Suggested change
#### [CB].Title
#### [CE].Title

</C.Property>
</Doc::ComponentApi>

#### [CB].Description
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here

Suggested change
#### [CB].Description
#### [CE].Description


<Doc::ComponentApi as |C|>
<C.Property @name="yield">
Accepts complex content, such as logic/conditionals, HTML elements, other Ember components, etc. Content inherits its style. Styling is applied for simple HTML elements, such as `strong`, `em`, `a`, `code/pre`. Consumers will need to style other HTML tags if used as children
Copy link
Contributor

Choose a reason for hiding this comment

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

I personally had to re-read this a few times to grasp it, I think what was confusing me was "Content inherits its style", which is then followed by the rest of the styling information, which seems somewhat contradictory? I also could totally be misunderstanding this

Suggested change
Accepts complex content, such as logic/conditionals, HTML elements, other Ember components, etc. Content inherits its style. Styling is applied for simple HTML elements, such as `strong`, `em`, `a`, `code/pre`. Consumers will need to style other HTML tags if used as children
Accepts complex content, such as logic/conditionals, HTML elements, other Ember components, etc. Styling is applied for simple HTML elements, such as `strong`, `em`, `a`, `code/pre`. Consumers will need to style other HTML tags if used as children


<Doc::ComponentApi as |C|>
<C.Property @name="yield">
Accepts complex content, such as logic/conditionals, HTML elements, other Ember components, etc. Content inherits its style. Styling is applied for simple HTML elements, such as `strong`, `em`, `a`, `code/pre`. Consumers will need to style other HTML tags if used as children.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question about "Content inherits its style", if this is still relevant, feel free to disregard.


This provides an accessible name for the Code Editor so that a user and assistive technology can understand its purpose.

![A partial form with a radio group labeled with "Enforement behavior" and then the options "Advisory" with helper text "failed policies produce a warning", "Soft mandatory" with helper text "Failed policies can be overriden", "Hard mandatory" with helper text "Failed policies stop the run". Then the Code Editor with an external acessible name/title "Policy code (Sentinel)"](/assets/components/code-editor/code-editor-external-do-accessible-name.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: We can shorten this up a bit.

Suggested change
![A partial form with a radio group labeled with "Enforement behavior" and then the options "Advisory" with helper text "failed policies produce a warning", "Soft mandatory" with helper text "Failed policies can be overriden", "Hard mandatory" with helper text "Failed policies stop the run". Then the Code Editor with an external acessible name/title "Policy code (Sentinel)"](/assets/components/code-editor/code-editor-external-do-accessible-name.png)
![A Code Editor embedded in a form following a set of radio buttons. It has the heading "Policy code (Sentinel)" immediately before.](/assets/components/code-editor/code-editor-external-do-accessible-name.png)


!!! Do

This provides an accessible name for the Code Editor so that a user and assistive technology can understand its purpose.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: one important thing to know is that the accessible name is not provided by just having the text in the DOM. Either the code editor needs to have aria-label or have aria-labelledby set to the id of the title.

@zamoore set up aria-labelledby to work automatically if you use the CE title component, but it wont work if the title is custom.


Sometimes it may be necessary to use the Code Editor in a more dense layout or nested within another component.

![Code Editor embedded inside of a larger UI, where it is highlighted where the user is actively editing.](/assets/components/code-editor/code-editor-block-level.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
![Code Editor embedded inside of a larger UI, where it is highlighted where the user is actively editing.](/assets/components/code-editor/code-editor-block-level.png)
![Code Editor embedded inside of a logs UI, where the corners are squared to fit within container.](/assets/components/code-editor/code-editor-block-level.png)



Assuming a user would understand the intent of the Code Editor without providing an accessible name will cause confusion and fail on accessibility requirements.
![A partial form with a radio group labeled with "Enforement behavior" and then the options "Advisory" with helper text "failed policies produce a warning", "Soft mandatory" with helper text "Failed policies can be overriden", "Hard mandatory" with helper text "Failed policies stop the run". The Code Editor has no accessible name.](/assets/components/code-editor/code-editor-dont-external-accessible-name.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
![A partial form with a radio group labeled with "Enforement behavior" and then the options "Advisory" with helper text "failed policies produce a warning", "Soft mandatory" with helper text "Failed policies can be overriden", "Hard mandatory" with helper text "Failed policies stop the run". The Code Editor has no accessible name.](/assets/components/code-editor/code-editor-dont-external-accessible-name.png)
![A Code Editor embedded in a form following a set of radio buttons. The Code Editor has no title before it.](/assets/components/code-editor/code-editor-dont-external-accessible-name.png)


!!! Warning

The Code Editor has limited support for dark mode styles. Buttons have pre-defined dark mode styles, but all other components require manual color adjustments until a dark mode theme is released. Please contact the Design Systems Team for help translating components into dark mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: link to the contact page here


Some elements or functions outside the Code Editor may affect the content within the Code Editor. In this case, we recommend turning off the header to couple the editor with the nearby elements.

![An external accessible name/title with a coupled search field, dropdown labeled with "Copy", another dropdown labeled with "Version" and a button labeled with "Create new version"](/assets/components/code-editor/code-editor-external-functions.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
![An external accessible name/title with a coupled search field, dropdown labeled with "Copy", another dropdown labeled with "Version" and a button labeled with "Create new version"](/assets/components/code-editor/code-editor-external-functions.png)
![A Code Editor with the external title "Automations and expressions" coupled with a filter input, "Copy" dropdown, "Version" dropdown, and a "Create new version" button.](/assets/components/code-editor/code-editor-external-functions.png)


When a user is editing code on a single line, a highlight will be present to emphasize their location in the Code Editor.

![The Code Editor's line 1 with the active line highlight.](/assets/components/code-editor/code-editor-code-active-line.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
![The Code Editor's line 1 with the active line highlight.](/assets/components/code-editor/code-editor-code-active-line.png)
![The Code Editor's line 1 with the active line highlight, shown with a blinking cursor and border around the entire line.](/assets/components/code-editor/code-editor-code-active-line.png)

### Applying syntax highlighting

If you wish to create custom examples using the Code Editor, we publish all of the relevant syntax highlighting variables in the [HDS Components v2.0](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?node-id=67166-37020&t=gWdKy44MzTP4cTRo-1) library. However, due to the number of languages supported by the component, the color variables use a generic naming schema (e.g., cyan, red, purple) to remain as agnostic as possible when being applied to different languages.
For more details around syntax visit the [specifications](https://helios.hashicorp.design/components/code-editor?tab=specifications).
Copy link
Contributor

Choose a reason for hiding this comment

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

Just this should work

Suggested change
For more details around syntax visit the [specifications](https://helios.hashicorp.design/components/code-editor?tab=specifications).
For more details around syntax visit the [specifications](/components/code-editor?tab=specifications).

@@ -0,0 +1,29 @@
## Anatomy

![Anatomy of Code Editor](/assets/components/code-editor/code-editor-anatomy.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
![Anatomy of Code Editor](/assets/components/code-editor/code-editor-anatomy.png)
![](/assets/components/code-editor/code-editor-anatomy.png)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-website Content updates to the documentation website packages/components showcase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants