11import { memo , useState } from "react" ;
22import { Handle , NodeProps , Position } from "reactflow" ;
33import compatDb from "./compat-db.json" ;
4+ import genericNames from "./generic-names.json" ;
45
56type DTStatus = "okay" | "disabled" ;
67
7- type DotColor = "blue" | "red" ;
8-
9- const getDotColor = ( status ?: DTStatus ) : DotColor | null => {
10- switch ( status ) {
11- case "okay" : return "blue" ;
12- case "disabled" : return "red" ;
13- default : return null ;
14- }
15- }
8+ const dotColors : Record < DTStatus , string > = {
9+ okay : "blue" ,
10+ disabled : "red"
11+ } ;
1612
1713export const Dot : FC < { status ?: DTStatus } > = ( { status } ) => {
1814 if ( ! status ) {
1915 return null ;
2016 }
21- const color = getDotColor ( status ) ;
17+ const color = dotColors [ status ] ;
2218 return (
23- < div className = "dot" >
19+ < div className = "dot" style = { { background : color } } >
2420 < style > { `
2521 div.dot {
2622 width: 10px;
2723 height: 10px;
28- background: ${ color } ;
2924 border-radius: 100%;
3025 }
3126 ` } </ style >
3227 </ div >
3328 ) ;
3429} ;
3530
36- const docsbaseUrl = "https://docs.kernel.org"
31+ const docsBaseUrl = "https://docs.kernel.org"
32+ const drvBaseUrl = "https://elixir.bootlin.com/linux/HEAD/source/drivers" ;
33+ //const drvBaseUrl = "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers";
3734const dtBaseUrl = "https://www.kernel.org/doc/Documentation/devicetree/bindings" ;
3835
39- type DocsCategory = "binding" | "docs" ;
36+ type DocsCategory = "binding" | "docs" | "driver" ;
4037
4138type DocsEntry = {
4239 category : DocsCategory ;
@@ -46,7 +43,8 @@ type DocsEntry = {
4643const getBaseUrl = ( category : DocsCategory ) : string => {
4744 switch ( category ) {
4845 case "binding" : return dtBaseUrl ;
49- case "docs" : return docsbaseUrl ;
46+ case "docs" : return docsBaseUrl ;
47+ case "driver" : return drvBaseUrl ;
5048 }
5149} ;
5250
@@ -87,33 +85,47 @@ export const DataNode: FC<{ data: object; status?: DTStatus }> = ({
8785 data,
8886 status,
8987} ) => {
90- if ( ! data ) {
91- return null ;
92- }
93-
88+ const extraClass = genericNames . includes ( data . label ) ? "generic" : "" ;
9489 return (
9590 < div className = "node" >
96- < span > { data . label } </ span >
97- < span > { data . baseAddr } </ span >
98- < Compat compat = { data . compat } />
99- < Dot status = { status } />
91+ < header className = { extraClass } > { data . label } </ header >
92+ < main >
93+ < span > { data . model } </ span >
94+ < span > { data . baseAddr } </ span >
95+ < Compat compat = { data . compat } />
96+ < Dot status = { status } />
97+ < span > { data . extra } </ span >
98+ </ main >
10099 < style > { `
101100 div.node {
102101 white-space: pre-wrap;
103- padding: 4px;
104- border: 2px solid #789789;
105- background: #0c0c0c;
106- color: #fff;
107- width: 150px;
108- font-size: 12px;
102+ border: 4px solid #789789;
103+ border-radius: 6px;
104+ width: 250px;
105+ font-size: 14px;
109106 font-family: "Fira Code";
110- display: flex;
111- flex-direction: column;
112107 }
113108 div.node:hover {
114109 border-color: #987987;
115110 border-style: dotted;
116111 }
112+ div.node header {
113+ color: #0c0c0c;
114+ background: #ccddcc;
115+ font-weight: bold;
116+ padding: 4px;
117+ }
118+ div.node header.generic {
119+ color: #fff;
120+ background: #850150;
121+ }
122+ div.node main {
123+ color: #fff;
124+ background: #0c0c0c;
125+ padding: 4px;
126+ display: flex;
127+ flex-direction: column;
128+ }
117129 ` } </ style >
118130 </ div >
119131 ) ;
0 commit comments