Browse Source

feat: antd + emotion 配置

master
suanmei 5 years ago
committed by 拾邑
parent
commit
5d09145fd1
  1. 10
      package-lock.json
  2. 2
      package.json
  3. 1215
      packages/core/package-lock.json
  4. 11
      packages/core/package.json
  5. 2
      packages/core/rollup.config.js
  6. 52
      packages/core/src/components/toolbar.tsx
  7. 74
      packages/core/src/index.tsx
  8. 16
      packages/core/src/utils/create-graph.ts
  9. 11
      packages/transform/README.md
  10. 0
      packages/transform/index.ts
  11. 32
      packages/transform/package.json
  12. 6
      packages/transform/scripts/prepublishOnly.js
  13. 3
      rollup.config.js

10
package-lock.json

@ -2916,15 +2916,13 @@
}
},
"@rollup/plugin-commonjs": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.1.0.tgz",
"integrity": "sha512-Ycr12N3ZPN96Fw2STurD21jMqzKwL9QuFhms3SD7KKRK7oaXUsBU9Zt0jL/rOPHiPYisI21/rXGO3jr9BnLHUA==",
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.2.tgz",
"integrity": "sha512-MPYGZr0qdbV5zZj8/2AuomVpnRVXRU5XKXb3HVniwRoRCreGlf5kOE081isNWeiLIi6IYkwTX9zE0/c7V8g81g==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^3.0.8",
"commondir": "^1.0.1",
"@rollup/pluginutils": "^3.0.0",
"estree-walker": "^1.0.1",
"glob": "^7.1.2",
"is-reference": "^1.1.2",
"magic-string": "^0.25.2",
"resolve": "^1.11.0"

2
package.json

@ -15,7 +15,7 @@
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.9.0",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-strip": "^1.3.2",
"@rollup/plugin-url": "^4.0.2",

1215
packages/core/package-lock.json

File diff suppressed because it is too large

11
packages/core/package.json

@ -36,13 +36,22 @@
"url": "https://github.com/suanmei/iMove/issues"
},
"devDependencies": {
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"@types/react": "^16.9.34",
"antd": "^4.1.4",
"react": "^16.13.1",
"rollup": "^2.6.1",
"watch": "^1.0.2"
},
"peerDependencies": {
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"antd": "^4.1.4",
"react": "^16.13.1"
},
"gitHead": "9fafd8c5390fa001e7b661ccccfaf65f636d721a"
"gitHead": "9fafd8c5390fa001e7b661ccccfaf65f636d721a",
"dependencies": {
"@antv/x6": "^0.3.3"
}
}

2
packages/core/rollup.config.js

@ -12,5 +12,5 @@ export default Object.assign(rollupBaseConfig, {
format: 'es',
},
],
external: Object.keys(pkg.peerDependencies),
external: Object.keys(pkg.peerDependencies).concat(/^antd\//),
});

52
packages/core/src/components/toolbar.tsx

@ -0,0 +1,52 @@
/** @jsx jsx */
import { jsx, css } from '@emotion/core';
import styled from '@emotion/styled';
import { Collapse } from 'antd';
import 'antd/lib/collapse/style';
const { Panel } = Collapse;
const ToolCollapse = styled(Collapse)`
border: none;
`;
const ToolPanel = styled(Panel)`
margin-right: -1px;
.ant-collapse-content-box {
margin-bottom: -1px;
padding: 0;
overflow: hidden;
}
`;
const Cell = styled.div`
box-sizing: border-box;
display: inline-block;
width: 50%;
height: 100px;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
`;
const Toolbar = (): JSX.Element => {
return (
<div
css={css`
height: 100%;
overflow: auto;
border-right: 1px solid #ddd;
`}
>
<ToolCollapse defaultActiveKey={['1']}>
<ToolPanel header="General" key="1">
<Cell>2</Cell>
<Cell>2</Cell>
<Cell>2</Cell>
</ToolPanel>
</ToolCollapse>
</div>
);
};
export default Toolbar;

74
packages/core/src/index.tsx

@ -1,15 +1,71 @@
import * as React from 'react';
import { Layout } from 'antd';
import { Graph, DomEvent } from '@antv/x6';
import styled from '@emotion/styled';
import Toolbar from './components/toolbar';
import { createGraph } from './utils/create-graph';
import 'antd/lib/layout/style';
const Core = (): JSX.Element => {
export interface CoreState {
inited: boolean;
}
const { Header, Sider, Content } = Layout;
const IMoveLayout = styled(Layout)`
height: 100%;
`;
const IMoveHeader = styled(Header)`
background: #fff;
border-bottom: 1px solid #ddd;
`;
const IMoveSider = styled(Sider)`
background: #fff;
`;
class Core extends React.Component<{}, CoreState> {
private graph: Graph | null = null;
private container = React.createRef<HTMLDivElement>();
constructor(props: {}) {
super(props);
this.state = {
inited: false,
};
}
componentDidMount(): void {
const container = this.container.current;
if (container) {
DomEvent.disableContextMenu(container);
this.graph = createGraph(container);
this.graph.center();
this.setState({
inited: true,
});
}
}
render(): JSX.Element {
const { inited } = this.state;
return (
<div>
2
<span role="img" aria-label="ok">
👌
</span>
2
</div>
<IMoveLayout>
<IMoveHeader>
<h2>iMove</h2>
</IMoveHeader>
<IMoveLayout>
<IMoveSider>{inited && <Toolbar />}</IMoveSider>
<Content>
<div ref={this.container} />
</Content>
<IMoveSider>Sider</IMoveSider>
</IMoveLayout>
</IMoveLayout>
);
};
}
}
export default Core;

16
packages/core/src/utils/create-graph.ts

@ -0,0 +1,16 @@
import { Graph } from '@antv/x6';
export function createGraph(container: HTMLDivElement): Graph {
return new Graph(container, {
rotate: false,
resize: true,
grid: {
type: 'dot',
color: '#bcbcbc',
},
});
}
export function A(): void {
// code
}

11
packages/transform/README.md

@ -0,0 +1,11 @@
# `transform`
> TODO: description
## Usage
```
const transform = require('transform');
// TODO: DEMONSTRATE API
```

0
packages/transform/index.ts

32
packages/transform/package.json

@ -0,0 +1,32 @@
{
"name": "@imove/transform",
"version": "0.1.10",
"description": "transform graph to schema",
"keywords": [
"json-schema"
],
"author": "suanmei <mr_suanmei@163.com>",
"homepage": "https://github.com/suanmei/iMove#readme",
"license": "MIT",
"main": "dist/transform.common.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"publishConfig": {
"registry": "http://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/suanmei/iMove.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
"url": "https://github.com/suanmei/iMove/issues"
}
}

6
packages/transform/scripts/prepublishOnly.js

@ -0,0 +1,6 @@
#!/usr/bin/env node
const path = require('path');
const prePublish = require('../../../scripts/prepublish');
prePublish('@imove/transform', path.join(__dirname, '../'));

3
rollup.config.js

@ -13,7 +13,7 @@ export default {
input,
plugins: [
resolve({ extensions }),
commonjs(),
commonjs({}),
babel({
extensions,
exclude: 'node_modules/**',
@ -26,4 +26,5 @@ export default {
strip({ debugger: true }),
sizeSnapshot({ printInfo: false }),
],
context: null,
};

Loading…
Cancel
Save