JSFiddle - React, Tailwind, and code Playground
by Vikram Deshmukh
HTML
<div id="tree"></div>
CSS
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.link {
stroke-width: 3px;
stroke: #F8DB68;
fill: none;
}
.text {
font-family: "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
font-size: 10px;
}
.hover {
stroke: darkblue;
}
.root {
visibility: hidden;
}
.chart {
width: 100%;
height: 100%;
}
div.label {
overflow-wrap: break-word;
box-sizing: border-box;
width: 100%;
height: 60px;
padding: 10px 15px;
font-size: 0.865rem;
background-color: white;
user-select: none;
box-shadow: rgba(0, 0, 0, 0.04) 0px 0px 0px 1px, rgba(0, 0, 0, 0.05) 0px 2px 2px 0px;
border-width: 1px;
border-style: solid;
border-color: rgb(230, 232, 233);
border-image: initial;
border-radius: 4px;
}
div.label div.description {
display: none;
}
div.label div.title {
display: flex;
align-items: center;
height: 100%;
}
div.label div.title p {
margin: 0;
font-weight: 600;
color: #333;
}
div.label:hover div.description {
display: block;
clear: both;
background-color: white;
border: 1px solid #efefef;
margin-top: 4px;
color: #666;
padding: 2px 4px;
}
div.label.terminal {
background-color: rgba(200,255,200,0.98);
}
div.label img {
width: 26px;
height: 26px;
vertical-align: middle;
margin-right: 10px;
}
div.tooltip {
position: absolute;
text-align: left;
max-width: 260px;
white-space: wrap;
word-wrap: break-word;
padding: 7px 10px;
font: 12px sans-serif;
color: white;
background: #111;
border: 0px;
border-radius: 2px;
pointer-events: none;
margin-left: 25px;
margin-top: -19px;
}
div.tooltip:before {
content: '';
position: absolute;
top: 0%;
left: 0%;
margin-top: 2px;
margin-left: -8px;
width: 0;
height: 0;
...
JavaScript
const commonChild = {
name: 'John Snow',
id: 'a-108',
children: []
}
const data = {
name: 'ROOT',
id: 'root',
children: [{
name: 'A',
id: 'A',
description: 'This is a tooltip with a long multi line text in it',
children: [{
name: 'AA',
id: 'AA',
description: 'This is a tooltip',
children: [commonChild]
},
{
name: 'BB',
id: 'BB',
children: [commonChild]
}
]
},
{
name: 'B',
id: 'B',
children: [{
name: 'AA',
id: 'AA'
},
{
name: 'BB',
id: 'BB'
},
{
name: 'CC',
id: 'CC'
}
]
}
]
};
const end = {
"name": "createSms#sentSMS",
"id": 18,
"type": "DUC",
"actor": "SIRI",
"utterance": "Done.",
"children": [
]
};
const common = {
"name": "createSms#willSendSms",
"id": 5,
"type": "DUC",
"actor": "SIRI",
"utterance": "Ready to send it?",
"children": [{
"name": "::sms[smsConfirmation]",
"id": 6,
"type": "INTENT",
"actor": "USER",
"utterance": "send it",
"children": [end]
},
{
"name": "::sms[smsConfirmation]",
"id": 11,
"type": "INTENT",
"actor": "USER",
"utterance": "Send",
"children": [end]
},
{
"name": "::sms[smsConfirmation]",
"id": 17,
"type": "INTENT",
"actor": "USER",
"utterance": "^smsConfirmation^=^yes^",
"children": [end]
}
]
};
const scope = {
data: {
"name": "::sms[smsVerb(send)]",
"utterance": "send a text",
"id": 20,
"children": [{
"name": "createSms#noRecipients",
"id": 1,
"type": "DUC",
"actor": "SIRI",
"utterance": "OK, to whom?",
"children": [{
"name": "sms[smsVerb(send)]::sms[smsContact[person+smsContactRole(to)]]",
...