JSFiddle - React, Tailwind, and code Playground
by codemeasandwich
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form and Chatbot</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<style>
#app {
display: flex;
height: 100vh;
}
#form-panel, #chat-panel {
width: 50%;
padding: 20px;
border: 1px solid #ccc;
overflow-y: auto;
}
#chat-panel {
border-left: none;
}
.chat-message {
margin-bottom: 10px;
}
.user {
text-align: right;
color: blue;
}
.bot {
text-align: left;
color: green;
}
.chat-input {
display: flex;
margin-top: 10px;
}
.chat-input input {
flex: 1;
margin-right: 10px;
}
</style>
</head>
<body>
<div id="app" class="container-fluid">
<div id="form-panel" class="p-3">
<form id="dynamic-form" class="mb-4"></form>
<div id="computed-answers"></div>
</div>
<div id="chat-panel" class="p-3">
<div id="chat-messages" class="mb-4"></div>
<div class="chat-input">
<input id="chat-input" type="text" class="form-control" placeholder="Type a message">
<button id="send-btn" class="btn btn-primary">Send</button>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
<script>
const formData = [
"name",
["having kids", "yes", "no"]
];
function FormPanel({ formData }) {
const formPanel = document.getElementById('dynamic-form');
const formValues = {};
const handleChange = (key, value) => {
...