-
Notifications
You must be signed in to change notification settings - Fork 48
Website - CodeBlock
height toggle docs
#2845
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6890f97
Feat: `CodeBlock` toggle code docs
dchyun 6e704e8
Fix: Linting
dchyun 24ef892
Update guidelines.md
andgen404 b782514
added images
andgen404 82d5e06
Update guidelines.md
andgen404 a00cb3c
Apply suggestions from code review
andgen404 838e7ad
Apply suggestions from code review
andgen404 3cc0838
Update website/docs/components/code-block/partials/guidelines/guideli…
andgen404 ddfc84d
Apply suggestions from code review
andgen404 4803fb8
Apply suggestions from code review
andgen404 ff191e0
Fix: Code docs missing word
dchyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -69,6 +69,21 @@ Line numbers are displayed by default and can make longer blocks of code and sni | |||||
In the Figma component, the code examples have the appropriate number of lines by default but must be manually hidden or shown to match the length of custom snippets. | ||||||
!!! | ||||||
|
||||||
## Height toggle button | ||||||
|
||||||
When displaying longer code snippets, it can be helpful to let users expand and collapse the content to save space in the UI. Setting a `maxHeight` on the Code Block limits how much is shown by default. If the content exceeds this height, a **Show more code** button will be displayed at the bottom of the block, allowing users to expand it. Interacting with the button again collapses the block back to its original height. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andgen404 How's this? (Above suggested edit) |
||||||
|
||||||
In Figma, this is enabled by setting `hasToggleHeightButton` to true. The button is placed inside a footer element that only appears when the content overflows, keeping the layout clean when the toggle isn’t needed. | ||||||
|
||||||
 | ||||||
|
||||||
Interacting with this button removes the height limit, expanding the Code Block to display the full code snippet. | ||||||
|
||||||
 | ||||||
|
||||||
Interacting with it again collapses the Code Block back to its set `maxHeight`. | ||||||
|
||||||
|
||||||
## Line highlighting | ||||||
|
||||||
Use line highlighting to target and call attention to specific lines or multiple lines within a block of code. | ||||||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Working on tweaking this as it still seems a bit awkward... (I'll make a suggested edit)