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

Automatically add data-cy and displayName classNames #40

Merged
merged 3 commits into from
Apr 8, 2019

Conversation

ItsJonQ
Copy link
Contributor

@ItsJonQ ItsJonQ commented Mar 1, 2019

Automatically add data-cy and displayName classNames

This update enhances the styled() factory to provide the component with
data-cy and a css-j21lkjf-COMPONENT_NAME className, if applicable.

data-cy will be added if the Component has a displayName or a name.
HTML Tags like span or div will not receive data-cy.

The displayName className will be added to all components. This is purely
for identification/debugging purposes. No actual styles will be associated
with these classNames.

Example:

<div data-cy="Card" class="card css-ko0v5 css-ko0v5-Card edlacb0">Card</div>

Jon Q added 2 commits March 1, 2019 12:39
This update enhances the `styled()` factory to provide the component with
`data-cy` and a `css-j21lkjf-COMPONENT_NAME` className, if applicable.

`data-cy` will be added if the Component has a `displayName` or a `name`.
HTML Tags like `span` or `div` will not receive `data-cy`.

The displayName className will be added to all components. This is purely
for identification/debugging purposes. No actual styles will be associated
with these classNames.
@ItsJonQ ItsJonQ added the enhancement New feature or request label Mar 1, 2019
@ItsJonQ ItsJonQ self-assigned this Mar 1, 2019
@@ -17,23 +17,6 @@ const Thing = styled('div')`
`

class Test extends React.Component {
componentDidMount() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer relevant

@coveralls
Copy link

coveralls commented Mar 1, 2019

Pull Request Test Coverage Report for Build 233

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 232: 0.0%
Covered Lines: 85
Relevant Lines: 85

💛 - Coveralls

@ItsJonQ
Copy link
Contributor Author

ItsJonQ commented Mar 5, 2019

cc'ing @ryan-mulrooney , as I think you'd be interested in this :)

package.json Outdated
@@ -66,11 +66,11 @@
"devDependencies": {
"@helpscout/hsds-react": "^2.5.6",
"@helpscout/zero": "^2.0.5",

Choose a reason for hiding this comment

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

Would it be worth it to update to Zero 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tinkertrain Zero@3 broke build of Fancy :(

#42

I have a working fix for it :). Tracking the issue down took a while, but the solution isn't too bad

@@ -63,7 +63,7 @@ type EmotionOptions = {
}

function createEmotion(
context: {__SECRET_FANCY_EMOTION__?: Emotion},
context: { __SECRET_FANCY_EMOTION__?: Emotion },

Choose a reason for hiding this comment

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

What would a "Secret Fancy Emotion" be? "Elated", "Discombobulated"? Don't mind me it's Friday

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hahaha... it's a secret ;)

For context... By default, Emotion generates a global variable called __SECRET_EMOTION__. We had an issue where a Fancy powered app (Beacon2) rendered into a user environment that happened to use Emotion as well.

Because of this... our modified version of Emotion broke their Emotion 😅

So! To prevent this from happening, we created our own __SECRET_FANCY_EMOTION__ namespace :)

@ItsJonQ
Copy link
Contributor Author

ItsJonQ commented Apr 8, 2019

Will follow up with this!! This would be handy to add in 💪 .

Minor bump for sure!

@ItsJonQ
Copy link
Contributor Author

ItsJonQ commented Apr 8, 2019

@knicklabs + @tinkertrain Thanks for the review!!!

@ItsJonQ ItsJonQ merged commit 8c25169 into master Apr 8, 2019
@netlify
Copy link

netlify bot commented Apr 8, 2019

Deploy preview for hs-fancy ready!

Built with commit 9e9fedc

https://deploy-preview-40--hs-fancy.netlify.com

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

Successfully merging this pull request may close these issues.

None yet

4 participants