fix: add highlight color for all views (logs context) (#3233)

* fix: add higlight color for all of views

* fix: resolve comments
This commit is contained in:
dnazarenkoo 2023-07-31 10:57:07 +03:00 committed by GitHub
parent 5f89e84eaf
commit fabdf87ed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 41 deletions

View File

@ -13,7 +13,6 @@ import dayjs from 'dayjs';
import dompurify from 'dompurify'; import dompurify from 'dompurify';
import { useActiveLog } from 'hooks/logs/useActiveLog'; import { useActiveLog } from 'hooks/logs/useActiveLog';
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink'; import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { useNotifications } from 'hooks/useNotifications'; import { useNotifications } from 'hooks/useNotifications';
// utils // utils
import { FlatLogData } from 'lib/logs/flatLogData'; import { FlatLogData } from 'lib/logs/flatLogData';
@ -104,7 +103,6 @@ function ListLogView({
}: ListLogViewProps): JSX.Element { }: ListLogViewProps): JSX.Element {
const flattenLogData = useMemo(() => FlatLogData(logData), [logData]); const flattenLogData = useMemo(() => FlatLogData(logData), [logData]);
const isDarkMode = useIsDarkMode();
const [, setCopy] = useCopyToClipboard(); const [, setCopy] = useCopyToClipboard();
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const { isHighlighted, isLogsExplorerPage, onLogCopy } = useCopyLogLink( const { isHighlighted, isLogsExplorerPage, onLogCopy } = useCopyLogLink(
@ -151,7 +149,7 @@ function ListLogView({
); );
return ( return (
<Container $isActiveLog={isHighlighted} $isDarkMode={isDarkMode}> <Container $isActiveLog={isHighlighted}>
<div> <div>
<LogContainer> <LogContainer>
<> <>

View File

@ -1,10 +1,8 @@
import { Card, Typography } from 'antd'; import { Card, Typography } from 'antd';
import { themeColors } from 'constants/theme';
import styled from 'styled-components'; import styled from 'styled-components';
import getAlphaColor from 'utils/getAlphaColor'; import { getActiveLogBackground } from 'utils/logs';
export const Container = styled(Card)<{ export const Container = styled(Card)<{
$isDarkMode: boolean;
$isActiveLog: boolean; $isActiveLog: boolean;
}>` }>`
width: 100% !important; width: 100% !important;
@ -13,14 +11,7 @@ export const Container = styled(Card)<{
padding: 0.3rem 0.6rem; padding: 0.3rem 0.6rem;
} }
${({ $isDarkMode, $isActiveLog }): string => ${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)}
$isActiveLog
? `background-color: ${
$isDarkMode
? getAlphaColor(themeColors.white)[10]
: getAlphaColor(themeColors.black)[10]
};`
: ''}
`; `;
export const Text = styled(Typography.Text)` export const Text = styled(Typography.Text)`

View File

@ -1,8 +1,7 @@
import { blue, orange } from '@ant-design/colors'; import { blue } from '@ant-design/colors';
import { Col, Row, Space } from 'antd'; import { Col, Row, Space } from 'antd';
import { themeColors } from 'constants/theme';
import styled from 'styled-components'; import styled from 'styled-components';
import getAlphaColor from 'utils/getAlphaColor'; import { getActiveLogBackground, getDefaultLogBackground } from 'utils/logs';
export const RawLogViewContainer = styled(Row)<{ export const RawLogViewContainer = styled(Row)<{
$isDarkMode: boolean; $isDarkMode: boolean;
@ -17,19 +16,12 @@ export const RawLogViewContainer = styled(Row)<{
transition: background-color 0.2s ease-in; transition: background-color 0.2s ease-in;
${({ $isActiveLog }): string => ${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)}
$isActiveLog ? `background-color: ${orange[3]};` : ''}
${({ $isReadOnly, $isDarkMode }): string => ${({ $isReadOnly, $isDarkMode, $isActiveLog }): string =>
!$isReadOnly $isActiveLog
? `&:hover { ? getActiveLogBackground()
background-color: ${ : getDefaultLogBackground($isReadOnly, $isDarkMode)}
$isDarkMode
? getAlphaColor(themeColors.white)[10]
: getAlphaColor(themeColors.black)[10]
};
}`
: ''}
`; `;
export const ExpandIconWrapper = styled(Col)` export const ExpandIconWrapper = styled(Col)`

View File

@ -44,6 +44,7 @@ const themeColors = {
lightWhite: '#ffffffd9', lightWhite: '#ffffffd9',
borderLightGrey: '#d9d9d9', borderLightGrey: '#d9d9d9',
borderDarkGrey: '#424242', borderDarkGrey: '#424242',
bckgGrey: '#1d1d1d',
}; };
export { themeColors }; export { themeColors };

View File

@ -5,7 +5,6 @@ import { LOCALSTORAGE } from 'constants/localStorage';
import LogsExplorerContext from 'container/LogsExplorerContext'; import LogsExplorerContext from 'container/LogsExplorerContext';
import { useActiveLog } from 'hooks/logs/useActiveLog'; import { useActiveLog } from 'hooks/logs/useActiveLog';
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink'; import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
import { useIsDarkMode } from 'hooks/useDarkMode';
import useDragColumns from 'hooks/useDragColumns'; import useDragColumns from 'hooks/useDragColumns';
import { getDraggedColumns } from 'hooks/useDragColumns/utils'; import { getDraggedColumns } from 'hooks/useDragColumns/utils';
import { import {
@ -38,12 +37,10 @@ const CustomTableRow: TableComponents<ILog>['TableRow'] = ({
context, context,
...props ...props
}) => { }) => {
const isDarkMode = useIsDarkMode();
const { isHighlighted } = useCopyLogLink(props.item.id); const { isHighlighted } = useCopyLogLink(props.item.id);
return ( return (
<TableRowStyled <TableRowStyled
$isDarkMode={isDarkMode}
$isActiveLog={isHighlighted} $isActiveLog={isHighlighted}
// eslint-disable-next-line react/jsx-props-no-spreading // eslint-disable-next-line react/jsx-props-no-spreading
{...props} {...props}

View File

@ -1,5 +1,6 @@
import { themeColors } from 'constants/theme'; import { themeColors } from 'constants/theme';
import styled from 'styled-components'; import styled from 'styled-components';
import { getActiveLogBackground } from 'utils/logs';
interface TableHeaderCellStyledProps { interface TableHeaderCellStyledProps {
isDragColumn: boolean; isDragColumn: boolean;
@ -23,21 +24,18 @@ export const TableCellStyled = styled.td`
`; `;
export const TableRowStyled = styled.tr<{ export const TableRowStyled = styled.tr<{
$isDarkMode: boolean;
$isActiveLog: boolean; $isActiveLog: boolean;
}>` }>`
td { td {
${({ $isDarkMode, $isActiveLog }): string => ${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)}
$isActiveLog
? `background-color: ${
$isDarkMode ? 'rgba(255,255,255,0.1)' : 'rgba(0, 0, 0, 0.1)'
};`
: ''}
} }
&:hover { &:hover {
${TableCellStyled} { ${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<TableHeaderCellStyledProps>` export const TableHeaderCellStyled = styled.th<TableHeaderCellStyledProps>`
padding: 0.5rem; padding: 0.5rem;
border-inline-end: 1px solid rgba(253, 253, 253, 0.12); border-inline-end: 1px solid rgba(253, 253, 253, 0.12);
background-color: #1d1d1d; background-color: ${themeColors.bckgGrey};
${({ isDragColumn }): string => (isDragColumn ? 'cursor: col-resize;' : '')} ${({ isDragColumn }): string => (isDragColumn ? 'cursor: col-resize;' : '')}
&:first-child { &:first-child {

View File

@ -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]};`;
};