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

Added option to wrap lines in EuiCodeBlock #3103

Merged
merged 20 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `wrapLines` prop to `EuiCodeBlock` ([#3103](https://github.com/elastic/eui/pull/3103))
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
- Added `Enter` key press functionality to `EuiSuperDatePicker` ([#3048](https://github.com/elastic/eui/pull/3048))

## [`21.1.0`](https://github.com/elastic/eui/tree/v21.1.0)
Expand Down
1 change: 1 addition & 0 deletions src/components/code/_code_block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
position: relative;
background: $euiCodeBlockBackgroundColor;
color: $euiCodeBlockColor;
white-space: nowrap;
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved

.euiCodeBlock__pre {
@include euiScrollBar;
Expand Down
9 changes: 9 additions & 0 deletions src/components/code/_code_block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ interface Props {
overflowHeight?: number;
paddingSize: PaddingSize;
transparentBackground: boolean;
/**
* specify how white-space inside the element is handled
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
*/
whiteSpace?: 'nowrap' | 'normal' | 'pre';
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
}

interface State {
Expand Down Expand Up @@ -152,6 +156,7 @@ export class EuiCodeBlockImpl extends Component<Props, State> {
paddingSize,
transparentBackground,
isCopyable,
whiteSpace,
...otherProps
} = this.props;

Expand All @@ -175,6 +180,10 @@ export class EuiCodeBlockImpl extends Component<Props, State> {
optionalStyles.maxHeight = overflowHeight;
}

if (whiteSpace) {
optionalStyles.whiteSpace = whiteSpace;
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
}

const codeSnippet = (
<code
ref={ref => {
Expand Down