diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a2cc60453c..54ed2a2927e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # [`master`](https://github.com/elastic/eui/tree/master) -- Changed the hover states of `EuiButtonEmpty` to look more like links. +- Changed the hover states of `EuiButtonEmpty` to look more like links. [#135](https://github.com/elastic/eui/pull/135) +- Added `transparentBackground` prop to `EuiCodeBlock`. Made light theme the default. +`EuiCode` now just wraps `EuiCodeBlock` so you can do inline highlighting. [#138](https://github.com/elastic/eui/pull/138) # [`0.0.1`](https://github.com/elastic/eui/tree/v0.0.1) Initial Release diff --git a/src-docs/src/views/code/code.js b/src-docs/src/views/code/code.js index 43c935b84e9..9d33eafab4a 100644 --- a/src-docs/src/views/code/code.js +++ b/src-docs/src/views/code/code.js @@ -5,8 +5,22 @@ import { EuiText, } from '../../../../src/components'; +const htmlCode = ` +
Sometimes you need to highlight
+ Sometimes you need to emphasize
+ You can also pass a language in like
+ Make the background transparent like this
- Description needed: how to use the
+
+
+
+
+
`;
diff --git a/src/components/code/_code.scss b/src/components/code/_code.scss
deleted file mode 100644
index 3cb49d44773..00000000000
--- a/src/components/code/_code.scss
+++ /dev/null
@@ -1,10 +0,0 @@
-.euiCode {
- @include euiCodeFont;
- display: inline-block;
- white-space: pre;
- background: $euiColorLightestShade;
- color: $euiColorAccent;
- border: $euiBorderThin;
- font-size: $euiFontSizeXS;
- padding: 0 $euiSizeXS;
-}
diff --git a/src/components/code/_code_block.scss b/src/components/code/_code_block.scss
index 1d588d406b1..377161b17d2 100644
--- a/src/components/code/_code_block.scss
+++ b/src/components/code/_code_block.scss
@@ -1,7 +1,9 @@
.euiCodeBlock {
+ display: block;
overflow: auto;
.euiCodeBlock__pre {
+ display: block;
white-space: pre-wrap;
}
@@ -35,4 +37,26 @@
&.euiCodeBlock--paddingLarge {
padding: $euiSizeL;
}
+
+ /**
+ ** 1. Size the code against the text its embedded within.
+ **/
+ &.euiCodeBlock--inline {
+ vertical-align: middle;
+ display: inline-block;
+ white-space: pre;
+ color: $euiTextColor;
+ font-size: 75%; // 1
+ padding: 0 $euiSizeXS;
+ background: $euiColorLightestShade;
+
+ .euiCodeBlock__pre, .euiCodeBlock__code {
+ display: inline;
+ white-space: normal;
+ }
+ }
+
+ &.euiCodeBlock--transparentBackground {
+ background: transparent;
+ }
}
diff --git a/src/components/code/_code_block_light.scss b/src/components/code/_code_block_light.scss
index 392f94b63e6..e578c8f60a9 100644
--- a/src/components/code/_code_block_light.scss
+++ b/src/components/code/_code_block_light.scss
@@ -1,3 +1,4 @@
+
.euiCodeBlock--light {
background: #F5F5F5;
color: #3F3F3F;
diff --git a/src/components/code/_index.scss b/src/components/code/_index.scss
index a893d614186..e3793b9f58c 100644
--- a/src/components/code/_index.scss
+++ b/src/components/code/_index.scss
@@ -1,4 +1,3 @@
-@import 'code';
@import 'code_block';
@import 'code_block_dark';
@import 'code_block_light';
diff --git a/src/components/code/code.js b/src/components/code/code.js
index eae52f22f9d..127c6c4e284 100644
--- a/src/components/code/code.js
+++ b/src/components/code/code.js
@@ -2,20 +2,24 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
+import {
+ EuiCodeBlock,
+} from '../../components';
+
export const EuiCode = ({
children,
className,
...rest
}) => {
- const classes = classNames('euiCode', className);
+ const classes = classNames('euiCodeBlock--inline', className);
return (
-
{children}
-
+
+
{ this.code = ref; }}
className={codeClasses}
@@ -88,8 +92,8 @@ export class EuiCodeBlock extends Component {
>
{children}
-
-