diff --git a/frontend/src/components/Logs/ListLogView/index.tsx b/frontend/src/components/Logs/ListLogView/index.tsx index b56614edcf..c5aa7a184d 100644 --- a/frontend/src/components/Logs/ListLogView/index.tsx +++ b/frontend/src/components/Logs/ListLogView/index.tsx @@ -13,7 +13,6 @@ import dayjs from 'dayjs'; import dompurify from 'dompurify'; import { useActiveLog } from 'hooks/logs/useActiveLog'; import { useCopyLogLink } from 'hooks/logs/useCopyLogLink'; -import { useIsDarkMode } from 'hooks/useDarkMode'; import { useNotifications } from 'hooks/useNotifications'; // utils import { FlatLogData } from 'lib/logs/flatLogData'; @@ -104,7 +103,6 @@ function ListLogView({ }: ListLogViewProps): JSX.Element { const flattenLogData = useMemo(() => FlatLogData(logData), [logData]); - const isDarkMode = useIsDarkMode(); const [, setCopy] = useCopyToClipboard(); const { notifications } = useNotifications(); const { isHighlighted, isLogsExplorerPage, onLogCopy } = useCopyLogLink( @@ -151,7 +149,7 @@ function ListLogView({ ); return ( - +
<> diff --git a/frontend/src/components/Logs/ListLogView/styles.ts b/frontend/src/components/Logs/ListLogView/styles.ts index 452bb653fa..0db1baafe5 100644 --- a/frontend/src/components/Logs/ListLogView/styles.ts +++ b/frontend/src/components/Logs/ListLogView/styles.ts @@ -1,10 +1,8 @@ import { Card, Typography } from 'antd'; -import { themeColors } from 'constants/theme'; import styled from 'styled-components'; -import getAlphaColor from 'utils/getAlphaColor'; +import { getActiveLogBackground } from 'utils/logs'; export const Container = styled(Card)<{ - $isDarkMode: boolean; $isActiveLog: boolean; }>` width: 100% !important; @@ -13,14 +11,7 @@ export const Container = styled(Card)<{ padding: 0.3rem 0.6rem; } - ${({ $isDarkMode, $isActiveLog }): string => - $isActiveLog - ? `background-color: ${ - $isDarkMode - ? getAlphaColor(themeColors.white)[10] - : getAlphaColor(themeColors.black)[10] - };` - : ''} + ${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)} `; export const Text = styled(Typography.Text)` diff --git a/frontend/src/components/Logs/RawLogView/styles.ts b/frontend/src/components/Logs/RawLogView/styles.ts index 162ee211a4..b4be783a2a 100644 --- a/frontend/src/components/Logs/RawLogView/styles.ts +++ b/frontend/src/components/Logs/RawLogView/styles.ts @@ -1,8 +1,7 @@ -import { blue, orange } from '@ant-design/colors'; +import { blue } from '@ant-design/colors'; import { Col, Row, Space } from 'antd'; -import { themeColors } from 'constants/theme'; import styled from 'styled-components'; -import getAlphaColor from 'utils/getAlphaColor'; +import { getActiveLogBackground, getDefaultLogBackground } from 'utils/logs'; export const RawLogViewContainer = styled(Row)<{ $isDarkMode: boolean; @@ -17,19 +16,12 @@ export const RawLogViewContainer = styled(Row)<{ transition: background-color 0.2s ease-in; - ${({ $isActiveLog }): string => - $isActiveLog ? `background-color: ${orange[3]};` : ''} + ${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)} - ${({ $isReadOnly, $isDarkMode }): string => - !$isReadOnly - ? `&:hover { - background-color: ${ - $isDarkMode - ? getAlphaColor(themeColors.white)[10] - : getAlphaColor(themeColors.black)[10] - }; - }` - : ''} + ${({ $isReadOnly, $isDarkMode, $isActiveLog }): string => + $isActiveLog + ? getActiveLogBackground() + : getDefaultLogBackground($isReadOnly, $isDarkMode)} `; export const ExpandIconWrapper = styled(Col)` diff --git a/frontend/src/constants/theme.ts b/frontend/src/constants/theme.ts index 33e4881409..354ea190a7 100644 --- a/frontend/src/constants/theme.ts +++ b/frontend/src/constants/theme.ts @@ -44,6 +44,7 @@ const themeColors = { lightWhite: '#ffffffd9', borderLightGrey: '#d9d9d9', borderDarkGrey: '#424242', + bckgGrey: '#1d1d1d', }; export { themeColors }; diff --git a/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx b/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx index 13101f38d0..b5a30e1568 100644 --- a/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx +++ b/frontend/src/container/LogsExplorerList/InfinityTableView/index.tsx @@ -5,7 +5,6 @@ import { LOCALSTORAGE } from 'constants/localStorage'; import LogsExplorerContext from 'container/LogsExplorerContext'; import { useActiveLog } from 'hooks/logs/useActiveLog'; import { useCopyLogLink } from 'hooks/logs/useCopyLogLink'; -import { useIsDarkMode } from 'hooks/useDarkMode'; import useDragColumns from 'hooks/useDragColumns'; import { getDraggedColumns } from 'hooks/useDragColumns/utils'; import { @@ -38,12 +37,10 @@ const CustomTableRow: TableComponents['TableRow'] = ({ context, ...props }) => { - const isDarkMode = useIsDarkMode(); const { isHighlighted } = useCopyLogLink(props.item.id); return ( ` td { - ${({ $isDarkMode, $isActiveLog }): string => - $isActiveLog - ? `background-color: ${ - $isDarkMode ? 'rgba(255,255,255,0.1)' : 'rgba(0, 0, 0, 0.1)' - };` - : ''} + ${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)} } &:hover { ${TableCellStyled} { - background-color: #1d1d1d; + ${({ $isActiveLog }): string => + $isActiveLog + ? getActiveLogBackground() + : `background-color: ${themeColors.bckgGrey};`} } } `; @@ -45,7 +43,7 @@ export const TableRowStyled = styled.tr<{ export const TableHeaderCellStyled = styled.th` padding: 0.5rem; border-inline-end: 1px solid rgba(253, 253, 253, 0.12); - background-color: #1d1d1d; + background-color: ${themeColors.bckgGrey}; ${({ isDragColumn }): string => (isDragColumn ? 'cursor: col-resize;' : '')} &:first-child { diff --git a/frontend/src/utils/logs.ts b/frontend/src/utils/logs.ts new file mode 100644 index 0000000000..66a6ba28a6 --- /dev/null +++ b/frontend/src/utils/logs.ts @@ -0,0 +1,22 @@ +import { orange } from '@ant-design/colors'; +import { themeColors } from 'constants/theme'; +import getAlphaColor from 'utils/getAlphaColor'; + +export const getDefaultLogBackground = ( + isReadOnly: boolean, + isDarkMode: boolean, +): string => { + if (isReadOnly) return ''; + return `&:hover { + background-color: ${ + isDarkMode + ? getAlphaColor(themeColors.white)[10] + : getAlphaColor(themeColors.black)[10] + }; + }`; +}; + +export const getActiveLogBackground = (isActiveLog = true): string => { + if (!isActiveLog) return ''; + return `background-color: ${orange[3]};`; +};