Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2c9bdf18

Přidáno uživatelem Dominik Poch před asi 2 roky(ů)

Upgraded visual of the tag tree

Zobrazit rozdíly:

webapp/components/annotation/CategoryItem.tsx
1 1
import { Col, Container, Row, Stack } from 'react-bootstrap';
2 2
import { Button } from 'antd';
3
import { DownOutlined, TagOutlined } from '@ant-design/icons';
3
import { DownOutlined, TagOutlined, UpOutlined } from '@ant-design/icons';
4 4
import { TagCategoryInfo } from '../../api';
5
import { useState } from 'react';
5
import React, { useState } from 'react';
6 6
import { TagItem } from './TagItem';
7 7

  
8 8
/**
......
16 16
     */
17 17
    const [visibleTags, setVisibleTags] = useState(false);
18 18

  
19
    /**
20
     * Button icon.
21
     */
22
    const [buttonIcon, setButtonIcon] = useState<React.ReactNode>(<DownOutlined />);
23

  
19 24
    /**
20 25
     * Changes visibility of tags.
21 26
     */
22 27
    const changeTagsVisibility = () => {
28
        setButtonIcon(visibleTags ? <DownOutlined /> : <UpOutlined />);
23 29
        setVisibleTags(!visibleTags);
24 30
    };
25 31

  
26 32
    return (
27
        <Container>
33
        <Container className="shadow-sm rounded">
28 34
            <Row>
29
                <Col>
30
                    <Button
31
                        type="text"
32
                        icon={<DownOutlined />}
33
                        onClick={changeTagsVisibility}
34
                        className="w-100 text-start"
35
                    >
36
                        {props.category.name}
37
                    </Button>
38
                </Col>
39
                <Col md="auto">
40
                    <TagOutlined style={{ color: props.category.color ?? 'black' }} />
41
                </Col>
35
                <Button
36
                    type="text"
37
                    icon={buttonIcon}
38
                    onClick={changeTagsVisibility}
39
                    className="w-100 text-start rounded"
40
                >
41
                    {props.category.name}
42
                </Button>
42 43
            </Row>
43 44
            {visibleTags && (
44
                <Stack>
45
                <Stack gap={2} className="mt-1 mb-2">
45 46
                    {props.category.tags?.map((tag, index) => (
46 47
                        <TagItem tag={tag} key={index} />
47 48
                    ))}

Také k dispozici: Unified diff