-
Notifications
You must be signed in to change notification settings - Fork 11
feat: allow user to configure default string and separator for dislay… #844
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
Codecov Report
@@ Coverage Diff @@
## main #844 +/- ##
==========================================
- Coverage 85.46% 85.46% -0.01%
==========================================
Files 796 796
Lines 16299 16298 -1
Branches 1937 1937
==========================================
- Hits 13930 13929 -1
Misses 2337 2337
Partials 32 32
Continue to review full report at Codecov.
|
@@ -5,7 +5,7 @@ import { displayStringEnum } from './display-string-enum'; | |||
name: 'htDisplayStringEnum' | |||
}) | |||
export class DisplayStringEnumPipe implements PipeTransform { | |||
public transform(value: string): string { | |||
return displayStringEnum(value); | |||
public transform(value?: string, unknown: string = '-', separator: string = ' '): string { |
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.
variable naming: unknown
shouldn't be used as it's a type - is that the defaulttValue
or similar?
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.
Fixed.
This comment has been minimized.
This comment has been minimized.
// We only want the first word capitalized. | ||
return `${startCased[0]}${startCased.substr(1).toLowerCase()}`; | ||
return `${startCasedSeparated[0]}${startCasedSeparated.substr(1).toLowerCase()}`; |
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 feel like I commented on this at the time but who knows:
return `${startCasedSeparated[0]}${startCasedSeparated.substr(1).toLowerCase()}`; | |
return capitalize(startCasedSeparated); |
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.
You did, but that doesn't work for certain use cases and I don't feel the alternative you provided is really any cleaner than this.
https://github.com/hypertrace/hypertrace-ui/pull/752/files#r609080471
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'm confused - you said in that linked comment you agreed that startCase(lowerCase(provided))
is cleaner, but it looks like it got merged without making that change. What use case isn't supported?
Here, I was just suggesting capitalize which is a 1:1 replacement of the explicit impl on line 14, but using
return capitalize(lowerCase(provided)).replace(' ', separator);`
to replace lines 8-14 I think is even better.
This change allows
displayStringEnum
to have its default value and separator configured through args.