diff --git a/ui/_/code/quill.js b/ui/_/code/quill.js index c8a0f7a..3be0247 100644 --- a/ui/_/code/quill.js +++ b/ui/_/code/quill.js @@ -1084,7 +1084,7 @@ HTMLElement.prototype.onTap = function(cb) { - We can't just put a listener on the element, because a window "navigate" event won't trigger it - We can't just put a listener on the window, because the "this" variable will only refer to the window - And, if we try to re-add that scope using bind(), it makes the return value of .toString() unreadable, which means we cannot detect duplicate listeners. -- Therefore, we attach a global navigate event to the window, and each navigate event in this array, and manually trigger each event when the global one fires. +- Therefore, we attach a global navigate event to the window, and store each navigate event in this navigateListeners array, and manually trigger each event on the elements when the global one fires. */ navigateListeners = [] window.addEventListener("navigate", () => { diff --git a/ui/desktop/Home.js b/ui/desktop/Home.js index 34435d3..d127962 100644 --- a/ui/desktop/Home.js +++ b/ui/desktop/Home.js @@ -47,6 +47,11 @@ class Home extends Shadow { }) a("/signout", "Sign Out") + .paddingVertical(0) + .paddingHorizontal(0.5, em) + .height(2, em) + .lineHeight(2, em) + .fontSize(0.8, em) .background("transparent") .border("1px solid var(--accent") .color("var(--accent)") diff --git a/ui/desktop/apps/Dashboard/Dashboard.js b/ui/desktop/apps/Dashboard/Dashboard.js index ee949d7..d7a14ea 100644 --- a/ui/desktop/apps/Dashboard/Dashboard.js +++ b/ui/desktop/apps/Dashboard/Dashboard.js @@ -41,7 +41,7 @@ class Dashboard extends Shadow { .maxWidth(95, pct) .gap(8); - window.comalData.contact.forEach((entry) => { + window.currentNetwork.data.contact.forEach((entry) => { HStack(() => { this.cell("time", entry.time); this.cell("fname", entry.fname); @@ -74,7 +74,7 @@ class Dashboard extends Shadow { .maxWidth(95, pct) .gap(8); - window.comalData.join.forEach((entry) => { + window.currentNetwork.data.contact.forEach((entry) => { HStack(() => { this.cell("time", entry.time); this.cell("fname", entry.fname); diff --git a/ui/desktop/apps/Forum/Forum.js b/ui/desktop/apps/Forum/Forum.js index 0f7fc26..95ace7a 100644 --- a/ui/desktop/apps/Forum/Forum.js +++ b/ui/desktop/apps/Forum/Forum.js @@ -69,7 +69,7 @@ class Forum extends Shadow { ForumPanel() - input("Message Hyperia", "98%") + input("Message Parchment", "98%") .paddingVertical(1, em) .paddingLeft(2, pct) .color("var(--accent)") diff --git a/ui/desktop/apps/Jobs/Jobs.js b/ui/desktop/apps/Jobs/Jobs.js index bb72598..25c6911 100644 --- a/ui/desktop/apps/Jobs/Jobs.js +++ b/ui/desktop/apps/Jobs/Jobs.js @@ -30,7 +30,7 @@ class Jobs extends Shadow { { title: "Austin Chapter Lead", salary: "1% of Local Revenue", - company: "Hyperia", + company: "Parchment", city: "Austin", state: "TX" } diff --git a/ui/desktop/apps/Market/Market.js b/ui/desktop/apps/Market/Market.js index e3bceeb..1da5332 100644 --- a/ui/desktop/apps/Market/Market.js +++ b/ui/desktop/apps/Market/Market.js @@ -33,7 +33,7 @@ class Market extends Shadow { stars: "5", reviews: 1, price: "$12", - company: "Hyperia", + company: "Parchment", type: "new", image: "/db/images/1", madeIn: "America" diff --git a/ui/desktop/apps/Market/MarketGrid.js b/ui/desktop/apps/Market/MarketGrid.js index 8740f9e..320f5ec 100644 --- a/ui/desktop/apps/Market/MarketGrid.js +++ b/ui/desktop/apps/Market/MarketGrid.js @@ -31,15 +31,15 @@ class MarketGrid extends Shadow { let params = new URLSearchParams(window.location.search); - const hyperiaMade = params.get("hyperia-made") === "true"; + const ParchmentMade = params.get("Parchment-made") === "true"; const americaMade = params.get("america-made") === "true"; const newItem = params.get("new") === "true"; const usedItem = params.get("used") === "true"; let filtered = this.listings; - if (hyperiaMade) { - filtered = filtered.filter(item => item.madeIn === "Hyperia"); + if (ParchmentMade) { + filtered = filtered.filter(item => item.madeIn === "Parchment"); } if (americaMade) { filtered = filtered.filter(item => item.madeIn === "America"); diff --git a/ui/desktop/apps/Market/MarketSidebar.js b/ui/desktop/apps/Market/MarketSidebar.js index 9324618..6843fc4 100644 --- a/ui/desktop/apps/Market/MarketSidebar.js +++ b/ui/desktop/apps/Market/MarketSidebar.js @@ -19,12 +19,12 @@ class MarketSidebar extends Shadow { input() .attr({ "type": "checkbox", - "id": "hyperia-check" + "id": "Parchment-check" }) .onChange(this.handleChecked) - label("Hyperia-Made") + label("Parchment-Made") .attr({ - "for": "hyperia-check" + "for": "Parchment-check" }) .marginLeft(0.5, em) }) diff --git a/ui/desktop/apps/People/People.js b/ui/desktop/apps/People/People.js new file mode 100644 index 0000000..d44e801 --- /dev/null +++ b/ui/desktop/apps/People/People.js @@ -0,0 +1,26 @@ +class People extends Shadow { + render() { + VStack(() => { + h1("Members") + .fontWeight("bold") + .marginBottom(2, em) + + for(let i = 0; i < window.currentNetwork.data.members.length; i++) { + let member = window.currentNetwork.data.members[i] + HStack(() => { + p(member.firstName + " " + member.lastName) + .width(10, pct) + p(member.email) + .width(10, pct) + }) + } + }) + .gap(0.5, em) + .paddingTop(4, pct) + .paddingLeft(5, pct) + .width(100, pct) + .height(100, pct); + } +} + +register(People) \ No newline at end of file diff --git a/ui/desktop/components/AppMenu.js b/ui/desktop/components/AppMenu.js index 6e393cb..ed6fbd5 100644 --- a/ui/desktop/components/AppMenu.js +++ b/ui/desktop/components/AppMenu.js @@ -46,7 +46,7 @@ class AppMenu extends Shadow { this.rerender() }) .onEvent("appchange", () => { - console.log("event firing successfully") + // console.log("app hello?") // BUG: Quill is not acknowledging this event unless there is something else in the function body this.rerender() }) .position("fixed") diff --git a/ui/desktop/components/AppWindow.js b/ui/desktop/components/AppWindow.js index 285ff8c..e495712 100644 --- a/ui/desktop/components/AppWindow.js +++ b/ui/desktop/components/AppWindow.js @@ -4,6 +4,7 @@ import "../apps/Tasks/Tasks.js" import "../apps/Messages/Messages.js" import "../apps/Market/Market.js" import "../apps/Jobs/Jobs.js" +import "../apps/People/People.js" class AppWindow extends Shadow { @@ -25,22 +26,16 @@ class AppWindow extends Shadow { case "Dashboard": Dashboard() break; - case "Forum": - Forum() - break; - case "Messages": - Messages() - break; - case "Market": - Market() - break; - case "Jobs": - Jobs() + case "People": + People() break; } }) .overflow("scroll") - .position("fixed") + .position("absolute") + .onEvent("resize", () => { + this.rerender() + }) .width(window.innerWidth - this.calculateWidth(), px) .height(window.innerHeight - this.calculateHeight(), px) .background("var(--app)") diff --git a/ui/desktop/index.js b/ui/desktop/index.js index 43908c4..bb40af5 100644 --- a/ui/desktop/index.js +++ b/ui/desktop/index.js @@ -9,17 +9,24 @@ window.Socket = new Socket() window.currentNetwork = "" window.currentApp = "" -window.addEventListener("navigate", () => { - if(window.currentNetwork !== selectedNetwork()) { - window.currentNetwork = selectedNetwork() +async function openNetworkAndApp() { + + if(window.currentNetwork !== networkFromPath()) { + window.currentNetwork = networkFromPath() const event = new CustomEvent('networkchanged', { detail: { name: currentNetwork } }); window.dispatchEvent(event) } - if(window.currentApp !== selectedApp()) { - window.currentApp = selectedApp() + if(!window.currentNetwork.data) { + let appData = await fetch("/app/orgdata/" + window.profile.networks[0].id, {method: "GET"}) + let json = await appData.json() + window.currentNetwork.data = json + } + + if(window.currentApp !== appFromPath()) { + window.currentApp = appFromPath() const event = new CustomEvent('appchange', { detail: { name: window.currentApp } }); @@ -29,9 +36,22 @@ window.addEventListener("navigate", () => { if(window.currentNetwork) { // 2 navigates fire on load: 1 initial, and one after the org redirect document.title = `${window.currentNetwork.abbreviation} | Parchment` } -}) +} -window.selectedNetwork = function () { +window.addEventListener("navigate", openNetworkAndApp) + +window.openApp = function(appName) { + const appUrl = appName.charAt(0).toLowerCase() + appName.slice(1); + let parts = window.location.pathname.split('/').filter(Boolean); + let newPath = "/" + parts[0] + "/" + appUrl + window.navigateTo(newPath) + const event = new CustomEvent('appchange', { + detail: { name: appName } + }); + window.dispatchEvent(event) +} + +window.networkFromPath = function () { const pathname = window.location.pathname; const firstSegment = pathname.split('/').filter(Boolean)[0] || ''; let networks = window.profile?.networks @@ -43,7 +63,7 @@ window.selectedNetwork = function () { } } -window.selectedApp = function() { +window.appFromPath = function() { const pathname = window.location.pathname; const segments = pathname.split('/').filter(Boolean); const secondSegment = segments[1] || ""; @@ -51,19 +71,6 @@ window.selectedApp = function() { return capitalized } -window.openApp = function(appName) { - const appUrl = appName.charAt(0).toLowerCase() + appName.slice(1); - let parts = window.location.pathname.split('/').filter(Boolean); - let newPath = "/" + parts[0] + "/" + appUrl - console.log(newPath) - window.navigateTo(newPath) - // window.history.replaceState({}, '', newPath); - const event = new CustomEvent('appchange', { - detail: { name: appName } - }); - window.dispatchEvent(event) -} - async function getProfile() { try { const res = await fetch("/profile", { @@ -77,38 +84,33 @@ async function getProfile() { if (!res.ok) throw new Error("Failed to fetch profile"); const profile = await res.json(); - console.log(profile); + console.log("getProfile: ", profile); window.profile = profile } catch (err) { console.error(err); } } -async function setCurrentNetwork() { +function getInitialNetworkPath() { let path = "" let defaultNetwork = window.profile.networks[0] - if(!selectedNetwork()) { + if(!networkFromPath()) { path += (defaultNetwork.abbreviation + "/") } - if(!selectedApp()) { + if(!appFromPath()) { let defaultApp = defaultNetwork.apps[0] path += defaultApp.toLowerCase() } - let appData = await fetch("/app/orgdata/" + defaultNetwork.id, {method: "GET"}) - let json = await appData.json() - console.log(json) - window.comalData = json - return path } getProfile().then(async () => { if(window.profile.networks.length > 0) { - let path = await setCurrentNetwork() + let path = getInitialNetworkPath() window.navigateTo(path) } diff --git a/ui/mobile/apps/Forum/Forum.js b/ui/mobile/apps/Forum/Forum.js index a507efc..aa40038 100644 --- a/ui/mobile/apps/Forum/Forum.js +++ b/ui/mobile/apps/Forum/Forum.js @@ -34,7 +34,7 @@ class Forum extends Shadow { ForumPanel() - input("Message Hyperia", "98%") + input("Message Parchment", "98%") .paddingVertical(1, em) .paddingLeft(2, pct) .color("var(--accent)") diff --git a/ui/mobile/apps/Jobs/Jobs.js b/ui/mobile/apps/Jobs/Jobs.js index bb72598..25c6911 100644 --- a/ui/mobile/apps/Jobs/Jobs.js +++ b/ui/mobile/apps/Jobs/Jobs.js @@ -30,7 +30,7 @@ class Jobs extends Shadow { { title: "Austin Chapter Lead", salary: "1% of Local Revenue", - company: "Hyperia", + company: "Parchment", city: "Austin", state: "TX" } diff --git a/ui/mobile/apps/Market/Market.js b/ui/mobile/apps/Market/Market.js index e3bceeb..1da5332 100644 --- a/ui/mobile/apps/Market/Market.js +++ b/ui/mobile/apps/Market/Market.js @@ -33,7 +33,7 @@ class Market extends Shadow { stars: "5", reviews: 1, price: "$12", - company: "Hyperia", + company: "Parchment", type: "new", image: "/db/images/1", madeIn: "America" diff --git a/ui/mobile/apps/Market/MarketGrid.js b/ui/mobile/apps/Market/MarketGrid.js index 8740f9e..320f5ec 100644 --- a/ui/mobile/apps/Market/MarketGrid.js +++ b/ui/mobile/apps/Market/MarketGrid.js @@ -31,15 +31,15 @@ class MarketGrid extends Shadow { let params = new URLSearchParams(window.location.search); - const hyperiaMade = params.get("hyperia-made") === "true"; + const ParchmentMade = params.get("Parchment-made") === "true"; const americaMade = params.get("america-made") === "true"; const newItem = params.get("new") === "true"; const usedItem = params.get("used") === "true"; let filtered = this.listings; - if (hyperiaMade) { - filtered = filtered.filter(item => item.madeIn === "Hyperia"); + if (ParchmentMade) { + filtered = filtered.filter(item => item.madeIn === "Parchment"); } if (americaMade) { filtered = filtered.filter(item => item.madeIn === "America"); diff --git a/ui/mobile/apps/Market/MarketSidebar.js b/ui/mobile/apps/Market/MarketSidebar.js index 9324618..6843fc4 100644 --- a/ui/mobile/apps/Market/MarketSidebar.js +++ b/ui/mobile/apps/Market/MarketSidebar.js @@ -19,12 +19,12 @@ class MarketSidebar extends Shadow { input() .attr({ "type": "checkbox", - "id": "hyperia-check" + "id": "Parchment-check" }) .onChange(this.handleChecked) - label("Hyperia-Made") + label("Parchment-Made") .attr({ - "for": "hyperia-check" + "for": "Parchment-check" }) .marginLeft(0.5, em) }) diff --git a/ui/mobile/index.html b/ui/mobile/index.html index 24bd703..fe8fbe8 100644 --- a/ui/mobile/index.html +++ b/ui/mobile/index.html @@ -1,7 +1,7 @@
-