Fixed invisible label view in label constructor (#5041)

* Fixed invisible label view in label constructor

* Updated changelog
main
Boris Sekachev 3 years ago committed by GitHub
parent 7850f1e9b1
commit e7c16064c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -31,6 +31,8 @@ non-ascii paths while adding files from "Connected file share" (issue #4428)
- Shape color is not changed on canvas after changing a label (<https://github.com/opencv/cvat/pull/5045>) - Shape color is not changed on canvas after changing a label (<https://github.com/opencv/cvat/pull/5045>)
- Unstable e2e restore tests (<https://github.com/opencv/cvat/pull/5010>) - Unstable e2e restore tests (<https://github.com/opencv/cvat/pull/5010>)
- IOG and f-BRS serverless function (<https://github.com/opencv/cvat/pulls>) - IOG and f-BRS serverless function (<https://github.com/opencv/cvat/pulls>)
- Invisible label item in label constructor when label color background is white,
or close to it (<https://github.com/opencv/cvat/pull/5041>)
### Security ### Security
- TDB - TDB

@ -1,6 +1,6 @@
{ {
"name": "cvat-ui", "name": "cvat-ui",
"version": "1.42.0", "version": "1.42.1",
"description": "CVAT single-page application", "description": "CVAT single-page application",
"main": "src/index.tsx", "main": "src/index.tsx",
"scripts": { "scripts": {

@ -22,11 +22,26 @@ export default function ConstructorViewerItem(props: ConstructorViewerItemProps)
color, label, onUpdate, onDelete, color, label, onUpdate, onDelete,
} = props; } = props;
const backgroundColor = color || consts.NEW_LABEL_COLOR;
let textColor = '#ffffff';
try {
// convert color to grayscale and from the result get better text color
// (for darken background -> lighter text, etc.)
const [r, g, b] = [backgroundColor.slice(1, 3), backgroundColor.slice(3, 5), backgroundColor.slice(5, 7)];
const grayscale = (parseInt(r, 16) + parseInt(g, 16) + parseInt(b, 16)) / 3;
if (grayscale - 128 >= 0) {
textColor = '#000000';
}
} catch (_: any) {
// nothing to do
}
return ( return (
<div style={{ background: color || consts.NEW_LABEL_COLOR }} className='cvat-constructor-viewer-item'> <div style={{ background: backgroundColor }} className='cvat-constructor-viewer-item'>
<Text>{label.name}</Text> <Text style={{ color: textColor }}>{label.name}</Text>
<CVATTooltip title='Update attributes'> <CVATTooltip title='Update attributes'>
<span <span
style={{ color: textColor }}
role='button' role='button'
tabIndex={0} tabIndex={0}
onClick={(): void => onUpdate(label)} onClick={(): void => onUpdate(label)}
@ -37,6 +52,7 @@ export default function ConstructorViewerItem(props: ConstructorViewerItemProps)
</CVATTooltip> </CVATTooltip>
<CVATTooltip title='Delete label'> <CVATTooltip title='Delete label'>
<span <span
style={{ color: textColor }}
role='button' role='button'
tabIndex={0} tabIndex={0}
onClick={(): void => onDelete(label)} onClick={(): void => onDelete(label)}

@ -45,15 +45,14 @@ textarea.ant-input.cvat-raw-labels-viewer {
margin: 2px; margin: 2px;
margin-left: $grid-unit-size * 2; margin-left: $grid-unit-size * 2;
user-select: none; user-select: none;
border: 1px solid $transparent-color; border: 1px solid $border-color-2;
opacity: 0.6; opacity: 0.6;
> span { > span {
margin-left: 5px; margin-left: 5px;
color: white;
> span[role='img']:hover { > span[role='img']:hover {
filter: invert(1); filter: invert(0.2);
} }
} }

Loading…
Cancel
Save