Add dashboard UI source and track it in the repository.
Expose the Vite/React website source under dashboard/ (with node_modules still ignored) so the full dashboard can be built and maintained from this repo.
This commit is contained in:
1 parent
e97e281bda
commit
b82f69783d
117 files changed
+18615
-3
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { api } from "@/api/client";
|
||||
|
||||
export function useAddonConfigs() {
|
||||
const location = useLocation();
|
||||
const [files, setFiles] = useState<string[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
try {
|
||||
const res = await api.listAddonConfigs();
|
||||
setFiles(res.data ?? []);
|
||||
} catch {
|
||||
setFiles([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
refresh();
|
||||
}, [refresh, location.pathname]);
|
||||
|
||||
return { files, loading, refresh };
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { useEffect, useRef, type ForwardedRef } from "react";
|
||||
|
||||
export function useForwardedRef<T>(forwardedRef: ForwardedRef<T>) {
|
||||
const innerRef = useRef<T>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!forwardedRef) return;
|
||||
if (typeof forwardedRef === "function") {
|
||||
forwardedRef(innerRef.current);
|
||||
} else {
|
||||
forwardedRef.current = innerRef.current;
|
||||
}
|
||||
});
|
||||
|
||||
return innerRef;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as React from "react"
|
||||
|
||||
const MOBILE_BREAKPOINT = 768
|
||||
|
||||
export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
||||
|
||||
React.useEffect(() => {
|
||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
||||
const onChange = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||
}
|
||||
mql.addEventListener("change", onChange)
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||
return () => mql.removeEventListener("change", onChange)
|
||||
}, [])
|
||||
|
||||
return !!isMobile
|
||||
}
|
||||
Reference in new issue
Block a user