diff --git a/backends/WebSocketsVideoBroadcast/package.json b/backends/WebSocketsVideoBroadcast/package.json deleted file mode 100644 index 45eb998..0000000 --- a/backends/WebSocketsVideoBroadcast/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "websocketsvideobroadcast", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js" - }, - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.18.2", - "socket.io": "^4.7.4" - } -} diff --git a/backends/WebSocketsVideoBroadcast/public/broadcast.html b/backends/WebSocketsVideoBroadcast/public/broadcast.html deleted file mode 100644 index e69de29..0000000 diff --git a/backends/WebSocketsVideoBroadcast/public/styles.css b/backends/WebSocketsVideoBroadcast/public/styles.css deleted file mode 100644 index e69de29..0000000 diff --git a/backends/WebSocketsVideoBroadcast/public/watch.js b/backends/WebSocketsVideoBroadcast/public/watch.js deleted file mode 100644 index e69de29..0000000 diff --git a/backends/WebSocketsVideoBroadcast/server.js b/backends/WebSocketsVideoBroadcast/server.js deleted file mode 100644 index 1d726c9..0000000 --- a/backends/WebSocketsVideoBroadcast/server.js +++ /dev/null @@ -1,28 +0,0 @@ -const express = require('express'); -const app = express(); - -const port = 4000; - -const http = require('http'); -const server = http.createServer(app); - -const io = require('socket.io')(server); -app.use(express.static(__dirname + '/public')); - -io.sockets.on('error', (e) => console.log(e)); -server.listen(port, () => console.log(`Server is running on port ${port}`)); - -let broadcaster; - -io.sockets.on('connection', (socket) => { - socket.on('broadcaster', () => { - broadcaster = socket.id; - socket.broadcast.emit('broadcaster'); - }); - socket.on('watcher', () => { - socket.to(broadcaster).emit('watcher', socket.id); - }); - socket.on('disconnect', () => { - socket.to(broadcaster).emit('disconnectPeer', socket.id); - }); -}); diff --git a/backends/webrtc/signalling-server.ts b/backends/webrtc/signalling-server.ts deleted file mode 100644 index e69de29..0000000 diff --git a/js/components/nav.js b/js/components/nav.js index 97fd56e..65d6869 100644 --- a/js/components/nav.js +++ b/js/components/nav.js @@ -1,143 +1,125 @@ -//stored in /components/nav.js +// stored in /components/nav.js /** - * IMPORTANT This component assumes a single parent wrapper alongside a main sibling for content so - * that it can change the flex direction of the parent - * @param hostComponent + * IMPORTANT: This component assumes a single parent wrapper alongside a main sibling for content + * so that it can change the flex direction of the parent. * - * @example - * in sidebar mode - * + * @param {HTMLElement} hostComponent * + * @example + * In sidebar mode: + * */ + export default (hostComponent) => { const render = (isHeaderBarMode = false) => { - // dont display the nav if we are in header bar mode and modify the parent flex direction - let { burgerPx, headerBar } = hostComponent.dataset; + // Validate that burgerPx is only used with headerBar + const { burgerPx, headerBar } = hostComponent.dataset; if (!headerBar && burgerPx) { - throw new Error("you do not need burgerPx when headerBar isn't true"); + throw new Error('burgerPx should only be used when headerBar is true'); } // CSS styles for the navigation component - - // language=CSS const navStyles = ` nav { + ${ + burgerPx + ? 'animation: 0.5s ease-in-out 0s 1 slideInFromTop;' + : 'animation: 0.5s ease-in-out 0s 1 slideInFromLeft;' + } - - ${ - burgerPx - ? 'animation: 0.5s ease-in-out 0s 1 slideInFromTop;' - : 'animation: 0.5s ease-in-out 0s 1 slideInFromLeft;' - } - - display: flex; - flex-direction: column; - gap: 1rem; - padding: 10px 20px; - background-color: var(--nav-background-color); - min-width: 140px; - flex-wrap: wrap; - -${ - !headerBar - ? ` + display: flex; + flex-direction: column; + gap: 1rem; + padding: 10px 20px; + background-color: var(--nav-background-color); + min-width: 140px; + flex-wrap: wrap; - @media (max-width: 600px) { - & .text { - display: none; - } - min-width: auto; - } - ` - : '' -} + ${ + !headerBar + ? ` + @media (max-width: 600px) { + & .text { + display: none; + } + min-width: auto; + } + ` + : '' + } - & button { - width: 100%; - } - &.header-bar-mode { - flex-direction: row; - justify-content: center; - background-color: transparent; - & a { - color: var(--default-text); - } + & button { + width: 100%; + } - ${ - burgerPx - ? ` - @media (max-width: ${burgerPx}px) { - - display: none; - - align-items: center; + &.header-bar-mode { + flex-direction: row; + justify-content: center; + background-color: transparent; - flex-direction: column; - position: absolute; - background-color: var(--nav-background-color); - - top: 40px; - left: 0; -/* - border: 1px solid var(--minor-text); -*/ - border-radius: 1rem; - &.burger-open { - display: flex; + & a { + color: var(--default-text); } - ` - : `` - } - } -}`; - if (hostComponent.dataset.headerBar === 'true') { + ${ + burgerPx + ? ` + @media (max-width: ${burgerPx}px) { + display: none; + align-items: center; + flex-direction: column; + position: absolute; + background-color: var(--nav-background-color); + top: 40px; + left: 0; + border-radius: 1rem; + + &.burger-open { + display: flex; + } + } + ` + : '' + } + } + } + `; + + // Add header bar class if applicable + if (headerBar === 'true') { hostComponent.classList.add('header-bar-mode'); hostComponent.parentElement.style.flexDirection = 'column'; } - // Update the count display and button markup together - hostComponent.innerHTML = /* html */ ` - + // Render the navigation items + hostComponent.innerHTML = ` + 🏠 - Home 🔘 - Button + Badges - Form 🗺 - Maps - - + 👥 DB users - 📆 - Calendar + 📆 + Calendar - + 🧬 Multiple instances @@ -148,30 +130,36 @@ ${ 🪄 WebRTC - `; + + `; + + // Add button styles hostComponent.querySelectorAll('a').forEach((navLink) => { navLink.classList.add('button', 'secondary', 'squarify'); }); - //add burger button to the parent if we are in header bar mode, use inline svg for icon + + // Add burger button for header bar mode if (headerBar === 'true' && burgerPx) { hostComponent.parentElement.insertAdjacentHTML( 'afterbegin', ` - + `, ); + + // Toggle burger menu visibility hostComponent.parentElement.querySelector('.burger-button').addEventListener('click', () => { hostComponent.classList.toggle('burger-open'); }); } }; - // Display the initial count + // Initial render render(); };