Skip to content

Commit

Permalink
Merge pull request #11155 from mbelsky/reuse-api-lib
Browse files Browse the repository at this point in the history
UI: Remove unused & duplicated code
  • Loading branch information
shilman committed Jun 14, 2020
2 parents 26b94ff + 531e9bc commit 1af7ae6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 172 deletions.
1 change: 1 addition & 0 deletions lib/api/shortcut.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/lib/shortcut.d';
1 change: 1 addition & 0 deletions lib/api/shortcut.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/lib/shortcut');
2 changes: 1 addition & 1 deletion lib/api/src/lib/shortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const isShortcutTaken = (arr1: string[], arr2: string[]): boolean =>

// Map a keyboard event to a keyboard shortcut
// NOTE: if we change the fields on the event that we need, we'll need to update the serialization in core/preview/start.js
export const eventToShortcut = (e: Event): KeyCollection | null => {
export const eventToShortcut = (e: KeyboardEvent): KeyCollection | null => {
// Meta key only doesn't map to a shortcut
if (['Meta', 'Alt', 'Control', 'Shift'].includes(e.key)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/containers/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/shortcut';
import { MenuItemIcon } from '../components/sidebar/Menu';

const focusableUIElements = {
Expand Down
23 changes: 0 additions & 23 deletions lib/ui/src/libs/merge.ts

This file was deleted.

108 changes: 0 additions & 108 deletions lib/ui/src/libs/shortcut.ts

This file was deleted.

36 changes: 0 additions & 36 deletions lib/ui/src/libs/withLifecycleDecorator.tsx

This file was deleted.

12 changes: 9 additions & 3 deletions lib/ui/src/settings/shortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import React, { Component, Fragment, SyntheticEvent } from 'react';
import { styled, keyframes } from '@storybook/theming';
import { GlobalHotKeys } from 'react-hotkeys';

import {
eventToShortcut,
shortcutToHumanString,
shortcutMatchesShortcut,
} from '@storybook/api/shortcut';
import { Form, IconButton, Icons, Tabs } from '@storybook/components';
import SettingsFooter from './SettingsFooter';

import { eventToShortcut, shortcutToHumanString, shortcutMatchesShortcut } from '../libs/shortcut';

const { Button, Input } = Form;

const Header = styled.header(({ theme }) => ({
Expand Down Expand Up @@ -200,7 +203,10 @@ class ShortcutsScreen extends Component<ShortcutsScreenProps, ShortcutsScreenSta

this.setState({
activeFeature: focusedInput,
shortcutKeys: { ...shortcutKeys, [focusedInput]: { shortcut: null, error: false } },
shortcutKeys: {
...shortcutKeys,
[focusedInput]: { shortcut: null, error: false },
},
});
};

Expand Down

0 comments on commit 1af7ae6

Please sign in to comment.