-
Notifications
You must be signed in to change notification settings - Fork 2
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: Add option for line-wrapping to prevent horizontal scrolling #20
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
59ecbce
feat: add option for line-wrapping to prevent horizontal scrolling
akoreman 9097cfc
Merge branch 'cloudscape-design:main' into line_wrap
akoreman 6cd99c4
chore: remove accidentally commited npm script
akoreman b40b2b0
fix: make line numbers unselectable
akoreman 6b9b6e7
chore: replace Ace text highlight rules with in-repo function
akoreman c9dd827
Merge branch 'main' into line_wrap
81bc51e
chore: Fix minimum-height and actions absolute positioning
4cd5711
fix: Fix code indentation by setting white-space to pre
1cdc45f
chore: Fix code color and lines Box variant
078fd46
chore: Add multi-line test
d44f75b
Merge branch 'main' into line_wrap
fb13d49
chore: Increase size-limit by 8 bytes
6da84dc
chore: Use logical properties
0658716
chore: Update findContent() test to be backward compatible
73a2b33
Give <table> role="presentation"
gethinwebster e1982b3
feat: add option for line-wrapping to prevent horizontal scrolling
akoreman a6277a0
chore: remove accidentally commited npm script
akoreman d0550ce
fix: make line numbers unselectable
akoreman 529aeb4
chore: replace Ace text highlight rules with in-repo function
akoreman 6741164
chore: Fix minimum-height and actions absolute positioning
4dc0603
fix: Fix code indentation by setting white-space to pre
d746e42
chore: Fix code color and lines Box variant
d3f469e
chore: Add multi-line test
b015fba
chore: Increase size-limit by 8 bytes
b10273d
Give <table> role="presentation"
gethinwebster ceecca6
Increase size limit
gethinwebster f543ac5
Merge branch 'main' into line_wrap
akoreman 323c76f
chore: increase size-limit
akoreman 7929a08
Merge branch 'main' into line_wrap
akoreman ed856c0
Merge remote-tracking branch 'origin/line_wrap_upstream' into line_wrap
akoreman 18ce8bb
small fixes after merging up to main
6e86b8d
small fix after merging up to main
e4c46c7
bump size limit
f300bd1
keep test util backwards compatible
5b7e6e6
small fixes from mistakes made while merging
713e49a
Merge branch 'main' into line_wrap
33411cc
revert highlight function type to return ReactNode
b0659b6
add syntax highlighting example line wrapping page
4fc29e2
small refactor
0dc2c7c
wrap text on pages in Box components
e4b2dae
update parameter jsdoc
4d69e81
update documentation snapshot
3b8ad86
update prop name to wrapLines
3de5396
add word break
df9f1b7
bump size
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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Box, SpaceBetween } from "@cloudscape-design/components"; | ||
|
||
import { CodeView } from "../../lib/components"; | ||
import cppHighlight from "../../lib/components/code-view/highlight/cpp"; | ||
import { ScreenshotArea } from "../screenshot-area"; | ||
|
||
export default function CodeViewPage() { | ||
return ( | ||
<ScreenshotArea> | ||
<h1>Code View</h1> | ||
<SpaceBetween direction="vertical" size="l"> | ||
<Box>No wrapping, no line numbers</Box> | ||
<CodeView | ||
content={`Hello this is a short line.\nHello this is a long line. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\nHello this is another short line.`} | ||
/> | ||
<Box>No wrapping, line numbers</Box> | ||
<CodeView | ||
lineNumbers={true} | ||
content={`Hello this is a short line.\nHello this is a long line. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\nHello this is another short line.`} | ||
/> | ||
<Box>Wrapping, no line numbers</Box> | ||
<CodeView | ||
wrapLines={true} | ||
content={`Hello this is a short line.\nHello this is a long line. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\nHello this is another short line.`} | ||
/> | ||
<Box>Wrapping, line numbers</Box> | ||
<CodeView | ||
wrapLines={true} | ||
lineNumbers={true} | ||
content={`Hello this is a short line.\nHello this is a long line. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\nHello this is another short line.`} | ||
/> | ||
<Box>Full example with indentation and code highlighting</Box> | ||
<CodeView | ||
wrapLines={true} | ||
lineNumbers={true} | ||
highlight={cppHighlight} | ||
content={`void UserQuery(map<string, vector<string> > &svmap) {\n string queryName;\n cout << "Please enter a family name you want to query: ";\n cin >> queryName;\n int i = 0;\n for (map<string, vector<string> >::iterator itr = svmap.begin(), mapEnd = svmap.end(); itr != mapEnd; ++itr) {\n i++;\n if (itr->first == queryName) {\n cout << "The " << itr->first << " family has " << itr->second.size() << " children: ";\n for (vector<string>::iterator itrvec = itr->second.begin(), vecEnd = itr->second.end(); itrvec != vecEnd; ++itrvec)\n cout << *itrvec << " ";\n break;\n }\n }\n if (i >= svmap.size())\n cout << "Sorry, the " << queryName << " family is not found." << endl;\n}`} | ||
/> | ||
<Box>Long word</Box> | ||
<CodeView | ||
wrapLines={true} | ||
lineNumbers={true} | ||
content={`LoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendumLoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendumLoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendumLoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendumLoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendumLoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendumLoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendumLoremipsumdolorsitametconsecteturadipiscingelitCurabitursagittismetusidornarebibendum`} | ||
/> | ||
</SpaceBetween> | ||
</ScreenshotArea> | ||
); | ||
} |
This file contains 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 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 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 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 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 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
Oops, something went wrong.
Oops, something went wrong.
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.
is it necessary for this to be semantically a table? or is this more just to get table layout, in which case could we do that purely with CSS? (thinking about a11y, and whether it makes sense for this to be announced as a "table")
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.
The primary reason for choosing a table here is to align line numbers with their corresponding lines of code, now that we are introducing line-wrapping. Let us consult with A11Y to double-check.