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

feat(Label): truncate by default #8771

Merged

Conversation

gitdallas
Copy link
Contributor

@gitdallas gitdallas commented Mar 2, 2023

@patternfly-build
Copy link
Contributor

patternfly-build commented Mar 2, 2023

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Discussed offline, but left a comment about

  • removing isTruncated
  • adding a prop for a custom truncation length

Also these conditionals should no longer be needed. We can just include the top block - the span.pf-c-label__text wrapping {children}

{isTruncated && (
<span ref={textRef} className={css(styles.labelText)}>
{children}
</span>
)}
{!isTruncated && children}

packages/react-core/src/components/Label/Label.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Just a couple of test updates that I didn't catch before, otherwise LGTM!

@tlabaj tlabaj requested a review from mmenestr March 3, 2023 18:20
@tlabaj tlabaj requested a review from mcarrano March 3, 2023 18:20
@mattnolting mattnolting self-requested a review March 3, 2023 18:29
Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

is there no default value for the --pf-c-label__text--MaxWidth variable? this PR is named 'truncate by default' but if it needs textMaxWidth prop, then it's not default?

@gitdallas
Copy link
Contributor Author

@nicolethoen - i believe it could still truncate due to other constraints limiting the size. @mcoker thoughts?

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

Why are the removable and non-removable labels in the examples displaying at different heights?

Screenshot 2023-03-03 at 1 57 05 PM

@gitdallas
Copy link
Contributor Author

gitdallas commented Mar 3, 2023

@mcarrano - there is another PR to address label/chip restructure, i could rebase this after that one is merged in

@mattnolting
Copy link
Contributor

mattnolting commented Mar 3, 2023

Why are the removable and non-removable labels in the examples displaying at different heights?

Screenshot 2023-03-03 at 1 57 05 PM

@mcarrano bc the global reset (which was removed) adds padding: 0 margin: 0 to [class*=pf-c-], which applies to buttons. There are buttons inside of those labels.

@gitdallas
Copy link
Contributor Author

gitdallas commented Mar 3, 2023

@mcarrano @mattnolting - here's the PR for that: #8773

i'll rebase this on that once it gets merged.

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Other than a non-blocker below and other comments that have been left, only other thing is whether it'd be worth adding a label to show the default truncation without textMaxWidth passed in. That also isn't a blocker, though.

packages/react-core/src/components/Label/Label.tsx Outdated Show resolved Hide resolved
@mcoker
Copy link
Contributor

mcoker commented Mar 3, 2023

@nicolethoen - i believe it could still truncate due to other constraints limiting the size. @mcoker thoughts?

Correct, it will truncate by default now when it runs out of space in its container. Setting the textMaxWidth prop allows for a custom width.

@gitdallas gitdallas force-pushed the feat/8258-labels-truncate-default branch from 026d986 to 10ce0f8 Compare March 3, 2023 20:34
Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

This looks good now. I agree with @thatblindgeye that it would be nice to have an example that explicitly shows the effect of adding a maxWidth, but not a blocker.

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

one small nit on a test

@@ -86,7 +86,7 @@ describe('Label', () => {

test('label with truncation', () => {
const { asFragment } = render(
<Label isTruncated>Something very very very very very long that should be truncated</Label>
<Label textMaxWidth="16c">textMaxWidth set at 16h on this very long label that should be truncated</Label>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Label textMaxWidth="16c">textMaxWidth set at 16h on this very long label that should be truncated</Label>
<Label textMaxWidth="16ch">textMaxWidth set at 16ch on this very long label that should be truncated</Label>

@@ -90,7 +90,7 @@ export const Label: React.FunctionComponent<LabelProps> = ({
isCompact = false,
isEditable = false,
editableProps,
isTruncated = false,
textMaxWidth = '',
Copy link
Contributor

@tlabaj tlabaj Mar 3, 2023

Choose a reason for hiding this comment

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

Should this be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well line 218 is a falsy check, but i don't see why we couldn't just let this be undefined

@gitdallas
Copy link
Contributor Author

@mcarrano @thatblindgeye - sorry i must have missed that comment, added an example of a parent-constrained label https://patternfly-react-pr-8771.surge.sh/components/label/

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

@nicolethoen nicolethoen merged commit df52d2d into patternfly:v5 Mar 4, 2023
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-code-editor@5.0.0-alpha.25
  • @patternfly/react-core@5.0.0-alpha.25
  • @patternfly/react-docs@6.0.0-alpha.28
  • demo-app-ts@5.0.0-alpha.8
  • @patternfly/react-integration@5.0.0-alpha.4
  • @patternfly/react-table@5.0.0-alpha.25

Thanks for your contribution! 🎉

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

Successfully merging this pull request may close these issues.

Labels should truncate by default
8 participants