diff --git a/src/views/avatar-editor/AvatarEditorView.tsx b/src/views/avatar-editor/AvatarEditorView.tsx index 1e27a62e..35616c20 100644 --- a/src/views/avatar-editor/AvatarEditorView.tsx +++ b/src/views/avatar-editor/AvatarEditorView.tsx @@ -1,11 +1,12 @@ import { AvatarEditorFigureCategory, FigureSetIdsMessageEvent, GetWardrobeMessageComposer, IAvatarFigureContainer, UserFigureComposer, UserWardrobePageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { GetAvatarRenderManager, GetClubMemberLevel, GetSessionDataManager, LocalizeText } from '../../api'; +import { Column } from '../../common/Column'; +import { Grid } from '../../common/Grid'; import { AvatarEditorEvent } from '../../events/avatar-editor'; import { CreateMessageHook, SendMessageHook } from '../../hooks'; import { useUiEvent } from '../../hooks/events/ui/ui-event'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView, NitroLayoutGrid, NitroLayoutGridColumn } from '../../layout'; -import { AvatarEditorViewProps } from './AvatarEditorView.types'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../layout'; import { AvatarEditorAction } from './common/AvatarEditorAction'; import { AvatarEditorUtilities } from './common/AvatarEditorUtilities'; import { BodyModel } from './common/BodyModel'; @@ -28,7 +29,7 @@ const ACTION_RESET = 'action_reset'; const ACTION_RANDOMIZE = 'action_randomize'; const ACTION_SAVE = 'action_save'; -export const AvatarEditorView: FC = props => +export const AvatarEditorView: FC<{}> = props => { const [ isVisible, setIsVisible ] = useState(false); const [ figures, setFigures ] = useState>(null); @@ -285,18 +286,18 @@ export const AvatarEditorView: FC = props => - - + + { (activeCategory && !isWardrobeVisible) && } { isWardrobeVisible && } - - + + - - + + ); diff --git a/src/views/avatar-editor/AvatarEditorView.types.ts b/src/views/avatar-editor/AvatarEditorView.types.ts deleted file mode 100644 index faab915a..00000000 --- a/src/views/avatar-editor/AvatarEditorView.types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface AvatarEditorViewProps -{ - -} diff --git a/src/views/avatar-editor/views/AvatarEditorIcon.tsx b/src/views/avatar-editor/views/AvatarEditorIcon.tsx new file mode 100644 index 00000000..b74ef3c9 --- /dev/null +++ b/src/views/avatar-editor/views/AvatarEditorIcon.tsx @@ -0,0 +1,30 @@ +import { FC, useMemo } from 'react'; +import { Base, BaseProps } from '../../../common/Base'; + +type AvatarIconType = 'male' | 'female' | 'clear' | 'sellable' | string; + +export interface AvatarEditorIconProps extends BaseProps +{ + icon: AvatarIconType; + selected?: boolean; +} + +export const AvatarEditorIcon: FC = 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 +} diff --git a/src/views/avatar-editor/views/figure-set-item/AvatarEditorFigureSetItemView.types.ts b/src/views/avatar-editor/views/figure-set-item/AvatarEditorFigureSetItemView.types.ts deleted file mode 100644 index 92172e9d..00000000 --- a/src/views/avatar-editor/views/figure-set-item/AvatarEditorFigureSetItemView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { AvatarEditorGridPartItem } from '../../common/AvatarEditorGridPartItem'; - -export interface AvatarEditorFigureSetItemViewProps -{ - partItem: AvatarEditorGridPartItem; - onClick: (item: AvatarEditorGridPartItem) => void; -} diff --git a/src/views/avatar-editor/views/figure-set-item/AvatarEditorFigureSetItemView.tsx b/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetItemView.tsx similarity index 59% rename from src/views/avatar-editor/views/figure-set-item/AvatarEditorFigureSetItemView.tsx rename to src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetItemView.tsx index ca4a85f1..37e06d99 100644 --- a/src/views/avatar-editor/views/figure-set-item/AvatarEditorFigureSetItemView.tsx +++ b/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetItemView.tsx @@ -1,11 +1,18 @@ import { FC, useCallback, useEffect, useState } from 'react'; +import { NitroCardGridItemViewProps } from '../../../../layout'; import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView'; import { CurrencyIcon } from '../../../shared/currency-icon/CurrencyIcon'; -import { AvatarEditorFigureSetItemViewProps } from './AvatarEditorFigureSetItemView.types'; +import { AvatarEditorGridPartItem } from '../../common/AvatarEditorGridPartItem'; +import { AvatarEditorIcon } from '../AvatarEditorIcon'; + +export interface AvatarEditorFigureSetItemViewProps extends NitroCardGridItemViewProps +{ + partItem: AvatarEditorGridPartItem; +} export const AvatarEditorFigureSetItemView: FC = props => { - const { partItem = null, onClick = null } = props; + const { partItem = null, children = null, ...rest } = props; const [ updateId, setUpdateId ] = useState(-1); const rerender = useCallback(() => @@ -24,10 +31,11 @@ export const AvatarEditorFigureSetItemView: FC onClick(partItem) }> + { partItem.isHC && } - { partItem.isClear &&
} - { partItem.isSellable &&
} + { partItem.isClear && } + { partItem.isSellable && } + { children } ); } diff --git a/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetView.tsx b/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetView.tsx index 28562fe8..ecfb7fb3 100644 --- a/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetView.tsx +++ b/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetView.tsx @@ -1,8 +1,16 @@ -import { FC, useCallback } from 'react'; -import { NitroCardGridView } from '../../../../layout/card/grid/NitroCardGridView'; +import { Dispatch, FC, SetStateAction, useCallback } from 'react'; +import { Grid } from '../../../../common/Grid'; import { AvatarEditorGridPartItem } from '../../common/AvatarEditorGridPartItem'; -import { AvatarEditorFigureSetItemView } from '../figure-set-item/AvatarEditorFigureSetItemView'; -import { AvatarEditorFigureSetViewProps } from './AvatarEditorFigureSetView.types'; +import { CategoryData } from '../../common/CategoryData'; +import { IAvatarEditorCategoryModel } from '../../common/IAvatarEditorCategoryModel'; +import { AvatarEditorFigureSetItemView } from './AvatarEditorFigureSetItemView'; + +export interface AvatarEditorFigureSetViewProps +{ + model: IAvatarEditorCategoryModel; + category: CategoryData; + setMaxPaletteCount: Dispatch>; +} export const AvatarEditorFigureSetView: FC = props => { @@ -22,11 +30,9 @@ export const AvatarEditorFigureSetView: FC = pro }, [ model, category, setMaxPaletteCount ]); return ( - + { (category.parts.length > 0) && category.parts.map((item, index) => - { - return ; - }) } - + selectPart(item) } />) } + ); } diff --git a/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetView.types.ts b/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetView.types.ts deleted file mode 100644 index d2e9e5cf..00000000 --- a/src/views/avatar-editor/views/figure-set/AvatarEditorFigureSetView.types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Dispatch, SetStateAction } from 'react'; -import { CategoryData } from '../../common/CategoryData'; -import { IAvatarEditorCategoryModel } from '../../common/IAvatarEditorCategoryModel'; - -export interface AvatarEditorFigureSetViewProps -{ - model: IAvatarEditorCategoryModel; - category: CategoryData; - setMaxPaletteCount: Dispatch>; -} diff --git a/src/views/avatar-editor/views/model/AvatarEditorModelView.tsx b/src/views/avatar-editor/views/model/AvatarEditorModelView.tsx index cb6e3b4d..c1d11164 100644 --- a/src/views/avatar-editor/views/model/AvatarEditorModelView.tsx +++ b/src/views/avatar-editor/views/model/AvatarEditorModelView.tsx @@ -1,10 +1,19 @@ -import { FC, useCallback, useEffect, useState } from 'react'; -import { NitroLayoutFlex, NitroLayoutGrid, NitroLayoutGridColumn } from '../../../../layout'; +import { Dispatch, FC, SetStateAction, useCallback, useEffect, useState } from 'react'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Grid } from '../../../../common/Grid'; import { CategoryData } from '../../common/CategoryData'; import { FigureData } from '../../common/FigureData'; +import { IAvatarEditorCategoryModel } from '../../common/IAvatarEditorCategoryModel'; +import { AvatarEditorIcon } from '../AvatarEditorIcon'; import { AvatarEditorFigureSetView } from '../figure-set/AvatarEditorFigureSetView'; import { AvatarEditorPaletteSetView } from '../palette-set/AvatarEditorPaletteSetView'; -import { AvatarEditorModelViewProps } from './AvatarEditorModelView.types'; +export interface AvatarEditorModelViewProps +{ + model: IAvatarEditorCategoryModel; + gender: string; + setGender: Dispatch>; +} export const AvatarEditorModelView: FC = props => { @@ -47,37 +56,37 @@ export const AvatarEditorModelView: FC = props => if(!model || !activeCategory) return null; return ( - - + + { model.canSetGender && <> - setGender(FigureData.MALE) }> -
- - setGender(FigureData.FEMALE) }> -
- + setGender(FigureData.MALE) }> + + + setGender(FigureData.FEMALE) }> + + } { !model.canSetGender && model.categories && (model.categories.size > 0) && Array.from(model.categories.keys()).map(name => { const category = model.categories.get(name); return ( - selectCategory(name) }> -
- + selectCategory(name) }> + + ); })} - - + + - - + + { (maxPaletteCount >= 1) && } { (maxPaletteCount === 2) && - } - - + } + + ); } diff --git a/src/views/avatar-editor/views/model/AvatarEditorModelView.types.ts b/src/views/avatar-editor/views/model/AvatarEditorModelView.types.ts deleted file mode 100644 index b86b58aa..00000000 --- a/src/views/avatar-editor/views/model/AvatarEditorModelView.types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Dispatch, SetStateAction } from 'react'; -import { IAvatarEditorCategoryModel } from '../../common/IAvatarEditorCategoryModel'; - -export interface AvatarEditorModelViewProps -{ - model: IAvatarEditorCategoryModel; - gender: string; - setGender: Dispatch>; -} diff --git a/src/views/avatar-editor/views/palette-set-item/AvatarEditorPaletteSetItem.types.ts b/src/views/avatar-editor/views/palette-set-item/AvatarEditorPaletteSetItem.types.ts deleted file mode 100644 index a0abc62e..00000000 --- a/src/views/avatar-editor/views/palette-set-item/AvatarEditorPaletteSetItem.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { DetailsHTMLAttributes } from 'react'; -import { AvatarEditorGridColorItem } from '../../common/AvatarEditorGridColorItem'; - -export interface AvatarEditorPaletteSetItemProps extends DetailsHTMLAttributes -{ - colorItem: AvatarEditorGridColorItem; -} diff --git a/src/views/avatar-editor/views/palette-set-item/AvatarEditorPaletteSetItem.tsx b/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetItemView.tsx similarity index 66% rename from src/views/avatar-editor/views/palette-set-item/AvatarEditorPaletteSetItem.tsx rename to src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetItemView.tsx index 4b0bbdc1..3c6d8528 100644 --- a/src/views/avatar-editor/views/palette-set-item/AvatarEditorPaletteSetItem.tsx +++ b/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetItemView.tsx @@ -1,11 +1,17 @@ import { FC, useCallback, useEffect, useState } from 'react'; +import { NitroCardGridItemViewProps } from '../../../../layout'; import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView'; import { CurrencyIcon } from '../../../shared/currency-icon/CurrencyIcon'; -import { AvatarEditorPaletteSetItemProps } from './AvatarEditorPaletteSetItem.types'; +import { AvatarEditorGridColorItem } from '../../common/AvatarEditorGridColorItem'; + +export interface AvatarEditorPaletteSetItemProps extends NitroCardGridItemViewProps +{ + colorItem: AvatarEditorGridColorItem; +} export const AvatarEditorPaletteSetItem: FC = props => { - const { colorItem = null, ...rest } = props; + const { colorItem = null, children = null, ...rest } = props; const [ updateId, setUpdateId ] = useState(-1); const rerender = useCallback(() => @@ -17,15 +23,13 @@ export const AvatarEditorPaletteSetItem: FC = p { colorItem.notify = rerender; - return () => - { - colorItem.notify = null; - } + return () => colorItem.notify = null; }); return ( { colorItem.isHC && } + { children } ); } diff --git a/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetView.tsx b/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetView.tsx index 31a113c0..5ccf1069 100644 --- a/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetView.tsx +++ b/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetView.tsx @@ -1,12 +1,21 @@ import { FC, useCallback } from 'react'; -import { NitroCardGridView } from '../../../../layout/card/grid/NitroCardGridView'; +import { Grid } from '../../../../common/Grid'; import { AvatarEditorGridColorItem } from '../../common/AvatarEditorGridColorItem'; -import { AvatarEditorPaletteSetItem } from '../palette-set-item/AvatarEditorPaletteSetItem'; -import { AvatarEditorPaletteSetViewProps } from './AvatarEditorPaletteSetView.types'; +import { CategoryData } from '../../common/CategoryData'; +import { IAvatarEditorCategoryModel } from '../../common/IAvatarEditorCategoryModel'; +import { AvatarEditorPaletteSetItem } from './AvatarEditorPaletteSetItemView'; + +export interface AvatarEditorPaletteSetViewProps +{ + model: IAvatarEditorCategoryModel; + category: CategoryData; + paletteSet: AvatarEditorGridColorItem[]; + paletteIndex: number; +} export const AvatarEditorPaletteSetView: FC = props => { - const { model = null, category = null, paletteSet = [], paletteIndex = -1, ...rest } = props; + const { model = null, category = null, paletteSet = [], paletteIndex = -1 } = props; const selectColor = useCallback((item: AvatarEditorGridColorItem) => { @@ -18,11 +27,9 @@ export const AvatarEditorPaletteSetView: FC = p }, [ model, category, paletteSet, paletteIndex ]); return ( - + { (paletteSet.length > 0) && paletteSet.map((item, index) => - { - return selectColor(item) } />; - }) } - + selectColor(item) } />) } + ); } diff --git a/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetView.types.ts b/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetView.types.ts deleted file mode 100644 index e7e62483..00000000 --- a/src/views/avatar-editor/views/palette-set/AvatarEditorPaletteSetView.types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { DetailsHTMLAttributes } from 'react'; -import { AvatarEditorGridColorItem } from '../../common/AvatarEditorGridColorItem'; -import { CategoryData } from '../../common/CategoryData'; -import { IAvatarEditorCategoryModel } from '../../common/IAvatarEditorCategoryModel'; - -export interface AvatarEditorPaletteSetViewProps extends DetailsHTMLAttributes -{ - model: IAvatarEditorCategoryModel; - category: CategoryData; - paletteSet: AvatarEditorGridColorItem[]; - paletteIndex: number; -} diff --git a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx index 1071bb2e..972ffdc4 100644 --- a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx +++ b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx @@ -1,13 +1,21 @@ -import { SaveWardrobeOutfitMessageComposer } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useMemo } from 'react'; +import { IAvatarFigureContainer, SaveWardrobeOutfitMessageComposer } from '@nitrots/nitro-renderer'; +import { Dispatch, FC, SetStateAction, useCallback, useMemo } from 'react'; import { Button } from 'react-bootstrap'; import { GetAvatarRenderManager, GetSessionDataManager } from '../../../../api'; +import { Grid } from '../../../../common/Grid'; import { SendMessageHook } from '../../../../hooks'; import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView'; -import { NitroCardGridView } from '../../../../layout/card/grid/NitroCardGridView'; import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; import { CurrencyIcon } from '../../../shared/currency-icon/CurrencyIcon'; -import { AvatarEditorWardrobeViewProps } from './AvatarEditorWardrobeView.types'; +import { FigureData } from '../../common/FigureData'; + +export interface AvatarEditorWardrobeViewProps +{ + figureData: FigureData; + savedFigures: [ IAvatarFigureContainer, string ][]; + setSavedFigures: Dispatch>; + loadAvatarInEditor: (figure: string, gender: string, reset?: boolean) => void; +} export const AvatarEditorWardrobeView: FC = props => { @@ -65,8 +73,8 @@ export const AvatarEditorWardrobeView: FC = props }, [ savedFigures, saveFigureAtWardrobeIndex, wearFigureAtIndex ]); return ( - + { figures } - + ); } diff --git a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts deleted file mode 100644 index 7c71bc5e..00000000 --- a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IAvatarFigureContainer } from '@nitrots/nitro-renderer'; -import { Dispatch, SetStateAction } from 'react'; -import { FigureData } from '../../common/FigureData'; - -export interface AvatarEditorWardrobeViewProps -{ - figureData: FigureData; - savedFigures: [ IAvatarFigureContainer, string ][]; - setSavedFigures: Dispatch>; - loadAvatarInEditor: (figure: string, gender: string, reset?: boolean) => void; -}