5180 fichiers 38.5 Mo 0 téléchargements 294 vues mis à jour il y a 6 heures ui
nitro-v36-with-renderer-v36 / src / components / avatar-editor / figure-set / AvatarEditorFigureSetView.tsx
AvatarEditorFigureSetView.tsx 2 Ko Télécharger le fichier
import { FC } from 'react';
import { IAvatarEditorCategory, IAvatarEditorCategoryPartItem } from '../../../api';
import { NativeTextTree } from '../../../common/native-text/NativeTextTree';
import { useAvatarEditor } from '../../../hooks';
import { InfiniteGrid } from '../../../layout';
import { AvatarEditorFigureSetItemView } from './AvatarEditorFigureSetItemView';

export const AvatarEditorFigureSetView: FC<{
    category: IAvatarEditorCategory;
    columnCount: number;
    estimateSize?: number;
}> = (props) => {
    const { category = null, columnCount = 3, estimateSize = 50 } = props;
    const { selectedParts = null, selectEditorPart } = useAvatarEditor();

    const isPartItemSelected = (partItem: IAvatarEditorCategoryPartItem) => {
        if (!category || !category.setType || !selectedParts) return false;

        if (!selectedParts[category.setType]) {
            if (partItem.isClear) return true;

            return false;
        }

        const partId = selectedParts[category.setType];

        return partId === partItem.id;
    };

    return (
        <NativeTextTree>
            <InfiniteGrid<IAvatarEditorCategoryPartItem>
                classicScrollbar
                columnCount={columnCount}
                columnGap={0}
                rowGap={0}
                estimateSize={estimateSize}
                itemRender={(item: IAvatarEditorCategoryPartItem) => {
                    if (!item) return null;

                    return (
                        <AvatarEditorFigureSetItemView
                            isSelected={isPartItemSelected(item)}
                            partItem={item}
                            setType={category.setType}
                            onClick={(event) => selectEditorPart(category.setType, item.partSet?.id ?? -1)}
                        />
                    );
                }}
                items={category.partItems}
                overscan={columnCount}
            />
        </NativeTextTree>
    );
};
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser