Skip to content

Commit

Permalink
Merge branch 'pyr' of https://github.com/seung-lab/ng-extend into pyr
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikue committed Feb 10, 2024
2 parents 141c3d5 + 1ec2fd4 commit e403723
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 72 deletions.
46 changes: 28 additions & 18 deletions src/components/Chatbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
import {onMounted, onUnmounted} from "vue";
import {storeToRefs} from "pinia";
import {useChatStore, useStatsStore} from '../store';
import simplebar from "simplebar-vue";
import "simplebar-core/dist/simplebar.css";
import HologramPanel from "components/HologramPanel.vue";
import sendImage from '../images/send.svg';
import chevronImage from '../images/chevron.svg';
//import sendImage from '../images/send.svg';
//import chevronImage from '../images/chevron.svg';
const store = useChatStore();
const {chatMessages, unreadMessages} = storeToRefs(store);
const {sendMessage, markLastMessageRead} = store;
const {leaderboardEntries} = storeToRefs(useStatsStore());
function encodeSVG(svg: string) {
/*function encodeSVG(svg: string) {
return "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg);
}
}*/
onMounted(() => {
(document.querySelector(".nge-chatbox-messageprompt > img")! as HTMLImageElement).src = encodeSVG(chevronImage);
(document.querySelector(".nge-chatbox-submit > button > img")! as HTMLImageElement).src = encodeSVG(sendImage);
//(document.querySelector(".nge-chatbox-messageprompt > img")! as HTMLImageElement).src = encodeSVG(chevronImage);
//(document.querySelector(".nge-chatbox-submit > button > img")! as HTMLImageElement).src = encodeSVG(sendImage);
const scrollEl = document.querySelector(".nge-chatbox-scroll .simplebar-content-wrapper")!;
scrollEl.addEventListener("scroll", handleScroll);
Expand Down Expand Up @@ -65,6 +68,7 @@ function handleScroll() {
</script>

<template>
<hologram-panel class="nge-chatbox-hologram">
<div class="nge-chatbox" tabindex="1">
<!--<div class="nge-chatbox-title">
<div>Chat</div>
Expand Down Expand Up @@ -138,25 +142,25 @@ function handleScroll() {
</simplebar>
<div class="nge-chatbox-unread" v-show="unreadMessages" @click="scrollToBottom()">NEW MESSAGES</div>
<form class="nge-chatbox-sendmessage" @submit.prevent="submitMessage" autocomplete="off">
<div class="nge-chatbox-messageprompt"><img src="insert-svg" width="15" style="transform: rotate(90deg);" /></div>
<div class="nge-chatbox-inputbox"><input type="text" id="chatMessage" /></div>
<div class="nge-chatbox-submit"><button type="submit"><img src="insert-svg" width="15" /></button></div>
<!--<div class="nge-chatbox-messageprompt"><img src="insert-svg" width="15" style="transform: rotate(90deg);" /></div>-->
<div class="nge-chatbox-inputbox"><input type="text" id="chatMessage" placeholder=">"/></div>
<!--<div class="nge-chatbox-submit"><button type="submit"><img src="insert-svg" width="15" /></button></div>-->
</form>
</div>
</div>
</hologram-panel>
</template>

<style>
.nge-chatbox {
position: absolute;
.nge-chatbox-hologram {
width: 250px;
height: 300px;
bottom: 10px;
left: 10px;
border-radius: 25px;
box-shadow: inset 0 0 20px 3px #a46fe2, 0 0 4px #a46fe2;
background-color: #00000099;
}
.nge-chatbox {
z-index: 80; /* over top of leaderboard simplebar */
height: inherit;
/*display: grid;
grid-template-rows: min-content auto;*/
}
Expand All @@ -178,12 +182,13 @@ function handleScroll() {
display: grid;
grid-template-rows: auto minmax(auto, min-content) min-content;
height: inherit;
overflow: auto;
}
.nge-chatbox-messages {
font-size: 0.75em;
padding-top: 10px;
padding-left: 10px;
padding-right: 10px;
padding-left: 15px;
padding-right: 15px;
}
.nge-chatbox-message {
overflow-wrap: break-word;
Expand All @@ -207,7 +212,7 @@ function handleScroll() {
}
.nge-chatbox-info-content {
padding: 0.5em;
text-align: center;
/*text-align: center;*/
font-style: italic;
}
.nge-chatbox-time {
Expand All @@ -221,6 +226,9 @@ function handleScroll() {
display: grid;
grid-template-columns: min-content auto min-content;
padding-top: 5px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 12px;
}
.nge-chatbox-messageprompt {
padding-top: 5px;
Expand All @@ -231,8 +239,10 @@ function handleScroll() {
.nge-chatbox-inputbox > input {
color: #fff;
background-color: #111;
width: 200px;
/*
max-width: 150px;
/*border-width: 0px;*/
border-width: 0px;*/
}
.nge-chatbox-unread {
z-index: 90;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExtensionBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function logout(session: loginSession) {
<div id="extensionBar">
<div class="ng-extend-logo">
<a href="https://flywire.ai/" target="_blank">
<img src="insert-logo" title="Cave Explorer">
<img src="insert-logo" title="Pyr">
</a>
</div>
<div id="insertNGTopBar" class="flex-fill"></div>
Expand Down
76 changes: 76 additions & 0 deletions src/components/HologramPanel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<script setup lang="ts">
// Based on https://www.w3schools.com/howto/howto_js_draggable.asp
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
let elem: HTMLElement;
function clickHeader(event: MouseEvent) {
event.preventDefault();
elem = (event.target as HTMLElement).parentElement!.parentElement!;
pos3 = event.clientX;
pos4 = event.clientY;
document.onmouseup = release;
document.onmousemove = drag;
}
function drag(e: MouseEvent) {
e.preventDefault();
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
elem.style.top = (elem.offsetTop - pos2) + "px";
elem.style.left = (elem.offsetLeft - pos1) + "px";
}
function release() {
document.onmouseup = null;
document.onmousemove = null;
}
</script>

<template>
<div class="pyr-hologram-panel">
<div class="pyr-hologram-content">
<div class="pyr-hologram-header" @mousedown="clickHeader"></div>
<slot></slot>
</div>
<!--<div class="pyr-hologram-border"></div>-->
</div>
</template>

<style>
.pyr-hologram-panel {
position: absolute;
background-color: #00000099;
font-family: sans-serif;
overflow: hidden;
font-size: 13px;
z-index: 50;
/*border-radius: 10px;
box-shadow: 0 0 5px #a46fe2aa;
backdrop-filter: blur(5px);*/
background: linear-gradient(90deg, #01ffff36, #01ffff14);
border-radius: 20px;
border: 5px solid #0000ff00;
border-left: 5px solid #01ffffba;
border-right: none;
backdrop-filter: blur(2px);
}
.pyr-hologram-content {
position: absolute;
width: inherit;
height: inherit;
}
.pyr-hologram-header {
cursor: move;
height: 20px;
/*border: 2px solid #a46fe2aa;*/
}
/*.pyr-hologram-border {
border-radius: 10px;
box-shadow: inset 0 0 30px 3px #a46fe2aa;
position: relative;
height: inherit;
pointer-events: none;
}*/
</style>
108 changes: 63 additions & 45 deletions src/components/Leaderboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import simplebar from "simplebar-vue";
import "simplebar-core/dist/simplebar.css";
import {onMounted} from "vue";
import {storeToRefs} from "pinia";
import {useStatsStore, LeaderboardTimespan} from '../store';
import {useStatsStore, LeaderboardTimespan} from "../store";
import HologramPanel from "components/HologramPanel.vue";
import nurroImage from '../images/flying nurro.png';
import nurroImage from '../images/confetti nurro.png';
const store = useStatsStore();
const {leaderboardLoaded, leaderboardEntries} = storeToRefs(store);
Expand All @@ -15,7 +16,7 @@ let timespan: string|null = localStorage.getItem("timespan");
onMounted(() => {
selectButton(timespan || "Weekly");
(document.querySelector('.nge-leaderboard-headerimage > img')! as HTMLImageElement).src = nurroImage;
(document.querySelector(".nge-leaderboard-headerimage > img")! as HTMLImageElement).src = nurroImage;
});
function getPlace(index: number): string {
Expand Down Expand Up @@ -57,46 +58,59 @@ function setButtonHighlighted(timespan: string|null, highlighted: boolean) {
</script>

<template>
<div class="nge-leaderboard">
<div class="nge-leaderboard-headerimage"><img src="insert-logo" title="Nurro"></div>
<div class="nge-leaderboard-titlebar">
<div class="nge-sidebar-section-title">Top Editors</div>
</div>
<div class="nge-leaderboard-content">
<div class="nge-leaderboard-timeselect">
<div class="nge-leaderboard-timeselect-filler"></div>
<button v-for="timespan of getTimespanNames()" :key="timespan" :class="'nge-sidebar-button ' + timespan"
:title="'Switch to ' + timespan.toLowerCase() + ' leaderboard'" @click="selectButton(timespan)">{{timespan}}</button>
<div class="nge-leaderboard-timeselect-filler"></div>
</div>
<simplebar data-simplebar-auto-hide="false">
<div class="nge-leaderboard-entries">
<div class="nge-leaderboard-row nge-leaderboard-header">
<div>Rank</div>
<div>Name</div>
<div>Edits</div>
</div>
<div v-for="(entry, index) of leaderboardEntries" :key="'entry' + index"
:class="'nge-leaderboard-row row' + (((index+1) % 2) ? 'Odd' : 'Even') + getPlace(index)">
<div class="nge-leaderboard-rank">{{index+1}}</div>
<div class="nge-leaderboard-name">{{entry.name}}</div>
<div class="nge-leaderboard-score">{{entry.score}}</div>
</div>
<hologram-panel class="nge-leaderboard-hologram">
<div class="nge-leaderboard">
<div class="nge-leaderboard-headerimage"><img src="insert-logo" title="Nurro"></div>
<div class="nge-leaderboard-titlebar">Top Editors</div>
<div class="nge-leaderboard-content">
<div class="nge-leaderboard-timeselect">
<div class="nge-leaderboard-timeselect-filler"></div>
<button v-for="timespan of getTimespanNames()" :key="timespan" :class="'nge-sidebar-button ' + timespan"
:title="'Switch to ' + timespan.toLowerCase() + ' leaderboard'" @click="selectButton(timespan)">{{timespan}}</button>
<div class="nge-leaderboard-timeselect-filler"></div>
</div>
</simplebar>
<div class="nge-leaderboard-loading" v-show="!leaderboardLoaded">Loading...</div>
<div class="nge-leaderboard-loading" v-show="leaderboardLoaded && leaderboardEntries.length === 0">No edits yet... why not make one?</div>
<div class="nge-leaderboard-scroll">
<simplebar data-simplebar-auto-hide="false">
<div class="nge-leaderboard-entries">
<div class="nge-leaderboard-row nge-leaderboard-header">
<div>Rank</div>
<div>Name</div>
<div>Edits</div>
</div>
<div v-for="(entry, index) of leaderboardEntries" :key="'entry' + index"
:class="'nge-leaderboard-row row' + (((index+1) % 2) ? 'Odd' : 'Even') + getPlace(index)">
<div class="nge-leaderboard-rank">{{index+1}}</div>
<div class="nge-leaderboard-name">{{entry.name}}</div>
<div class="nge-leaderboard-score">{{entry.score}}</div>
</div>
</div>
</simplebar>
</div>
<div class="nge-leaderboard-loading" v-show="!leaderboardLoaded">Loading...</div>
<div class="nge-leaderboard-loading" v-show="leaderboardLoaded && leaderboardEntries.length === 0">No edits yet... why not make one?</div>
</div>
</div>
</div>
</hologram-panel>
</template>

<style>
.nge-leaderboard-hologram {
top: 45px;
bottom: 10px;
right: 10px;
width: 250px;
height: 700px;
}
.nge-leaderboard {
width: 200px;
background-color: #111;
display: grid;
grid-template-rows: min-content min-content auto;
font-family: sans-serif;
height: inherit;
}
.nge-leaderboard-headerimage {
margin: auto;
}
.nge-leaderboard-headerimage > img {
Expand All @@ -108,7 +122,15 @@ function setButtonHighlighted(timespan: string|null, highlighted: boolean) {
grid-template-rows: min-content auto auto;
}
.nge-leaderboard-titlebar {
font-size: 1.15em;
padding-top: 0.75em;
padding-bottom: 0.75em;
text-align: center;
}
.nge-leaderboard-timeselect {
/*background-color: #111;*/
display: grid;
grid-template-columns: 5% 45% 45% 5%;
}
Expand Down Expand Up @@ -136,13 +158,17 @@ function setButtonHighlighted(timespan: string|null, highlighted: boolean) {
overflow: auto;
}
.nge-leaderboard-scroll {
overflow: auto;
}
.nge-leaderboard-row {
display: contents;
}
.nge-leaderboard-row > div {
padding-top: 0.5em;
padding-bottom: 0.5em;
padding-top: 0.8em;
padding-bottom: 0.8em;
padding-left: 0.4em;
font-size: 0.9em;
}
Expand All @@ -153,7 +179,7 @@ function setButtonHighlighted(timespan: string|null, highlighted: boolean) {
}
.rowOdd > div {
background-color: #222;
background-color: #2226;
}
.nge-leaderboard-rank {
Expand All @@ -180,14 +206,6 @@ function setButtonHighlighted(timespan: string|null, highlighted: boolean) {
padding: 5px;
}
.nge-sidebar-section-title {
background-color: #111;
font-size: 1.15em;
padding-top: 0.75em;
padding-bottom: 0.75em;
text-align: center;
}
.firstplace {
color: gold;
}
Expand Down
Loading

0 comments on commit e403723

Please sign in to comment.