Projekt

Obecné

Profil

Stáhnout (2.01 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { SubTagInfo, TagInfo } from '../../api';
2
import { Container, Row } from 'react-bootstrap';
3
import { Button, Tooltip } from 'antd';
4
import React, { useContext } from 'react';
5
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
6
import { AnnotationContext } from '../../contexts/AnnotationContext';
7

    
8
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
import { faCircleQuestion } from '@fortawesome/free-regular-svg-icons';
10
import styles from '/styles/Icon.module.scss';
11
/**
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
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
17
    /**
18
     * Tag context.
19
     */
20
    const { selectTag } = useContext(TagCategoryContext);
21

    
22
    /**
23
     * Annotation context
24
     */
25
    const { submitting } = useContext(AnnotationContext);
26

    
27
    /**
28
     * Selects the sub tag.
29
     */
30
    const onSelectSubTag = () => {
31
        selectTag(props.tag, props.subTag);
32
    };
33

    
34
    return (
35
        <Container>
36
            <Row>
37
                <Button
38
                    onClick={onSelectSubTag}
39
                    className="w-100 text-start rounded"
40
                    disabled={submitting}
41
                >
42
                    <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
                </Button>
57
            </Row>
58
        </Container>
59
    );
60
}
(6-6/8)