|
| 1 | +/* eslint-disable @typescript-eslint/explicit-function-return-type */ |
| 2 | +import React, { FC } from 'react'; |
| 3 | +import { withKnobs, text, select, number } from '@storybook/addon-knobs'; |
| 4 | +import { Graphviz } from '../web'; |
| 5 | +import { Digraph, Graph, Node, Edge } from '../index'; |
| 6 | + |
| 7 | +export default { title: 'Graphviz/Components', decorators: [withKnobs] }; |
| 8 | + |
| 9 | +export const RootGraph: FC = () => { |
| 10 | + const root = select('root', ['digraph', 'graph'], 'digraph'); |
| 11 | + const Root = root === 'digraph' ? Digraph : Graph; |
| 12 | + const rankdir = select('rankdir', ['TB', 'BT', 'RL', 'LR'], 'TB'); |
| 13 | + return ( |
| 14 | + <Graphviz> |
| 15 | + <Root rankdir={rankdir}> |
| 16 | + <Node id="n1" /> |
| 17 | + <Node id="n2" /> |
| 18 | + <Node id="n3" /> |
| 19 | + <Edge targets={['n1', 'n2', 'n3']} /> |
| 20 | + <Edge targets={['n1', 'n3']} /> |
| 21 | + </Root> |
| 22 | + </Graphviz> |
| 23 | + ); |
| 24 | +}; |
| 25 | + |
| 26 | +export const NodeSample: FC = () => { |
| 27 | + return ( |
| 28 | + <Graphviz> |
| 29 | + <Digraph> |
| 30 | + <Node |
| 31 | + id="n" |
| 32 | + label={text('label', 'label')} |
| 33 | + xlabel={text('xlabel', '')} |
| 34 | + color={text('color', 'black')} |
| 35 | + fillcolor={text('fillcolor', 'yellow')} |
| 36 | + style={text('style', 'filled')} |
| 37 | + shape={select( |
| 38 | + 'shape', |
| 39 | + [ |
| 40 | + 'box', |
| 41 | + 'assembly', |
| 42 | + 'box3d', |
| 43 | + 'cds', |
| 44 | + 'circle', |
| 45 | + 'component', |
| 46 | + 'cylinder', |
| 47 | + 'diamond', |
| 48 | + 'doublecircle', |
| 49 | + 'doubleoctagon', |
| 50 | + 'egg', |
| 51 | + 'ellipse', |
| 52 | + 'fivepoverhang', |
| 53 | + 'folder', |
| 54 | + 'hexagon', |
| 55 | + 'house', |
| 56 | + 'insulator', |
| 57 | + 'invhouse', |
| 58 | + 'invtrapezium', |
| 59 | + 'invtriangle', |
| 60 | + 'larrow', |
| 61 | + 'lpromoter', |
| 62 | + 'Mcircle', |
| 63 | + 'Mdiamond', |
| 64 | + 'Msquare', |
| 65 | + 'none', |
| 66 | + 'note', |
| 67 | + 'noverhang', |
| 68 | + 'octagon', |
| 69 | + 'oval', |
| 70 | + 'parallelogram', |
| 71 | + 'pentagon', |
| 72 | + 'plain', |
| 73 | + 'plaintext', |
| 74 | + 'point', |
| 75 | + 'polygon', |
| 76 | + 'primersite', |
| 77 | + 'promoter', |
| 78 | + 'proteasesite', |
| 79 | + 'proteinstab', |
| 80 | + 'rarrow', |
| 81 | + 'rect', |
| 82 | + 'rectangle', |
| 83 | + 'restrictionsite', |
| 84 | + 'ribosite', |
| 85 | + 'rnastab', |
| 86 | + 'rpromoter', |
| 87 | + 'septagon', |
| 88 | + 'signature', |
| 89 | + 'square', |
| 90 | + 'star', |
| 91 | + 'tab', |
| 92 | + 'terminator', |
| 93 | + 'threepoverhang', |
| 94 | + 'trapezium', |
| 95 | + 'triangle', |
| 96 | + 'tripleoctagon', |
| 97 | + 'underline', |
| 98 | + 'utr', |
| 99 | + ], |
| 100 | + 'box', |
| 101 | + )} |
| 102 | + /> |
| 103 | + </Digraph> |
| 104 | + </Graphviz> |
| 105 | + ); |
| 106 | +}; |
| 107 | + |
| 108 | +export const EdgeSample: FC = () => { |
| 109 | + return ( |
| 110 | + <Graphviz> |
| 111 | + <Digraph> |
| 112 | + <Node id="n1" /> |
| 113 | + <Node id="n2" /> |
| 114 | + <Edge |
| 115 | + targets={['n1', 'n2']} |
| 116 | + label={text('label', 'label')} |
| 117 | + dir={select('dir', ['forward', 'back', 'both'], 'forward')} |
| 118 | + arrowhead={select( |
| 119 | + 'arrowhead', |
| 120 | + ['box', 'crow', 'curve', 'icurve', 'diamond', 'dot', 'inv', 'none', 'normal', 'tee', 'vee'], |
| 121 | + 'normal', |
| 122 | + )} |
| 123 | + arrowtail={select( |
| 124 | + 'arrowtail', |
| 125 | + ['box', 'crow', 'curve', 'icurve', 'diamond', 'dot', 'inv', 'none', 'normal', 'tee', 'vee'], |
| 126 | + 'normal', |
| 127 | + )} |
| 128 | + arrowsize={number('arrowsize', 1, { min: 0, step: 0.1 })} |
| 129 | + /> |
| 130 | + </Digraph> |
| 131 | + </Graphviz> |
| 132 | + ); |
| 133 | +}; |
0 commit comments