Projekt

Obecné

Profil

Stáhnout (2.01 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 a44aa67e Jaroslav Hrubý
import { Button, Tooltip } from 'antd';
4
import React, { useContext } from 'react';
5 5593c10b Dominik Poch
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
6 dee53692 Jaroslav Hrubý
import { AnnotationContext } from '../../contexts/AnnotationContext';
7 ed01528f Dominik Poch
8 fa93df26 Dominik Poch
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
import { faCircleQuestion } from '@fortawesome/free-regular-svg-icons';
10
import styles from '/styles/Icon.module.scss';
11 ed01528f Dominik Poch
/**
12
 * Creates a single tag item in a tag panel.
13
 * @param props Properties should contain the tag.
14
 * @returns The item that represents the tag.
15
 */
16 5593c10b Dominik Poch
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
17 0441c314 Dominik Poch
    /**
18
     * Tag context.
19
     */
20 5593c10b Dominik Poch
    const { selectTag } = useContext(TagCategoryContext);
21
22 dee53692 Jaroslav Hrubý
    /**
23
     * Annotation context
24
     */
25
    const { submitting } = useContext(AnnotationContext);
26
27 ed01528f Dominik Poch
    /**
28
     * Selects the sub tag.
29
     */
30 5593c10b Dominik Poch
    const onSelectSubTag = () => {
31
        selectTag(props.tag, props.subTag);
32
    };
33 ed01528f Dominik Poch
34
    return (
35
        <Container>
36
            <Row>
37 dee53692 Jaroslav Hrubý
                <Button
38
                    onClick={onSelectSubTag}
39
                    className="w-100 text-start rounded"
40
                    disabled={submitting}
41
                >
42 fa93df26 Dominik Poch
                    <div className=" align-middle">
43
                        {props.subTag.name}
44
                        {props.subTag.description && props.subTag.description !== '' && (
45
                            <Tooltip
46
                                title={props.subTag.description}
47
                                key={props.subTag.description}
48
                            >
49
                                <FontAwesomeIcon
50
                                    icon={faCircleQuestion}
51
                                    className={styles.iconRight}
52
                                />
53
                            </Tooltip>
54
                        )}
55
                    </div>
56 ed01528f Dominik Poch
                </Button>
57
            </Row>
58
        </Container>
59
    );
60
}