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

Add full-screen code functionality to and remove custom theming from EuiCodeBlock #259

Merged
merged 9 commits into from
Jan 9, 2018

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Jan 3, 2018

This change also removes the .euiCodeBlock--dark and .euiCodeBlock--light classes. If you have CSS selectors which depend upon these classes then your <EuiCodeBlock> instances may appear broken. To reinstate the styles applied by those selectors, you'll have to apply those color values as SCSS color variables.

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Cool. Think we should just add this to the component itself? Seems useful enough to be an optional prop allowFullscreen on EuiCodeBlock?

Stylistically I can clean it up a bit in a separate PR. Functionally I'd add a keydown event for ESC to close it, otherwise works as advertised.

@cjcenizal
Copy link
Contributor Author

Good idea @snide! I'll add that.

@cjcenizal
Copy link
Contributor Author

@snide I made a few changes. Could you take a look?

  • Added full-screen functionality to all code blocks.
  • I changed the way highlighting works so that it adheres to the active theme. I think this makes the most sense in terms of how highlighting colors and theme colors interact.
  • Made a few small adjustments to the way the EuiImage code is formatted.

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Added full-screen functionality to all code blocks.

Think something is up with your focus-trap / ESC combo. Wasn't able to get either working correctly. I could still tab through the original document. That stuff is tricky.

I'll clean up the styling a bit in a separate PR after you've got it in. Off-hand I'll likely make the icon absolutely positioned so it's always around as you scroll, make the coloring a little more monotone and only show the icon on hover of the block.

Made a few small adjustments to the way the EuiImage code is formatted.

Looks good. All your changes are great.

I changed the way highlighting works so that it adheres to the active theme. I think this makes the most sense in terms of how highlighting colors and theme colors interact.

I ... am ok with this, but I'll likely go in after the fact and clean up that light theme. Probably add a border around the block...etc. I think you'll want to ping @bevacqua just to let him know, since I think he was utilizing some theming overwrites and will need to make some changes to cloud.

left: 0;
right: 0;
bottom: 0;
padding: $euiSizeL !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd bump this up a notch since you have so much space to work with.


// Code

$euiCodeBlockBackgroundColor: #F5F5F5 !default;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just $euiColorLightestShade

// Code

$euiCodeBlockBackgroundColor: #F5F5F5 !default;
$euiCodeBlockColor: #3F3F3F !default;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just $euiTextColor. Know these seems small, but saves people from needed to edit multiple vars.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks good catch.

@@ -126,18 +128,18 @@ export class EuiImage extends Component {
return (
<figure
className={classes}
onClick={this.toggleImageFullScreen}
onClick={allowFullScreen ? this.openFullScreen : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

TY. This is a better way to do this.

CHANGELOG.md Outdated
No public interface changes since `0.0.11`.
**Breaking changes**

- Removed `color` prop from `<EuiCodeBlock>`. This component's highlighting now matches whichever theme is currently active. [(#259)](https://github.com/elastic/eui/pull/259)
Copy link
Contributor

Choose a reason for hiding this comment

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

When we do a breaking change like this, can we make it a policy to put upgrade instructions in the PR itself. I think I did that for the last couple, and if not I should be! This ones funny though in that it won't technically break, it should just stylistically change.

Copy link
Contributor Author

@cjcenizal cjcenizal Jan 7, 2018

Choose a reason for hiding this comment

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

I totally agree. Should I just add a note that this may result in a stylistic shift but no change in functionality, since color is now just a no-op? I figure that people will know to remove the use of this prop now that it no longer exists, but I can mention that too if you think we need to be that explicit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. I think we just check on each other when we make merges to add something like the below...

Upgrade path

This PR only changes the look of previous code blocks and does not require any changes if you are OK with the new styling. It will however break styling if you were applying custom code block themes beyond the default values. To retain that custom coloring, you'll want to apply those color values to the colors.scss files directly now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh I think I get it! You mean we need to update the CHANGELOG with fallout caused by breaking changes to the SCSS, too right? I completely overlooked that, so thanks for pointing it out. I just pushed an update, let me know if I need to adjust it.

@cjcenizal
Copy link
Contributor Author

@snide Thanks for the solid feedback. I addressed your notes, could you take another look? I also added Nico as a reviewer, thanks for that suggestion. Your style improvements sound great. This PR was pretty quick-and-dirty from a design standpoint.

@cjcenizal cjcenizal changed the title Add full-screen code example functionality. Add full-screen code example functionality and default theming. Jan 8, 2018
@cjcenizal cjcenizal changed the title Add full-screen code example functionality and default theming. Add full-screen code example functionality and remove custom theming. Jan 8, 2018
@cjcenizal cjcenizal changed the title Add full-screen code example functionality and remove custom theming. Add full-screen code functionality to and remove custom theming from EuiCodeBlock Jan 8, 2018
@cjcenizal cjcenizal merged commit 165fb28 into elastic:master Jan 9, 2018
@cjcenizal cjcenizal deleted the docs/full-screen-code branch January 9, 2018 20:03
@cjcenizal
Copy link
Contributor Author

@uboness You can rebase master to get the full screen code example functionality now.

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