mirror of
https://github.com/duckietm/Nitro-Cool-UI.git
synced 2025-06-21 22:36:58 +00:00
31 lines
907 B
TypeScript
31 lines
907 B
TypeScript
import { FC, useMemo } from 'react';
|
|
import { Base, BaseProps } from '../../../common';
|
|
|
|
type AvatarIconType = 'male' | 'female' | 'clear' | 'sellable' | string;
|
|
|
|
export interface AvatarEditorIconProps extends BaseProps<HTMLDivElement>
|
|
{
|
|
icon: AvatarIconType;
|
|
selected?: boolean;
|
|
}
|
|
|
|
export const AvatarEditorIcon: FC<AvatarEditorIconProps> = props =>
|
|
{
|
|
const { icon = null, selected = false, classNames = [], children = null, ...rest } = props;
|
|
|
|
const getClassNames = useMemo(() =>
|
|
{
|
|
const newClassNames: string[] = [ 'nitro-avatar-editor-spritesheet' ];
|
|
|
|
if(icon && icon.length) newClassNames.push(icon + '-icon');
|
|
|
|
if(selected) newClassNames.push('selected');
|
|
|
|
if(classNames.length) newClassNames.push(...classNames);
|
|
|
|
return newClassNames;
|
|
}, [ icon, selected, classNames ]);
|
|
|
|
return <Base classNames={ getClassNames } { ...rest } />
|
|
}
|