-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
CSF: Transform CSF named exports w/ makeDisplayName
#7878
Conversation
This pull request is automatically deployed with Now. |
lib/client-api/src/client_api.ts
Outdated
@@ -82,6 +83,8 @@ const withSubscriptionTracking = (storyFn: StoryFn) => { | |||
return result; | |||
}; | |||
|
|||
export const defaultDisplayName = key => startCase(key); |
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.
src/client_api.ts(86,35): error TS7006: Parameter 'key' implicitly has an 'any' type.
UPDATE: @ndelangen has suggested an alternative where instead of changing the |
Should we really mark it as a breaking change if it only affects functionality from beta? |
@Hypnosphi Good point. I've created a new label, |
lib/client-api/src/client_api.ts
Outdated
@@ -123,6 +126,10 @@ export default class ClientApi { | |||
this._globalParameters.options | |||
); | |||
|
|||
getDisplayName = () => |
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 returns a function?
I think this method name is misleading
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.
makeGetDisplayName
displayName
optionmakeDisplayName
option
makeDisplayName
optionmakeDisplayName
option
makeDisplayName
optionmakeDisplayName
Thanks @shilman! Apologies for not getting back to the PR. 🙇 |
@kevinSuttle My pleasure. Thanks for conceiving this feature -- it's huge for CSF ergonomics |
Unfortunately, this is what actually happens now in a couple of corner cases like following:
Oddly enough, It's even worse in case of collision, when |
You can currently control the ID and display name independently, though there is no way to get a reserved keyword as the ID. do you have any suggestions for how to do it differently? We might be able to change in 6.0 |
Honestly, it brings more confusion than value. Here's my suggestion: |
@ndelangen wants the ID to be controlled by the named export for monoconfig. Won't make any changes until we make sure they are compatible with what he needs |
Another example of ID change after applying transform: #8000 (comment) |
I'm fine with that, monoconfig won't be happening before 6.0 anyway |
Issue: #7599
What I did
options.makeDisplayName
parameterlodash.startCase
Examples (input => output):
This dramatically improves the ergonomics of CSF (thanks @kevinSuttle!!) but is disruptive to anybody who's already using CSF. Moreover it will be expensive to change in the future so I really want to get this right. Feedback wanted.
Other options I considered:
How to test
Source.stories.tsx
change and output inofficial-storybook
yarn test --testPathPattern client_api.test.ts