|
| 1 | +import * as React from 'react'; |
| 2 | +import { COLOR } from '../styles/tangleStyles'; |
| 3 | +import { BRANCH, UTXO } from '../styles/cytoscapeStyles'; |
| 4 | + |
| 5 | +export class TangleLegend extends React.Component<any, any> { |
| 6 | + render() { |
| 7 | + const nodeLabels = [ |
| 8 | + 'MSG Confirmed', |
| 9 | + 'MSG Pending', |
| 10 | + 'TX Confirmed', |
| 11 | + 'TX Pending', |
| 12 | + 'Tip', |
| 13 | + 'Unknown' |
| 14 | + ]; |
| 15 | + const nodeColors = [ |
| 16 | + COLOR.MESSAGE_CONFIRMED, |
| 17 | + COLOR.MESSAGE_PENDING, |
| 18 | + COLOR.TRANSACTION_CONFIRMED, |
| 19 | + COLOR.TRANSACTION_PENDING, |
| 20 | + COLOR.TIP, |
| 21 | + COLOR.NODE_UNKNOWN |
| 22 | + ]; |
| 23 | + const linkLabels = [ |
| 24 | + 'Strong', |
| 25 | + 'Weak', |
| 26 | + 'Shallow Liked', |
| 27 | + 'Shallow Disliked' |
| 28 | + ]; |
| 29 | + const linksColors = [ |
| 30 | + COLOR.LINK_STRONG, |
| 31 | + COLOR.LINK_WEAK, |
| 32 | + COLOR.LINK_SHALLOW_LIKED, |
| 33 | + COLOR.LINK_SHALLOW_DISLIKED |
| 34 | + ]; |
| 35 | + const linkTypes = ['solid', 'dashed', 'dotted', 'dotted']; |
| 36 | + |
| 37 | + const legendItemsNodes = []; |
| 38 | + const legendItemsLinks = []; |
| 39 | + |
| 40 | + for (const i in nodeLabels) { |
| 41 | + legendItemsNodes.push( |
| 42 | + <div className={'legend-item'}> |
| 43 | + <div |
| 44 | + className="legend-color" |
| 45 | + style={{ |
| 46 | + backgroundColor: nodeColors[i] |
| 47 | + }} |
| 48 | + /> |
| 49 | + <div className="legend-label">{nodeLabels[i]}</div> |
| 50 | + </div> |
| 51 | + ); |
| 52 | + } |
| 53 | + legendItemsLinks.push( |
| 54 | + <div className={'legend-item'}> |
| 55 | + <div |
| 56 | + className="legend-color" |
| 57 | + style={{ |
| 58 | + backgroundColor: COLOR.MESSAGE_CONFIRMED |
| 59 | + }} |
| 60 | + > |
| 61 | + <div className={'legend-marker'} /> |
| 62 | + </div> |
| 63 | + <div className="legend-label">Marker</div> |
| 64 | + </div> |
| 65 | + ); |
| 66 | + for (const i in linkLabels) { |
| 67 | + legendItemsLinks.push( |
| 68 | + <div className={'legend-item'}> |
| 69 | + <div |
| 70 | + className="link-type" |
| 71 | + style={{ |
| 72 | + borderBottom: `${linkTypes[i]} 2px ${linksColors[i]}` |
| 73 | + }} |
| 74 | + /> |
| 75 | + <div className="legend-label">{linkLabels[i]}</div> |
| 76 | + </div> |
| 77 | + ); |
| 78 | + } |
| 79 | + return ( |
| 80 | + <> |
| 81 | + <div className="legend">{legendItemsNodes}</div> |
| 82 | + <div className="legend">{legendItemsLinks}</div> |
| 83 | + </> |
| 84 | + ); |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +export class UTXOLegend extends React.Component<any, any> { |
| 89 | + render() { |
| 90 | + const nodeLabels = ['TX Confirmed', 'TX Pending']; |
| 91 | + const nodeColors = [UTXO.COLOR_CONFIRMED, UTXO.PARENT_COLOR]; |
| 92 | + |
| 93 | + const legendItemsNodes = []; |
| 94 | + |
| 95 | + for (const i in nodeLabels) { |
| 96 | + legendItemsNodes.push( |
| 97 | + <div className={'legend-item'}> |
| 98 | + <div |
| 99 | + className="legend-color" |
| 100 | + style={{ |
| 101 | + backgroundColor: nodeColors[i] |
| 102 | + }} |
| 103 | + /> |
| 104 | + <div className="legend-label">{nodeLabels[i]}</div> |
| 105 | + </div> |
| 106 | + ); |
| 107 | + } |
| 108 | + return ( |
| 109 | + <> |
| 110 | + <div className="legend">{legendItemsNodes}</div> |
| 111 | + </> |
| 112 | + ); |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +export class BranchLegend extends React.Component<any, any> { |
| 117 | + render() { |
| 118 | + const nodeLabels = [ |
| 119 | + 'Conflict branch confirmed', |
| 120 | + 'Conflict branch pending/rejected', |
| 121 | + 'Master branch' |
| 122 | + ]; |
| 123 | + const nodeColors = [ |
| 124 | + BRANCH.COLOR_CONFIRMED, |
| 125 | + BRANCH.COLOR, |
| 126 | + BRANCH.MASTER_COLOR |
| 127 | + ]; |
| 128 | + |
| 129 | + const legendItemsNodes = []; |
| 130 | + |
| 131 | + for (const i in nodeLabels) { |
| 132 | + legendItemsNodes.push( |
| 133 | + <div className={'legend-item'}> |
| 134 | + <div |
| 135 | + className="legend-color" |
| 136 | + style={{ |
| 137 | + backgroundColor: nodeColors[i] |
| 138 | + }} |
| 139 | + /> |
| 140 | + <div className="legend-label">{nodeLabels[i]}</div> |
| 141 | + </div> |
| 142 | + ); |
| 143 | + } |
| 144 | + return ( |
| 145 | + <> |
| 146 | + <div className="legend">{legendItemsNodes}</div> |
| 147 | + </> |
| 148 | + ); |
| 149 | + } |
| 150 | +} |
0 commit comments