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
UI: Remove unused & duplicated code #11155
Conversation
@@ -200,7 +203,10 @@ class ShortcutsScreen extends Component<ShortcutsScreenProps, ShortcutsScreenSta | |||
|
|||
this.setState({ | |||
activeFeature: focusedInput, | |||
shortcutKeys: { ...shortcutKeys, [focusedInput]: { shortcut: null, error: false } }, | |||
shortcutKeys: { |
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.
Auto formatted on pre-commit hook
lib/ui/src/containers/menu.tsx
Outdated
@@ -3,7 +3,7 @@ import React, { useMemo } from 'react'; | |||
import { Badge } from '@storybook/components'; | |||
import { API } from '@storybook/api'; | |||
|
|||
import { shortcutToHumanString } from '../libs/shortcut'; | |||
import { shortcutToHumanString } from '@storybook/api/dist/lib/shortcut'; |
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.
we shouldn't be importing from dist
. can you export these from @storybook/api/shortcut
maybe?
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.
To be able use the @storybook/api/shortcut
import I also need add the shortcut
module declaration in lib/api/src/typings.d.ts
. And @storybook/api/shortcut
won't be typed and won't make auto-suggestions while coding.
As an alternative I can export shortcut
from lib/api/src/index.tsx
:
import * as shortcut from './lib/shortcut';
export { shortcut };
And use it like
import { shortcut } from '@storybook/api';
const { shortcutToHumanString } = shortcut;
Which way is preferred to make shortcut
importable?
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 can also add typings for the shortcut
entry. Here's an example of that:
https://github.com/storybookjs/storybook/blob/next/lib/components/html.js
https://github.com/storybookjs/storybook/blob/next/lib/components/html.d.ts
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.
Thank you for this example, fixed
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 🤦 ... amazing what sneaks into a large codebase with 1000 contributors. Small comment, otherwise looks great.
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.
Awesome. Thanks for the fix!!!
What I did
Hey,
I've found that
/lib/ui/src/libs
files are unused or have some duplication.How to test
lib/ui/src/settings/shortcuts.test.js
is passed