Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6c72a5789 | ||
|
|
e9040bb02f | ||
|
|
552525d272 | ||
|
|
4420e4d0fe | ||
|
|
3cc16bdeb2 | ||
|
|
48eb7d71b2 | ||
|
|
4f81f3c0ca | ||
|
|
778f0f7994 | ||
|
|
b6085ff329 | ||
|
|
ec334bbed4 |
@@ -79,6 +79,9 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: pin rancher host
|
||||||
|
run: echo "192.168.4.43 rancher.yohler.net" >> /etc/hosts
|
||||||
|
|
||||||
- name: Set environment variables
|
- name: Set environment variables
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ yarn.lock
|
|||||||
/playwright-report/
|
/playwright-report/
|
||||||
/blob-report/
|
/blob-report/
|
||||||
/playwright/.cache/
|
/playwright/.cache/
|
||||||
/scripts/
|
/_scripts/
|
||||||
/pb_data/
|
/pb_data/
|
||||||
/.tanstack/
|
/.tanstack/
|
||||||
/dist/
|
/dist/
|
||||||
@@ -2,7 +2,7 @@ FROM oven/bun:1 AS builder
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json bun.lockb* ./
|
COPY package.json bun.lock ./
|
||||||
|
|
||||||
RUN bun install --frozen-lockfile
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
@@ -21,7 +21,6 @@ EXPOSE 3000
|
|||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
ENV NITRO_PORT=3000
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||||
CMD bun -e "fetch('http://localhost:3000/api/health').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))"
|
CMD bun -e "fetch('http://localhost:3000/api/health').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ metadata:
|
|||||||
data:
|
data:
|
||||||
vite_api_domain: "https://dev.flexxon.app"
|
vite_api_domain: "https://dev.flexxon.app"
|
||||||
vite_website_domain: "https://dev.flexxon.app"
|
vite_website_domain: "https://dev.flexxon.app"
|
||||||
supertokens_uri: "http://192.168.0.50:30568"
|
supertokens_uri: "http://192.168.4.43:30568"
|
||||||
pocketbase_url: "http://192.168.0.50:30096"
|
pocketbase_url: "http://192.168.4.43:30096"
|
||||||
vite_spotify_client_id: "3ffde6b594e84460b3d4b329b8919277"
|
vite_spotify_client_id: "3ffde6b594e84460b3d4b329b8919277"
|
||||||
vite_spotify_redirect_uri: "https://dev.flexxon.app/api/spotify/callback"
|
vite_spotify_redirect_uri: "https://dev.flexxon.app/api/spotify/callback"
|
||||||
s3_endpoint: "https://s3.yohler.net"
|
s3_endpoint: "https://s3.yohler.net"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ metadata:
|
|||||||
data:
|
data:
|
||||||
vite_api_domain: "https://flexxon.app"
|
vite_api_domain: "https://flexxon.app"
|
||||||
vite_website_domain: "https://flexxon.app"
|
vite_website_domain: "https://flexxon.app"
|
||||||
supertokens_uri: "http://192.168.0.50:30568"
|
supertokens_uri: "http://192.168.4.43:30568"
|
||||||
pocketbase_url: "http://192.168.0.50:30097"
|
pocketbase_url: "http://192.168.4.43:30097"
|
||||||
vite_spotify_client_id: "3ffde6b594e84460b3d4b329b8919277"
|
vite_spotify_client_id: "3ffde6b594e84460b3d4b329b8919277"
|
||||||
vite_spotify_redirect_uri: "https://flexxon.app/api/spotify/callback"
|
vite_spotify_redirect_uri: "https://flexxon.app/api/spotify/callback"
|
||||||
s3_endpoint: "https://s3.yohler.net"
|
s3_endpoint: "https://s3.yohler.net"
|
||||||
|
|||||||
@@ -5,65 +5,53 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev --host 0.0.0.0",
|
"dev": "vite dev --host 0.0.0.0",
|
||||||
"build": "vite build && tsc --noEmit",
|
"build": "vite build && tsc --noEmit && bun scripts/generate-sw.mjs",
|
||||||
"start": "bun run server.ts"
|
"start": "bun run server.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hello-pangea/dnd": "^18.0.1",
|
"@hello-pangea/dnd": "^18.0.1",
|
||||||
"@mantine/carousel": "^8.2.4",
|
"@mantine/carousel": "^8.2.4",
|
||||||
"@mantine/charts": "^8.2.4",
|
|
||||||
"@mantine/core": "^8.2.4",
|
"@mantine/core": "^8.2.4",
|
||||||
"@mantine/dates": "^8.2.4",
|
"@mantine/dates": "^8.2.4",
|
||||||
"@mantine/form": "^8.2.4",
|
"@mantine/form": "^8.2.4",
|
||||||
"@mantine/hooks": "^8.2.4",
|
"@mantine/hooks": "^8.2.4",
|
||||||
"@mantine/tiptap": "^8.2.4",
|
"@mantine/tiptap": "^8.2.4",
|
||||||
"@phosphor-icons/react": "^2.1.10",
|
"@phosphor-icons/react": "^2.1.10",
|
||||||
"@svgmoji/noto": "^3.2.0",
|
|
||||||
"@tanstack/react-devtools": "^0.7.6",
|
"@tanstack/react-devtools": "^0.7.6",
|
||||||
"@tanstack/react-query": "^5.66.0",
|
"@tanstack/react-query": "^5.101.2",
|
||||||
"@tanstack/react-query-devtools": "^5.66.0",
|
"@tanstack/react-query-devtools": "^5.101.2",
|
||||||
"@tanstack/react-router": "^1.143.6",
|
"@tanstack/react-router": "^1.170.17",
|
||||||
"@tanstack/react-router-devtools": "^1.143.6",
|
"@tanstack/react-router-devtools": "^1.167.0",
|
||||||
"@tanstack/react-router-ssr-query": "^1.143.6",
|
"@tanstack/react-router-ssr-query": "^1.167.1",
|
||||||
"@tanstack/react-start": "^1.143.6",
|
"@tanstack/react-start": "^1.168.27",
|
||||||
"@tanstack/react-virtual": "^3.13.12",
|
|
||||||
"@tiptap/pm": "^3.4.3",
|
"@tiptap/pm": "^3.4.3",
|
||||||
"@tiptap/react": "^3.4.3",
|
"@tiptap/react": "^3.4.3",
|
||||||
"@tiptap/starter-kit": "^3.4.3",
|
"@tiptap/starter-kit": "^3.4.3",
|
||||||
"@types/bun": "^1.2.22",
|
"@types/bun": "^1.2.22",
|
||||||
"@types/ioredis": "^4.28.10",
|
|
||||||
"browser-image-compression": "^2.0.2",
|
"browser-image-compression": "^2.0.2",
|
||||||
"dotenv": "^17.2.2",
|
"dotenv": "^17.2.2",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"facehash": "^0.0.7",
|
"facehash": "^0.0.7",
|
||||||
"framer-motion": "^12.23.12",
|
"framer-motion": "^12.23.12",
|
||||||
"ioredis": "^5.7.0",
|
|
||||||
"pg": "^8.16.3",
|
|
||||||
"pocketbase": "^0.26.2",
|
"pocketbase": "^0.26.2",
|
||||||
"react": "^19.0.0",
|
"react": "^19.2.7",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.2.7",
|
||||||
"react-imask": "^7.6.1",
|
"react-imask": "^7.6.1",
|
||||||
"react-scan": "^0.4.3",
|
|
||||||
"react-use-draggable-scroll": "^0.4.7",
|
|
||||||
"recharts": "^3.1.2",
|
|
||||||
"redaxios": "^0.5.1",
|
"redaxios": "^0.5.1",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.7",
|
||||||
"supertokens-node": "^23.0.1",
|
"supertokens-node": "^23.0.1",
|
||||||
"supertokens-web-js": "^0.15.0",
|
"supertokens-web-js": "^0.15.0",
|
||||||
"twilio": "^5.8.0",
|
"twilio": "^5.8.0",
|
||||||
"vaul": "^1.1.2",
|
"vaul": "^1.1.2",
|
||||||
"xlsx": "^0.18.5",
|
"zod": "^4.0.15"
|
||||||
"zod": "^4.0.15",
|
|
||||||
"zustand": "^5.0.7"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tanstack/router-plugin": "^1.132.2",
|
|
||||||
"@types/node": "^22.5.4",
|
"@types/node": "^22.5.4",
|
||||||
"@types/pg": "^8.15.5",
|
"@types/react": "^19.2.17",
|
||||||
"@types/react": "^19.0.8",
|
"@types/react-dom": "^19.2.3",
|
||||||
"@types/react-dom": "^19.0.3",
|
|
||||||
"@vitejs/plugin-react": "^5.0.0",
|
"@vitejs/plugin-react": "^5.0.0",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
|
"babel-plugin-react-compiler": "^1.0.0",
|
||||||
"dotenv-cli": "^10.0.0",
|
"dotenv-cli": "^10.0.0",
|
||||||
"postcss": "^8.5.1",
|
"postcss": "^8.5.1",
|
||||||
"postcss-preset-mantine": "^1.18.0",
|
"postcss-preset-mantine": "^1.18.0",
|
||||||
@@ -71,8 +59,7 @@
|
|||||||
"tsx": "^4.20.3",
|
"tsx": "^4.20.3",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"vite": "^7.1.7",
|
"vite": "^7.1.7",
|
||||||
"vite-plugin-pwa": "^1.2.0",
|
|
||||||
"vite-tsconfig-paths": "^5.1.4",
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
"workbox-window": "^7.4.0"
|
"workbox-build": "^7.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
],
|
],
|
||||||
"start_url": "/",
|
"start_url": "/",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"theme_color": "#1e293b",
|
"theme_color": "#242424",
|
||||||
"background_color": "#0f172a",
|
"background_color": "#242424",
|
||||||
"orientation": "portrait-primary",
|
"orientation": "portrait-primary",
|
||||||
"scope": "/",
|
"scope": "/",
|
||||||
"categories": ["games", "social", "beer pong"],
|
"categories": ["games", "social", "beer pong"],
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 436 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 273 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 31 KiB |
@@ -29,3 +29,27 @@
|
|||||||
[data-drawer-level="3"].drawer-scaling {
|
[data-drawer-level="3"].drawer-scaling {
|
||||||
transform: scale(0.90) translateY(-4px);
|
transform: scale(0.90) translateY(-4px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.app,
|
||||||
|
[data-drawer-level] {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app.drawer-scaling,
|
||||||
|
[data-drawer-level].drawer-scaling {
|
||||||
|
transform: none;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-vaul-drawer],
|
||||||
|
[data-vaul-overlay] {
|
||||||
|
animation: none !important;
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
from { transform: rotate(0deg); }
|
||||||
|
to { transform: rotate(0deg); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { generateSW } from 'workbox-build'
|
||||||
|
|
||||||
|
const ONE_YEAR = 60 * 60 * 24 * 365
|
||||||
|
const THIRTY_DAYS = 60 * 60 * 24 * 30
|
||||||
|
|
||||||
|
const { count, size, warnings } = await generateSW({
|
||||||
|
swDest: 'dist/client/sw.js',
|
||||||
|
globDirectory: 'dist/client',
|
||||||
|
globPatterns: [
|
||||||
|
'assets/**/*.{js,css}',
|
||||||
|
'favicon*.{ico,png}',
|
||||||
|
'apple-touch-icon.png',
|
||||||
|
'icon-192x192.png',
|
||||||
|
'icon-512x512.png',
|
||||||
|
'site.webmanifest',
|
||||||
|
'styles.css',
|
||||||
|
],
|
||||||
|
navigateFallback: null,
|
||||||
|
skipWaiting: true,
|
||||||
|
clientsClaim: true,
|
||||||
|
cleanupOutdatedCaches: true,
|
||||||
|
sourcemap: false,
|
||||||
|
runtimeCaching: [
|
||||||
|
{
|
||||||
|
urlPattern: ({ url, request }) =>
|
||||||
|
url.origin === self.location.origin && request.destination === 'image',
|
||||||
|
handler: 'CacheFirst',
|
||||||
|
options: {
|
||||||
|
cacheName: 'images-cache',
|
||||||
|
expiration: {
|
||||||
|
maxEntries: 60,
|
||||||
|
maxAgeSeconds: THIRTY_DAYS,
|
||||||
|
},
|
||||||
|
cacheableResponse: {
|
||||||
|
statuses: [0, 200],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
|
||||||
|
handler: 'StaleWhileRevalidate',
|
||||||
|
options: {
|
||||||
|
cacheName: 'google-fonts-cache',
|
||||||
|
expiration: {
|
||||||
|
maxEntries: 10,
|
||||||
|
maxAgeSeconds: ONE_YEAR,
|
||||||
|
},
|
||||||
|
cacheableResponse: {
|
||||||
|
statuses: [0, 200],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
|
||||||
|
handler: 'CacheFirst',
|
||||||
|
options: {
|
||||||
|
cacheName: 'gstatic-fonts-cache',
|
||||||
|
expiration: {
|
||||||
|
maxEntries: 10,
|
||||||
|
maxAgeSeconds: ONE_YEAR,
|
||||||
|
},
|
||||||
|
cacheableResponse: {
|
||||||
|
statuses: [0, 200],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const warning of warnings) console.warn(warning)
|
||||||
|
console.log(
|
||||||
|
`sw.js generated: precached ${count} files, ${(size / 1024).toFixed(1)} KiB`,
|
||||||
|
)
|
||||||
@@ -343,7 +343,10 @@ async function initializeStaticRoutes(
|
|||||||
gz,
|
gz,
|
||||||
etag,
|
etag,
|
||||||
type: metadata.type,
|
type: metadata.type,
|
||||||
immutable: true,
|
// Only Vite's content-hashed output under /assets/ is safe to
|
||||||
|
// cache immutably; unhashed files (favicon, manifest, images)
|
||||||
|
// can change between deploys and must revalidate.
|
||||||
|
immutable: route.startsWith('/assets/'),
|
||||||
size: bytes.byteLength,
|
size: bytes.byteLength,
|
||||||
}
|
}
|
||||||
routes[route] = createResponseHandler(asset)
|
routes[route] = createResponseHandler(asset)
|
||||||
@@ -529,14 +532,9 @@ async function initializeServer() {
|
|||||||
// Fallback to TanStack Start handler for all other routes
|
// Fallback to TanStack Start handler for all other routes
|
||||||
'/*': async (req: Request) => {
|
'/*': async (req: Request) => {
|
||||||
try {
|
try {
|
||||||
const h3Response = await handler.fetch(req)
|
// Return the handler's Response as-is so streaming bodies
|
||||||
|
// (SSR streaming, SSE event streams) pass through unbuffered.
|
||||||
const body = await h3Response.arrayBuffer()
|
return await handler.fetch(req)
|
||||||
return new Response(body, {
|
|
||||||
status: h3Response.status,
|
|
||||||
statusText: h3Response.statusText,
|
|
||||||
headers: h3Response.headers,
|
|
||||||
})
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(`Server handler error: ${String(error)}`)
|
log.error(`Server handler error: ${String(error)}`)
|
||||||
return new Response('Internal Server Error', { status: 500 })
|
return new Response('Internal Server Error', { status: 500 })
|
||||||
|
|||||||
@@ -29,9 +29,8 @@ export function getRouter() {
|
|||||||
fullWidth: false,
|
fullWidth: false,
|
||||||
},
|
},
|
||||||
defaultPreload: "intent",
|
defaultPreload: "intent",
|
||||||
|
defaultPreloadStaleTime: 60_000,
|
||||||
defaultErrorComponent: DefaultCatchBoundary,
|
defaultErrorComponent: DefaultCatchBoundary,
|
||||||
scrollRestoration: true,
|
|
||||||
defaultViewTransition: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setupRouterSsrQueryIntegration({
|
setupRouterSsrQueryIntegration({
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
Outlet,
|
Outlet,
|
||||||
Scripts,
|
Scripts,
|
||||||
createRootRouteWithContext,
|
createRootRouteWithContext,
|
||||||
|
isRedirect,
|
||||||
} from "@tanstack/react-router";
|
} from "@tanstack/react-router";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { DefaultCatchBoundary } from "@/components/DefaultCatchBoundary";
|
import { DefaultCatchBoundary } from "@/components/DefaultCatchBoundary";
|
||||||
@@ -18,6 +19,7 @@ import { HeaderConfig } from "@/features/core/types/header-config";
|
|||||||
import { playerQueries } from "@/features/players/queries";
|
import { playerQueries } from "@/features/players/queries";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
import FullScreenLoader from "@/components/full-screen-loader";
|
import FullScreenLoader from "@/components/full-screen-loader";
|
||||||
|
import { CHROME_COLORS } from "@/lib/mantine/theme-colors";
|
||||||
import mantineCssUrl from '@mantine/core/styles.css?url'
|
import mantineCssUrl from '@mantine/core/styles.css?url'
|
||||||
import mantineDatesCssUrl from '@mantine/dates/styles.css?url'
|
import mantineDatesCssUrl from '@mantine/dates/styles.css?url'
|
||||||
import mantineCarouselCssUrl from '@mantine/carousel/styles.css?url'
|
import mantineCarouselCssUrl from '@mantine/carousel/styles.css?url'
|
||||||
@@ -40,11 +42,10 @@ export const Route = createRootRouteWithContext<{
|
|||||||
{
|
{
|
||||||
name: "viewport",
|
name: "viewport",
|
||||||
content:
|
content:
|
||||||
"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, interactive-widget=resizes-content",
|
"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, interactive-widget=resizes-content, viewport-fit=cover",
|
||||||
},
|
},
|
||||||
{ name: 'description', content: 'Amicus meus madidus' },
|
{ name: 'description', content: 'Amicus meus madidus' },
|
||||||
{ name: 'keywords', content: 'FLXN, beer pong, tournament, sports, statistics, pong' },
|
{ name: 'keywords', content: 'FLXN, beer pong, tournament, sports, statistics, pong' },
|
||||||
{ name: 'theme-color', content: '#1e293b' },
|
|
||||||
{ property: 'og:title', content: 'FLXN' },
|
{ property: 'og:title', content: 'FLXN' },
|
||||||
{ property: 'og:description', content: 'Amicus meus madidus' },
|
{ property: 'og:description', content: 'Amicus meus madidus' },
|
||||||
{ property: 'og:url', content: 'https://flexxon.app' },
|
{ property: 'og:url', content: 'https://flexxon.app' },
|
||||||
@@ -61,7 +62,7 @@ export const Route = createRootRouteWithContext<{
|
|||||||
{ name: 'twitter:image', content: 'https://flexxon.app/favicon.png' },
|
{ name: 'twitter:image', content: 'https://flexxon.app/favicon.png' },
|
||||||
{ name: 'mobile-web-app-capable', content: 'yes' },
|
{ name: 'mobile-web-app-capable', content: 'yes' },
|
||||||
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
||||||
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
|
{ name: 'apple-mobile-web-app-status-bar-style', content: 'default' },
|
||||||
{ name: 'apple-mobile-web-app-title', content: 'FLXN' },
|
{ name: 'apple-mobile-web-app-title', content: 'FLXN' },
|
||||||
],
|
],
|
||||||
links: [
|
links: [
|
||||||
@@ -124,6 +125,8 @@ export const Route = createRootRouteWithContext<{
|
|||||||
);
|
);
|
||||||
return { auth };
|
return { auth };
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
if (isRedirect(error) || error instanceof Response) throw error;
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
const { doesSessionExist, attemptRefreshingSession } = await import('supertokens-web-js/recipe/session');
|
const { doesSessionExist, attemptRefreshingSession } = await import('supertokens-web-js/recipe/session');
|
||||||
|
|
||||||
@@ -150,6 +153,9 @@ export const Route = createRootRouteWithContext<{
|
|||||||
function RootComponent() {
|
function RootComponent() {
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
ensureSuperTokensFrontend();
|
ensureSuperTokensFrontend();
|
||||||
|
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.register('/sw.js').catch(() => {});
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -176,6 +182,16 @@ function RootDocument({ children }: { children: React.ReactNode }) {
|
|||||||
>
|
>
|
||||||
<head>
|
<head>
|
||||||
<HeadContent />
|
<HeadContent />
|
||||||
|
<meta
|
||||||
|
name="theme-color"
|
||||||
|
media="(prefers-color-scheme: light)"
|
||||||
|
content={CHROME_COLORS.light.base}
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
name="theme-color"
|
||||||
|
media="(prefers-color-scheme: dark)"
|
||||||
|
content={CHROME_COLORS.dark.base}
|
||||||
|
/>
|
||||||
<ColorSchemeScript />
|
<ColorSchemeScript />
|
||||||
<link rel="stylesheet" href="/styles.css" />
|
<link rel="stylesheet" href="/styles.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { redirect, createFileRoute, Outlet } from "@tanstack/react-router";
|
import { redirect, createFileRoute, Outlet } from "@tanstack/react-router";
|
||||||
import Layout from "@/features/core/components/layout";
|
import Layout from "@/features/core/components/layout";
|
||||||
import { useServerEvents } from "@/hooks/use-server-events";
|
import { useServerEvents } from "@/hooks/use-server-events";
|
||||||
import { Flex, Loader } from "@mantine/core";
|
import { Group, Skeleton, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed")({
|
export const Route = createFileRoute("/_authed")({
|
||||||
beforeLoad: ({ context }) => {
|
beforeLoad: ({ context }) => {
|
||||||
@@ -26,9 +26,21 @@ export const Route = createFileRoute("/_authed")({
|
|||||||
},
|
},
|
||||||
pendingComponent: () => (
|
pendingComponent: () => (
|
||||||
<Layout>
|
<Layout>
|
||||||
<Flex w='100%' h="40dvh" justify="center" align="flex-end">
|
<Stack gap="md" p="md" w="100%">
|
||||||
<Loader size='xl' />
|
<Group gap="sm">
|
||||||
</Flex>
|
<Skeleton height={40} width={40} radius="sm" />
|
||||||
|
<Skeleton height={24} width="45%" radius="sm" />
|
||||||
|
</Group>
|
||||||
|
{Array.from({ length: 4 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`authed-pending-${index}`}
|
||||||
|
height={96}
|
||||||
|
w="100%"
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.18, 0.3) }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
</Layout>
|
</Layout>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { createFileRoute } from "@tanstack/react-router";
|
|||||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||||
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
||||||
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
||||||
import { Tabs } from "@mantine/core";
|
import { Box, Divider, Group, Skeleton, Stack, Tabs } from "@mantine/core";
|
||||||
import { useState } from "react";
|
import { Suspense, useState } from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/activities")({
|
export const Route = createFileRoute("/_authed/admin/activities")({
|
||||||
component: Stats,
|
component: Stats,
|
||||||
@@ -23,6 +23,30 @@ export const Route = createFileRoute("/_authed/admin/activities")({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function ActivityRowsSkeleton({ withSearch = false }: { withSearch?: boolean }) {
|
||||||
|
return (
|
||||||
|
<Stack gap={0}>
|
||||||
|
{withSearch && (
|
||||||
|
<Box px="md" pb="sm">
|
||||||
|
<Skeleton height={42} radius="sm" />
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
{Array.from({ length: 8 }).map((_, index) => (
|
||||||
|
<div key={`activity-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.1, 0.35) }}>
|
||||||
|
<Group p="md" wrap="nowrap" w="100%" justify="space-between">
|
||||||
|
<Stack gap={6}>
|
||||||
|
<Skeleton height={14} width={160} radius="sm" />
|
||||||
|
<Skeleton height={10} width={100} radius="sm" />
|
||||||
|
</Stack>
|
||||||
|
<Skeleton height={10} width={60} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Stats() {
|
function Stats() {
|
||||||
const [activeTab, setActiveTab] = useState<string | null>("server-functions");
|
const [activeTab, setActiveTab] = useState<string | null>("server-functions");
|
||||||
|
|
||||||
@@ -34,11 +58,15 @@ function Stats() {
|
|||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
|
|
||||||
<Tabs.Panel value="server-functions">
|
<Tabs.Panel value="server-functions">
|
||||||
<ActivitiesTable />
|
<Suspense fallback={<ActivityRowsSkeleton withSearch />}>
|
||||||
|
<ActivitiesTable />
|
||||||
|
</Suspense>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
|
|
||||||
<Tabs.Panel value="player-activity">
|
<Tabs.Panel value="player-activity">
|
||||||
<PlayersActivityTable />
|
<Suspense fallback={<ActivityRowsSkeleton />}>
|
||||||
|
<PlayersActivityTable />
|
||||||
|
</Suspense>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
|
||||||
import { tournamentQueries, useFreeAgents, useTournament } from "@/features/tournaments/queries";
|
import { tournamentQueries, useFreeAgents, useTournament } from "@/features/tournaments/queries";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
import { Stack, Text, Button, Alert, LoadingOverlay, Group } from "@mantine/core";
|
import { Stack, Text, Button, Alert, LoadingOverlay, Group, Skeleton } from "@mantine/core";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import useGenerateRandomTeams from "@/features/tournaments/hooks/use-generate-random-teams";
|
import useGenerateRandomTeams from "@/features/tournaments/hooks/use-generate-random-teams";
|
||||||
import useConfirmTeamAssignments from "@/features/tournaments/hooks/use-confirm-team-assignments";
|
import useConfirmTeamAssignments from "@/features/tournaments/hooks/use-confirm-team-assignments";
|
||||||
@@ -27,8 +27,23 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/assign-part
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: AssignPartnersPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function AssignPartnersPending() {
|
||||||
|
return (
|
||||||
|
<Stack gap="lg">
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Group gap="xs" align="baseline">
|
||||||
|
<Skeleton height={28} width={36} radius="sm" />
|
||||||
|
<Skeleton height={14} width={110} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Skeleton height={36} w="100%" radius="sm" style={{ opacity: 0.7 }} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
interface TeamAssignment {
|
interface TeamAssignment {
|
||||||
player1: PlayerInfo;
|
player1: PlayerInfo;
|
||||||
player2: PlayerInfo;
|
player2: PlayerInfo;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
|||||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||||
import ManageTournament from "@/features/tournaments/components/manage-tournament";
|
import ManageTournament from "@/features/tournaments/components/manage-tournament";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
@@ -23,8 +24,26 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
|||||||
withPadding: false,
|
withPadding: false,
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: ManageTournamentPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function ManageTournamentPending() {
|
||||||
|
return (
|
||||||
|
<Stack gap={0}>
|
||||||
|
{Array.from({ length: 5 }).map((_, index) => (
|
||||||
|
<div key={`manage-tournament-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.14, 0.4) }}>
|
||||||
|
<Group p="md" wrap="nowrap" w="100%">
|
||||||
|
<Skeleton height={20} width={20} radius="sm" />
|
||||||
|
<Skeleton height={16} width="45%" radius="sm" />
|
||||||
|
<Skeleton ml="auto" height={20} width={20} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
return <ManageTournament tournamentId={id} />;
|
return <ManageTournament tournamentId={id} />;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
|||||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||||
import ManageTeams from "@/features/teams/components/manage-teams";
|
import ManageTeams from "@/features/teams/components/manage-teams";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { Box, Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
@@ -23,8 +24,37 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
|||||||
withPadding: false,
|
withPadding: false,
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: ManageTeamsPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function ManageTeamsPending() {
|
||||||
|
return (
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Box px="md">
|
||||||
|
<Skeleton height={42} radius="sm" />
|
||||||
|
</Box>
|
||||||
|
<Box px="md">
|
||||||
|
<Skeleton height={12} width={90} radius="sm" />
|
||||||
|
</Box>
|
||||||
|
<Stack gap={0}>
|
||||||
|
{Array.from({ length: 8 }).map((_, index) => (
|
||||||
|
<div key={`manage-teams-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.1, 0.35) }}>
|
||||||
|
<Group p="xs" wrap="nowrap" w="100%">
|
||||||
|
<Skeleton height={40} width={40} radius="sm" />
|
||||||
|
<Skeleton height={16} width="45%" radius="sm" />
|
||||||
|
<Stack ml="auto" gap={6} align="flex-end">
|
||||||
|
<Skeleton height={10} width={90} radius="sm" />
|
||||||
|
<Skeleton height={10} width={70} radius="sm" />
|
||||||
|
</Stack>
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { tournament } = Route.useRouteContext();
|
const { tournament } = Route.useRouteContext();
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import ManageTournaments from "@/features/admin/components/manage-tournaments";
|
import ManageTournaments from "@/features/admin/components/manage-tournaments";
|
||||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||||
|
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
||||||
beforeLoad: async ({ context }) => {
|
beforeLoad: ({ context }) => {
|
||||||
const { queryClient } = context;
|
const { queryClient } = context;
|
||||||
await prefetchServerQuery(queryClient, tournamentQueries.list());
|
prefetchServerQuery(queryClient, tournamentQueries.list());
|
||||||
},
|
},
|
||||||
loader: () => ({
|
loader: () => ({
|
||||||
header: {
|
header: {
|
||||||
@@ -19,6 +21,26 @@ export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
|||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function TournamentListSkeleton() {
|
||||||
|
return (
|
||||||
|
<Stack gap={0}>
|
||||||
|
{Array.from({ length: 6 }).map((_, index) => (
|
||||||
|
<div key={`manage-tournaments-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.12, 0.4) }}>
|
||||||
|
<Group p="md" wrap="nowrap" w="100%">
|
||||||
|
<Skeleton height={16} width="55%" radius="sm" />
|
||||||
|
<Skeleton ml="auto" height={20} width={20} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
return <ManageTournaments />;
|
return (
|
||||||
|
<Suspense fallback={<TournamentListSkeleton />}>
|
||||||
|
<ManageTournaments />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
|||||||
import SeedTournament from "@/features/tournaments/components/seed-tournament";
|
import SeedTournament from "@/features/tournaments/components/seed-tournament";
|
||||||
import SetupGroupStage from "@/features/tournaments/components/setup-group-stage";
|
import SetupGroupStage from "@/features/tournaments/components/setup-group-stage";
|
||||||
import GroupStageView from "@/features/tournaments/components/group-stage-view";
|
import GroupStageView from "@/features/tournaments/components/group-stage-view";
|
||||||
import { Container, Stack, Divider, Title } from "@mantine/core";
|
import { Container, Stack, Divider, Title, Box, Card, Group, Skeleton, SimpleGrid } from "@mantine/core";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { BracketData } from "@/features/bracket/types";
|
import { BracketData } from "@/features/bracket/types";
|
||||||
import { Match } from "@/features/matches/types";
|
import { Match } from "@/features/matches/types";
|
||||||
@@ -37,8 +37,46 @@ export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: RunTournamentPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function RunTournamentPending() {
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<Box p="md">
|
||||||
|
<Stack gap="md">
|
||||||
|
<Group gap={0} grow mb="md">
|
||||||
|
{Array.from({ length: 4 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`run-pending-tab-${index}`}
|
||||||
|
height={44}
|
||||||
|
radius="sm"
|
||||||
|
style={{ opacity: 0.85 - index * 0.1 }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Group>
|
||||||
|
<Card withBorder radius="md" p={0}>
|
||||||
|
<Group justify="space-between" p="sm">
|
||||||
|
<Skeleton height={16} width={120} radius="sm" />
|
||||||
|
<Skeleton height={22} width={22} radius="xl" />
|
||||||
|
</Group>
|
||||||
|
</Card>
|
||||||
|
<SimpleGrid cols={{ base: 1, sm: 2, lg: 3 }} spacing="md">
|
||||||
|
{Array.from({ length: 6 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`run-pending-match-${index}`}
|
||||||
|
height={100}
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.12, 0.4) }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { data: tournament } = useTournament(id);
|
const { data: tournament } = useTournament(id);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function Stats() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
<Box style={{ opacity: isStale ? 0.6 : 1, transition: 'opacity 150ms' }}>
|
<Box style={{ opacity: isStale ? 0.6 : 1, transition: 'opacity 150ms' }}>
|
||||||
<Suspense key={deferredViewType} fallback={<PlayerStatsTableSkeleton hideFilters />}>
|
<Suspense fallback={<PlayerStatsTableSkeleton hideFilters />}>
|
||||||
<PlayerStatsTable viewType={deferredViewType} />
|
<PlayerStatsTable viewType={deferredViewType} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
useTournament,
|
useTournament,
|
||||||
} from "@/features/tournaments/queries";
|
} from "@/features/tournaments/queries";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
import { Container } from "@mantine/core";
|
import { Box, Container, Flex, Skeleton, Stack } from "@mantine/core";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { BracketData } from "@/features/bracket/types";
|
import { BracketData } from "@/features/bracket/types";
|
||||||
import { Match } from "@/features/matches/types";
|
import { Match } from "@/features/matches/types";
|
||||||
@@ -31,8 +31,49 @@ export const Route = createFileRoute("/_authed/tournaments/$id/bracket")({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: BracketPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function BracketPending() {
|
||||||
|
const columns = [4, 2, 1];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<Box
|
||||||
|
p={0}
|
||||||
|
style={{
|
||||||
|
overflow: "hidden",
|
||||||
|
backgroundImage: `radial-gradient(circle, var(--mantine-color-default-border) 1px, transparent 1px)`,
|
||||||
|
backgroundSize: "16px 16px",
|
||||||
|
backgroundPosition: "0 0, 8px 8px",
|
||||||
|
minHeight: "70dvh",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Skeleton height={18} width={140} radius="sm" m={16} />
|
||||||
|
<Flex gap="xl" px={16} align="stretch">
|
||||||
|
{columns.map((count, columnIndex) => (
|
||||||
|
<Stack
|
||||||
|
key={`bracket-pending-round-${columnIndex}`}
|
||||||
|
gap="xl"
|
||||||
|
justify="space-around"
|
||||||
|
style={{ opacity: 1 - columnIndex * 0.25 }}
|
||||||
|
>
|
||||||
|
{Array.from({ length: count }).map((_, matchIndex) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`bracket-pending-match-${columnIndex}-${matchIndex}`}
|
||||||
|
height={84}
|
||||||
|
width={220}
|
||||||
|
radius="md"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
</Flex>
|
||||||
|
</Box>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { data: tournament } = useTournament(id);
|
const { data: tournament } = useTournament(id);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
} from "@/features/tournaments/queries";
|
} from "@/features/tournaments/queries";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
import GroupStageView from "@/features/tournaments/components/group-stage-view";
|
import GroupStageView from "@/features/tournaments/components/group-stage-view";
|
||||||
import { Container } from "@mantine/core";
|
import { Box, Card, Container, Group, Skeleton, SimpleGrid, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/tournaments/$id/groups")({
|
export const Route = createFileRoute("/_authed/tournaments/$id/groups")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
@@ -28,8 +28,46 @@ export const Route = createFileRoute("/_authed/tournaments/$id/groups")({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: GroupsPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function GroupsPending() {
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<Box p="md">
|
||||||
|
<Stack gap="md">
|
||||||
|
<Group gap={0} grow mb="md">
|
||||||
|
{Array.from({ length: 4 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`groups-pending-tab-${index}`}
|
||||||
|
height={44}
|
||||||
|
radius="sm"
|
||||||
|
style={{ opacity: 0.85 - index * 0.1 }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Group>
|
||||||
|
<Card withBorder radius="md" p={0}>
|
||||||
|
<Group justify="space-between" p="sm">
|
||||||
|
<Skeleton height={16} width={120} radius="sm" />
|
||||||
|
<Skeleton height={22} width={22} radius="xl" />
|
||||||
|
</Group>
|
||||||
|
</Card>
|
||||||
|
<SimpleGrid cols={{ base: 1, sm: 2, lg: 3 }} spacing="md">
|
||||||
|
{Array.from({ length: 6 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`groups-pending-match-${index}`}
|
||||||
|
height={100}
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.12, 0.4) }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { data: tournament } = useTournament(id);
|
const { data: tournament } = useTournament(id);
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ export const Route = createFileRoute('/_authed/tournaments/')({
|
|||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
return <Suspense fallback={<Stack gap="md">
|
return <Suspense fallback={<Stack gap="md">
|
||||||
{Array(10).fill(null).map((_, index) => (
|
{Array(10).fill(null).map((_, index) => (
|
||||||
<Skeleton height="120px" w="100%" />
|
<Skeleton
|
||||||
|
key={`tournament-card-skeleton-${index}`}
|
||||||
|
height="120px"
|
||||||
|
w="100%"
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.08, 0.35) }}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</Stack>}>
|
</Stack>}>
|
||||||
<TournamentCardList />
|
<TournamentCardList />
|
||||||
|
|||||||
@@ -29,9 +29,16 @@ function RouteComponent() {
|
|||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const redirect = urlParams.get('redirect');
|
const redirect = urlParams.get('redirect');
|
||||||
|
|
||||||
if (redirect && !redirect.includes('_serverFn') && !redirect.includes('/api/')) {
|
const safe =
|
||||||
|
redirect &&
|
||||||
|
redirect.startsWith('/') &&
|
||||||
|
!redirect.startsWith('/refresh-session') &&
|
||||||
|
!redirect.includes('_serverFn') &&
|
||||||
|
!redirect.includes('/api/');
|
||||||
|
|
||||||
|
if (safe) {
|
||||||
logger.info("Refresh session route: redirecting to", redirect);
|
logger.info("Refresh session route: redirecting to", redirect);
|
||||||
window.location.href = decodeURIComponent(redirect);
|
window.location.href = redirect;
|
||||||
} else {
|
} else {
|
||||||
logger.info("Refresh session route: redirecting to home");
|
logger.info("Refresh session route: redirecting to home");
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
|
|||||||
@@ -98,20 +98,21 @@ const Avatar = ({
|
|||||||
>
|
>
|
||||||
<div style={{ position: 'relative', maxWidth: '90vw', maxHeight: '90vh' }}>
|
<div style={{ position: 'relative', maxWidth: '90vw', maxHeight: '90vh' }}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant="filled"
|
variant="white"
|
||||||
color="dark"
|
color="dark"
|
||||||
size="lg"
|
size="lg"
|
||||||
radius="xl"
|
radius="xl"
|
||||||
|
aria-label="Close image preview"
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: -10,
|
top: -10,
|
||||||
right: -10,
|
right: -10,
|
||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
backgroundColor: 'rgba(255, 255, 255, 0.9)',
|
||||||
}}
|
}}
|
||||||
onClick={() => setIsFullscreenOpen(false)}
|
onClick={() => setIsFullscreenOpen(false)}
|
||||||
>
|
>
|
||||||
<XIcon size={18} color="white" />
|
<XIcon size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
|
||||||
<Image
|
<Image
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
.time {
|
||||||
|
transition: color 300ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.seconds {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tick {
|
||||||
|
animation: digit-tick 200ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finalTick {
|
||||||
|
animation: final-tick 250ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes digit-tick {
|
||||||
|
from {
|
||||||
|
opacity: 0.2;
|
||||||
|
transform: translateY(-0.12em);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes final-tick {
|
||||||
|
from {
|
||||||
|
opacity: 0.4;
|
||||||
|
transform: scale(1.15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.tick,
|
||||||
|
.finalTick {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import useNow from '@/hooks/use-now';
|
import useNow from '@/hooks/use-now';
|
||||||
import { Text, Group } from '@mantine/core';
|
import { Text, Group } from '@mantine/core';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
import classes from './countdown.module.css';
|
||||||
|
|
||||||
interface CountdownProps {
|
interface CountdownProps {
|
||||||
date: Date;
|
date: Date;
|
||||||
@@ -30,25 +31,42 @@ function calculateTimeLeft(targetDate: Date, currentTime = new Date()): TimeLeft
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pad = (num: number) => num.toString().padStart(2, '0');
|
||||||
|
|
||||||
export function Countdown({ date, label, color }: CountdownProps) {
|
export function Countdown({ date, label, color }: CountdownProps) {
|
||||||
const now = useNow();
|
const now = useNow();
|
||||||
const timeLeft = useMemo(() => calculateTimeLeft(date, now), [date, now]);
|
const timeLeft = useMemo(() => calculateTimeLeft(date, now), [date, now]);
|
||||||
|
|
||||||
const formatTime = () => {
|
const totalSecondsLeft = Math.max(
|
||||||
const pad = (num: number) => num.toString().padStart(2, '0');
|
0,
|
||||||
|
Math.floor((date.getTime() - now.getTime()) / 1000)
|
||||||
|
);
|
||||||
|
const isFinalStretch = totalSecondsLeft > 0 && totalSecondsLeft <= 10;
|
||||||
|
|
||||||
if (timeLeft.days > 0) {
|
const prefix =
|
||||||
return `${timeLeft.days}d ${pad(timeLeft.hours)}:${pad(timeLeft.minutes)}:${pad(timeLeft.seconds)}`;
|
timeLeft.days > 0
|
||||||
} else {
|
? `${timeLeft.days}d ${pad(timeLeft.hours)}:${pad(timeLeft.minutes)}:`
|
||||||
return `${pad(timeLeft.hours)}:${pad(timeLeft.minutes)}:${pad(timeLeft.seconds)}`;
|
: `${pad(timeLeft.hours)}:${pad(timeLeft.minutes)}:`;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
{label && <Text size='sm' fw={500}>{label}:</Text>}
|
{label && <Text size='sm' fw={500}>{label}:</Text>}
|
||||||
<Text size='sm' fw={600} c={color} ff="monospace">
|
<Text
|
||||||
{formatTime()}
|
size='sm'
|
||||||
|
fw={600}
|
||||||
|
c={isFinalStretch ? 'red' : color}
|
||||||
|
ff="monospace"
|
||||||
|
className={classes.time}
|
||||||
|
>
|
||||||
|
{prefix}
|
||||||
|
<span
|
||||||
|
key={timeLeft.seconds}
|
||||||
|
className={`${classes.seconds} ${
|
||||||
|
isFinalStretch ? classes.finalTick : classes.tick
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{pad(timeLeft.seconds)}
|
||||||
|
</span>
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { Stack, Text, ThemeIcon, Title } from "@mantine/core";
|
||||||
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
|
interface EmptyStateProps {
|
||||||
|
icon: ReactNode;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
action?: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EmptyState = ({ icon, title, description, action }: EmptyStateProps) => {
|
||||||
|
return (
|
||||||
|
<Stack align="center" gap="md" py="xl">
|
||||||
|
<ThemeIcon size="xl" variant="light" radius="md">
|
||||||
|
{icon}
|
||||||
|
</ThemeIcon>
|
||||||
|
<Stack align="center" gap={4}>
|
||||||
|
<Title order={3} c="dimmed" ta="center">
|
||||||
|
{title}
|
||||||
|
</Title>
|
||||||
|
{description && (
|
||||||
|
<Text size="sm" c="dimmed" ta="center" maw={280}>
|
||||||
|
{description}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
{action}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EmptyState;
|
||||||
@@ -16,6 +16,7 @@ interface GlitchAvatarProps
|
|||||||
contain?: boolean;
|
contain?: boolean;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
px?: string | number;
|
px?: string | number;
|
||||||
|
frame?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GlitchAvatar = ({
|
const GlitchAvatar = ({
|
||||||
@@ -28,6 +29,7 @@ const GlitchAvatar = ({
|
|||||||
contain = false,
|
contain = false,
|
||||||
children,
|
children,
|
||||||
px,
|
px,
|
||||||
|
frame = false,
|
||||||
...props
|
...props
|
||||||
}: GlitchAvatarProps) => {
|
}: GlitchAvatarProps) => {
|
||||||
const [showGlitch, setShowGlitch] = useState(false);
|
const [showGlitch, setShowGlitch] = useState(false);
|
||||||
@@ -37,13 +39,16 @@ const GlitchAvatar = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!glitchSrc) return;
|
if (!glitchSrc) return;
|
||||||
|
|
||||||
|
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
||||||
|
|
||||||
|
let timeoutId: ReturnType<typeof setTimeout>;
|
||||||
const scheduleNextGlitch = () => {
|
const scheduleNextGlitch = () => {
|
||||||
const delay = Math.random() * 10000 + 5000;
|
const delay = Math.random() * 10000 + 5000;
|
||||||
return setTimeout(() => {
|
timeoutId = setTimeout(() => {
|
||||||
setShowGlitch(true);
|
setShowGlitch(true);
|
||||||
setIsPlaying(true);
|
setIsPlaying(true);
|
||||||
|
|
||||||
setTimeout(() => {
|
timeoutId = setTimeout(() => {
|
||||||
setShowGlitch(false);
|
setShowGlitch(false);
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
scheduleNextGlitch();
|
scheduleNextGlitch();
|
||||||
@@ -51,7 +56,7 @@ const GlitchAvatar = ({
|
|||||||
}, delay);
|
}, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeoutId = scheduleNextGlitch();
|
scheduleNextGlitch();
|
||||||
return () => clearTimeout(timeoutId);
|
return () => clearTimeout(timeoutId);
|
||||||
}, [glitchSrc]);
|
}, [glitchSrc]);
|
||||||
|
|
||||||
@@ -94,12 +99,18 @@ const GlitchAvatar = ({
|
|||||||
? `${radius + 8}px`
|
? `${radius + 8}px`
|
||||||
: "calc(var(--mantine-radius-md) + 8px)",
|
: "calc(var(--mantine-radius-md) + 8px)",
|
||||||
position: "relative",
|
position: "relative",
|
||||||
|
...(frame && {
|
||||||
|
boxShadow:
|
||||||
|
"0 0 0 1px color-mix(in srgb, var(--mantine-primary-color-filled) 35%, transparent), 0 8px 32px -8px color-mix(in srgb, var(--mantine-primary-color-filled) 30%, transparent)",
|
||||||
|
}),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
style={{
|
style={{
|
||||||
opacity: showGlitch ? 0 : 1,
|
opacity: showGlitch ? 0 : 1,
|
||||||
transition: "opacity 0.05s ease-in-out",
|
transition: showGlitch
|
||||||
|
? "opacity 0.05s ease-in"
|
||||||
|
: "opacity 0.25s ease-out",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Paper
|
<Paper
|
||||||
@@ -141,7 +152,7 @@ const GlitchAvatar = ({
|
|||||||
left: "8px",
|
left: "8px",
|
||||||
opacity: showGlitch ? 1 : 0,
|
opacity: showGlitch ? 1 : 0,
|
||||||
visibility: showGlitch ? "visible" : "hidden",
|
visibility: showGlitch ? "visible" : "hidden",
|
||||||
transition: "opacity 0.05s ease-in-out",
|
transition: showGlitch ? "opacity 0.05s ease-in" : "none",
|
||||||
pointerEvents: "none",
|
pointerEvents: "none",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Divider, Group, Loader, Text, UnstyledButton } from "@mantine/core";
|
import { Divider, Group, Loader, Text, UnstyledButton } from "@mantine/core";
|
||||||
import { CaretRightIcon, Icon } from "@phosphor-icons/react";
|
import { CaretRightIcon, Icon } from "@phosphor-icons/react";
|
||||||
|
import styles from "./list-row.module.css";
|
||||||
|
|
||||||
interface ListButtonProps {
|
interface ListButtonProps {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -12,6 +13,7 @@ const ListButton = ({ label, onClick, Icon, loading }: ListButtonProps) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UnstyledButton
|
<UnstyledButton
|
||||||
|
className={styles.listRow}
|
||||||
w="100%"
|
w="100%"
|
||||||
p="md"
|
p="md"
|
||||||
component={"button"}
|
component={"button"}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Divider, NavLink, Text } from "@mantine/core";
|
import { Divider, NavLink, Text } from "@mantine/core";
|
||||||
import { CaretRightIcon, Icon } from "@phosphor-icons/react";
|
import { CaretRightIcon, Icon } from "@phosphor-icons/react";
|
||||||
import { Link, useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import styles from "./list-row.module.css";
|
||||||
|
|
||||||
interface ListLinkProps {
|
interface ListLinkProps {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -15,6 +16,7 @@ const ListLink = ({ label, to, Icon, disabled=false }: ListLinkProps) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NavLink
|
<NavLink
|
||||||
|
className={styles.listRow}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
w="100%"
|
w="100%"
|
||||||
p="md"
|
p="md"
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
.listRow {
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (hover: hover) {
|
||||||
|
.listRow:hover:not(:disabled) {
|
||||||
|
background-color: var(--mantine-color-default-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.listRow:active:not(:disabled) {
|
||||||
|
background-color: var(--mantine-color-default-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.listRow {
|
||||||
|
transition: background-color 120ms ease-out, transform 120ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.listRow:active:not(:disabled) {
|
||||||
|
transform: translateY(1px);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
import {
|
import { Box, Container, Title, useComputedColorScheme } from "@mantine/core";
|
||||||
Box,
|
|
||||||
Container,
|
|
||||||
Title,
|
|
||||||
useComputedColorScheme,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { PropsWithChildren, useEffect, useRef } from "react";
|
import { PropsWithChildren, useEffect, useRef } from "react";
|
||||||
import { Drawer as VaulDrawer } from "vaul";
|
import { Drawer as VaulDrawer } from "vaul";
|
||||||
|
import { CHROME_COLORS, setThemeColorMeta } from "@/lib/mantine/theme-colors";
|
||||||
import styles from "./styles.module.css";
|
import styles from "./styles.module.css";
|
||||||
|
|
||||||
interface DrawerProps extends PropsWithChildren {
|
interface DrawerProps extends PropsWithChildren {
|
||||||
title?: string;
|
title?: string;
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
onChange: (next: boolean) => void;
|
onChange: (next: boolean) => void;
|
||||||
|
onClose?: () => void;
|
||||||
|
onExited?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Drawer: React.FC<DrawerProps> = ({
|
const Drawer: React.FC<DrawerProps> = ({
|
||||||
@@ -19,55 +17,25 @@ const Drawer: React.FC<DrawerProps> = ({
|
|||||||
children,
|
children,
|
||||||
opened,
|
opened,
|
||||||
onChange,
|
onChange,
|
||||||
|
onExited,
|
||||||
}) => {
|
}) => {
|
||||||
const colorScheme = useComputedColorScheme("light");
|
const colorScheme = useComputedColorScheme("light");
|
||||||
const contentRef = useRef<HTMLDivElement>(null);
|
const contentRef = useRef<HTMLDivElement>(null);
|
||||||
const openedRef = useRef(opened);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
openedRef.current = opened;
|
if (!opened) return;
|
||||||
}, [opened]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const appElement = document.querySelector<HTMLElement>(".app");
|
||||||
const appElement = document.querySelector(".app") as HTMLElement;
|
const colors = CHROME_COLORS[colorScheme];
|
||||||
|
|
||||||
if (!appElement) return;
|
appElement?.classList.add("drawer-scaling");
|
||||||
|
setThemeColorMeta(colors.dimmed);
|
||||||
let themeColorMeta = document.querySelector(
|
|
||||||
'meta[name="theme-color"]'
|
|
||||||
) as HTMLMetaElement;
|
|
||||||
if (!themeColorMeta) {
|
|
||||||
themeColorMeta = document.createElement("meta");
|
|
||||||
themeColorMeta.name = "theme-color";
|
|
||||||
document.head.appendChild(themeColorMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
const colors = {
|
|
||||||
light: {
|
|
||||||
normal: "rgb(255,255,255)",
|
|
||||||
overlay: "rgb(153,153,153)",
|
|
||||||
},
|
|
||||||
dark: {
|
|
||||||
normal: "rgb(36,36,36)",
|
|
||||||
overlay: "rgb(22,22,22)",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const currentColors = colors[colorScheme] || colors.light;
|
|
||||||
|
|
||||||
if (opened) {
|
|
||||||
appElement.classList.add("drawer-scaling");
|
|
||||||
themeColorMeta.content = currentColors.overlay;
|
|
||||||
} else {
|
|
||||||
appElement.classList.remove("drawer-scaling");
|
|
||||||
themeColorMeta.content = currentColors.normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
appElement.classList.remove("drawer-scaling");
|
appElement?.classList.remove("drawer-scaling");
|
||||||
themeColorMeta.content = currentColors.normal;
|
setThemeColorMeta(colors.base);
|
||||||
};
|
};
|
||||||
}, [opened]);
|
}, [opened, colorScheme]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!opened || !contentRef.current) return;
|
if (!opened || !contentRef.current) return;
|
||||||
@@ -109,6 +77,9 @@ const Drawer: React.FC<DrawerProps> = ({
|
|||||||
repositionInputs={false}
|
repositionInputs={false}
|
||||||
open={opened}
|
open={opened}
|
||||||
onOpenChange={onChange}
|
onOpenChange={onChange}
|
||||||
|
onAnimationEnd={(open) => {
|
||||||
|
if (!open) onExited?.();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<VaulDrawer.Portal>
|
<VaulDrawer.Portal>
|
||||||
<VaulDrawer.Overlay className={styles.drawerOverlay} />
|
<VaulDrawer.Overlay className={styles.drawerOverlay} />
|
||||||
|
|||||||
@@ -5,13 +5,30 @@ interface ModalProps extends PropsWithChildren {
|
|||||||
title?: string;
|
title?: string;
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
onChange?: (next: boolean) => void;
|
||||||
|
onExited?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Modal: React.FC<ModalProps> = ({ title, children, opened, onClose }) => (
|
const Modal: React.FC<ModalProps> = ({
|
||||||
|
title,
|
||||||
|
children,
|
||||||
|
opened,
|
||||||
|
onClose,
|
||||||
|
onExited,
|
||||||
|
}) => (
|
||||||
<MantineModal
|
<MantineModal
|
||||||
opened={opened}
|
opened={opened}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Title order={3}>{title}</Title>}
|
title={<Title order={3}>{title}</Title>}
|
||||||
|
radius={20}
|
||||||
|
transitionProps={{
|
||||||
|
transition: "pop",
|
||||||
|
duration: 200,
|
||||||
|
timingFunction: "ease-out",
|
||||||
|
onExited,
|
||||||
|
}}
|
||||||
|
overlayProps={{ backgroundOpacity: 0.4 }}
|
||||||
|
closeButtonProps={{ "aria-label": "Close" }}
|
||||||
>
|
>
|
||||||
<Suspense
|
<Suspense
|
||||||
fallback={
|
fallback={
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
import { PropsWithChildren, Suspense, useCallback } from "react";
|
import {
|
||||||
|
PropsWithChildren,
|
||||||
|
Suspense,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import { useIsMobile } from "@/hooks/use-is-mobile";
|
import { useIsMobile } from "@/hooks/use-is-mobile";
|
||||||
import Drawer from "./drawer";
|
import Drawer from "./drawer";
|
||||||
import Modal from "./modal";
|
import Modal from "./modal";
|
||||||
@@ -10,13 +17,35 @@ interface SheetProps extends PropsWithChildren {
|
|||||||
onChange: (next: boolean) => void;
|
onChange: (next: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DRAWER_EXIT_MS = 500;
|
||||||
|
const MODAL_EXIT_MS = 200;
|
||||||
|
const EXIT_BUFFER_MS = 100;
|
||||||
|
|
||||||
const Sheet: React.FC<SheetProps> = ({ title, children, opened, onChange }) => {
|
const Sheet: React.FC<SheetProps> = ({ title, children, opened, onChange }) => {
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const handleClose = useCallback(() => onChange(false), [onChange]);
|
const handleClose = useCallback(() => onChange(false), [onChange]);
|
||||||
|
|
||||||
|
const [mounted, setMounted] = useState(opened);
|
||||||
|
const openedRef = useRef(opened);
|
||||||
|
openedRef.current = opened;
|
||||||
|
const handleExited = useCallback(() => {
|
||||||
|
if (!openedRef.current) setMounted(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (opened) {
|
||||||
|
setMounted(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const exitDuration =
|
||||||
|
(isMobile ? DRAWER_EXIT_MS : MODAL_EXIT_MS) + EXIT_BUFFER_MS;
|
||||||
|
const timer = window.setTimeout(() => setMounted(false), exitDuration);
|
||||||
|
return () => window.clearTimeout(timer);
|
||||||
|
}, [opened, isMobile]);
|
||||||
|
|
||||||
const SheetComponent = isMobile ? Drawer : Modal;
|
const SheetComponent = isMobile ? Drawer : Modal;
|
||||||
|
|
||||||
if (!opened) return null;
|
if (!opened && !mounted) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SheetComponent
|
<SheetComponent
|
||||||
@@ -24,6 +53,7 @@ const Sheet: React.FC<SheetProps> = ({ title, children, opened, onChange }) => {
|
|||||||
opened={opened}
|
opened={opened}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
|
onExited={handleExited}
|
||||||
>
|
>
|
||||||
<Suspense fallback={
|
<Suspense fallback={
|
||||||
<Flex justify='center' align='center' w='100%' style={{ minHeight: '25vh' }}>
|
<Flex justify='center' align='center' w='100%' style={{ minHeight: '25vh' }}>
|
||||||
|
|||||||
@@ -150,7 +150,11 @@ const SlidePanel = ({
|
|||||||
{panelConfig && (
|
{panelConfig && (
|
||||||
<>
|
<>
|
||||||
<Group justify="space-between" p="md" align="center" w="100%">
|
<Group justify="space-between" p="md" align="center" w="100%">
|
||||||
<ActionIcon variant="transparent" onClick={closePanel}>
|
<ActionIcon
|
||||||
|
variant="transparent"
|
||||||
|
onClick={closePanel}
|
||||||
|
aria-label="Back"
|
||||||
|
>
|
||||||
<ArrowLeftIcon size={24} />
|
<ArrowLeftIcon size={24} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
<Text fw={500}>{panelConfig.title}</Text>
|
<Text fw={500}>{panelConfig.title}</Text>
|
||||||
@@ -158,6 +162,7 @@ const SlidePanel = ({
|
|||||||
variant="transparent"
|
variant="transparent"
|
||||||
color="green"
|
color="green"
|
||||||
onClick={handleConfirm}
|
onClick={handleConfirm}
|
||||||
|
aria-label="Confirm"
|
||||||
>
|
>
|
||||||
<CheckIcon size={24} />
|
<CheckIcon size={24} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
|||||||
@@ -20,3 +20,9 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
transition: height 0.2s ease-out, max-height 0.2s ease-out;
|
transition: height 0.2s ease-out, max-height 0.2s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.drawerContent {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ function SwipeableTabs({
|
|||||||
embla?.scrollTo(index);
|
embla?.scrollTo(index);
|
||||||
onTabChange?.(index, tabs[index]);
|
onTabChange?.(index, tabs[index]);
|
||||||
|
|
||||||
|
document
|
||||||
|
.getElementById("scroll-wrapper")
|
||||||
|
?.querySelector(".mantine-ScrollArea-viewport")
|
||||||
|
?.scrollTo({ top: 0 });
|
||||||
|
|
||||||
const tabLabel = tabs[index].label.toLowerCase();
|
const tabLabel = tabs[index].label.toLowerCase();
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createContext, useCallback, useEffect, useState, PropsWithChildren } from 'react';
|
import { createContext, useCallback, useEffect, useMemo, useState, PropsWithChildren } from 'react';
|
||||||
import { SpotifyAuth } from '@/lib/spotify/auth';
|
import { SpotifyAuth } from '@/lib/spotify/auth';
|
||||||
import { useAuth } from './auth-context';
|
import { useAuth } from './auth-context';
|
||||||
import { useConfig } from '@/hooks/use-config';
|
import { useConfig } from '@/hooks/use-config';
|
||||||
@@ -21,6 +21,62 @@ const defaultSpotifyState: SpotifyAuthState = {
|
|||||||
|
|
||||||
export const SpotifyContext = createContext<SpotifyContextType | null>(null);
|
export const SpotifyContext = createContext<SpotifyContextType | null>(null);
|
||||||
|
|
||||||
|
const deepEqual = (a: unknown, b: unknown): boolean => {
|
||||||
|
if (a === b) return true;
|
||||||
|
if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
||||||
|
const aKeys = Object.keys(a as Record<string, unknown>);
|
||||||
|
const bKeys = Object.keys(b as Record<string, unknown>);
|
||||||
|
if (aKeys.length !== bKeys.length) return false;
|
||||||
|
return aKeys.every((key) =>
|
||||||
|
deepEqual(
|
||||||
|
(a as Record<string, unknown>)[key],
|
||||||
|
(b as Record<string, unknown>)[key]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const makeSpotifyRequest = async (endpoint: string, options: RequestInit = {}) => {
|
||||||
|
const response = await fetch(`/api/spotify/${endpoint}`, {
|
||||||
|
...options,
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
let errorMessage = 'Request failed';
|
||||||
|
try {
|
||||||
|
const errorData = await response.json();
|
||||||
|
errorMessage = errorData.error || errorMessage;
|
||||||
|
} catch {
|
||||||
|
errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
||||||
|
}
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.status === 204 || response.headers.get('content-length') === '0') {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const contentType = response.headers.get('content-type') || '';
|
||||||
|
if (!contentType.includes('application/json')) {
|
||||||
|
console.warn(`Non-JSON response from ${endpoint}:`, contentType);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Failed to parse JSON response from ${endpoint}:`, error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
||||||
const { roles } = useAuth();
|
const { roles } = useAuth();
|
||||||
const isAdmin = roles?.includes('Admin') || false;
|
const isAdmin = roles?.includes('Admin') || false;
|
||||||
@@ -41,9 +97,9 @@ export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
const [isCaptureLoading, setIsCaptureLoading] = useState(false);
|
const [isCaptureLoading, setIsCaptureLoading] = useState(false);
|
||||||
const [isResumeLoading, setIsResumeLoading] = useState(false);
|
const [isResumeLoading, setIsResumeLoading] = useState(false);
|
||||||
|
|
||||||
const spotifyAuth = new SpotifyAuth(
|
const spotifyAuth = useMemo(
|
||||||
config.spotifyClientId,
|
() => new SpotifyAuth(config.spotifyClientId, config.spotifyRedirectUri),
|
||||||
config.spotifyRedirectUri
|
[config.spotifyClientId, config.spotifyRedirectUri]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -126,45 +182,6 @@ export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
document.cookie = 'spotify_refresh_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
document.cookie = 'spotify_refresh_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const makeSpotifyRequest = async (endpoint: string, options: RequestInit = {}) => {
|
|
||||||
const response = await fetch(`/api/spotify/${endpoint}`, {
|
|
||||||
...options,
|
|
||||||
credentials: 'include',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
...options.headers,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
let errorMessage = 'Request failed';
|
|
||||||
try {
|
|
||||||
const errorData = await response.json();
|
|
||||||
errorMessage = errorData.error || errorMessage;
|
|
||||||
} catch {
|
|
||||||
errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
||||||
}
|
|
||||||
throw new Error(errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.status === 204 || response.headers.get('content-length') === '0') {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const contentType = response.headers.get('content-type') || '';
|
|
||||||
if (!contentType.includes('application/json')) {
|
|
||||||
console.warn(`Non-JSON response from ${endpoint}:`, contentType);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return await response.json();
|
|
||||||
} catch (error) {
|
|
||||||
console.warn(`Failed to parse JSON response from ${endpoint}:`, error);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const play = useCallback(async (deviceId?: string) => {
|
const play = useCallback(async (deviceId?: string) => {
|
||||||
if (!authState.isAuthenticated) return;
|
if (!authState.isAuthenticated) return;
|
||||||
|
|
||||||
@@ -351,11 +368,16 @@ export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
const data = await makeSpotifyRequest('playback?type=state');
|
const data = await makeSpotifyRequest('playback?type=state');
|
||||||
const state = data.playbackState;
|
const state = data.playbackState;
|
||||||
|
|
||||||
setPlaybackState(state);
|
setPlaybackState((prev) => (deepEqual(prev, state ?? null) ? prev : state));
|
||||||
setCurrentTrack(state?.item || null);
|
setCurrentTrack((prev) => {
|
||||||
|
const next = state?.item || null;
|
||||||
|
return deepEqual(prev, next) ? prev : next;
|
||||||
|
});
|
||||||
|
|
||||||
if (state?.device) {
|
if (state?.device) {
|
||||||
setActiveDeviceState(state.device);
|
setActiveDeviceState((prev) =>
|
||||||
|
deepEqual(prev, state.device) ? prev : state.device
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Failed to refresh playback state:', error);
|
console.warn('Failed to refresh playback state:', error);
|
||||||
@@ -365,8 +387,24 @@ export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!authState.isAuthenticated) return;
|
if (!authState.isAuthenticated) return;
|
||||||
|
|
||||||
const interval = setInterval(refreshPlaybackState, 5000);
|
const poll = () => {
|
||||||
return () => clearInterval(interval);
|
if (document.hidden) return;
|
||||||
|
refreshPlaybackState();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVisibilityChange = () => {
|
||||||
|
if (!document.hidden) {
|
||||||
|
refreshPlaybackState();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const interval = setInterval(poll, 5000);
|
||||||
|
document.addEventListener('visibilitychange', handleVisibilityChange);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(interval);
|
||||||
|
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
||||||
|
};
|
||||||
}, [authState.isAuthenticated, refreshPlaybackState]);
|
}, [authState.isAuthenticated, refreshPlaybackState]);
|
||||||
|
|
||||||
const capturePlaybackState = useCallback(async () => {
|
const capturePlaybackState = useCallback(async () => {
|
||||||
@@ -432,7 +470,7 @@ export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const contextValue: SpotifyContextType = {
|
const contextValue: SpotifyContextType = useMemo(() => ({
|
||||||
...authState,
|
...authState,
|
||||||
currentTrack,
|
currentTrack,
|
||||||
playbackState,
|
playbackState,
|
||||||
@@ -461,7 +499,33 @@ export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
clearCapturedState,
|
clearCapturedState,
|
||||||
// Search
|
// Search
|
||||||
searchTracks,
|
searchTracks,
|
||||||
};
|
}), [
|
||||||
|
authState,
|
||||||
|
currentTrack,
|
||||||
|
playbackState,
|
||||||
|
devices,
|
||||||
|
activeDevice,
|
||||||
|
isLoading,
|
||||||
|
error,
|
||||||
|
capturedState,
|
||||||
|
isCaptureLoading,
|
||||||
|
isResumeLoading,
|
||||||
|
login,
|
||||||
|
logout,
|
||||||
|
play,
|
||||||
|
playTrack,
|
||||||
|
pause,
|
||||||
|
skipNext,
|
||||||
|
skipPrevious,
|
||||||
|
setVolume,
|
||||||
|
getDevices,
|
||||||
|
setActiveDevice,
|
||||||
|
refreshPlaybackState,
|
||||||
|
capturePlaybackState,
|
||||||
|
resumePlaybackState,
|
||||||
|
clearCapturedState,
|
||||||
|
searchTracks,
|
||||||
|
]);
|
||||||
|
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import {
|
|||||||
Pagination,
|
Pagination,
|
||||||
Code,
|
Code,
|
||||||
Alert,
|
Alert,
|
||||||
|
ThemeIcon,
|
||||||
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import {
|
import {
|
||||||
MagnifyingGlassIcon,
|
MagnifyingGlassIcon,
|
||||||
@@ -20,6 +22,7 @@ import {
|
|||||||
CheckIcon,
|
CheckIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
ChecksIcon,
|
ChecksIcon,
|
||||||
|
PulseIcon,
|
||||||
} from "@phosphor-icons/react";
|
} from "@phosphor-icons/react";
|
||||||
import { Activity, ActivitySearchParams } from "../types";
|
import { Activity, ActivitySearchParams } from "../types";
|
||||||
import { useActivities } from "../queries";
|
import { useActivities } from "../queries";
|
||||||
@@ -220,9 +223,14 @@ const ActivitiesResults = ({ searchParams, page, setPage, onActivityClick }: any
|
|||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
{result.items.length === 0 && (
|
{result.items.length === 0 && (
|
||||||
<Text ta="center" c="dimmed" py="xl">
|
<Stack align="center" gap="md" py="xl">
|
||||||
No activities found
|
<ThemeIcon size="xl" variant="light" radius="md">
|
||||||
</Text>
|
<PulseIcon size={32} />
|
||||||
|
</ThemeIcon>
|
||||||
|
<Title order={3} c="dimmed">
|
||||||
|
No Activities Found
|
||||||
|
</Title>
|
||||||
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{result.totalPages > 1 && (
|
{result.totalPages > 1 && (
|
||||||
@@ -339,7 +347,7 @@ export const ActivitiesTable = () => {
|
|||||||
<Text
|
<Text
|
||||||
size="xs"
|
size="xs"
|
||||||
fw={sortBy.includes("created") ? 600 : 400}
|
fw={sortBy.includes("created") ? 600 : 400}
|
||||||
c={sortBy.includes("created") ? "dark" : "dimmed"}
|
c={sortBy.includes("created") ? "var(--mantine-color-text)" : "dimmed"}
|
||||||
>
|
>
|
||||||
Date
|
Date
|
||||||
</Text>
|
</Text>
|
||||||
@@ -355,7 +363,7 @@ export const ActivitiesTable = () => {
|
|||||||
<Text
|
<Text
|
||||||
size="xs"
|
size="xs"
|
||||||
fw={sortBy.includes("duration") ? 600 : 400}
|
fw={sortBy.includes("duration") ? 600 : 400}
|
||||||
c={sortBy.includes("duration") ? "dark" : "dimmed"}
|
c={sortBy.includes("duration") ? "var(--mantine-color-text)" : "dimmed"}
|
||||||
>
|
>
|
||||||
Duration
|
Duration
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const activitySearchParamsSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const searchActivities = createServerFn()
|
export const searchActivities = createServerFn()
|
||||||
.inputValidator(activitySearchParamsSchema)
|
.validator(activitySearchParamsSchema)
|
||||||
.middleware([superTokensAdminFunctionMiddleware])
|
.middleware([superTokensAdminFunctionMiddleware])
|
||||||
.handler(async ({ data }) =>
|
.handler(async ({ data }) =>
|
||||||
toServerResult<ActivityListResult>(async () => {
|
toServerResult<ActivityListResult>(async () => {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const ManageTournaments = () => {
|
|||||||
return (
|
return (
|
||||||
<List p="0">
|
<List p="0">
|
||||||
{tournaments.map((t) => (
|
{tournaments.map((t) => (
|
||||||
<ListLink label={t.name} to={`/admin/tournaments/${t.id}`} />
|
<ListLink key={t.id} label={t.name} to={`/admin/tournaments/${t.id}`} />
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export const BadgeIcon = ({ badge, filled, size = 48 }: BadgeIconProps & { size?
|
|||||||
alt={badge.name}
|
alt={badge.name}
|
||||||
width={size}
|
width={size}
|
||||||
height={size}
|
height={size}
|
||||||
|
loading="lazy"
|
||||||
onError={() => setImageError(true)}
|
onError={() => setImageError(true)}
|
||||||
style={{
|
style={{
|
||||||
objectFit: 'contain',
|
objectFit: 'contain',
|
||||||
@@ -57,6 +58,28 @@ export const BadgeIcon = ({ badge, filled, size = 48 }: BadgeIconProps & { size?
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const badgeTileCss = `
|
||||||
|
.flxn-badge-tile {
|
||||||
|
transition: transform 160ms cubic-bezier(0.32, 0.72, 0, 1);
|
||||||
|
}
|
||||||
|
@media (hover: hover) {
|
||||||
|
.flxn-badge-tile:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.flxn-badge-tile:active {
|
||||||
|
transform: scale(0.97);
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.flxn-badge-tile,
|
||||||
|
.flxn-badge-tile:hover,
|
||||||
|
.flxn-badge-tile:active {
|
||||||
|
transition: none;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const BadgeShowcase = ({ playerId }: BadgeShowcaseProps) => {
|
const BadgeShowcase = ({ playerId }: BadgeShowcaseProps) => {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { data: badgeProgress } = usePlayerBadges(playerId);
|
const { data: badgeProgress } = usePlayerBadges(playerId);
|
||||||
@@ -138,6 +161,9 @@ const BadgeShowcase = ({ playerId }: BadgeShowcaseProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box mb="lg">
|
<Box mb="lg">
|
||||||
|
<style href="flxn-badge-tile" precedence="medium">
|
||||||
|
{badgeTileCss}
|
||||||
|
</style>
|
||||||
<Box
|
<Box
|
||||||
px="md"
|
px="md"
|
||||||
style={{
|
style={{
|
||||||
@@ -167,9 +193,9 @@ const BadgeShowcase = ({ playerId }: BadgeShowcaseProps) => {
|
|||||||
<Popover key={display.badge.id} width={280} position="top" withArrow shadow="md" withinPortal>
|
<Popover key={display.badge.id} width={280} position="top" withArrow shadow="md" withinPortal>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
<Box
|
<Box
|
||||||
|
className="flxn-badge-tile"
|
||||||
style={{
|
style={{
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
transition: 'all 0.2s ease',
|
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { pbAdmin } from "@/lib/pocketbase/client";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const getPlayerBadges = createServerFn()
|
export const getPlayerBadges = createServerFn()
|
||||||
.inputValidator(z.string())
|
.validator(z.string())
|
||||||
.middleware([superTokensFunctionMiddleware])
|
.middleware([superTokensFunctionMiddleware])
|
||||||
.handler(async ({ data: playerId }) =>
|
.handler(async ({ data: playerId }) =>
|
||||||
toServerResult(() => pbAdmin.getPlayerBadgeProgress(playerId))
|
toServerResult(() => pbAdmin.getPlayerBadgeProgress(playerId))
|
||||||
@@ -28,7 +28,7 @@ export const getAllEarnedBadges = createServerFn()
|
|||||||
.handler(async () => toServerResult(() => pbAdmin.listEarnedBadges()));
|
.handler(async () => toServerResult(() => pbAdmin.listEarnedBadges()));
|
||||||
|
|
||||||
export const awardManualBadge = createServerFn()
|
export const awardManualBadge = createServerFn()
|
||||||
.inputValidator(z.object({
|
.validator(z.object({
|
||||||
playerId: z.string(),
|
playerId: z.string(),
|
||||||
badgeId: z.string(),
|
badgeId: z.string(),
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { BracketData } from "../types";
|
|||||||
import { Bracket } from "./bracket";
|
import { Bracket } from "./bracket";
|
||||||
import useAppShellHeight from "@/hooks/use-appshell-height";
|
import useAppShellHeight from "@/hooks/use-appshell-height";
|
||||||
import { Match } from "@/features/matches/types";
|
import { Match } from "@/features/matches/types";
|
||||||
|
import styles from "./styles.module.css";
|
||||||
|
|
||||||
interface BracketViewProps {
|
interface BracketViewProps {
|
||||||
bracket: BracketData;
|
bracket: BracketData;
|
||||||
@@ -25,7 +26,7 @@ const BracketView: React.FC<BracketViewProps> = ({ bracket, showControls, groupC
|
|||||||
|
|
||||||
return <ScrollArea
|
return <ScrollArea
|
||||||
h={`calc(${height})`}
|
h={`calc(${height})`}
|
||||||
className="bracket-container"
|
className={styles["bracket-container"]}
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `radial-gradient(circle, var(--mantine-color-default-border) 1px, transparent 1px)`,
|
backgroundImage: `radial-gradient(circle, var(--mantine-color-default-border) 1px, transparent 1px)`,
|
||||||
backgroundSize: "16px 16px",
|
backgroundSize: "16px 16px",
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
|||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: tournamentKeys.details(match.tournament.id),
|
queryKey: tournamentKeys.details(match.tournament.id),
|
||||||
});
|
});
|
||||||
|
editSheet.close();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -149,9 +150,8 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
|||||||
matchId: match.id,
|
matchId: match.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
editSheet.close();
|
|
||||||
},
|
},
|
||||||
[match.id, editSheet]
|
[end, match.id]
|
||||||
);
|
);
|
||||||
|
|
||||||
const speak = useCallback((text: string): Promise<void> => {
|
const speak = useCallback((text: string): Promise<void> => {
|
||||||
@@ -311,6 +311,7 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
|||||||
variant="subtle"
|
variant="subtle"
|
||||||
color="gray"
|
color="gray"
|
||||||
onClick={handleSpeakerClick}
|
onClick={handleSpeakerClick}
|
||||||
|
aria-label="Announce matchup"
|
||||||
>
|
>
|
||||||
<SpeakerHighIcon size={12} />
|
<SpeakerHighIcon size={12} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -323,10 +324,12 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
color="green"
|
color="green"
|
||||||
onClick={handleStart}
|
onClick={handleStart}
|
||||||
|
loading={start.isPending}
|
||||||
size="sm"
|
size="sm"
|
||||||
h="100%"
|
h="100%"
|
||||||
radius="sm"
|
radius="sm"
|
||||||
ml={-4}
|
ml={-4}
|
||||||
|
aria-label="Start match"
|
||||||
style={{
|
style={{
|
||||||
borderTopLeftRadius: 0,
|
borderTopLeftRadius: 0,
|
||||||
borderBottomLeftRadius: 0,
|
borderBottomLeftRadius: 0,
|
||||||
@@ -343,10 +346,12 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
color="blue"
|
color="blue"
|
||||||
onClick={editSheet.open}
|
onClick={editSheet.open}
|
||||||
|
loading={end.isPending}
|
||||||
size="sm"
|
size="sm"
|
||||||
h="100%"
|
h="100%"
|
||||||
radius="sm"
|
radius="sm"
|
||||||
ml={-4}
|
ml={-4}
|
||||||
|
aria-label="Edit match score"
|
||||||
style={{
|
style={{
|
||||||
borderTopLeftRadius: 0,
|
borderTopLeftRadius: 0,
|
||||||
borderBottomLeftRadius: 0,
|
borderBottomLeftRadius: 0,
|
||||||
@@ -363,6 +368,7 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
|||||||
match={match}
|
match={match}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
onCancel={editSheet.close}
|
onCancel={editSheet.close}
|
||||||
|
loading={end.isPending}
|
||||||
/>
|
/>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ interface MatchFormProps {
|
|||||||
ot_count: number;
|
ot_count: number;
|
||||||
}) => void;
|
}) => void;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
|
loading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MatchForm: React.FC<MatchFormProps> = ({
|
export const MatchForm: React.FC<MatchFormProps> = ({
|
||||||
match,
|
match,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onCancel,
|
onCancel,
|
||||||
|
loading = false,
|
||||||
}) => {
|
}) => {
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
@@ -35,7 +37,6 @@ export const MatchForm: React.FC<MatchFormProps> = ({
|
|||||||
return "At least one team must have 10 cups";
|
return "At least one team must have 10 cups";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both teams can't have 10 cups
|
|
||||||
if (homeCups === 10 && awayCups === 10) {
|
if (homeCups === 10 && awayCups === 10) {
|
||||||
return "Both teams cannot have 10 cups";
|
return "Both teams cannot have 10 cups";
|
||||||
}
|
}
|
||||||
@@ -145,8 +146,15 @@ export const MatchForm: React.FC<MatchFormProps> = ({
|
|||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Stack mt="md">
|
<Stack mt="md">
|
||||||
<Button type="submit">Update Match</Button>
|
<Button type="submit" loading={loading}>
|
||||||
<Button variant="subtle" color="red" onClick={onCancel}>
|
Update Match
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="subtle"
|
||||||
|
color="red"
|
||||||
|
onClick={onCancel}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
.slotEnter {
|
||||||
|
animation: slot-enter 300ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slot-enter {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(4px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.slotEnter {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
import { Flex, Text } from "@mantine/core";
|
import { Flex, Text } from "@mantine/core";
|
||||||
import React from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { CrownIcon } from "@phosphor-icons/react";
|
import { CrownIcon } from "@phosphor-icons/react";
|
||||||
import { SeedBadge } from "./seed-badge";
|
import { SeedBadge } from "./seed-badge";
|
||||||
import { TeamInfo } from "@/features/teams/types";
|
import { TeamInfo } from "@/features/teams/types";
|
||||||
|
import AnimatedScore from "@/features/matches/components/animated-score";
|
||||||
|
import classes from "./match-slot.module.css";
|
||||||
|
|
||||||
interface MatchSlotProps {
|
interface MatchSlotProps {
|
||||||
from?: number;
|
from?: number;
|
||||||
@@ -22,60 +24,80 @@ export const MatchSlot: React.FC<MatchSlotProps> = ({
|
|||||||
cups,
|
cups,
|
||||||
isWinner,
|
isWinner,
|
||||||
groupLabel
|
groupLabel
|
||||||
}) => (
|
}) => {
|
||||||
<Flex
|
const teamId = team?.id;
|
||||||
align="stretch"
|
const previousTeamIdRef = useRef<string | undefined>(teamId);
|
||||||
style={{
|
const [entranceKey, setEntranceKey] = useState(0);
|
||||||
backgroundColor: isWinner ? 'var(--mantine-color-green-light)' : 'transparent',
|
|
||||||
borderRadius: 'var(--mantine-radius-sm)',
|
useEffect(() => {
|
||||||
transition: 'background-color 200ms ease',
|
const previousTeamId = previousTeamIdRef.current;
|
||||||
}}
|
previousTeamIdRef.current = teamId;
|
||||||
>
|
if (teamId && previousTeamId !== teamId) {
|
||||||
{(seed && seed > 0) ? <SeedBadge seed={seed} /> : undefined}
|
setEntranceKey((key) => key + 1);
|
||||||
<Flex p="6px 10px" w='100%' align="center">
|
}
|
||||||
<Flex align="center" gap={4} flex={1}>
|
}, [teamId]);
|
||||||
{team ? (
|
|
||||||
<>
|
return (
|
||||||
<Text
|
<Flex
|
||||||
size={team.name.length > 12 ? (team.name.length > 18 ? '10px' : '11px') : 'xs'}
|
align="stretch"
|
||||||
truncate
|
style={{
|
||||||
style={{ minWidth: 0, flex: 1, lineHeight: "12px" }}
|
backgroundColor: isWinner ? 'var(--mantine-color-green-light)' : 'transparent',
|
||||||
>
|
borderRadius: 'var(--mantine-radius-sm)',
|
||||||
{team.name}
|
transition: 'background-color 200ms ease',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{(seed && seed > 0) ? <SeedBadge seed={seed} /> : undefined}
|
||||||
|
<Flex p="6px 10px" w='100%' align="center">
|
||||||
|
<Flex
|
||||||
|
key={entranceKey}
|
||||||
|
className={entranceKey > 0 ? classes.slotEnter : undefined}
|
||||||
|
align="center"
|
||||||
|
gap={4}
|
||||||
|
flex={1}
|
||||||
|
>
|
||||||
|
{team ? (
|
||||||
|
<>
|
||||||
|
<Text
|
||||||
|
size={team.name.length > 12 ? (team.name.length > 18 ? '10px' : '11px') : 'xs'}
|
||||||
|
truncate
|
||||||
|
style={{ minWidth: 0, flex: 1, lineHeight: "12px" }}
|
||||||
|
>
|
||||||
|
{team.name}
|
||||||
|
</Text>
|
||||||
|
{isWinner && (
|
||||||
|
<CrownIcon
|
||||||
|
size={14}
|
||||||
|
weight="fill"
|
||||||
|
style={{
|
||||||
|
color: 'gold',
|
||||||
|
marginLeft: '2px',
|
||||||
|
marginTop: '-1px',
|
||||||
|
filter: 'drop-shadow(0 1px 1px rgba(0,0,0,0.3))',
|
||||||
|
flexShrink: 0
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : groupLabel ? (
|
||||||
|
<Text c="dimmed" size="xs" truncate style={{ minWidth: 0, flex: 1 }}>
|
||||||
|
{groupLabel}
|
||||||
</Text>
|
</Text>
|
||||||
{isWinner && (
|
) : from ? (
|
||||||
<CrownIcon
|
<Text c="dimmed" size="xs" truncate style={{ minWidth: 0, flex: 1 }}>
|
||||||
size={14}
|
{from_loser ? "Loser" : "Winner"} of Match {from}
|
||||||
weight="fill"
|
</Text>
|
||||||
style={{
|
) : (
|
||||||
color: 'gold',
|
<Text c="dimmed" size="xs" truncate style={{ minWidth: 0, flex: 1 }}>
|
||||||
marginLeft: '2px',
|
TBD
|
||||||
marginTop: '-1px',
|
</Text>
|
||||||
filter: 'drop-shadow(0 1px 1px rgba(0,0,0,0.3))',
|
)}
|
||||||
flexShrink: 0
|
</Flex>
|
||||||
}}
|
{
|
||||||
/>
|
cups !== undefined ? (
|
||||||
)}
|
<AnimatedScore ta='center' w={15} fw={800} ml={4} size="xs" value={cups} />
|
||||||
</>
|
) : undefined
|
||||||
) : groupLabel ? (
|
}
|
||||||
<Text c="dimmed" size="xs" truncate style={{ minWidth: 0, flex: 1 }}>
|
|
||||||
{groupLabel}
|
|
||||||
</Text>
|
|
||||||
) : from ? (
|
|
||||||
<Text c="dimmed" size="xs" truncate style={{ minWidth: 0, flex: 1 }}>
|
|
||||||
{from_loser ? "Loser" : "Winner"} of Match {from}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<Text c="dimmed" size="xs" truncate style={{ minWidth: 0, flex: 1 }}>
|
|
||||||
TBD
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</Flex>
|
</Flex>
|
||||||
{
|
|
||||||
cups !== undefined ? (
|
|
||||||
<Text ta='center' w={15} fw="800" ml={4} size="xs">{cups}</Text>
|
|
||||||
) : undefined
|
|
||||||
}
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
);
|
||||||
);
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { toServerResult } from "@/lib/tanstack-query/utils/to-server-result";
|
|||||||
const logger = new Logger("Bracket Generation");
|
const logger = new Logger("Bracket Generation");
|
||||||
|
|
||||||
export const previewBracket = createServerFn()
|
export const previewBracket = createServerFn()
|
||||||
.inputValidator(z.number())
|
.validator(z.number())
|
||||||
.middleware([superTokensFunctionMiddleware])
|
.middleware([superTokensFunctionMiddleware])
|
||||||
.handler(async ({ data: teams }) =>
|
.handler(async ({ data: teams }) =>
|
||||||
toServerResult(async () => {
|
toServerResult(async () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box } from "@mantine/core"
|
import { UnstyledButton } from "@mantine/core"
|
||||||
import { ArrowLeftIcon } from "@phosphor-icons/react"
|
import { ArrowLeftIcon } from "@phosphor-icons/react"
|
||||||
import { useRouter } from "@tanstack/react-router"
|
import { useRouter } from "@tanstack/react-router"
|
||||||
|
|
||||||
@@ -6,15 +6,16 @@ const BackButton = ({ top=20, left=20 }: { top?: number, left?: number }) => {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<UnstyledButton
|
||||||
style={{ cursor: 'pointer', zIndex: 1000 }}
|
aria-label='Go back'
|
||||||
|
style={{ cursor: 'pointer', zIndex: 1000, display: 'flex' }}
|
||||||
onClick={() => router.history.back()}
|
onClick={() => router.history.back()}
|
||||||
pos='absolute'
|
pos='absolute'
|
||||||
left={left}
|
left={left}
|
||||||
top={top}
|
top={top}
|
||||||
>
|
>
|
||||||
<ArrowLeftIcon weight='bold' size={20} />
|
<ArrowLeftIcon weight='bold' size={20} />
|
||||||
</Box>
|
</UnstyledButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
import { Title, AppShell, Flex, Box, Paper } from "@mantine/core";
|
import { Title, AppShell, Flex } from "@mantine/core";
|
||||||
import { HeaderConfig } from "../types/header-config";
|
import { HeaderConfig } from "../types/header-config";
|
||||||
import BackButton from "./back-button";
|
import BackButton from "./back-button";
|
||||||
|
|
||||||
interface HeaderProps extends HeaderConfig {}
|
const Header = ({ collapsed, title, withBackButton }: HeaderConfig) => {
|
||||||
|
|
||||||
const Header = ({ collapsed, title, withBackButton }: HeaderProps) => {
|
|
||||||
return (
|
return (
|
||||||
<AppShell.Header
|
<AppShell.Header
|
||||||
id='app-header'
|
id='app-header'
|
||||||
display={collapsed ? 'none' : 'flex'}
|
display={collapsed ? 'none' : 'flex'}
|
||||||
style={{ alignItems: 'center', justifyContent: 'center' }}
|
withBorder={false}
|
||||||
|
style={{
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
transition: 'border-color 200ms ease-out',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{ withBackButton && <BackButton /> }
|
{ withBackButton && <BackButton /> }
|
||||||
<Flex justify='center' px='md' mt={8}>
|
<Flex justify='center' px='md' mt={8}>
|
||||||
<Title order={1}>{title?.toLocaleUpperCase()}</Title>
|
<Title order={1} lts='0.08em' style={{ userSelect: 'none' }}>
|
||||||
|
{title?.toLocaleUpperCase()}
|
||||||
|
</Title>
|
||||||
</Flex>
|
</Flex>
|
||||||
</AppShell.Header>
|
</AppShell.Header>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import { AppShell } from '@mantine/core';
|
import { AppShell, Box } from '@mantine/core';
|
||||||
import { PropsWithChildren, useState } from 'react';
|
import { PropsWithChildren } from 'react';
|
||||||
|
import { useLocation } from '@tanstack/react-router';
|
||||||
import Header from './header';
|
import Header from './header';
|
||||||
import Navbar from './navbar';
|
import Navbar from './navbar';
|
||||||
import Pullable from './pullable';
|
import Pullable from './pullable';
|
||||||
import useVisualViewportSize from '../hooks/use-visual-viewport-size';
|
import useVisualViewportSize from '../hooks/use-visual-viewport-size';
|
||||||
import useRouterConfig from '../hooks/use-router-config';
|
import useRouterConfig from '../hooks/use-router-config';
|
||||||
import Page from '@/components/page';
|
import Page from '@/components/page';
|
||||||
|
import './route-transition.css';
|
||||||
|
|
||||||
const Layout: React.FC<PropsWithChildren> = ({ children }) => {
|
const Layout: React.FC<PropsWithChildren> = ({ children }) => {
|
||||||
const { header } = useRouterConfig();
|
const { header, withPadding, fullWidth } = useRouterConfig();
|
||||||
const viewport = useVisualViewportSize();
|
const viewport = useVisualViewportSize();
|
||||||
const [scrollPosition, setScrollPosition] = useState({ x: 0, y: 0 });
|
const location = useLocation();
|
||||||
const { withPadding, fullWidth } = useRouterConfig();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppShell
|
<AppShell
|
||||||
@@ -42,14 +43,16 @@ const Layout: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
pos='relative'
|
pos='relative'
|
||||||
h='100%'
|
h='100%'
|
||||||
mah='100%'
|
mah='100%'
|
||||||
pb={{ base: 65, sm: 0 }}
|
pb={{ base: 'calc(65px + env(safe-area-inset-bottom, 0px))', sm: 0 }}
|
||||||
px={{ base: 0.01, sm: 100, md: 200, lg: 300 }}
|
px={{ base: 0.01, sm: 100, md: 200, lg: 300 }}
|
||||||
maw='100dvw'
|
maw='100dvw'
|
||||||
style={{ transition: 'none', overflow: 'hidden' }}
|
style={{ overflow: 'hidden' }}
|
||||||
>
|
>
|
||||||
<Pullable scrollPosition={scrollPosition} onScrollPositionChange={setScrollPosition}>
|
<Pullable>
|
||||||
<Page noPadding={!withPadding} fullWidth={fullWidth}>
|
<Page noPadding={!withPadding} fullWidth={fullWidth}>
|
||||||
{children}
|
<Box key={location.pathname} className="flxn-route-enter">
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
</Page>
|
</Page>
|
||||||
</Pullable>
|
</Pullable>
|
||||||
</AppShell.Main>
|
</AppShell.Main>
|
||||||
|
|||||||
@@ -19,14 +19,13 @@ export const NavLink = ({
|
|||||||
include,
|
include,
|
||||||
exclude,
|
exclude,
|
||||||
}: NavLinkProps) => {
|
}: NavLinkProps) => {
|
||||||
const router = useRouterState();
|
const pathname = useRouterState({ select: (s) => s.location.pathname });
|
||||||
const isActive = useMemo(
|
const isActive = useMemo(
|
||||||
() =>
|
() =>
|
||||||
(!exclude?.some((e) => router.location.pathname.includes(e)) &&
|
(!exclude?.some((e) => pathname.includes(e)) &&
|
||||||
(router.location.pathname === href ||
|
(pathname === href || (pathname.includes(href) && href !== "/"))) ||
|
||||||
(router.location.pathname.includes(href) && href !== "/"))) ||
|
include?.includes(pathname),
|
||||||
include?.includes(router.location.pathname),
|
[pathname, href]
|
||||||
[router.location.pathname, href]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -35,6 +34,8 @@ export const NavLink = ({
|
|||||||
to={href}
|
to={href}
|
||||||
className={styles.navLinkBox}
|
className={styles.navLinkBox}
|
||||||
p={{ base: 0, sm: 8 }}
|
p={{ base: 0, sm: 8 }}
|
||||||
|
aria-label={label}
|
||||||
|
aria-current={isActive ? "page" : undefined}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
direction={{ base: "column", md: "row" }}
|
direction={{ base: "column", md: "row" }}
|
||||||
|
|||||||
@@ -2,5 +2,26 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border-radius: var(--mantine-radius-md);
|
border-radius: var(--mantine-radius-md);
|
||||||
color: unset;
|
color: unset;
|
||||||
|
min-width: 2.75rem;
|
||||||
|
min-height: 2.75rem;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLinkBox svg,
|
||||||
|
.navLinkBox p {
|
||||||
|
transition: color 150ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.navLinkBox {
|
||||||
|
transition: transform 150ms cubic-bezier(0.32, 0.72, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLinkBox:active {
|
||||||
|
transform: scale(0.92);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AppShell, ScrollArea, Stack, Group, Paper, useMantineColorScheme } from "@mantine/core";
|
import { AppShell, ScrollArea, Stack, Group, Paper } from "@mantine/core";
|
||||||
import { NavLink } from "./nav-link";
|
import { NavLink } from "./nav-link";
|
||||||
import { useIsMobile } from "@/hooks/use-is-mobile";
|
import { useIsMobile } from "@/hooks/use-is-mobile";
|
||||||
import { useAuth } from "@/contexts/auth-context";
|
import { useAuth } from "@/contexts/auth-context";
|
||||||
@@ -9,18 +9,16 @@ import { useIsPWA } from "@/hooks/use-is-pwa";
|
|||||||
const Navbar = () => {
|
const Navbar = () => {
|
||||||
const { user, roles } = useAuth()
|
const { user, roles } = useAuth()
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const { colorScheme } = useMantineColorScheme();
|
|
||||||
const isPWA = useIsPWA();
|
const isPWA = useIsPWA();
|
||||||
|
|
||||||
const links = useLinks(user?.id, roles);
|
const links = useLinks(user?.id, roles);
|
||||||
|
|
||||||
const isDark = colorScheme === 'dark';
|
const bottomOffset = isPWA
|
||||||
const borderColor = isDark ? 'var(--mantine-color-dimmed)' : 'black';
|
? 'max(env(safe-area-inset-bottom, 0px), 0.5rem)'
|
||||||
const boxShadowColor = isDark ? 'var(--mantine-color-dimmed)' : 'black';
|
: 'env(safe-area-inset-bottom, 0px)';
|
||||||
// boxShadow: `5px 5px ${boxShadowColor}`, borderColor
|
|
||||||
|
|
||||||
if (isMobile) return (
|
if (isMobile) return (
|
||||||
<Paper component='nav' role='navigation' withBorder shadow="sm" radius='lg' h='4rem' w='calc(100% - 1rem)' pos='fixed' m='0.5rem' bottom={isPWA ? '1rem' : '0'} style={{ zIndex: 10 }}>
|
<Paper component='nav' role='navigation' withBorder shadow="sm" radius='lg' h='4rem' w='calc(100% - 1rem)' pos='fixed' m='0.5rem' bottom={bottomOffset} style={{ zIndex: 10 }}>
|
||||||
<Group gap='xs' justify='space-around' h='100%' w='100%' px={{ base: 12, sm: 0 }}>
|
<Group gap='xs' justify='space-around' h='100%' w='100%' px={{ base: 12, sm: 0 }}>
|
||||||
{links.map((link) => (
|
{links.map((link) => (
|
||||||
<NavLink key={link.href} {...link} />
|
<NavLink key={link.href} {...link} />
|
||||||
|
|||||||
@@ -1,22 +1,14 @@
|
|||||||
import { ActionIcon, Box, Button, Flex, ScrollArea } from "@mantine/core";
|
import { Box, Flex, ScrollArea } from "@mantine/core";
|
||||||
import { PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import useAppShellHeight from "@/hooks/use-appshell-height";
|
import useAppShellHeight from "@/hooks/use-appshell-height";
|
||||||
import { ArrowClockwiseIcon, SpinnerIcon } from "@phosphor-icons/react";
|
import { SpinnerIcon } from "@phosphor-icons/react";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import useRouterConfig from "../hooks/use-router-config";
|
import useRouterConfig from "../hooks/use-router-config";
|
||||||
import { useLocation } from "@tanstack/react-router";
|
import { useLocation } from "@tanstack/react-router";
|
||||||
|
|
||||||
const THRESHOLD = 80;
|
const THRESHOLD = 80;
|
||||||
|
|
||||||
interface PullableProps extends PropsWithChildren {
|
const Pullable: React.FC<PropsWithChildren> = ({ children }) => {
|
||||||
scrollPosition: { x: number, y: number };
|
|
||||||
onScrollPositionChange: (position: { x: number, y: number }) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pullable is a component that allows the user to pull down to refresh the page
|
|
||||||
*/
|
|
||||||
const Pullable: React.FC<PullableProps> = ({ children, scrollPosition, onScrollPositionChange }) => {
|
|
||||||
const height = useAppShellHeight();
|
const height = useAppShellHeight();
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const [scrolling, setScrolling] = useState(false);
|
const [scrolling, setScrolling] = useState(false);
|
||||||
@@ -25,20 +17,29 @@ const Pullable: React.FC<PullableProps> = ({ children, scrollPosition, onScrollP
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const scrollAreaRef = useRef<HTMLDivElement>(null);
|
const scrollAreaRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const scrollY = useMemo(() => scrollPosition.y < 0 && scrolling ? Math.abs(scrollPosition.y) : 0, [scrollPosition.y, scrolling]);
|
const [pullDistance, setPullDistance] = useState(0);
|
||||||
|
|
||||||
|
const handleScrollPositionChange = useCallback((position: { x: number, y: number }) => {
|
||||||
|
const next = position.y < 0 ? Math.abs(position.y) : 0;
|
||||||
|
setPullDistance((prev) => (prev === next ? prev : next));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const scrollY = scrolling ? pullDistance : 0;
|
||||||
|
|
||||||
const onTrigger = useCallback(async () => {
|
const onTrigger = useCallback(async () => {
|
||||||
setIsRefreshing(true);
|
setIsRefreshing(true);
|
||||||
|
const minSpinnerDisplay = new Promise((resolve) => setTimeout(resolve, 400));
|
||||||
if (refresh.length > 0) {
|
if (refresh.length > 0) {
|
||||||
// TODO: Remove this after testing - or does the delay help ux?
|
await Promise.all(
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
refresh.map((queryKey) => {
|
||||||
refresh.forEach(async (queryKey) => {
|
const keyArray = Array.isArray(queryKey) ? queryKey : [queryKey];
|
||||||
const keyArray = Array.isArray(queryKey) ? queryKey : [queryKey];
|
return queryClient.refetchQueries({ queryKey: keyArray, exact: true });
|
||||||
await queryClient.refetchQueries({ queryKey: keyArray, exact: true });
|
})
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
await minSpinnerDisplay;
|
||||||
setIsRefreshing(false);
|
setIsRefreshing(false);
|
||||||
}, [refresh]);
|
}, [refresh, queryClient]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isRefreshing && scrollY > THRESHOLD) {
|
if (!isRefreshing && scrollY > THRESHOLD) {
|
||||||
@@ -85,7 +86,6 @@ const Pullable: React.FC<PullableProps> = ({ children, scrollPosition, onScrollP
|
|||||||
return () => void ac.abort();
|
return () => void ac.abort();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Fix wheel scrolling over child elements
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const scrollWrapper = document.getElementById('scroll-wrapper');
|
const scrollWrapper = document.getElementById('scroll-wrapper');
|
||||||
if (!scrollWrapper) return;
|
if (!scrollWrapper) return;
|
||||||
@@ -96,33 +96,29 @@ const Pullable: React.FC<PullableProps> = ({ children, scrollPosition, onScrollP
|
|||||||
const handleWheel = (e: WheelEvent) => {
|
const handleWheel = (e: WheelEvent) => {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
|
|
||||||
// Check if the target is inside a nested scrollable container
|
|
||||||
let element = target;
|
let element = target;
|
||||||
while (element && element !== viewport) {
|
while (element && element !== viewport) {
|
||||||
const overflow = window.getComputedStyle(element).overflow;
|
const overflow = window.getComputedStyle(element).overflow;
|
||||||
const overflowY = window.getComputedStyle(element).overflowY;
|
const overflowY = window.getComputedStyle(element).overflowY;
|
||||||
const overflowX = window.getComputedStyle(element).overflowX;
|
const overflowX = window.getComputedStyle(element).overflowX;
|
||||||
|
|
||||||
// If we found a scrollable ancestor (not the main viewport), don't interfere
|
|
||||||
if (
|
if (
|
||||||
(overflow === 'auto' || overflow === 'scroll' ||
|
(overflow === 'auto' || overflow === 'scroll' ||
|
||||||
overflowY === 'auto' || overflowY === 'scroll' ||
|
overflowY === 'auto' || overflowY === 'scroll' ||
|
||||||
overflowX === 'auto' || overflowX === 'scroll') &&
|
overflowX === 'auto' || overflowX === 'scroll') &&
|
||||||
element !== viewport
|
element !== viewport
|
||||||
) {
|
) {
|
||||||
// Check if this element can actually scroll in the wheel direction
|
|
||||||
const canScrollY = element.scrollHeight > element.clientHeight;
|
const canScrollY = element.scrollHeight > element.clientHeight;
|
||||||
const canScrollX = element.scrollWidth > element.clientWidth;
|
const canScrollX = element.scrollWidth > element.clientWidth;
|
||||||
|
|
||||||
if ((e.deltaY !== 0 && canScrollY) || (e.deltaX !== 0 && canScrollX)) {
|
if ((e.deltaY !== 0 && canScrollY) || (e.deltaX !== 0 && canScrollX)) {
|
||||||
return; // Let the nested scroller handle it
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
element = element.parentElement as HTMLElement;
|
element = element.parentElement as HTMLElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No nested scroller found, scroll the main viewport
|
|
||||||
viewport.scrollTop += e.deltaY;
|
viewport.scrollTop += e.deltaY;
|
||||||
viewport.scrollLeft += e.deltaX;
|
viewport.scrollLeft += e.deltaX;
|
||||||
};
|
};
|
||||||
@@ -143,11 +139,11 @@ const Pullable: React.FC<PullableProps> = ({ children, scrollPosition, onScrollP
|
|||||||
viewport.scrollLeft = 0;
|
viewport.scrollLeft = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onScrollPositionChange({ x: 0, y: 0 });
|
setPullDistance(0);
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
return () => clearTimeout(timeoutId);
|
return () => clearTimeout(timeoutId);
|
||||||
}, [location.pathname, onScrollPositionChange]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -175,7 +171,7 @@ const Pullable: React.FC<PullableProps> = ({ children, scrollPosition, onScrollP
|
|||||||
<ScrollArea
|
<ScrollArea
|
||||||
ref={scrollAreaRef}
|
ref={scrollAreaRef}
|
||||||
id='scroll-wrapper'
|
id='scroll-wrapper'
|
||||||
onScrollPositionChange={onScrollPositionChange}
|
onScrollPositionChange={handleScrollPositionChange}
|
||||||
type='never' mah='100%' h='100%'
|
type='never' mah='100%' h='100%'
|
||||||
pt={(scrolling || scrollY > 40) || !isRefreshing ? 0 : 40 - scrollY}
|
pt={(scrolling || scrollY > 40) || !isRefreshing ? 0 : 40 - scrollY}
|
||||||
styles={{
|
styles={{
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.flxn-route-enter {
|
||||||
|
animation: flxn-route-fade-in 180ms ease-out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flxn-route-fade-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box } from "@mantine/core"
|
import { UnstyledButton } from "@mantine/core"
|
||||||
import { GearIcon } from "@phosphor-icons/react"
|
import { GearIcon } from "@phosphor-icons/react"
|
||||||
import { useNavigate } from "@tanstack/react-router"
|
import { useNavigate } from "@tanstack/react-router"
|
||||||
import { memo } from "react";
|
import { memo } from "react";
|
||||||
@@ -13,16 +13,17 @@ const SettingsButton = ({ to }: SettingButtonProps) => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<UnstyledButton
|
||||||
style={{ cursor: 'pointer', zIndex: 1000 }}
|
aria-label='Settings'
|
||||||
|
style={{ cursor: 'pointer', zIndex: 1000, display: 'flex' }}
|
||||||
onClick={() => navigate({ to })}
|
onClick={() => navigate({ to })}
|
||||||
pos='absolute'
|
pos='absolute'
|
||||||
right={20}
|
right={20}
|
||||||
top={6}
|
top={6}
|
||||||
>
|
>
|
||||||
<GearIcon weight='bold' size={20} />
|
<GearIcon weight='bold' size={20} />
|
||||||
</Box>
|
</UnstyledButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(SettingsButton, (prev, next) => prev.to !== next.to);
|
export default memo(SettingsButton, (prev, next) => prev.to === next.to);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useMatches } from "@tanstack/react-router";
|
import { useMatches } from "@tanstack/react-router";
|
||||||
|
import { useMemo } from "react";
|
||||||
import { HeaderConfig } from "../types/header-config";
|
import { HeaderConfig } from "../types/header-config";
|
||||||
|
|
||||||
export const defaultHeaderConfig: HeaderConfig = {
|
export const defaultHeaderConfig: HeaderConfig = {
|
||||||
@@ -10,32 +11,34 @@ export const defaultHeaderConfig: HeaderConfig = {
|
|||||||
const useRouterConfig = () => {
|
const useRouterConfig = () => {
|
||||||
const matches = useMatches();
|
const matches = useMatches();
|
||||||
|
|
||||||
const matchesWithHeader = matches.filter((match) =>
|
return useMemo(() => {
|
||||||
match?.loaderData && 'header' in match.loaderData
|
const matchesWithHeader = matches.filter((match) =>
|
||||||
);
|
match?.loaderData && 'header' in match.loaderData
|
||||||
|
);
|
||||||
|
|
||||||
const headerConfig = matchesWithHeader.reduce((acc, match) => {
|
const headerConfig = matchesWithHeader.reduce((acc, match) => {
|
||||||
const loaderData = match?.loaderData;
|
const loaderData = match?.loaderData;
|
||||||
if (loaderData && typeof loaderData === 'object' && 'header' in loaderData) {
|
if (loaderData && typeof loaderData === 'object' && 'header' in loaderData) {
|
||||||
const header = loaderData.header;
|
const header = loaderData.header;
|
||||||
if (header && typeof header === 'object') {
|
if (header && typeof header === 'object') {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
...header,
|
...header,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return acc;
|
||||||
return acc;
|
}, defaultHeaderConfig);
|
||||||
}, defaultHeaderConfig);
|
|
||||||
|
|
||||||
const current = matches[matches.length - 1]?.loaderData;
|
const current = matches[matches.length - 1]?.loaderData;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
header: headerConfig,
|
header: headerConfig,
|
||||||
refresh: current && typeof current === 'object' && 'refresh' in current ? current.refresh : [],
|
refresh: current && typeof current === 'object' && 'refresh' in current ? current.refresh : [],
|
||||||
withPadding: current && typeof current === 'object' && 'withPadding' in current ? current.withPadding : true,
|
withPadding: current && typeof current === 'object' && 'withPadding' in current ? current.withPadding : true,
|
||||||
fullWidth: current && typeof current === 'object' && 'fullWidth' in current ? current.fullWidth : false,
|
fullWidth: current && typeof current === 'object' && 'fullWidth' in current ? current.fullWidth : false,
|
||||||
};
|
};
|
||||||
|
}, [matches]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useRouterConfig;
|
export default useRouterConfig;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
const eventListerOptions = {
|
const eventListerOptions = {
|
||||||
passive: true,
|
passive: true,
|
||||||
@@ -11,25 +11,49 @@ const useVisualViewportSize = () => {
|
|||||||
height: windowExists ? window.visualViewport?.height || 0 : 0,
|
height: windowExists ? window.visualViewport?.height || 0 : 0,
|
||||||
top: windowExists ? window.visualViewport?.offsetTop || 0 : 0,
|
top: windowExists ? window.visualViewport?.offsetTop || 0 : 0,
|
||||||
});
|
});
|
||||||
|
const rafRef = useRef<number | null>(null);
|
||||||
const setSize = useCallback(() => {
|
|
||||||
if (!windowExists) return;
|
|
||||||
setWindowSize({ width: window.visualViewport?.width || 0, height: window.visualViewport?.height || 0, top: window.visualViewport?.offsetTop || 0 });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!windowExists) return;
|
if (typeof window === 'undefined') return;
|
||||||
|
|
||||||
|
const setSize = () => {
|
||||||
|
setWindowSize((prev) => {
|
||||||
|
const next = {
|
||||||
|
width: window.visualViewport?.width || 0,
|
||||||
|
height: window.visualViewport?.height || 0,
|
||||||
|
top: window.visualViewport?.offsetTop || 0,
|
||||||
|
};
|
||||||
|
if (
|
||||||
|
prev.width === next.width &&
|
||||||
|
prev.height === next.height &&
|
||||||
|
prev.top === next.top
|
||||||
|
) {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const scheduleSetSize = () => {
|
||||||
|
if (rafRef.current !== null) return;
|
||||||
|
rafRef.current = window.requestAnimationFrame(() => {
|
||||||
|
rafRef.current = null;
|
||||||
|
setSize();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
setSize();
|
setSize();
|
||||||
|
|
||||||
window.visualViewport?.addEventListener('resize', setSize, eventListerOptions);
|
window.visualViewport?.addEventListener('resize', scheduleSetSize, eventListerOptions);
|
||||||
window.visualViewport?.addEventListener('scroll', setSize, eventListerOptions);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.visualViewport?.removeEventListener('resize', setSize);
|
window.visualViewport?.removeEventListener('resize', scheduleSetSize);
|
||||||
window.visualViewport?.removeEventListener('scroll', setSize);
|
if (rafRef.current !== null) {
|
||||||
}
|
window.cancelAnimationFrame(rafRef.current);
|
||||||
}, [setSize]);
|
rafRef.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return windowSize;
|
return windowSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import GlitchAvatar from '@/components/glitch-avatar';
|
import GlitchAvatar from '@/components/glitch-avatar';
|
||||||
import useVisualViewportSize from '@/features/core/hooks/use-visual-viewport-size';
|
import useVisualViewportSize from '@/features/core/hooks/use-visual-viewport-size';
|
||||||
import { useCurrentTournament } from '@/features/tournaments/queries';
|
import { useCurrentTournament } from '@/features/tournaments/queries';
|
||||||
import { AppShell, Flex, Paper, em, Title, Stack } from '@mantine/core';
|
import { AppShell, Flex, Paper, em, Title, Text, Stack } from '@mantine/core';
|
||||||
import { useMediaQuery, useViewportSize } from '@mantine/hooks';
|
import { useMediaQuery, useViewportSize } from '@mantine/hooks';
|
||||||
import { TrophyIcon } from '@phosphor-icons/react';
|
import { TrophyIcon } from '@phosphor-icons/react';
|
||||||
import { PropsWithChildren } from 'react';
|
import { PropsWithChildren } from 'react';
|
||||||
@@ -27,7 +27,8 @@ const Layout: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
style={{ transition: 'padding-top 0.1s ease' }}
|
style={{ transition: 'padding-top 0.1s ease' }}
|
||||||
>
|
>
|
||||||
<Paper
|
<Paper
|
||||||
shadow='none'
|
shadow='md'
|
||||||
|
withBorder
|
||||||
p='md'
|
p='md'
|
||||||
w='100%'
|
w='100%'
|
||||||
maw='375px'
|
maw='375px'
|
||||||
@@ -37,6 +38,7 @@ const Layout: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
<GlitchAvatar
|
<GlitchAvatar
|
||||||
name={tournament.name}
|
name={tournament.name}
|
||||||
contain
|
contain
|
||||||
|
frame
|
||||||
src={
|
src={
|
||||||
tournament.logo
|
tournament.logo
|
||||||
? `/api/files/tournaments/${tournament.id}/${tournament.logo}`
|
? `/api/files/tournaments/${tournament.id}/${tournament.logo}`
|
||||||
@@ -54,7 +56,12 @@ const Layout: React.FC<PropsWithChildren> = ({ children }) => {
|
|||||||
>
|
>
|
||||||
<TrophyIcon size={32} />
|
<TrophyIcon size={32} />
|
||||||
</GlitchAvatar>
|
</GlitchAvatar>
|
||||||
<Title order={1} ta='center'>Welcome to FLXN</Title>
|
<Stack align='center' gap={2}>
|
||||||
|
<Title order={1} ta='center'>Welcome to FLXN</Title>
|
||||||
|
<Text size='sm' c='dimmed' fs='italic' ta='center'>
|
||||||
|
Amicus meus madidus
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
{children}
|
{children}
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const LoginFlow = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return <Center>
|
return <Center>
|
||||||
<Loader color="blue" size="xl" type="dots" />
|
<Loader size="xl" type="dots" />
|
||||||
</Center>;
|
</Center>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ const PlayerPrompt = () => {
|
|||||||
|
|
||||||
return <>
|
return <>
|
||||||
<UnstyledButton
|
<UnstyledButton
|
||||||
|
aria-label="Go back"
|
||||||
onClick={() => setStage(undefined)}
|
onClick={() => setStage(undefined)}
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
.value {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pulse {
|
||||||
|
animation: score-pulse 250ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes score-pulse {
|
||||||
|
from {
|
||||||
|
transform: scale(1.3);
|
||||||
|
color: var(--mantine-color-red-filled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.pulse {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Text, TextProps } from "@mantine/core";
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import classes from "./animated-score.module.css";
|
||||||
|
|
||||||
|
interface AnimatedScoreProps extends TextProps {
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AnimatedScore = ({ value, ...textProps }: AnimatedScoreProps) => {
|
||||||
|
const previousValueRef = useRef<number>(value);
|
||||||
|
const [pulseKey, setPulseKey] = useState(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (previousValueRef.current !== value) {
|
||||||
|
previousValueRef.current = value;
|
||||||
|
setPulseKey((key) => key + 1);
|
||||||
|
}
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Text {...textProps}>
|
||||||
|
<span
|
||||||
|
key={pulseKey}
|
||||||
|
className={
|
||||||
|
pulseKey > 0 ? `${classes.value} ${classes.pulse}` : classes.value
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{value}
|
||||||
|
</span>
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AnimatedScore;
|
||||||