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 setStyle utility #9

Merged
merged 1 commit into from Nov 30, 2016
Merged

Add setStyle utility #9

merged 1 commit into from Nov 30, 2016

Conversation

cristiano-belloni
Copy link

Description

This PR adds the setStyle utility, which adds a CSS rule in the head of the current document.

Motivation and Context

This is factored out from the grid and added here as a general-purpose utility. setStyle is particularly useful when we have a lot of heterogeneous elements (e.g. grid cells) and we want to change the appearance of them all without selecting them and changing each of them.
One practical example I'm using this for is highlighting the grid columns in a "cross-hairs" fashion on hover: it can't be done via CSS and doing that the traditional way would involve selecting all the cells in the column on mouseEnter and mouseLeave + adding or removing a class for each of them.
setStyle does the same job by efficiently changing only its dedicated <style> element.

How Was This Tested?

Manually, on the examples sandbox.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change follows the style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the contribution guidelines
  • I have added tests to cover my changes
  • All new and existing tests passed

Copy link
Contributor

@gabrielmontagne gabrielmontagne left a comment

Choose a reason for hiding this comment

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

Good stuff. Thanks. I think it's good to have it out here.
Will create an issue on the grid to use this instead of its own internal organelle.

@gabrielmontagne gabrielmontagne merged commit 16abbe1 into master Nov 30, 2016
@gabrielmontagne gabrielmontagne deleted the implement-set-style branch November 30, 2016 15:48
@gabrielmontagne
Copy link
Contributor

v3.5.0 with this change has been published to npm : ) thanks all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants