-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: allow custom help text class #761
Merged
petermakowski
merged 1 commit into
canonical:main
from
petermakowski:allow-custom-help-text-class
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ import Input from "./Input"; | |
type: "text", | ||
}, | ||
}, | ||
helpClassName: { | ||
control: { | ||
type: "text", | ||
}, | ||
}, | ||
label: { | ||
control: { | ||
type: "text", | ||
|
@@ -67,6 +72,7 @@ An input field where the user can enter data, which can vary in many ways, depen | |
placeholder: "[email protected]", | ||
label: "Email address", | ||
help: "Additional description for the field", | ||
helpClassName: "u-no-margin--bottom", | ||
}} | ||
> | ||
{Template.bind({})} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would be good to have some convention for adding those child class names, I think some other components do it as well (don't remember which one).
Not sure how detailed or strict we want to be on which elements have configurable class name and which don't. But at least some prop naming convention would be good.
elementClassName
seems fine for start (and consistency with defaultclassName
.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.
Agreed that this is needed (and I like your suggested naming convention).
I think we should have a common way of translating base/modifier classes that exist in vanilla to props in
react-components
as well, e.g. thehelp
prop inInput
should probably be namedformHelpText
instead to matchp-form-help-text
from Vanilla. There are many examples for inconsistencies like that.This would make working with react-components more intuitive for people who are already familiar with the vanilla framework (and vice-versa).
If we agree on a naming convention it might be worth updating all components props at some point even though there will be breaking changes.
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 created an issue for this #762
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.
Considering that the related element in vanilla has a base class
p-form-help-text
, would you consider a name of the element to beformHelpText
? That would result informHelpTextClassName
instead ofhelpClassName
.A bit lengthy, but I don't think that matters - having prop names that are long but consistent is much better than having props that are shorter but different in vanilla and react-components.
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.
Unfortunately form components in Vanilla have very inconsistent and lengthy names. There is no "p-form", but we do have "p-form-others"… and there are more issues like that, so forms are definitely not something we should base the naming convention on 😆
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.
Okay, should we go with my initial suggestion (
helpClassName
) then? It's consistent with the relatedhelp
prop that already exists on this component.