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

EuiCode now consumes EuiCodeBlock and can highlight text #138

Merged
merged 7 commits into from
Nov 10, 2017

Conversation

snide
Copy link
Contributor

@snide snide commented Nov 10, 2017

Needed this for some concepts I'm working on for Discover. This also defaults the theme to the light coloring, since I seem to be the minority in the dark theming.

  • EuiCode now consumes EuiCodeBlock.
  • EuiCode now can carry syntax highlighting. Further, the default coloring was changed.
  • Defaults to light theme

For a later PR

  • I need to pass the overall EUI theme state to these components so they know which theme to use properly. For now it works fine, but is not optimal.

image

image

@snide snide requested a review from bevacqua November 10, 2017 17:35
CHANGELOG.md Outdated
@@ -1,6 +1,7 @@
# [`master`](https://github.com/elastic/eui/tree/master)

- Changed the hover states of `EuiButtonEmpty` to look more like links.
- Added `inline` and `transparentBackground` props to `EuiCodeBlock`. Made light theme the default.
Copy link
Contributor

@bevacqua bevacqua Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Team light theme wins! Can I get a link to the PR at the end of this line? Same ask as in the other PR:

- Added `inline` and `transparentBackground` props to `<EuiCodeBlock>`. [(#138)](https://github.com/elastic/eui/pull/138)
- The default `<EuiCodeBlock>` `theme` prop value is now `light`. [(#138)](https://github.com/elastic/eui/pull/138)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I specifically didn't add them because your example docs didn't have them 🗡

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shall fix that

},
{
'euiCodeBlock--inline': inline,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loving this. I think the transparentBackground default should be smart: if it's not set, can we use inline === true instead?

That'd be:

{
  'euiCodeBlock--inline': inline,
  'euiCodeBlock--transparentBackground': typeof transparentBackground === 'boolean'
    ? transparentBackground
    : inline,
}

@snide
Copy link
Contributor Author

snide commented Nov 10, 2017

@bevacqua OK. Ready for review again.

@@ -1,3 +1,4 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove!

<code
<EuiCodeBlock
transparentBackground={transparentBackground}
language={language}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to mention language or transparentBackground explicitly, since they are taken care of by ...rest. Same goes for the propType

<pre className="euiCodeBlock__pre">
<code
<span className="euiCodeBlock__pre">
<span
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we keep <pre> and <code> because semantics?

Copy link
Contributor Author

@snide snide Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React spits out errors if <pre> tags live within text content. I guess I can keep code though.

Copy link
Contributor

@bevacqua bevacqua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@snide snide changed the title inline and transparentBackground props added to code block EuiCode now consumes EuiCodeBlock and can highlight text Nov 10, 2017
@snide snide merged commit 98010b5 into elastic:master Nov 10, 2017
@snide snide deleted the inline_code branch November 10, 2017 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants