-
Notifications
You must be signed in to change notification settings - Fork 377
feat(tooltip): allow tooltip text to be left-aligned #3053
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
Conversation
|
PatternFly-React preview: https://patternfly-react-pr-3053.surge.sh |
Codecov Report
@@ Coverage Diff @@
## master #3053 +/- ##
==========================================
- Coverage 69.02% 69.02% -0.01%
==========================================
Files 858 858
Lines 23413 23416 +3
Branches 1853 1854 +1
==========================================
+ Hits 16160 16162 +2
- Misses 6333 6334 +1
Partials 920 920
Continue to review full report at Codecov.
|
|
Very close to CI passing: |
| /** Tooltip trigger: click, mouseenter, focus, manual */ | ||
| trigger?: string; | ||
| /** Flag to indicate that the text content is left aligned */ | ||
| isContentLeftAligned?: boolean; |
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.
Why only support a left aligned option? What if designers want to support right-aligned content, next?
Even if we don't support right-aligned content for now, something more like this would scale better in the future.
contentPosition?: 'bottom' | 'center' | 'right';
Then we could create an enum
export enum TooltipContentPosition {
bottom = 'bottom',
center = 'center',
right = 'right'
}
Looks like we already take this approach for the position property.
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.
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.
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 wasn't necessarily asking for right-aligned tooltips, just that we use a property that is more scalable. Once we introduce the isContentLeftAligned prop, it will be difficult to change without a breaking change. That's why I suggested we use something more like the existing position property.
I just want to consider a use case where we end up with both isContentLeftAligned and isContentRightAligned props together? Or, would it be better to have something more like contentPosition?: 'bottom' | 'center' | 'right' where we can easily add future support.
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.
Dan makes good point here. I don't think there are plans of introducing the right aligned variant and the naming here seems to be consistent with other components. That being said those components would be hard to change if we added another variant.
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.
@tlabaj Thank you for your feedback! Does that mean I should change the prop to look like contentPosition?: 'left' | 'center'? Or did you mean that this PR is okay the way it is?
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.
If you don't feel we'll ever have another variant, I'm fine leaving it as is. Just wanted to raise the question.
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.
@jenny-s51 I think we should use contentPosition?: 'left' | 'center'. It's also consistent with the position enum we are already using in this component. Can we change it to that?
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.
@jenny-s51 I like what @dlabrecq suggested. But, if we are not going to have a right alignment variation I don't see the need to introduce the inconstancy. We have at least one other component that uses isLeftAligned (or similar).
@mcarrano can you verify that there is no intent on introducing a right aligned variant.
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 see no reason to support right-aligned tooltips.
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.
LGTM, unused import doesn't affect anything.
| cssPrefix: 'pf-c-tooltip' | ||
| typescript: true | ||
| propComponents: ['Tooltip'] | ||
| propComponents: ['Tooltip', 'TooltipContent'] |
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.
Good catch, we export TooltipContent in Tooltip/index.ts but don't show its props in the docs.
Edit: We should add a followup issue to provide examples on how/why to use TooltipContent.
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.
All set! #3088
| --- | ||
|
|
||
| import { Button, Tooltip, TooltipPosition, Checkbox } from '@patternfly/react-core'; | ||
| import { Button, Tooltip, TooltipPosition, TooltipContent, Checkbox } from '@patternfly/react-core'; |
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.
Unused import.
mcoker
left a comment
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.
lgtm, thanks @jenny-s51!!
dlabaj
left a comment
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.
Can you update this to use contentPosition?: 'left' | 'center'`
| /** Tooltip trigger: click, mouseenter, focus, manual */ | ||
| trigger?: string; | ||
| /** Flag to indicate that the text content is left aligned */ | ||
| isContentLeftAligned?: boolean; |
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.
@jenny-s51 I think we should use contentPosition?: 'left' | 'center'. It's also consistent with the position enum we are already using in this component. Can we change it to that?
dlabaj
left a comment
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.
After looking at what we do elsewhere it seems we should go with IsContentLeftAligned. We only seem to use the enum when there are more than one style, and we are using IsLeftAligned elsewhere through out the product.
will close #3013