Skip to content

Commit

Permalink
apply prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Jun 24, 2023
1 parent 328c182 commit 010188a
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-webxdc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release Webxdc
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
dist-xdc
webxdc.js
webxdc.d.ts
webxdc.d.ts
pnpm-lock.yaml
30 changes: 15 additions & 15 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
.btn {
background-color: #248bf5;
color: white;
padding: 0.4em;
border: none;
border-radius: 0.2rem;
background-color: #248bf5;
color: white;
padding: 0.4em;
border: none;
border-radius: 0.2rem;
}

input[type="text" i] {
padding: 0.3em;
padding: 0.3em;
}

.nick {
font-weight: bold;
font-weight: bold;
}

#chat-area {
background-color: #fff;
border: 1px solid #e5e5ea;
border-radius: 0.25rem;
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 0.5rem;
background-color: #fff;
border: 1px solid #e5e5ea;
border-radius: 0.25rem;
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 0.5rem;
}

.msg {
border-radius: 1.15rem;
line-height: 1.25;
padding: 0.5rem .875rem;
padding: 0.5rem 0.875rem;
margin: 0.1rem;
position: relative;
word-wrap: break-word;
Expand Down
49 changes: 31 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<script src="webxdc.js"></script>
<link rel="stylesheet" href="./css/main.css">
</head>
<body>
<h1>Chat</h1>
<form>
<input id="input" type="text" autocomplete="off" placeholder="Message" autofocus />
<input class="btn" type="submit" onclick="sendMsg(); return false;" value="Send" />
</form>
<p id="chat-area"></p>
<p><em><small id="deviceName"></small></em></p>
<script src="./js/main.js" type="module"></script>
<script src="webxdc.js"></script>
<link rel="stylesheet" href="./css/main.css" />
</head>
<body>
<h1>Chat</h1>
<form>
<input
id="input"
type="text"
autocomplete="off"
placeholder="Message"
autofocus
/>
<input
class="btn"
type="submit"
onclick="sendMsg(); return false;"
value="Send"
/>
</form>
<p id="chat-area"></p>
<p>
<em><small id="deviceName"></small></em>
</p>
<script src="./js/main.js" type="module"></script>

<!-- Uncomment to include developer tools in your webxdc to debug it inside Delta Chat -->
<!--
<!-- Uncomment to include developer tools in your webxdc to debug it inside Delta Chat -->
<!--
<script type="module">
import init from 'eruda'
init.init();
</script>
-->
</body>
</body>
</html>
67 changes: 36 additions & 31 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
function h(tag, attributes, ...children) {
const element = document.createElement(tag);
if (attributes) {
Object.entries(attributes).forEach(entry => {
element.setAttribute(entry[0], entry[1]);
});
}
element.append(...children);
return element;
const element = document.createElement(tag);
if (attributes) {
Object.entries(attributes).forEach((entry) => {
element.setAttribute(entry[0], entry[1]);
});
}
element.append(...children);
return element;
}

window.sendMsg = () => {
let msg = document.getElementById("input").value;
let info = window.webxdc.selfName + ': ' + msg;
document.getElementById("input").value = '';
let msg = document.getElementById("input").value;
let info = window.webxdc.selfName + ": " + msg;
document.getElementById("input").value = "";

// send new updates
window.webxdc.sendUpdate({
payload: {
name: window.webxdc.selfName,
msg,
},
info,
}, info);
}
// send new updates
window.webxdc.sendUpdate(
{
payload: {
name: window.webxdc.selfName,
msg,
},
info,
},
info
);
};

window.onload = () => {
// handle past and future state updates
window.webxdc.setUpdateListener(function (update) {
const chat = document.getElementById('chat-area');
chat.append(
h("p", {class: "msg"},
h("span", {class: "nick"}, update.payload.name, ": "),
update.payload.msg,
)
);
});
// handle past and future state updates
window.webxdc.setUpdateListener(function (update) {
const chat = document.getElementById("chat-area");
chat.append(
h(
"p",
{ class: "msg" },
h("span", { class: "nick" }, update.payload.name, ": "),
update.payload.msg
)
);
});

window.deviceName.innerHTML = 'You are: ' + window.webxdc.selfName;
window.deviceName.innerHTML = "You are: " + window.webxdc.selfName;
};
3 changes: 1 addition & 2 deletions test/basic.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect, test } from "vitest";


test("Example Test", () => {
expect(1+1).toBe(2);
expect(1 + 1).toBe(2);
});
15 changes: 7 additions & 8 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import packageJson from "./package.json";

let version = "";
if (packageJson.version) {
version = "_" + packageJson.version;
version = "_" + packageJson.version;
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
zipPack({
outDir: "dist-xdc",
outFileName:
(packageJson.name || "app") + version + ".xdc",
}),
],
plugins: [
zipPack({
outDir: "dist-xdc",
outFileName: (packageJson.name || "app") + version + ".xdc",
}),
],

// https://github.com/vitest-dev/vitest
test: {
Expand Down

0 comments on commit 010188a

Please sign in to comment.