Pour créer 4 modèles différents à partir de ton code HTML complet, je te propose 4 variantes de mise en page (UI) et d'organisation, toutes basées sur les mêmes fonctionnalités principales. Chaque modèle va représenter une disposition ou un style différent qui pourrait convenir à différents usages ou goûts.
Modèle 1 : Disposition en onglets (Tabulation)
C’est un classique d’UI où chaque section devient un onglet. Cela rend la navigation claire, surtout pour une Web UI riche.
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Ganache Web UI - Modèle Onglets</title>
<style>
body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
header { background: #2a3f54; color: white; padding: 1em; text-align: center; }
nav {
display: flex;
background: #34495e;
}
nav button {
flex: 1;
background: #34495e;
border: none;
padding: 1em;
color: white;
cursor: pointer;
font-weight: bold;
transition: background 0.3s;
}
nav button:hover, nav button.active {
background: #1abc9c;
}
section {
display: none;
padding: 1em;
}
section.active {
display: block;
}
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #ccc; padding: 0.5em; }
th { background: #ecf0f1; }
#searchTx { width: 300px; margin-left: auto; display: block; margin-bottom: 0.5em; }
</style>
</head>
<body>
<header>
<h1>Ganache Web UI avancé - Onglets</h1>
</header>
<nav>
<button class="tabBtn active" data-target="accounts">Comptes</button>
<button class="tabBtn" data-target="transactions">Transactions</button>
<button class="tabBtn" data-target="blocks">Blocs</button>
<button class="tabBtn" data-target="deploy-contract">Déployer</button>
</nav>
<main>
<section id="accounts" class="active">
<h2>Comptes</h2>
<table id="accounts-table">
<thead><tr><th>Adresse</th><th>Solde (ETH)</th></tr></thead>
<tbody></tbody>
</table>
</section>
<section id="transactions">
<h2>Transactions</h2>
<input id="searchTx" placeholder="Rechercher hash ou adresse..." />
<table id="transactions-table">
<thead><tr><th>Hash</th><th>De</th><th>À</th><th>Valeur (ETH)</th><th>Voir logs</th></tr></thead>
<tbody></tbody>
</table>
</section>
<section id="blocks">
<h2>Blocs</h2>
<table id="blocks-table">
<thead><tr><th>Numéro</th><th>Mineur</th><th>Timestamp</th><th>Tx count</th></tr></thead>
<tbody></tbody>
</table>
<div style="text-align:center; margin-top: 1em;">
<button id="prevPageBtn">Précédent</button>
<span id="pageNumber">1</span>
<button id="nextPageBtn">Suivant</button>
</div>
</section>
<section id="deploy-contract">
<h2>Déployer un contrat</h2>
<form id="deployForm">
<label>Nom du contrat:<input type="text" id="contractName" required/></label>
<label>Code Solidity:<textarea id="contractCode" rows="10" required>pragma solidity ^0.8.0;
contract SimpleStorage {
uint256 storedData;
event DataStored(uint256 data);
function set(uint256 x) public {
storedData = x;
emit DataStored(x);
}
function get() public view returns (uint256) {
return storedData;
}
}</textarea></label>
<button type="submit">Déployer</button>
</form>
<p id="deployResult"></p>
</section>
</main>
<script>
const tabs = document.querySelectorAll('.tabBtn');
const sections = document.querySelectorAll('main > section');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
tabs.forEach(t => t.classList.remove('active'));
sections.forEach(s => s.classList.remove('active'));
tab.classList.add('active');
document.getElementById(tab.dataset.target).classList.add('active');
});
});
// Le reste de ton script JS (chargements API, événements...) reste ici, identique au code d’origine,
// à adapter simplement si besoin pour le searchTx input dans la nouvelle position.
</script>
<script src="https://cdn.jsdelivr.net/npm/ethers@5.7.2/dist/ethers.min.js"></script>
</body>
</html>
Modèle 2 : Layout en grille avec sidebar fixe
Sidebar fixe sur la gauche avec toutes les sections accessibles. Le contenu change en fonction de la sélection. Plus moderne et utilisable avec de larges écrans.
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Ganache Web UI - Sidebar fixe</title>
<style>
body,html {
margin:0; padding:0; height:100%;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.sidebar {
width: 220px;
background: #2c3e50;
color: white;
height: 100vh;
position: fixed;
top:0; left:0;
display: flex; flex-direction: column;
}
.sidebar h2 {
padding: 1em;
text-align: center;
background: #1abc9c;
margin: 0;
}
.sidebar nav {
flex: 1;
display: flex;
flex-direction: column;
}
.sidebar nav button {
background: none;
border: none;
color: white;
padding: 1em;
text-align: left;
cursor: pointer;
border-left: 5px solid transparent;
font-size: 1em;
transition: background 0.3s, border-left-color 0.3s;
}
.sidebar nav button:hover,
.sidebar nav button.active {
background: #16a085;
border-left-color: white;
}
main {
margin-left: 220px;
padding: 1em;
}
section {
display: none;
}
section.active {
display: block;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ddd;
padding: 0.5em;
}
th {
background: #ecf0f1;
}
#searchTx {
margin-bottom: 0.5em;
width: 300px;
}
</style>
</head>
<body>
<div class="sidebar">
<h2>Ganache UI</h2>
<nav>
<button class="tabBtn active" data-target="accounts">Comptes</button>
<button class="tabBtn" data-target="transactions">Transactions</button>
<button class="tabBtn" data-target="blocks">Blocs</button>
<button class="tabBtn" data-target="contracts">Contrats</button>
<button class="tabBtn" data-target="deploy-contract">Déployer Contrat</button>
<button class="tabBtn" data-target="send-tx">Envoyer Tx</button>
</nav>
</div>
<main>
<section id="accounts" class="active">
<h2>Comptes</h2>
<table id="accounts-table">
<thead><tr><th>Adresse</th><th>Solde (ETH)</th></tr></thead>
<tbody></tbody>
</table>
</section>
<section id="transactions">
<h2>Transactions</h2>
<input id="searchTx" placeholder="Rechercher hash ou adresse..." />
<table id="transactions-table">
<thead><tr><th>Hash</th><th>De</th><th>À</th><th>Valeur (ETH)</th><th>Voir logs</th></tr></thead>
<tbody></tbody>
</table>
</section>
<section id="blocks">
<h2>Blocs</h2>
<table id="blocks-table">
<thead><tr><th>Numéro</th><th>Mineur</th><th>Timestamp</th><th>Tx count</th></tr></thead>
<tbody></tbody>
</table>
<div style="margin-top: 1em; text-align:center;">
<button id="prevPageBtn">Précédent</button>
<span id="pageNumber">1</span>
<button id="nextPageBtn">Suivant</button>
</div>
</section>
<section id="contracts">
<h2>Contrats</h2>
<table id="contracts-table">
<thead><tr><th>Nom</th><th>Adresse</th><th>Bloc déploiement</th></tr></thead>
<tbody></tbody>
</table>
</section>
<section id="deploy-contract">
<h2>Déployer un contrat</h2>
<form id="deployForm">
<label>Nom du contrat:<input type="text" id="contractName" required/></label>
<label>Code Solidity:<textarea id="contractCode" rows="10" required>pragma solidity ^0.8.0;
contract SimpleStorage {
uint256 storedData;
event DataStored(uint256 data);
function set(uint256 x) public {
storedData = x;
emit DataStored(x);
}
function get() public view returns (uint256) {
return storedData;
}
}</textarea></label>
<button type="submit">Déployer</button>
</form>
<p id="deployResult"></p>
</section>
<section id="send-tx">
<h2>Envoyer une transaction</h2>
<form id="sendTxForm">
<label>De:
<select id="txFrom" required></select>
</label><br><br>
<label>À:
<input type="text" id="txTo" placeholder="Adresse destination" required/>
</label><br><br>
<label>Valeur (ETH):
<input type="number" id="txValue" min="0" step="0.0001" required/>
</label><br><br>
<button type="submit">Envoyer</button>
</form>
<p id="sendTxResult"></p>
</section>
</main>
<script>
const tabs = document.querySelectorAll('.tabBtn');
const sections = document.querySelectorAll('main > section');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
tabs.forEach(t => t.classList.remove('active'));
sections.forEach(s => s.classList.remove('active'));
tab.classList.add('active');
document.getElementById(tab.dataset.target).classList.add('active');
});
});
// Intégrer le JS original (chargements API, événements...) ici aussi.
</script>
<script src="https://cdn.jsdelivr.net/npm/ethers@5.7.2/dist/ethers.min.js"></script>
</body>
</html>
Modèle 3 : Affichage tout en scrolling avec accordéons
Un modèle où toutes les sections s’affichent sur une seule page, mais réglées avec des accordéons pour masquer/afficher le contenu. Bien pour un aperçu rapide.
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Ganache Web UI - Accordéons</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 1em;
background: #fafafa;
}
h1 {
text-align: center;
}
.accordion {
background-color: #2c3e50;
color: white;
cursor: pointer;
padding: 1em;
width: 100%;
text-align: left;
border: none;
outline: none;
transition: background-color 0.3s ease;
margin-bottom: 0.5em;
font-size: 1.2em;
}
.accordion:hover, .accordion.active {
background-color: #16a085;
}
.panel {
padding: 0 1em;
background-color: white;
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
box-shadow: 0 1px 5px rgba(0,0,0,0.1);
margin-bottom: 1em;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ddd;
padding: 0.5em;
}
th {
background: #f4f4f4;
}
#searchTx {
width: 100%;
margin-bottom: 0.5em;
}
form label {
display: block;
margin: 0.5em 0;
}
form input, form textarea, form select {
width: 100%;
padding: 0.3em;
box-sizing: border-box;
}
form button {
margin-top: 1em;
padding: 0.7em;
width: 100%;
background: #16a085;
border: none;
color: white;
font-size: 1em;
cursor: pointer;
}
form button:hover {
background: #138d75;
}
</style>
</head>
<body>
<h1>Ganache Web UI avancé - Accordéons</h1>
<button class="accordion" aria-expanded="false">Comptes</button>
<div class="panel" aria-hidden="true">
<table id="accounts-table">
<thead><tr><th>Adresse</th><th>Solde (ETH)</th></tr></thead>
<tbody></tbody>
</table>
</div>
<button class="accordion" aria-expanded="false">Transactions</button>
<div class="panel" aria-hidden="true">
<input id="searchTx" placeholder="Rechercher hash ou adresse..." />
<table id="transactions-table">
<thead><tr><th>Hash</th><th>De</th><th>À</th><th>Valeur (ETH)</th><th>Voir logs</th></tr></thead>
<tbody></tbody>
</table>
</div>
<button class="accordion" aria-expanded="false">Blocs</button>
<div class="panel" aria-hidden="true">
<table id="blocks-table">
<thead><tr><th>Numéro</th><th>Mineur</th><th>Timestamp</th><th>Tx count</th></tr></thead>
<tbody></tbody>
</table>
<div style="text-align:center; margin-top: 1em;">
<button id="prevPageBtn">Précédent</button>
<span id="pageNumber">1</span>
<button id="nextPageBtn">Suivant</button>
</div>
</div>
<button class="accordion" aria-expanded="false">Contrats</button>
<div class="panel" aria-hidden="true">
<table id="contracts-table">
<thead><tr><th>Nom</th><th>Adresse</th><th>Bloc déploiement</th></tr></thead>
<tbody></tbody>
</table>
</div>
<button class="accordion" aria-expanded="false">Déployer un contrat</button>
<div class="panel" aria-hidden="true">
<form id="deployForm">
<label>Nom du contrat:<input type="text" id="contractName" required/></label>
<label>Code Solidity:<textarea id="contractCode" rows="10" required>pragma solidity ^0.8.0;
contract SimpleStorage {
uint256 storedData;
event DataStored(uint256 data);
function set(uint256 x) public {
storedData = x;
emit DataStored(x);
}
function get() public view returns (uint256) {
return storedData;
}
}</textarea></label>
<button type="submit">Déployer</button>
</form>
<p id="deployResult"></p>
</div>
<button class="accordion" aria-expanded="false">Envoyer une transaction</button>
<div class="panel" aria-hidden="true">
<form id="sendTxForm">
<label>De:
<select id="txFrom" required></select>
</label>
<label>À:
<input type="text" id="txTo" placeholder="Adresse destination" required/>
</label>
<label>Valeur (ETH):
<input type="number" id="txValue" min="0" step="0.0001" required/>
</label>
<button type="submit">Envoyer</button>
</form>
<p id="sendTxResult"></p>
</div>
<script>
const acc = document.querySelectorAll(".accordion");
acc.forEach(button => {
button.addEventListener("click", () => {
const isActive = button.classList.contains("active");
acc.forEach(b => {
b.classList.remove("active");
b.setAttribute('aria-expanded', 'false');
b.nextElementSibling.style.maxHeight = null;
b.nextElementSibling.setAttribute('aria-hidden', 'true');
});
if(!isActive) {
button.classList.add("active");
button.setAttribute('aria-expanded', 'true');
const panel = button.nextElementSibling;
panel.style.maxHeight = panel.scrollHeight + "px";
panel.setAttribute('aria-hidden', 'false');
}
});
});
// Le reste du JS comme avant (fetch, event listener, modal, etc.)
</script>
<script src="https://cdn.jsdelivr.net/npm/ethers@5.7.2/dist/ethers.min.js"></script>
</body>
</html>
Modèle 4 : Design épuré en "cards" (cartes)
Un design moderne où chaque section est une carte avec un titre, concis et joli, parfaitement adapté aux mises en page responsives.
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Ganache Web UI - Cartes</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 1em;
background: #f0f4f7;
}
h1 {
text-align: center;
margin-bottom: 2em;
}
.card {
background: white;
padding: 1.5em;
margin-bottom: 2em;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.card h2 {
margin-top: 0;
margin-bottom: 1em;
border-bottom: 2px solid #16a085;
padding-bottom: 0.5em;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 1em;
}
th, td {
border: 1px solid #ddd;
padding: 0.5em;
}
th {
background: #16a085;
color: white;
}
#searchTx {
float: right;
margin-bottom: 1em;
padding: 0.4em;
border: 1px solid #ccc;
border-radius: 5px;
width: 280px;
}
label {
display: block;
margin: 0.7em 0 0.3em;
}
input[type=text], input[type=number], select, textarea {
width: 100%;
padding: 0.5em;
box-sizing: border-box;
border-radius: 6px;
border: 1px solid #ccc;
}
button {
background: #16a085;
color: white;
padding: 0.7em 1.2em;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 1em;
}
button:hover {
background: #138d75;
}
.pagination {
text-align: center;
}
.pagination button {
margin: 0 1em;
}
</style>
</head>
<body>
<h1>Ganache Web UI avancé - Cartes</h1>
<div class="card" id="accounts">
<h2>Comptes</h2>
<table id="accounts-table">
<thead><tr><th>Adresse</th><th>Solde (ETH)</th></tr></thead>
<tbody></tbody>
</table>
</div>
<div class="card" id="transactions">
<h2>Transactions <input id="searchTx" placeholder="Rechercher hash ou adresse..."></h2>
<table id="transactions-table">
<thead><tr><th>Hash</th><th>De</th><th>À</th><th>Valeur (ETH)</th><th>Voir logs</th></tr></thead>
<tbody></tbody>
</table>
</div>
<div class="card" id="blocks">
<h2>Blocs</h2>
<table id="blocks-table">
<thead><tr><th>Numéro</th><th>Mineur</th><th>Timestamp</th><th>Tx count</th></tr></thead>
<tbody></tbody>
</table>
<div class="pagination">
<button id="prevPageBtn">Précédent</button>
<span id="pageNumber">1</span>
<button id="nextPageBtn">Suivant</button>
</div>
</div>
<div class="card" id="contracts">
<h2>Contrats</h2>
<table id="contracts-table">
<thead><tr><th>Nom</th><th>Adresse</th><th>Bloc déploiement</th></tr></thead>
<tbody></tbody>
</table>
</div>
<div class="card" id="deploy-contract">
<h2>Déployer un contrat</h2>
<form id="deployForm">
<label>Nom du contrat:</label>
<input type="text" id="contractName" required/>
<label>Code Solidity:</label>
<textarea id="contractCode" rows="10" required>pragma solidity ^0.8.0;
contract SimpleStorage {
uint256 storedData;
event DataStored(uint256 data);
function set(uint256 x) public {
storedData = x;
emit DataStored(x);
}
function get() public view returns (uint256) {
return storedData;
}
}</textarea>
<button type="submit">Déployer</button>
</form>
<p id="deployResult"></p>
</div>
<div class="card" id="send-tx">
<h2>Envoyer une transaction</h2>
<form id="sendTxForm">
<label>De:</label>
<select id="txFrom" required></select>
<label>À:</label>
<input type="text" id="txTo" placeholder="Adresse destination" required/>
<label>Valeur (ETH):</label>
<input type="number" id="txValue" min="0" step="0.0001" required/>
<button type="submit">Envoyer</button>
</form>
<p id="sendTxResult"></p>
</div>
<script>
// Le Javascript reste le même qu'en version originale, s'adapte très bien tel quel.
</script>
<script src="https://cdn.jsdelivr.net/npm/ethers@5.7.2/dist/ethers.min.js"></script>
</body>
</html>
Notes pour les 4 modèles
- L’essentiel est d’adapter la navigation/présentation (onglets, sidebar, accordéons, cartes).
- Le code JS et les interactions (fetch API, form submit, gestion des modals) restent quasiment identiques et peuvent être extraits dans un fichier ou dupliqués.
- Tu peux facilement ajouter les styles personnalisés en CSS en fonction de tes couleurs/branding.
- Pour les fonctions JS, veille à bien adapter les sélecteurs si tu places par exemple le champ
#searchTx dans une autre section.
- Pour chaque modèle tu peux t’inspirer ou réutiliser ton code d’origine côté JS, il ne faut adapter que la partie interaction UI (gestion des visibles, affichage).
Si tu veux je peux aussi te générer des scripts JS adaptatifs pour chacun, dis-le-moi !