mirror of
https://github.com/status-im/status-chat-widget.git
synced 2025-02-20 16:28:44 +00:00
improve styling; add autoscroll
This commit is contained in:
parent
fbab9d8496
commit
072b077017
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
````Html
|
||||
<script src="https://status-im.github.io/status-chat-widget/dist/js/statuswidget.js"></script>
|
||||
<div id="status-chat-widget"></div>
|
||||
<script>StatusWidget("your-channel-name");</script>
|
||||
```
|
||||
|
2
dist/js/statuswidget.js
vendored
2
dist/js/statuswidget.js
vendored
File diff suppressed because one or more lines are too long
32
index.html
32
index.html
@ -1,5 +1,37 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
background-color: #eef2f5;
|
||||
}
|
||||
|
||||
#status-chat-widget {
|
||||
background-color: white;
|
||||
width: 33%;
|
||||
padding: 24px;
|
||||
border-radius: 16px;
|
||||
font-family: "Inter UI",-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top: 0px;
|
||||
color: #4360df;
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
#chat {
|
||||
height: 186px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#post {
|
||||
margin-top: 16px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
padding-left: 7px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="./dist/js/statuswidget.js"></script>
|
||||
|
10
src/index.js
10
src/index.js
@ -2,13 +2,18 @@ import StatusJS from 'status-js-api';
|
||||
import Murmur from 'murmur-client';
|
||||
|
||||
window.StatusWidget = function (channelName) {
|
||||
var channelTitle = document.createElement('h3');
|
||||
channelTitle.innerHTML = "#" + channelName;
|
||||
|
||||
var chatBox = document.createElement('div');
|
||||
chatBox.id = "chat";
|
||||
|
||||
var chatInput = document.createElement('input');
|
||||
chatInput.type = "input";
|
||||
chatInput.id = "post";
|
||||
chatInput.placeholder = "Type a message..";
|
||||
|
||||
document.querySelectorAll("#status-chat-widget")[0].append(channelTitle);
|
||||
document.querySelectorAll("#status-chat-widget")[0].append(chatBox);
|
||||
document.querySelectorAll("#status-chat-widget")[0].append(chatInput);
|
||||
|
||||
@ -32,7 +37,10 @@ window.StatusWidget = function (channelName) {
|
||||
let div = document.createElement('div');
|
||||
div.innerHTML = message.username + "> " + message.message;
|
||||
document.querySelectorAll("#chat")[0].append(div)
|
||||
})
|
||||
|
||||
var element = document.getElementById("chat");
|
||||
element.scrollTop = element.scrollHeight;
|
||||
});
|
||||
|
||||
var input = document.getElementById("post")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user