Projekt

Obecné

Profil

Stáhnout (1.18 KB) Statistiky
| Větev: | Tag: | Revize:
1 5593c10b Dominik Poch
import { SubTagInfo, TagInfo } from '../../api';
2 ed01528f Dominik Poch
import { Container, Row } from 'react-bootstrap';
3
import { Button } from 'antd';
4 5593c10b Dominik Poch
import { useContext } from 'react';
5
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
6 dee53692 Jaroslav Hrubý
import { AnnotationContext } from '../../contexts/AnnotationContext';
7 ed01528f Dominik Poch
8
/**
9
 * Creates a single tag item in a tag panel.
10
 * @param props Properties should contain the tag.
11
 * @returns The item that represents the tag.
12
 */
13 5593c10b Dominik Poch
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
14 0441c314 Dominik Poch
    /**
15
     * Tag context.
16
     */
17 5593c10b Dominik Poch
    const { selectTag } = useContext(TagCategoryContext);
18
19 dee53692 Jaroslav Hrubý
    /**
20
     * Annotation context
21
     */
22
    const { submitting } = useContext(AnnotationContext);
23
24 ed01528f Dominik Poch
    /**
25
     * Selects the sub tag.
26
     */
27 5593c10b Dominik Poch
    const onSelectSubTag = () => {
28
        selectTag(props.tag, props.subTag);
29
    };
30 ed01528f Dominik Poch
31
    return (
32
        <Container>
33
            <Row>
34 dee53692 Jaroslav Hrubý
                <Button
35
                    onClick={onSelectSubTag}
36
                    className="w-100 text-start rounded"
37
                    disabled={submitting}
38
                >
39 ed01528f Dominik Poch
                    {props.subTag.name}
40
                </Button>
41
            </Row>
42
        </Container>
43
    );
44
}