Improve UI styles

This commit is contained in:
Nur Muhammad
2022-07-05 17:42:13 +08:00
parent e1eb461cbb
commit b16bf4a5e2
2 changed files with 110 additions and 16 deletions

View File

@@ -2,17 +2,73 @@
<html>
<head>
<title>Whatsapp API by Ngekoding</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- This parts is optional, just for improve the styles -->
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
<style>
.client {
border: 1px solid #ccc;
padding: 20px;
box-sizing: border-box;
display: inline-block;
margin: 10px;
}
.hide {
display: none;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Montserrat', sans-serif;
padding: 20px;
}
.form-container {
margin: 15px 0;
max-width: 500px;
}
.form-container input,
.form-container textarea {
width: 100%;
border: 1px solid #ccc;
border-radius: 2px;
padding: 5px 8px;
font-family: inherit;
}
.add-client-btn {
padding: 6px 15px;
margin-top: 10px;
background: green;
color: white;
border: 1px solid rgb(0, 93, 0);
border-radius: 2px;
}
.client-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
grid-gap: 15px;
margin-top: 30px;
}
.client {
border: 1px solid #ccc;
border-radius: 4px;
padding: 15px;
}
#qrcode {
display: none; /* Showed when qr code received */
width: 100%;
margin: 10px 0;
border: 1px solid #efefef;
border-radius: 4px;
}
ul.logs {
max-height: 150px;
padding: 15px 15px 15px 30px;
margin-top: 5px;
border-radius: 4px;
overflow-y: auto;
background: #efefef;
color: #666;
font-size: 14px;
}
ul.logs li:first-child {
color: green;
}
.hide {
display: none;
}
</style>
</head>
<body>
@@ -26,10 +82,9 @@
<br><br>
<label for="client-description">Deskripsi</label><br>
<textarea rows="3" id="client-description" placeholder="Masukkan deskripsi"></textarea>
<br><br>
<br>
<button class="add-client-btn">Tambah Client</button>
</div>
<hr>
<div class="client-container">
<div class="client hide">
<h3 class="title"></h3>
@@ -67,6 +122,7 @@
template.find('.title').html(clientId);
template.find('.description').html(clientDescription);
template.find('.logs').append($('<li>').text('Connecting...'));
$('.client-container').append(template);
socket.emit('create-session', {
@@ -94,9 +150,9 @@
$('.client-container').append(template);
if (session.ready) {
$(`.client.${clientClass} .logs`).append($('<li>').text('Whatsapp is ready!'));
$(`.client.${clientClass} .logs`).prepend($('<li>').text('Whatsapp is ready!'));
} else {
$(`.client.${clientClass} .logs`).append($('<li>').text('Connecting...'));
$(`.client.${clientClass} .logs`).prepend($('<li>').text('Connecting...'));
}
}
});
@@ -106,7 +162,7 @@
});
socket.on('message', function(data) {
$(`.client.client-${data.id} .logs`).append($('<li>').text(data.text));
$(`.client.client-${data.id} .logs`).prepend($('<li>').text(data.text));
});
socket.on('qr', function(data) {

View File

@@ -2,6 +2,44 @@
<html>
<head>
<title>Whatsapp API by Ngekoding</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- This parts is optional, just for improve the styles -->
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Montserrat', sans-serif;
padding: 20px;
}
#app {
max-width: 500px;
margin: 20px auto;
}
#qrcode {
display: none; /* Showed when qr code received */
width: 100%;
margin: 10px 0;
border: 1px solid #efefef;
border-radius: 4px;
}
ul.logs {
max-height: 150px;
padding: 15px 15px 15px 30px;
margin-top: 5px;
border-radius: 4px;
overflow-y: auto;
background: #efefef;
color: #666;
font-size: 14px;
}
ul.logs li:first-child {
color: green;
}
</style>
</head>
<body>
@@ -20,7 +58,7 @@
var socket = io();
socket.on('message', function(msg) {
$('.logs').append($('<li>').text(msg));
$('.logs').prepend($('<li>').text(msg));
});
socket.on('qr', function(src) {