Skip to content

Commit

Permalink
code cleanup, more padding for controls
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankeairns committed Feb 13, 2019
1 parent 033b531 commit 802db77
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src-docs/src/components/guide_section/guide_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class GuideSection extends Component {
super(props);

this.componentNames = Object.keys(props.props);
this.hasSnippet = 'snippet' in props;
const hasSnippet = 'snippet' in props;

this.tabs = [{
name: 'demo',
Expand All @@ -101,7 +101,7 @@ export class GuideSection extends Component {
isCode: true,
}];

if (this.hasSnippet) {
if (hasSnippet) {
this.tabs.push({
name: 'snippet',
displayName: 'Snippet',
Expand Down
28 changes: 16 additions & 12 deletions src/components/code/_code_block.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,21 @@ export class EuiCodeBlockImpl extends Component {
copyButton = (
// TODO add i18n
<div className="euiCodeBlock__copyButton">
<EuiCopy textToCopy={children}>
{(copy) => (
<EuiButtonIcon
size="s"
onClick={copy}
iconType="copy"
color="text"
aria-label="Copy"
/>
<EuiI18n token="euiCodeBlock.copyButton" default="Copy">
{copyButton => (
<EuiCopy textToCopy={children}>
{(copy) => (
<EuiButtonIcon
size="s"
onClick={copy}
iconType="copy"
color="text"
aria-label={copyButton}
/>
)}
</EuiCopy>
)}
</EuiCopy>
</EuiI18n>
</div>
);
}
Expand Down Expand Up @@ -194,8 +198,8 @@ export class EuiCodeBlockImpl extends Component {
if (copyButton || fullScreenButton) {
codeBlockControls = (
<div className="euiCodeBlock__controls">
{copyButton}
{fullScreenButton}
{copyButton}
</div>
);
}
Expand Down Expand Up @@ -277,7 +281,7 @@ EuiCodeBlockImpl.propTypes = {
inline: PropTypes.bool,

/**
* Displays an icon button that copies the code snippet to your clipboard.
* Displays an icon button to copy the code snippet to the clipboard.
*/
isCopyable: PropTypes.bool,
};
Expand Down
18 changes: 11 additions & 7 deletions src/components/code/_code_block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
color: $euiCodeBlockColor;

.euiCodeBlock__pre {
@include euiScrollBar;
height: 100%;
overflow: auto;
display: block;
white-space: pre-wrap;
// sass-lint:disable-block no-important
padding-right: $euiSizeXXL !important; // Space for controls
}

.euiCodeBlock__code {
Expand All @@ -18,19 +21,19 @@
font-weight: $euiFontWeightRegular;
}

.euiCodeBlock__fullScreenButton + .euiCodeBlock__copyButton {
margin-top: $euiSizeXS;
}

.euiCodeBlock__copyButton {
background-color: $euiColorLightestShade;
}

.euiCodeBlock__controls {
position: absolute;
top: $euiSizeM;
right: $euiSize;
}

.euiCodeBlock__copyButton,
.euiCodeBlock__fullScreenButton {
display: inline-block;
right: $euiSizeM;
width: $euiSizeL;
}

&.euiCodeBlock-isFullScreen {
Expand All @@ -41,7 +44,8 @@
bottom: 0;

.euiCodeBlock__pre {
padding: $euiSizeXL !important; // sass-lint:disable-line no-important
// sass-lint:disable-block no-important
padding: $euiSizeXL !important;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/components/code/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ declare module '@elastic/eui' {
overflowHeight?: number;
fontSize?: FontSize;
transparentBackground?: boolean;
isCopyable?: boolean;
}


Expand Down

0 comments on commit 802db77

Please sign in to comment.