-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Prefixes fixes #453
Prefixes fixes #453
Conversation
* master: 4.0.0-beta.11 Transpile nano-css to fix IE11 4.0.0-beta.10
I wasn't sure if we needed prefixes for the modal. Would you have two tours running at the same time? |
@@ -9,6 +9,8 @@ | |||
} | |||
|
|||
function setupShepherd() { | |||
var prefix = 'demo-'; | |||
var buttonSecondaryClass = prefix + 'shepherd-button-secondary'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the demo code, we shouldn't need to do anything here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have styling for this class as part of the library here: https://github.com/shipshapecode/shepherd/blob/master/src/js/styles/generateStyles.js#L46
So it's not a regular custom class like other 'class 1' class 2', etc
So it should be prefixed as well.
@@ -43,7 +45,7 @@ export function generateStyles(options) { | |||
'&:hover': { | |||
background: darken(0.1, variables.shepherdThemePrimary) | |||
}, | |||
'&.shepherd-button-secondary': { | |||
[`&.${classPrefix}shepherd-button-secondary`]: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is not generated by shepherd, but passed in as a custom class, so I don't think it should get prefixes, unless we want to support secondary buttons, which maybe we should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the style is still part of the library, so I think it should be prefixes like all the others.
I do believe it would be more intuitive, instead of having a "hidden" class for secondary button, to have a more expressive way of setting a button as secondary via configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely agree. We should expose an option to make a button secondary.
@genadis have you tried the code without these changes and hit issues? I think we have all the prefixes we need, more or less, due to nesting of things etc. |
We have to have prefixes to all the classes, so if adding this support is not an option we would have to maintain a separate fork :( The reasoning is:
Consider the following: .app-a .shepherd-target {
background-color: red;
} App A owner is not bound to any styling constraints. He can just add plain css to his site, we have no control over it (in our cases it's third party application/page). On the other hand if we prefix everything the above will not effect App B custom built shepherd version which will have
This doesn't add any complexity to the library, and keeps consistency, so it would be great if this could be merged. |
The styling collision I've described in my previous comment are based on the extensive experience we had integrating our product on various systems. So it really is a necessity for us to prevent future issues before they occur. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overall looks good, don't worry, we'll get all the prefixes in 😃
@genadis would you perhaps be open to helping write some tests for adding prefixes to ensure all the things are properly prefixed when you expect them to be? This will help us ensure this functionality does not break in the future.
src/js/utils/general.js
Outdated
if (typeof prefix !== 'string' || prefix === '') { | ||
return ''; | ||
} | ||
if (prefix.charAt(prefix.length - 1) !== '-') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we could simplify this method to:
if(!isString(prefix) || prefix === '') {
return '';
}
return prefix.endsWith('-') ? prefix : `${prefix}-`;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've simplified.
but endsWith
is not supported by IE11 using additional polifill just for this line seems too much.
@@ -164,20 +166,20 @@ export function generateStyles(options) { | |||
'&[x-placement^="top"]': { | |||
marginBottom: arrowMargin, | |||
|
|||
'.tippy-arrow': { | |||
[`.${tippyPrefix}tippy-arrow`]: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While maintaining a separate classPrefix
and tippyPrefix
is technically okay, I'm curious, do you have a need for them to be different or could they both be demo-
? etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess practically they would be the same, but we still need option to choose if to prefix tippy or not (separate from the shepherd prefix).
specifically for our use case, it will always be the same, but some users of this project might have different more loose requirement. we don't want to enforce them using custom tippy build if they want to just prefix the shepherd.
great news! |
@genadis I am going to go ahead and merge this, then I am going to work on exposing the secondary button stuff. I will also try to write some tests for the prefixes. |
* master: Cleanup some issues from prefixing Prefixes fixes (shipshapecode#453)
@rwwagner90 This pull request contains some fixes related to prefixes.
There are a few more things to fix, which I'll do in separate pull requests (or maybe you will beat me to it):