Split chat into public and private widgets, Places out of Collage, hide stamp scrollbars
Chat.vue (public) and PrivateChat.vue (admins only) are now separate canvas widgets over a shared ChatPanel.vue, replacing the tabbed widget. The messages store counts connect()/disconnect() so both can share one socket, and reopens it on an admin change itself so two mounted chats reconnect once. Places is its own widget (views/home/Places.vue); Collage is just the slideshow. The stamp wall hides its scrollbars. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,125 +1,24 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "鸟" widget on /stp — a two-tab cell: a <Slideshow> and, once signed in, the
|
||||
* Places list.
|
||||
*
|
||||
* The Places tab is added to `tabs` only when logged in, and the watcher forces
|
||||
* the view back to the collage on logout so a signed-out user is never left
|
||||
* staring at an empty private tab.
|
||||
* "鸟" widget on /stp — a <Slideshow>. The Places list that used to share it
|
||||
* as a second tab is its own widget now, views/home/Places.vue.
|
||||
*/
|
||||
import { ref, computed, watch } from "vue";
|
||||
import Slideshow from "@/components/util/Slideshow.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
import PlacesTable from "./PlacesTable.vue";
|
||||
import CreatePlace from "@/views/admin/CreatePlace.vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
const images = [{ url: "/img/memes/pidgeon.gif", comment: "鸟" }];
|
||||
|
||||
const auth = useAuthStore();
|
||||
const loggedIn = computed(() => auth.loggedIn);
|
||||
|
||||
const tabs = computed(() => [
|
||||
{ id: "collage", label: "鸟" },
|
||||
...(loggedIn.value ? [{ id: "places", label: "Places" }] : []),
|
||||
]);
|
||||
|
||||
const activeTab = ref("collage");
|
||||
const showAdd = ref(false);
|
||||
|
||||
// On logout the Places tab disappears from `tabs`; without this the component
|
||||
// would be left pointing at a tab that no longer exists and render nothing.
|
||||
watch(loggedIn, (isIn) => {
|
||||
if (!isIn && activeTab.value === "places") activeTab.value = "collage";
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="collage-cell">
|
||||
<div class="tabs">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.id"
|
||||
class="tab"
|
||||
:class="{ 'is-active': activeTab === tab.id }"
|
||||
@click="activeTab = tab.id"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
<div class="tab-spacer" />
|
||||
<button
|
||||
v-if="loggedIn && activeTab === 'places'"
|
||||
class="tab add-btn"
|
||||
title="Add a place / thing to do"
|
||||
@click="showAdd = true"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="tab-body">
|
||||
<Slideshow v-if="activeTab === 'collage'" :images="images" />
|
||||
<PlacesTable v-else-if="loggedIn" />
|
||||
</div>
|
||||
|
||||
<Modal v-model="showAdd">
|
||||
<CreatePlace @done="showAdd = false" @cancel="showAdd = false" />
|
||||
</Modal>
|
||||
<Slideshow :images="images" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.collage-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 2px;
|
||||
padding: 2px;
|
||||
border-bottom: 1px solid var(--color-quaternary);
|
||||
background-color: var(--color-surface-deep);
|
||||
}
|
||||
|
||||
.tab {
|
||||
background-color: var(--color-link-bg);
|
||||
color: var(--color-primary);
|
||||
border: 1px solid transparent;
|
||||
padding: 2px 8px;
|
||||
font-family: var(--font-heading);
|
||||
letter-spacing: 0.05em;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background-color 120ms ease,
|
||||
border-color 120ms ease,
|
||||
color 120ms ease;
|
||||
}
|
||||
.tab:hover {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
.tab.is-active {
|
||||
border-color: var(--color-primary);
|
||||
color: var(--color-tertiary);
|
||||
background-color: var(--color-surface-tint);
|
||||
}
|
||||
|
||||
.tab-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
min-width: 24px;
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
.tab-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Places-to-go widget: the <PlacesTable> under a header whose "+" opens the
|
||||
* create form. Sign-in only, like the places mutations themselves, so a
|
||||
* signed-out visitor gets a one-line prompt instead of an empty table.
|
||||
*
|
||||
* Its own "+" rather than <CreateToggle>, because that one is admin-only and
|
||||
* any signed-in user may add a place.
|
||||
*/
|
||||
import { computed, ref } from "vue";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
import PlacesTable from "./PlacesTable.vue";
|
||||
import CreatePlace from "@/views/admin/CreatePlace.vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
const auth = useAuthStore();
|
||||
const loggedIn = computed(() => auth.loggedIn);
|
||||
const showAdd = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="places-cell">
|
||||
<Header class="text-left">
|
||||
Places
|
||||
<template v-if="loggedIn" #action>
|
||||
<button
|
||||
class="text-sm px-1"
|
||||
title="Add a place / thing to do"
|
||||
@click="showAdd = !showAdd"
|
||||
>
|
||||
{{ showAdd ? "x" : "+" }}
|
||||
</button>
|
||||
</template>
|
||||
</Header>
|
||||
<div class="places-body">
|
||||
<PlacesTable v-if="loggedIn" />
|
||||
<p v-else class="places-signin">Sign in to see places.</p>
|
||||
</div>
|
||||
|
||||
<Modal v-model="showAdd">
|
||||
<CreatePlace @done="showAdd = false" @cancel="showAdd = false" />
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.places-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.places-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.places-signin {
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
color: var(--color-muted);
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
/**
|
||||
* The Places-to-go table inside the Collage widget. Sign-in only.
|
||||
* The Places-to-go table inside the Places widget (Places.vue). Sign-in only.
|
||||
*
|
||||
* Fetches lazily and at most once: onMounted covers an already-signed-in visitor,
|
||||
* the `loggedIn` watcher covers someone who signs in while the page is open, and
|
||||
|
||||
@@ -129,8 +129,8 @@ function bounce() {
|
||||
|
||||
onMounted(() => {
|
||||
fitWall();
|
||||
// The cell's size follows the home grid's breakpoints (and the scrollbars
|
||||
// appearing inside it), not just window resizes, so observe the element.
|
||||
// The cell's size follows the box it sits in, not just window resizes, so
|
||||
// observe the element.
|
||||
resizeObserver = new ResizeObserver(fitWall);
|
||||
resizeObserver.observe(touchscreen.value.$el);
|
||||
animId = requestAnimationFrame(bounce);
|
||||
@@ -143,7 +143,7 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Touchscreen ref="touchscreen">
|
||||
<Touchscreen ref="touchscreen" class="stamp-wall">
|
||||
<div class="wall" :style="{ '--cols': cols }">
|
||||
<template v-for="(stamp, i) in cells" :key="i">
|
||||
<Link v-if="stamp.href" bare :href="stamp.href">
|
||||
@@ -162,6 +162,15 @@ img {
|
||||
height: 59px;
|
||||
}
|
||||
|
||||
/* The wall drifts by itself and can be dragged, so scrollbars are only noise.
|
||||
Hidden rather than overflow: hidden, which would stop both. */
|
||||
.stamp-wall {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.stamp-wall::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Fixed tracks rather than flex-wrap: the wall's size comes from --cols (set
|
||||
by fitWall), never from how much room the cell happens to have. */
|
||||
.wall {
|
||||
|
||||
@@ -17,6 +17,7 @@ export const WIDGETS = {
|
||||
Feed: { component: lazy(() => import("@/views/home/Feed.vue")), size: [235, 440] },
|
||||
Links: { component: lazy(() => import("@/views/home/Links.vue")), size: [155, 440] },
|
||||
Collage: { component: lazy(() => import("@/views/home/Collage.vue")), size: [395, 440] },
|
||||
Places: { component: lazy(() => import("@/views/home/Places.vue")), size: [395, 440] },
|
||||
Consumption: { component: lazy(() => import("@/views/home/Consumption.vue")), size: [315, 220] },
|
||||
Favorites: { component: lazy(() => import("@/views/home/Favorites.vue")), size: [235, 220] },
|
||||
Gym: { component: lazy(() => import("@/views/home/Gym2.vue")), size: [235, 220] },
|
||||
@@ -27,5 +28,6 @@ export const WIDGETS = {
|
||||
Timer: { component: lazy(() => import("@/components/util/Timer.vue")), size: [240, 130] },
|
||||
Radio: { component: lazy(() => import("@/components/util/Radio.vue")), size: [240, 160] },
|
||||
Chat: { component: lazy(() => import("@/components/util/Chat.vue")), size: [240, 450] },
|
||||
PrivateChat: { component: lazy(() => import("@/components/util/PrivateChat.vue")), size: [240, 450] },
|
||||
Commits: { component: lazy(() => import("@/components/util/CommitHistory.vue")), size: [240, 400] },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user