Skip to content

Commit fd3e91e

Browse files
committed
Rebase and reorganize files & folders
1 parent e6bfdcb commit fd3e91e

38 files changed

+61
-81
lines changed

ui/src/components/interfaces.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (C) 2025 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export type Label = { id: string; name: string; color: string; isPrediction: boolean; score?: number };

ui/src/features/annotator/annotation-shape.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { describe, expect, it } from 'vitest';
66

77
import { getMockedAnnotation } from '../../../tests/test-utils/mocked-annotation';
88
import { AnnotationShape } from './annotation-shape';
9-
import { Annotation, BoundingBox, Polygon } from './types';
9+
import { Annotation, Polygon, Rect } from './shapes/interfaces';
1010

11-
type AnnotationBoundingBox = Annotation & { shape: BoundingBox };
11+
type AnnotationBoundingBox = Annotation & { shape: Rect };
1212
type AnnotationPolygon = Annotation & { shape: Polygon };
1313

1414
describe('AnnotationShape', () => {
@@ -31,7 +31,7 @@ describe('AnnotationShape', () => {
3131
{ x: 3, y: 4 },
3232
{ x: 5, y: 6 },
3333
];
34-
const annotation = getMockedAnnotation({ shape: { type: 'polygon', points } }) as AnnotationPolygon;
34+
const annotation = getMockedAnnotation({ shape: { shapeType: 'polygon', points } }) as AnnotationPolygon;
3535

3636
render(<AnnotationShape annotation={annotation} />);
3737
const polygon = screen.getByLabelText('annotation polygon');

ui/src/features/annotator/annotation-shape.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright (C) 2025 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { Point } from '../../components/shapes/interfaces';
5-
import { Annotation } from './types';
4+
import { Annotation, Point } from './shapes/interfaces';
65

76
type AnnotationShapeProps = {
87
annotation: Annotation;
@@ -16,7 +15,7 @@ export const AnnotationShape = ({ annotation }: AnnotationShapeProps) => {
1615
const shape = annotation.shape;
1716
const color = annotation.labels[0].color;
1817

19-
if (shape.type === 'bounding-box') {
18+
if (shape.shapeType === 'rect') {
2019
return (
2120
<rect
2221
aria-label='annotation bounding-box'

ui/src/components/annotation/annotation.component.tsx renamed to ui/src/features/annotator/annotation/annotation.component.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ interface AnnotationProps {
1010
}
1111

1212
export const Annotation = ({ maskId, annotation }: AnnotationProps): JSX.Element => {
13-
const { id, color, shape } = annotation;
13+
const { id, labels, shape } = annotation;
1414

1515
return (
1616
<>
1717
<g
1818
mask={maskId}
1919
id={`canvas-annotation-${id}`}
2020
strokeLinecap={'round'}
21-
{...(color !== undefined
21+
{...(labels.length > 0
2222
? {
23-
fill: color,
24-
stroke: color,
23+
// TODO: fix this color behavior
24+
fill: labels[0].color,
25+
stroke: labels[0].color,
2526
strokeOpacity: 'var(--annotation-border-opacity)',
2627
}
2728
: {})}
File renamed without changes.
File renamed without changes.

ui/src/features/annotator/annotations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CSSProperties } from 'react';
55

66
import { AnnotationShape } from './annotation-shape';
77
import { MaskAnnotations } from './mask-annotations';
8-
import { Annotation } from './types';
8+
import { Annotation } from './shapes/interfaces';
99

1010
type AnnotationsProps = {
1111
annotations: Array<Annotation>;

ui/src/features/annotator/mask-annotations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { ReactNode, useId } from 'react';
55

66
import { AnnotationShape } from './annotation-shape';
7-
import { Annotation } from './types';
7+
import { Annotation } from './shapes/interfaces';
88

99
type MaskAnnotationsProps = {
1010
annotations: Array<Annotation>;
File renamed without changes.

ui/src/components/shapes/interfaces.ts renamed to ui/src/features/annotator/shapes/interfaces.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
// Copyright (C) 2025 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33

4-
export interface Annotation {
5-
readonly id: string;
6-
readonly shape: Shape;
7-
color: string;
8-
}
4+
import { Label } from '../../../components/interfaces';
95

106
export interface RegionOfInterest {
117
x: number;
@@ -45,4 +41,17 @@ export interface ClipperPoint {
4541
Y: number;
4642
}
4743

44+
export type Annotation = {
45+
id: string;
46+
shape: Shape;
47+
labels: Array<Label>;
48+
};
49+
50+
export type AnnotationState = {
51+
isHovered: boolean;
52+
isSelected: boolean;
53+
isHidden: boolean;
54+
isLocked: boolean;
55+
};
56+
4857
export type Shape = Rect | Polygon;

0 commit comments

Comments
 (0)