Projekt

Obecné

Profil

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

    
7
/**
8
 * Creates a single tag item in a tag panel.
9
 * @param props Properties should contain the tag.
10
 * @returns The item that represents the tag.
11
 */
12
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
13
    const { selectTag } = useContext(TagCategoryContext);
14

    
15
    /**
16
     * Selects the sub tag.
17
     */
18
    const onSelectSubTag = () => {
19
        selectTag(props.tag, props.subTag);
20
    };
21

    
22
    return (
23
        <Container>
24
            <Row>
25
                <Button type="text" onClick={onSelectSubTag} className="w-100 text-start">
26
                    {props.subTag.name}
27
                </Button>
28
            </Row>
29
        </Container>
30
    );
31
}
(5-5/7)