-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ekko-live/feature/restructure-project
🎨 Restructure project
- Loading branch information
Showing
11 changed files
with
80 additions
and
1,501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,3 @@ | ||
# ekko - user app example | ||
# `ekko-client` | ||
|
||
## TODO | ||
|
||
- Add wrappers around socket.io methods in BOTH `ekko-client.js` files | ||
- Get the `publish` and `subscribe` stuff setup | ||
- Add in DOM modification to update the actual DOM (see below) | ||
- Look into how to actually get all the code combined and loaded in... CDN? NPM package? | ||
|
||
``` | ||
// CODE FROM "Ephemeral" front end | ||
<script> | ||
const socket = io(); | ||
const form = document.querySelector("form"); | ||
const thought = document.getElementById("thought"); | ||
const thoughts = document.getElementById("thoughts"); | ||
form.addEventListener("submit", e => { | ||
e.preventDefault(); | ||
if (thought.value) { | ||
socket.emit("thought", thought.value); | ||
thought.value = ""; | ||
} | ||
}) | ||
socket.on('thought', (msg) => { | ||
let thought = document.createElement('LI'); | ||
thought.innerHTML = msg | ||
thoughts.insertBefore(thought, thoughts.children[0]) | ||
updateStyle() | ||
}) | ||
const updateStyle = () => { | ||
let thoughts = [...document.querySelectorAll("li")]; | ||
for (let i = 0; i < thoughts.length; i++) { | ||
const thought = thoughts[i]; | ||
if (i > 9) { | ||
thought.parentElement.removeChild(thought); | ||
} | ||
thought.style.color = `rgba(0, 0, 0, ${(10 - i) / 10})`; | ||
} | ||
} | ||
</script> | ||
``` | ||
JavaScript client to interact with realtime `ekko-server` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.