Skip to content

Commit

Permalink
Merge branch 'main' into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
luckfunc committed Aug 26, 2023
2 parents 2703f02 + 15b2d25 commit de4eac4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "avatar",
"private": true,
"version": "0.0.1",
"version": "0.0.2",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
1 change: 0 additions & 1 deletion src/components/perfect-scrollbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export default function PerfectScrollbar(props: IProps) {
if (!sections) {
return null;
}
// @ts-ignore
return (
<div ref={scrollWrapper} style={{ position: 'relative', overflowY: 'auto', overflowX: 'hidden' }} className='configurator-scroll'>
<div className='configurator'>
Expand Down
23 changes: 12 additions & 11 deletions src/components/react-color-avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CSSProperties, RefObject, useEffect, useState } from 'react';
import { Background } from '@/components/widgets';
import { WidgetType, WrapperShape } from '@/enums';
import { AvatarOption } from '@/types';
import { WidgetShape, WidgetType, WrapperShape } from '@/enums';
import { AvatarOption, Widget } from '@/types';
import { AVATAR_LAYER, NONE } from '@/constants';
import { widgetData } from '@/utils/dynamic-data';
import './style.less';
Expand All @@ -20,24 +20,25 @@ export default function ReactColorAvatar(props: IReactColorAvatarProps) {
(async () => {
const sortedList = Object.entries(avatarOption.widgets).sort(
([prevShape, prev], [nextShape, next]) => {
// @ts-ignore
const ix = prev.zIndex ?? AVATAR_LAYER[prevShape]?.zIndex ?? 0;
// @ts-ignore
const iix = next.zIndex ?? AVATAR_LAYER[nextShape]?.zIndex ?? 0;
return ix - iix;
const prevZIndex = prev.zIndex ?? AVATAR_LAYER[prevShape as WidgetType]?.zIndex ?? 0;
const nextZIndex = next.zIndex ?? AVATAR_LAYER[nextShape as WidgetType]?.zIndex ?? 0;
return prevZIndex - nextZIndex;
}
);

const promises = sortedList.map(async ([widgetType, opt]) => {
// @ts-ignore
const getWidgetSvg = async (widgetType: WidgetType, opt: Widget<WidgetShape>) => {
if (opt.shape !== NONE && widgetData?.[widgetType]?.[opt.shape]) {
// @ts-ignore
return (await widgetData[widgetType][opt.shape]()).default;
}
return '';
};

const promises = sortedList.map(async ([widgetType, opt]) => {
return getWidgetSvg(widgetType as WidgetType, opt);
});

let skinColor: any;

let skinColor: string | undefined;

const svgRawList = await Promise.all(promises).then((raw) =>
raw.map((svgRaw, i) => {
Expand Down
1 change: 0 additions & 1 deletion src/layouts/container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default function Container(props: IProps) {
)
if (avatarEle) {
const html2canvas = (await import('html2canvas')).default
// @ts-ignore
const canvas = await html2canvas(avatarEle, {
backgroundColor: null,
})
Expand Down
4 changes: 2 additions & 2 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import {

export type None = typeof NONE

interface Widget<Shape> {
export interface Widget<Shape> {
shape: Shape | None
zIndex?: number
fillColor?: string
strokeColor?: string
}

type AvatarWidgets = {
export type AvatarWidgets = {
face: Widget<FaceShape>
tops: Widget<TopsShape>
ear: Widget<EarShape>
Expand Down

0 comments on commit de4eac4

Please sign in to comment.