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

Addon-contexts: Remove peer dependencies #7675

Merged
merged 7 commits into from
Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions addons/contexts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@
"@storybook/api": "5.3.0-alpha.0",
"@storybook/components": "5.3.0-alpha.0",
"@storybook/core-events": "5.3.0-alpha.0",
"core-js": "^3.0.1"
},
"peerDependencies": {
"global": "*",
"preact": "*",
"qs": "*",
"react": "*",
"vue": "*"
"core-js": "^3.0.1",
"global": "^4.3.2",
"qs": "^6.6.0"
},
"devDependencies": {
"preact": "*",
Expand Down
11 changes: 7 additions & 4 deletions addons/contexts/src/manager/ContextsManager.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
import React, { useEffect, useState, useCallback } from 'react';
import { useChannel } from './libs/useChannel';
import { useChannel } from '@storybook/api';
import { ToolBar } from './components/ToolBar';
import { deserialize, serialize } from '../shared/serializers';
import { PARAM, REBOOT_MANAGER, UPDATE_MANAGER, UPDATE_PREVIEW } from '../shared/constants';
Expand All @@ -21,11 +22,13 @@ export const ContextsManager: ContextsManager = ({ api }) => {
);

// from preview
useChannel(UPDATE_MANAGER, newNodes => setNodes(newNodes || []), []);
const emit = useChannel({
[UPDATE_MANAGER]: newNodes => setNodes(newNodes || []),
});
leoyli marked this conversation as resolved.
Show resolved Hide resolved

// to preview
useEffect(() => api.emit(REBOOT_MANAGER), []);
useEffect(() => api.emit(UPDATE_PREVIEW, state), [state]);
useEffect(() => emit(REBOOT_MANAGER), []);
useEffect(() => emit(UPDATE_PREVIEW, state), [state]);
useEffect(() => api.setQueryParams({ [PARAM]: serialize(state) }), [state]);

return <ToolBar nodes={nodes} state={state || {}} setSelected={setSelected} />;
Expand Down
1 change: 1 addition & 0 deletions addons/contexts/src/manager/components/ToolBar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import React, { ComponentProps } from 'react';
import { Separator } from '@storybook/components';
import { ToolBarControl } from './ToolBarControl';
Expand Down
1 change: 1 addition & 0 deletions addons/contexts/src/manager/components/ToolBarControl.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { ToolBarMenu } from './ToolBarMenu';
import { OPT_OUT } from '../../shared/constants';
Expand Down
1 change: 1 addition & 0 deletions addons/contexts/src/manager/components/ToolBarMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import React, { ComponentProps } from 'react';
import { Icons, IconButton, WithTooltipPure, TabButton } from '@storybook/components';
import { ToolBarMenuOptions } from './ToolBarMenuOptions';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { TooltipLinkList } from '@storybook/components';
import { OPT_OUT } from '../../shared/constants';
Expand Down
19 changes: 0 additions & 19 deletions addons/contexts/src/manager/libs/useChannel.ts

This file was deleted.

1 change: 1 addition & 0 deletions addons/contexts/src/preview/frameworks/preact.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import Preact from 'preact';
import { createAddonDecorator, Render } from '../../index';
import { ContextsPreviewAPI } from '../ContextsPreviewAPI';
Expand Down
1 change: 1 addition & 0 deletions addons/contexts/src/preview/frameworks/react.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { createAddonDecorator, Render } from '../../index';
import { ContextsPreviewAPI } from '../ContextsPreviewAPI';
Expand Down
1 change: 1 addition & 0 deletions addons/contexts/src/preview/frameworks/vue.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import Vue from 'vue';
import { createAddonDecorator, Render } from '../../index';
import { ContextsPreviewAPI } from '../ContextsPreviewAPI';
Expand Down
1 change: 1 addition & 0 deletions addons/contexts/src/register.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import { createElement } from 'react';
import addons, { types } from '@storybook/addons';
import { ContextsManager } from './manager/ContextsManager';
Expand Down