mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-14 02:47:00 +00:00
fix: Make trianglify/canvas optional and handle gracefully
Canvas requires Python and native build tools which fail in Docker builds with --ignore-scripts. Since trianglify is only used for cosmetic backgrounds on the login and layout pages, we can make it optional. Changes: - Added try-catch around trianglify usage in Login and Layout - Using --ignore-scripts in frontend Dockerfile to skip canvas native build - Gracefully fail when trianglify is not available (background won't render) This allows the frontend to build and run even without canvas/trianglify.
This commit is contained in:
@@ -245,23 +245,28 @@ const Layout = ({ children }) => {
|
||||
themeConfig?.login &&
|
||||
document.documentElement.classList.contains("dark")
|
||||
) {
|
||||
// Get current date as seed for daily variation
|
||||
const today = new Date();
|
||||
const dateSeed = `${today.getFullYear()}-${today.getMonth()}-${today.getDate()}`;
|
||||
try {
|
||||
// Get current date as seed for daily variation
|
||||
const today = new Date();
|
||||
const dateSeed = `${today.getFullYear()}-${today.getMonth()}-${today.getDate()}`;
|
||||
|
||||
// Generate pattern with selected theme configuration
|
||||
const pattern = trianglify({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
cellSize: themeConfig.login.cellSize,
|
||||
variance: themeConfig.login.variance,
|
||||
seed: dateSeed,
|
||||
xColors: themeConfig.login.xColors,
|
||||
yColors: themeConfig.login.yColors,
|
||||
});
|
||||
// Generate pattern with selected theme configuration
|
||||
const pattern = trianglify({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
cellSize: themeConfig.login.cellSize,
|
||||
variance: themeConfig.login.variance,
|
||||
seed: dateSeed,
|
||||
xColors: themeConfig.login.xColors,
|
||||
yColors: themeConfig.login.yColors,
|
||||
});
|
||||
|
||||
// Render to canvas
|
||||
pattern.toCanvas(bgCanvasRef.current);
|
||||
// Render to canvas
|
||||
pattern.toCanvas(bgCanvasRef.current);
|
||||
} catch (error) {
|
||||
// Silently fail if trianglify/canvas is not available
|
||||
console.debug("Trianglify background not available:", error.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -61,23 +61,28 @@ const Login = () => {
|
||||
useEffect(() => {
|
||||
const generateBackground = () => {
|
||||
if (canvasRef.current && themeConfig?.login) {
|
||||
// Get current date as seed for daily variation
|
||||
const today = new Date();
|
||||
const dateSeed = `${today.getFullYear()}-${today.getMonth()}-${today.getDate()}`;
|
||||
try {
|
||||
// Get current date as seed for daily variation
|
||||
const today = new Date();
|
||||
const dateSeed = `${today.getFullYear()}-${today.getMonth()}-${today.getDate()}`;
|
||||
|
||||
// Generate pattern with selected theme configuration
|
||||
const pattern = trianglify({
|
||||
width: canvasRef.current.offsetWidth,
|
||||
height: canvasRef.current.offsetHeight,
|
||||
cellSize: themeConfig.login.cellSize,
|
||||
variance: themeConfig.login.variance,
|
||||
seed: dateSeed,
|
||||
xColors: themeConfig.login.xColors,
|
||||
yColors: themeConfig.login.yColors,
|
||||
});
|
||||
// Generate pattern with selected theme configuration
|
||||
const pattern = trianglify({
|
||||
width: canvasRef.current.offsetWidth,
|
||||
height: canvasRef.current.offsetHeight,
|
||||
cellSize: themeConfig.login.cellSize,
|
||||
variance: themeConfig.login.variance,
|
||||
seed: dateSeed,
|
||||
xColors: themeConfig.login.xColors,
|
||||
yColors: themeConfig.login.yColors,
|
||||
});
|
||||
|
||||
// Render to canvas
|
||||
pattern.toCanvas(canvasRef.current);
|
||||
// Render to canvas
|
||||
pattern.toCanvas(canvasRef.current);
|
||||
} catch (error) {
|
||||
// Silently fail if trianglify/canvas is not available
|
||||
console.debug("Trianglify background not available:", error.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user