Files
place_maxlan/client/src/lib/config.ts

71 lines
1.7 KiB
TypeScript

// Official r/place 2022 color palette (32 colors)
export const COLORS = [
"#6d001a", // Dark Red
"#be0039", // Red
"#ff4500", // Orange
"#ffa800", // Yellow Orange
"#ffd635", // Yellow
"#fff8b8", // Pale Yellow
"#00a368", // Dark Green
"#00cc78", // Green
"#7eed56", // Light Green
"#00756f", // Dark Teal
"#009eaa", // Teal
"#00ccc0", // Light Teal
"#2450a4", // Dark Blue
"#3690ea", // Blue
"#51e9f4", // Light Blue
"#493ac1", // Indigo
"#6a5cff", // Periwinkle
"#94b3ff", // Lavender
"#811e9f", // Dark Purple
"#b44ac0", // Purple
"#e4abff", // Pale Purple
"#de107f", // Magenta
"#ff3881", // Pink
"#ff99aa", // Light Pink
"#6d482f", // Dark Brown
"#9c6926", // Brown
"#ffb470", // Beige
"#000000", // Black
"#515252", // Dark Gray
"#898989", // Gray
"#d4d7d9", // Light Gray
"#ffffff", // White
] as const;
export const DEFAULT_SELECTED_COLOR = "#be0039"; // Official r/place red
export function generateUserId(): string {
const stored = localStorage.getItem("r-place-user-id");
if (stored) return stored;
const newId = `User#${Math.floor(Math.random() * 10000)}`;
localStorage.setItem("r-place-user-id", newId);
return newId;
}
export function getUsername(): string {
return generateUserId();
}
export const API_BASE = "/api";
export interface AuthStatus {
authenticated: boolean;
keycloakEnabled: boolean;
user?: {
userId: string;
username: string;
};
}
export async function getAuthStatus(): Promise<AuthStatus> {
try {
const response = await fetch(`${API_BASE}/auth/status`);
return await response.json();
} catch (error) {
console.error("Failed to get auth status:", error);
return { authenticated: false, keycloakEnabled: false };
}
}