Skip to content

Commit

Permalink
✏️ provide layout api's return type
Browse files Browse the repository at this point in the history
  • Loading branch information
佛肚 committed Dec 25, 2019
1 parent ed4c867 commit bc62059
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/graphin-site/docs/api/extend.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ The property `extend` of component `<Graphin/>` is used to extend layout, NodeS

|   Property | Type | Required | Description |
| --------- | -------------------------------------------------------------- | -------- | ---------- |
| layout | (graphin: [Graphin](), prevProps: [GraphinProps](/zh/docs/api/graphin#props)) => [ExendLayout](#extendlayout)[ ] | no | custom Layout |
| layout | (graphin: [Graphin](), prevProps: [GraphinProps](/zh/docs/api/graphin#props)) => [ExtendLayout](#extendlayout)[ ] | no | custom Layout |
| nodeShape | (node: [Node](/zh/docs/api/graphin#node)) => [ExtendNodeShape](#extendnodeshape)[ ] | no | custom Node |
| marker | ( ) => [ExtendMarker](#extendmarker)[ ] | no | custom Icon |


### ExendLayout
### ExtendLayout

Configuration of custom layout

Expand Down
4 changes: 2 additions & 2 deletions packages/graphin-site/docs/api/extend.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ order: 3

|   属性 | 类型 | 是否必选 | 说明 |
| --------- | -------------------------------------------------------------- | -------- | ---------- |
| layout | (graphin: [Graphin](), prevProps: [GraphinProps](/zh/docs/api/graphin#props)) => [ExendLayout](#extendlayout)[ ] || 自定义布局 |
| layout | (graphin: [Graphin](), prevProps: [GraphinProps](/zh/docs/api/graphin#props)) => [ExtendLayout](#extendlayout)[ ] || 自定义布局 |
| nodeShape | (node: [Node](/zh/docs/api/graphin#node)) => [ExtendNodeShape](#extendnodeshape)[ ] || 自定义节点 |
| marker | ( ) => [ExtendMarker](#extendmarker)[ ] || 自定义图标 |
| icon | ( ) => [ExtendIcon](#extendicon)[ ] || 自定义图标(iconfont 形式) |

### ExendLayout
### ExtendLayout

自定义布局配置

Expand Down
11 changes: 10 additions & 1 deletion packages/graphin/src/Graphin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ import apisController from './apis';
import eventController from './events/index';

/** types */
import { GraphinProps, GraphinState, ExtendedGraphOptions, GraphType, ForceSimulation, Data, Layout } from './types';
import {
GraphinProps,
GraphinState,
ExtendedGraphOptions,
GraphType,
ForceSimulation,
Data,
Layout,
ExtendLayout,
} from './types';

/** utils */
import debug from './utils/debug';
Expand Down
4 changes: 2 additions & 2 deletions packages/graphin/src/controller/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dataChecking from './dataChecking';
import { GraphinProps, Data, ForceSimulation, ExendLayout } from '../../types';
import { GraphinProps, Data, ForceSimulation, ExtendLayout } from '../../types';
import Graphin from '../../Graphin';
import defaultLayouts, { LayoutOption } from './defaultLayouts';

Expand All @@ -8,7 +8,7 @@ interface LayoutParams {
prevProps?: GraphinProps;
}

const layoutInfo = (layouts: ExendLayout[]) => {
const layoutInfo = (layouts: ExtendLayout[]) => {
return layouts.map(item => {
const { desc, name, icon } = item;
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/graphin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export interface ExtendNodeShape {
name: string;
render: NodeShapeFunction;
}
export interface ExendLayout {
export interface ExtendLayout {
/** 布局名称,唯一标示 */
name: string;
/** 布局展示名称 */
Expand Down Expand Up @@ -286,7 +286,7 @@ export interface GraphinProps {
layout?: Layout;

extend?: {
layout?: (graphin: Graphin, prevProps: GraphinProps) => ExendLayout[];
layout?: (graphin: Graphin, prevProps: GraphinProps) => ExtendLayout[];
nodeShape?: () => ExtendNodeShape[];
marker?: () => ExtendMarker[];
icon?: () => ExtendIcon[];
Expand Down

0 comments on commit bc62059

Please sign in to comment.