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]: <rh-code-block> extensions #1091

Open
1 of 4 tasks
bennypowers opened this issue Jun 26, 2023 · 12 comments · Fixed by #1496 or #1837
Open
1 of 4 tasks

[feat]: <rh-code-block> extensions #1091

bennypowers opened this issue Jun 26, 2023 · 12 comments · Fixed by #1496 or #1837
Labels
feature New feature or request for dev Ready for development priority: high High priority

Comments

@bennypowers
Copy link
Member

bennypowers commented Jun 26, 2023

Today at Office hours we took the decision to release a very basic version of code-block with bellsprout.

features we'll push off to bulbasaur:

  • new variants of <rh-button>: icon button / FAB for copy
  • syntax highlighting
  • callout badges
  • toolbar/container

We also have some usability questions we'd like to address:

  • should copy button always be a FAB (i.e. floating over the codeblock, not slotted into the toolbar)
  • is combining tabs with links/actions a usability problem for sighted keyboard users?

SO, basically the bellsprout version will be a gray box that formats a script of text

Originally posted by @bennypowers in #328 (comment)

@bennypowers bennypowers added this to the RHDS Bulbasaur milestone Jun 26, 2023
@markcaron markcaron added the for dev Ready for development label Sep 14, 2023
@bennypowers bennypowers added blocked Issue is blocked for design Design work is requested labels Sep 21, 2023
@bennypowers bennypowers removed their assignment Oct 18, 2023
@bennypowers bennypowers removed the for dev Ready for development label Oct 19, 2023
@markcaron
Copy link
Collaborator

@coreyvickery can you provide @bennypowers with guidance on new color tokens for syntax highlighting?

@coreyvickery
Copy link
Collaborator

@bennypowers Here are new syntax highlighting colors based on our new color design tokens. Happy to do more work in other places to flesh these out.

Light theme

Red - red-50
Orange - orange-60
Yellow - yellow-60
Green - green-60
Blue - blue-50
Purple - purple-50
Black (text) - gray-95
Dark gray (secondary text) - gray-60
Light gray (lines/borders) - gray-30

Dark theme

Red - red-40
Orange - orange-40
Yellow - yellow-40
Green - green-40
Blue - blue-40
Purple - purple-30
White (text) - white
Dark gray (lines/borders) - gray-50
Light gray (secondary text) - gray-30

@markcaron
Copy link
Collaborator

Thanks, @coreyvickery!

@bennypowers, how far along are we with the rest of the work? Wondering if we can wrap this up in Caterpie or if we need to move it to the Chansey release?

@markcaron markcaron added for dev Ready for development priority: high High priority and removed for design Design work is requested labels Jan 11, 2024
@markcaron
Copy link
Collaborator

We discussed today in the Docs Overhaul meeting about adding a Show more / View code disclosure button to code blocks. This would be a good way to limit initial vertical height, and ease scanning and finding info.

@zeroedin
Copy link
Collaborator

We discussed today in the Docs Overhaul meeting about adding a Show more / View code disclosure button to code blocks. This would be a good way to limit initial vertical height, and ease scanning and finding info.

Here is a screenshot from salesforce lightning design system where they are doing something similar.

image

@coreyvickery
Copy link
Collaborator

@markcaron It's been a while since I've touched the design of this component (hence the XD link), but here are some examples of the Expand to full height feature (question about that below).

To get this completed ASAP, let me know where I need to provide additional design guidance or mock-ups. Maybe we need to have a separate call with Greg or Nikki to tackle some of Benny's usability questions. But first, can we finalize the list of features that we need to ship? This is Benny's list from above, I'm just adding more talking points.

  • Toolbar
    • I think this feature needs to be tackled first
    • Is the goal that the next version of this component always includes a toolbar?
    • How do we decide on what's displayed by default? Text only? Tabs? Links?
      • Could there be code written to display different options?
  • Copy button
    • What's the format? Text only or an icon button?
      • I know the link is the same, just scroll to see the different options
    • Is it always in the toolbar or is it a FAB in the light/dark gray container?
    • Does it have a tooltip?
  • Callout numbers
    • Is this old mock-up sufficient or are more design explorations required?
  • Syntax highlighting
    • I added values above that correspond to our color design tokens
    • Are they sufficient? Is using custom colors still the right approach?
  • Expand to full height
    • Do we want to add this to the list of features we want to ship?
    • If so, I think this presumes that a minimum height value is needed, so I'll need to figure that out in order to give the right specs

cc @hellogreg

@coreyvickery
Copy link
Collaborator

Changes to make

  • Copy button is always a FAB
  • Only tabs on top
  • Secondary toolbar/links on bottom (View demo, for example)
  • Diagonal arrows icon for expand to full height? - OR - Expand to full height text in fade/gradient?
  • Wrap text toggle or button
  • Sample icon:
Screenshot 2024-01-26 at 6 31 20 AM
  • Callout numbers
    • Explore new design NOW, code later
    • Toggle annotations?
    • Less visual noise

Near future

Syntax highlighting

@nikkimk
Copy link
Collaborator

nikkimk commented Jan 30, 2024

.@marionnegp and I met and tested colors with PrismJS's types. Here's what we found works best.

Light Theme

Variable Color
--rh-code-block-default-color gray-95
--rh-code-block-background gray-10
--rh-code-block-selected-text-background blue-10
--rh-code-block-comment-color gray-60
--rh-code-block-comment-block-color gray-60
--rh-code-block-doctype-color gray-60
--rh-code-block-cdata-color gray-60
--rh-code-block-punctuation-color gray-40
--rh-code-block-namespace-color  gray-95
--rh-code-block-property-color purple-50
--rh-code-block-tag-color purple-50
--rh-code-block-boolean-color purple-50
--rh-code-block-number-color purple-50
--rh-code-block-constant-color purple-50
--rh-code-block-symbol-color purple-50
--rh-code-block-deleted-color purple-50
--rh-code-block-function-name-color purple-50
--rh-code-block-selector-color teal-60
--rh-code-block-attr-name-color teal-60
--rh-code-block-string-color teal-60
--rh-code-block-character-color teal-60
--rh-code-block-built-in-color teal-60
--rh-code-block-inserted-color teal-60
--rh-code-block-operator-color yellow-60
--rh-code-block-entity-color yellow-60
--rh-code-block-url-color yellow-60
--rh-code-block-string-color yellow-60
--rh-code-block-at-rule-color blue-60
--rh-code-block-attr-value-color blue-60
--rh-code-block-keyword-color blue-60
--rh-code-block-function-color red-60
--rh-code-block-class-name-color red-60
--rh-code-block-regex-color orange-60
--rh-code-block-important-color orange-60
--rh-code-block-variable-color orange-60

Dark theme

Variable Color
--rh-code-block-default-color gray-20
--rh-code-block-background gray-70
--rh-code-block-selected-text-background gray-95
--rh-code-block-comment-color gray-50
--rh-code-block-comment-block-color gray-50
--rh-code-block-doctype-color gray-50
--rh-code-block-cdata-color gray-50
--rh-code-block-punctuation-color gray-20
--rh-code-block-namespace-color red-40
--rh-code-block-property-color yellow-40
--rh-code-block-tag-color red-10
--rh-code-block-boolean-color orange-40
--rh-code-block-number-color orange-40
--rh-code-block-constant-color yellow-40
--rh-code-block-symbol-color yellow-40
--rh-code-block-deleted-color red-40
--rh-code-block-function-name-color teal-20
--rh-code-block-selector-color purple-30
--rh-code-block-attr-name-color red-40
--rh-code-block-string-color green-40
--rh-code-block-character-color green-40
--rh-code-block-built-in-color purple-30
--rh-code-block-inserted-color green-40
--rh-code-block-operator-color blue-40
--rh-code-block-entity-color blue-40
--rh-code-block-url-color blue-40
--rh-code-block-string-color green-40
--rh-code-block-at-rule-color purple-30
--rh-code-block-attr-value-color green-40
--rh-code-block-keyword-color purple-30
--rh-code-block-function-color orange-40
--rh-code-block-class-name-color yellow-40
--rh-code-block-regex-color green-40
--rh-code-block-important-color purple-30
--rh-code-block-variable-color green-40

@coreyvickery coreyvickery moved this from Todo to In Progress 🟢 in Red Hat Design System Feb 4, 2024
@coreyvickery coreyvickery moved this from Todo to In Progress 🟢 in Red Hat Design System Roadmap Feb 4, 2024
@coreyvickery coreyvickery added feature New feature or request for design Design work is requested and removed for dev Ready for development blocked Issue is blocked labels Feb 4, 2024
@coreyvickery coreyvickery added for dev Ready for development and removed for design Design work is requested labels Feb 20, 2024
@bennypowers
Copy link
Member Author

Notes from 2024-03-07

  • add to codeblock

    • show more expand button
    • fabs for copy and wrap (default to pre)
    • demos for callout tags
    • line numbers (always)
  • add to docs:

    • card with tab bar and panels for code languages
    • external links in footer
    • switch for callouts in footer
    • callout legend beneath card (manual, at least for now)

@bennypowers
Copy link
Member Author

proposal:

  1. gather all the token names we'd need to write a prism.js theme
  2. gather all the token names we'd need to write a highlight.js theme
  3. gather all the token names we'd need to write a treesitter theme
  4. decide on the common denominators we want to support from steps 1-3
  5. publish our syntax token names

WDYT of that approach @marionnegp ?

@marionnegp
Copy link
Collaborator

Sounds good to me. We should still be able to use the token names from Nikki's comment.

@bennypowers
Copy link
Member Author

we got syntax highlighting in for clefairy, moving the leftovers to cubone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request for dev Ready for development priority: high High priority
Projects
Status: Done ☑️
Status: In Progress 🟢
7 participants