修正 react storybook

This commit is contained in:
hotlong 2020-09-22 19:25:43 +08:00
parent 9802dc1faa
commit 3784b3eef8
6 changed files with 63 additions and 1 deletions

View File

@ -1 +1 @@
REACT_APP_API_BASE_URL=127.0.0.1:5000
REACT_APP_API_BASE_URL=http://127.0.0.1:5000

View File

@ -0,0 +1,3 @@
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-cssresources/register';

View File

@ -0,0 +1,23 @@
import { configure, addDecorator, addParameters } from '@storybook/react';
import { withCssResources } from '@storybook/addon-cssresources';
const REACT_APP_API_BASE_URL = process.env.REACT_APP_API_BASE_URL;
addDecorator(withCssResources)
addParameters({
cssresources: [{
id: `bootstrap`,
code: `<link rel="stylesheet" type="text/css" href="/assets/styles/bootstrap.css"></link>`,
picked: true,
}, {
id: `sfds`,
code: `<link rel="stylesheet" type="text/css" href="` + REACT_APP_API_BASE_URL + `/assets/styles/salesforce-lightning-design-system.min.css"></link>`,
picked: true,
}, {
id: `style`,
code: `<style>html,body{background: #fff;height:100%;}#root{height: 100%;}</style>`,
picked: true,
}],
});
// automatically import all files ending in *.stories.js
configure(require.context('../src/stories', true, /\.stories\.js$/), module);

View File

@ -0,0 +1,3 @@
module.exports = [
'@storybook/addon-storysource/preset'
];

View File

@ -1,3 +1,17 @@
import * as React from 'react';
import * as ReactDom from 'react-dom';
import * as Redux from 'redux';
import * as ReactRedux from 'react-redux';
import PropTypes from 'prop-types';
import * as ReactDesignSystem from '@salesforce/design-system-react';
import styled from 'styled-components';
import * as ReduxThunk from 'redux-thunk';
import * as Immer from 'immer';
import * as TSODataClient from 'ts-odata-client';
import * as NodeFetch from 'node-fetch';
import * as SteedosFilters from '@steedos/filters';
import * as ReactSteedos from '../export';
import store from "../stores/configureStore";
import { receivePluginInstance, receivePluginComponent } from '../actions';
import { ObjectHomeIFrame, generateIFrame } from "../components/object_home_iframe";
@ -14,6 +28,25 @@ export const registerPlugin = ( pluginName, pluginInstance ) => {
pluginInstance.initialize(registry, store);
}
export const registerWindowLibraries = () => {
window["React"] = React;
window["PropTypes"] = PropTypes;
window["ReactDom"] = ReactDom;
window["Redux"] = Redux;
window["ReactRedux"] = ReactRedux;
window["ReactDesignSystem"] = ReactDesignSystem;
window["ReactSteedos"] = ReactSteedos;
window["StyledComponents"] = styled;
window["ReduxThunk"] = ReduxThunk;
window["Immer"] = Immer;
window["TSODataClient"] = TSODataClient;
window["NodeFetch"] = NodeFetch;
window["SteedosFilters"] = SteedosFilters;
window["registerPlugin"] = registerPlugin;
}
function dispatchPluginComponentAction(name: string, pluginId: string, component: any, id: string = "") {
if(!id){
id = generateId();

BIN
yarn.lock

Binary file not shown.