Refactor logging components and styles; remove unused CSS; enhance log icon functionality
- Removed the random color generation function from ProductionCapacity component. - Updated ThroughputSummary component to remove unused imports. - Simplified LogList component by removing unnecessary icons and integrating GetLogIcon for log types. - Enhanced LoggerContext to support a new "success" log type and optimized logger methods with useMemo. - Adjusted SimulationPlayer to conditionally render analysis components. - Deleted index.css and removed its import from index.tsx. - Cleaned up builder module by removing unused imports and optimizing state management. - Removed savedTheme from Ground component. - Changed log message from info to warning in Project component. - Updated log color variables in SCSS files for better visibility and consistency. - Added new log icons for success, error, info, and warning in LogIcons component. - Created GetLogIcon utility to streamline log icon rendering based on log type.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { createContext, useContext, useState, useCallback } from "react";
|
||||
import React, { createContext, useContext, useState, useCallback, useMemo } from "react";
|
||||
|
||||
export type LogType = "log" | "info" | "warning" | "error";
|
||||
export type LogType = "log" | "info" | "warning" | "error" | "success";
|
||||
|
||||
export interface LogEntry {
|
||||
id: string;
|
||||
@@ -18,6 +18,7 @@ interface LoggerContextValue {
|
||||
info: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
success: (message: string) => void;
|
||||
clear: () => void;
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ export const LoggerProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||
[generateId]
|
||||
);
|
||||
|
||||
const loggerMethods: LoggerContextValue = {
|
||||
const loggerMethods: LoggerContextValue = useMemo(() => ({
|
||||
logs,
|
||||
setLogs,
|
||||
isLogListVisible,
|
||||
@@ -56,10 +57,9 @@ export const LoggerProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||
info: (message: string) => addLog("info", message),
|
||||
warn: (message: string) => addLog("warning", message),
|
||||
error: (message: string) => addLog("error", message),
|
||||
clear: () => {
|
||||
setLogs([]);
|
||||
},
|
||||
};
|
||||
success: (message: string) => addLog("success", message),
|
||||
clear: () => setLogs([]),
|
||||
}), [logs, setLogs, isLogListVisible, setIsLogListVisible, addLog]);
|
||||
|
||||
return (
|
||||
<LoggerContext.Provider value={loggerMethods}>
|
||||
|
||||
Reference in New Issue
Block a user