Revize 967f45fc
Přidáno uživatelem Dominik Poch před asi 3 roky(ů)
webapp/components/annotation/annotationItem.tsx | ||
---|---|---|
1 |
import { Row } from 'react-bootstrap'; |
|
2 |
import { Occurrence, Tag } from '../models/tag'; |
|
3 |
import { useState } from 'react'; |
|
4 | ||
5 |
import 'antd/dist/antd.css'; |
|
6 |
import { Button } from 'antd'; |
|
7 |
import { |
|
8 |
PlusOutlined, |
|
9 |
EyeOutlined, |
|
10 |
DownOutlined, |
|
11 |
DeleteOutlined, |
|
12 |
} from '@ant-design/icons'; |
|
13 | ||
14 |
function AnnotationItem(tag: Tag) { |
|
15 |
const [visibleProperties, setVisibleProperties] = useState(false); |
|
16 |
const [visible, setVisible] = useState(true); |
|
17 | ||
18 |
const addOccurrence = () => {}; |
|
19 | ||
20 |
const deleteOccurrence = (occurrence: Occurrence) => (e: any) => {}; |
|
21 | ||
22 |
const changeVisibility = () => {}; |
|
23 | ||
24 |
const changePropertiesVisiblity = () => { |
|
25 |
setVisibleProperties(!visibleProperties); |
|
26 |
}; |
|
27 | ||
28 |
return ( |
|
29 |
<div> |
|
30 |
<Row> |
|
31 |
{tag.name} |
|
32 |
<Button |
|
33 |
type="text" |
|
34 |
shape="circle" |
|
35 |
icon={<PlusOutlined />} |
|
36 |
onClick={addOccurrence} |
|
37 |
/> |
|
38 |
<Button |
|
39 |
type="text" |
|
40 |
shape="circle" |
|
41 |
icon={<EyeOutlined />} |
|
42 |
onClick={changeVisibility} |
|
43 |
/> |
|
44 |
<Button |
|
45 |
type="text" |
|
46 |
shape="circle" |
|
47 |
icon={<DownOutlined />} |
|
48 |
onClick={changePropertiesVisiblity} |
|
49 |
/> |
|
50 |
</Row> |
|
51 |
{visibleProperties && ( |
|
52 |
<Row> |
|
53 |
{tag.category} |
|
54 |
Výskyty |
|
55 |
{tag.occurrences.map((occurrence, index) => { |
|
56 |
return ( |
|
57 |
<div key={index}> |
|
58 |
{occurrence.position} |
|
59 |
{occurrence.length} |
|
60 |
<Button |
|
61 |
icon={<DeleteOutlined />} |
|
62 |
onClick={deleteOccurrence(occurrence)} |
|
63 |
></Button> |
|
64 |
</div> |
|
65 |
); |
|
66 |
})} |
|
67 |
</Row> |
|
68 |
)} |
|
69 |
</div> |
|
70 |
); |
|
71 |
} |
|
72 | ||
73 |
export default AnnotationItem; |
webapp/components/annotation/annotationPanel.tsx | ||
---|---|---|
1 |
import AnnotationItem from './annotationItem'; |
|
2 | ||
1 | 3 |
/** |
2 | 4 |
* Creates a panel in the annotation screen that contains a list of annotations. |
3 | 5 |
* @returns Panel with a list of annotations. |
... | ... | |
6 | 8 |
return ( |
7 | 9 |
<div> |
8 | 10 |
<p>Panel with a list of annotations</p> |
11 |
<AnnotationItem name={'tag a'} category={'kategorie 1'} occurrences={[]} /> |
|
12 |
<AnnotationItem name={'tag b'} category={'kategorie 2'} occurrences={[]} /> |
|
9 | 13 |
</div> |
10 | 14 |
); |
11 | 15 |
} |
webapp/components/models/tag.tsx | ||
---|---|---|
1 |
import internal from 'stream'; |
|
2 | ||
3 |
export type Tag = { |
|
4 |
name: string; |
|
5 |
category: string; |
|
6 |
occurrences: Occurrence[]; |
|
7 |
}; |
|
8 | ||
9 |
export type Occurrence = { |
|
10 |
position: number; |
|
11 |
length: number; |
|
12 |
}; |
Také k dispozici: Unified diff
Basic functionality of an annotation panel
The panel is without css styles. Basic functionality is implemented.