diff --git a/frontend/src/Editor/LeftSidebar/SidebarDebugger.jsx b/frontend/src/Editor/LeftSidebar/SidebarDebugger.jsx index 292fc6838c..d380fa0b5c 100644 --- a/frontend/src/Editor/LeftSidebar/SidebarDebugger.jsx +++ b/frontend/src/Editor/LeftSidebar/SidebarDebugger.jsx @@ -10,6 +10,7 @@ export const LeftSidebarDebugger = ({ darkMode, components, errors }) => { const [open, trigger, content] = usePopover(false) const [currrentTab, setCurrentTab] = React.useState(1) const [errorLogs, setErrorLogs] = React.useState([]) + const [unReadErrorCount, setUnReadErrorCount] = React.useState({read: 0, unread: 0}) const switchCurrentTab = (tab) => { setCurrentTab(tab) @@ -56,20 +57,39 @@ export const LeftSidebarDebugger = ({ darkMode, components, errors }) => { }) },[errors]) + React.useEffect(() => { + + if(open === false && errorLogs.length !== unReadErrorCount.read) { + const unReadErrors = errorLogs.length - unReadErrorCount.read + setUnReadErrorCount((prev) => { + let copy = JSON.parse(JSON.stringify(prev)) + copy.unread = unReadErrors + return copy + }) + } else { + setUnReadErrorCount((prev) => { + let copy = JSON.parse(JSON.stringify(prev)) + copy.read = errorLogs.length + copy.unread = 0 + return copy + }) + } + },[errorLogs.length, open]) + return ( <> - +
-
+ +
@@ -147,4 +167,4 @@ function ErrorLogsComponent ({ errorProps, idx, darkMode }) { -LeftSidebarDebugger.ErrorLogs = ErrorLogsComponent; \ No newline at end of file +LeftSidebarDebugger.ErrorLogs = ErrorLogsComponent; \ No newline at end of file diff --git a/frontend/src/Editor/LeftSidebar/sidebar-item.js b/frontend/src/Editor/LeftSidebar/sidebar-item.js index bb170278c1..f1b4772586 100644 --- a/frontend/src/Editor/LeftSidebar/sidebar-item.js +++ b/frontend/src/Editor/LeftSidebar/sidebar-item.js @@ -2,7 +2,7 @@ import React from 'react'; import OverlayTrigger from 'react-bootstrap/OverlayTrigger'; import Tooltip from 'react-bootstrap/Tooltip'; -export const LeftSidebarItem = ({ tip = '', className, icon, text, onClick, ...rest }) => { +export const LeftSidebarItem = ({ tip = '', className, icon, text, onClick, badge=false, count,...rest }) => { return (
{icon && } + {badge && } {text && text} -
+
) } + +function NotificationBadge({count}) { + const fontSize = count > 999 ? '7.5px' : '8.5px' + return ( + <> + {count > 0 && ( + + {count > 999 ? `999+` : count} + + )} + + ) +} + + +LeftSidebarItem.Badge = NotificationBadge \ No newline at end of file diff --git a/frontend/src/_styles/left-sidebar.scss b/frontend/src/_styles/left-sidebar.scss index a2a6554cc9..b808ac2065 100644 --- a/frontend/src/_styles/left-sidebar.scss +++ b/frontend/src/_styles/left-sidebar.scss @@ -14,6 +14,10 @@ &:hover { transform: scale(1.2); + + .debugger-badge { + display: none; + } } } .left-sidebar-stack-bottom { @@ -48,11 +52,18 @@ overflow: hidden; } } - .iopen { transform: rotate(90deg); transition: 0.12s; } + .debugger-badge { + position: fixed; + margin-top: -0.82rem; + margin-left: -0.3rem; + height: 20px; + width: 20px; + font-weight: 400; + } .zoom-popover { top: 500px; }