Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 38 additions & 19 deletions client/src/components/guidance/assets/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
export const Assets = {
welcome: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*gACYRIZ5m0YAAAAAAAAAAAAADgOBAQ/fmt.webp',
query: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*UhR6QpIWBmIAAAAAAAAAAAAADgOBAQ/fmt.webp',
spread: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*6g-mS7BKH_kAAAAAAAAAAAAADgOBAQ/fmt.webp',
styleBtn: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*Ls3WRaRHU30AAAAAAAAAAAAADgOBAQ/original',
stylePanel: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*4OutRZw69QIAAAAAAAAAAAAADgOBAQ/fmt.webp',
filterBtn: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*CiM9R73L10cAAAAAAAAAAAAADgOBAQ/original',
filterPanel: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QlKsS4gxcT8AAAAAAAAAAAAADgOBAQ/fmt.webp',
download: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QjWNRZ-LQ2kAAAAAAAAAAAAADgOBAQ/original',
welcome:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*gACYRIZ5m0YAAAAAAAAAAAAADgOBAQ/fmt.webp',
query:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*UhR6QpIWBmIAAAAAAAAAAAAADgOBAQ/fmt.webp',
spread:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*jpB0Q7Hbm5sAAAAAAAAAAAAADgOBAQ/original',
styleBtn:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*Ls3WRaRHU30AAAAAAAAAAAAADgOBAQ/original',
stylePanel:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*4OutRZw69QIAAAAAAAAAAAAADgOBAQ/fmt.webp',
filterBtn:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*CiM9R73L10cAAAAAAAAAAAAADgOBAQ/original',
filterPanel:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QlKsS4gxcT8AAAAAAAAAAAAADgOBAQ/fmt.webp',
download:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*QjWNRZ-LQ2kAAAAAAAAAAAAADgOBAQ/original',
end: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*-a6uRYo-9qEAAAAAAAAAAAAADgOBAQ/fmt.webp',
close: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*1qMxQ4fS3e0AAAAAAAAAAAAADgOBAQ/original',
btnWelcome: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*-0IkQ4wm8TEAAAAAAAAAAAAADgOBAQ/original',
btnNext: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*T7bRTrLqVcUAAAAAAAAAAAAADgOBAQ/original',
btnEnd: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*8lvqQr_me34AAAAAAAAAAAAADgOBAQ/original',
afterStyle: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*x3QnTr_EA2oAAAAAAAAAAAAADgOBAQ/original',
afterFilter: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*iWG-S7i0c6EAAAAAAAAAAAAADgOBAQ/original',
afterSpread: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*2XqOQ4y9pjsAAAAAAAAAAAAADgOBAQ/original',
styleGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*v8SsRJ0mkFAAAAAAAAAAAAAADgOBAQ/original',
spreadGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*P2nrTLAjhCkAAAAAAAAAAAAADgOBAQ/original',
queryGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*hsYDRLBPUj8AAAAAAAAAAAAADgOBAQ/original',
filterGif: 'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*p8zcR7cc0tQAAAAAAAAAAAAADgOBAQ/original',
close:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*1qMxQ4fS3e0AAAAAAAAAAAAADgOBAQ/original',
btnWelcome:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*-0IkQ4wm8TEAAAAAAAAAAAAADgOBAQ/original',
btnNext:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*T7bRTrLqVcUAAAAAAAAAAAAADgOBAQ/original',
btnEnd:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*8lvqQr_me34AAAAAAAAAAAAADgOBAQ/original',
afterStyle:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*x3QnTr_EA2oAAAAAAAAAAAAADgOBAQ/original',
afterFilter:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*q5jTQ5vZLAQAAAAAAAAAAAAADgOBAQ/original',
afterSpread:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*k8NSR4y7j40AAAAAAAAAAAAADgOBAQ/original',
styleGif:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*v8SsRJ0mkFAAAAAAAAAAAAAADgOBAQ/original',
spreadGif:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*P2nrTLAjhCkAAAAAAAAAAAAADgOBAQ/original',
queryGif:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*hsYDRLBPUj8AAAAAAAAAAAAADgOBAQ/original',
filterGif:
'https://mdn.alipayobjects.com/huamei_qcdryc/afts/img/A*p8zcR7cc0tQAAAAAAAAAAAAADgOBAQ/original',
};
119 changes: 93 additions & 26 deletions client/src/components/guidance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,50 @@ function getBoundings(selector: string): DOMRect {

function getClipPathByTwoRect(rect: DOMRect, fullscreen: DOMRect) {
const rects = [
[[fullscreen.left, fullscreen.top], [rect.left, fullscreen.bottom]],
[[rect.right, fullscreen.top], [fullscreen.right, fullscreen.bottom]],
[[rect.left, fullscreen.top], [rect.right, rect.top]],
[[rect.left, rect.bottom], [rect.right, fullscreen.bottom]],
[
[fullscreen.left, fullscreen.top],
[rect.left, fullscreen.bottom],
],
[
[rect.right, fullscreen.top],
[fullscreen.right, fullscreen.bottom],
],
[
[rect.left, fullscreen.top],
[rect.right, rect.top],
],
[
[rect.left, rect.bottom],
[rect.right, fullscreen.bottom],
],
];

const points = rects.map(([p1, p2]) => {
return [[p1[0], p1[1]], [p2[0], p1[1]], [p2[0], p2[1]], [p1[0], p2[1]]];
})
return [
[p1[0], p1[1]],
[p2[0], p1[1]],
[p2[0], p2[1]],
[p1[0], p2[1]],
];
});

const path = points.map(point => (
point.map(([x, y], idx) => idx === 0 ? `M${x},${y}` : `L${x},${y}`).join(' ') + 'Z'
));
const path = points.map(
point =>
point
.map(([x, y], idx) => (idx === 0 ? `M${x},${y}` : `L${x},${y}`))
.join(' ') + 'Z',
);
return `path("${path.join(' ')}")`;
}

/**
* 新手引导组件
* @returns
* @returns
*/
export const Guidance: React.FC = () => {
// localStorage 存储
const [isGuidanceFinished, setGuidanceFinished] = useLocalStorageState<string>(LocalStorageKey);
const [isGuidanceFinished, setGuidanceFinished] =
useLocalStorageState<string>(LocalStorageKey);

const [step, setStep] = useState<number>(0);

Expand Down Expand Up @@ -90,47 +111,87 @@ export const Guidance: React.FC = () => {
setStep(-1);
setGuidanceFinished('1');
},
}
};

function getGuidanceUI() {
if (step === 0) return (<Welcome {...props} />);
if (step === 0) return <Welcome {...props} />;
if (step === 1) {
const rect = getBoundings(SelectorSidebar);
return (<Query {...props } x={rect.right - 16} y={rect.top + 100} />);
return <Query {...props} x={rect.right - 16} y={rect.top + 100} />;
}
if (step === 2) {
const rect = getBoundings(SelectorCanvas);
return (<Spread {...props } x={rect.x + rect.width * 0.382} y={300} />);
return <Spread {...props} x={rect.x + rect.width * 0.382} y={300} />;
}
if (step === 3) {
const rect = getBoundings(SelectorStyle);
const canvasRect = getBoundings(SelectorCanvas);
// 32px 是箭头的偏移
return (<StyleBtn {...props } x={rect.x + rect.width / 2 - 32} y={rect.bottom} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
return (
<StyleBtn
{...props}
x={rect.x + rect.width / 2 - 32}
y={rect.bottom}
canvasX={canvasRect.x + canvasRect.width * 0.382}
canvasY={300}
/>
);
}
if (step === 4) {
const rect = getBoundings(SelectorSidebar);
const canvasRect = getBoundings(SelectorCanvas);
return (<StylePanel {...props } x={rect.right - 16} y={rect.top + 200} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
return (
<StylePanel
{...props}
x={rect.right - 16}
y={rect.top + 200}
canvasX={canvasRect.x + canvasRect.width * 0.382}
canvasY={300}
/>
);
}
if (step === 5) {
const rect = getBoundings(SelectorFilter);
const canvasRect = getBoundings(SelectorCanvas);
// 32px 是箭头的偏移
return (<FilterBtn {...props } x={rect.x + rect.width / 2 - 32} y={rect.bottom} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
return (
<FilterBtn
{...props}
x={rect.x + rect.width / 2 - 32}
y={rect.bottom}
canvasX={canvasRect.x + canvasRect.width * 0.382}
canvasY={300}
/>
);
}
if (step === 6) {
const rect = getBoundings(SelectorSidebar);
const canvasRect = getBoundings(SelectorCanvas);
return (<FilterPanel {...props } x={rect.right - 16} y={rect.top + 100} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
return (
<FilterPanel
{...props}
x={rect.right - 16}
y={rect.top + 100}
canvasX={canvasRect.x + canvasRect.width * 0.382}
canvasY={300}
/>
);
}
if (step === 7) {
const rect = getBoundings(SelectorDownload);
const canvasRect = getBoundings(SelectorCanvas);
return (<Download {...props } x={rect.x + rect.width / 2} y={rect.bottom} canvasX={canvasRect.x + canvasRect.width * 0.382} canvasY={300} />);
return (
<Download
{...props}
x={rect.x + rect.width / 2}
y={rect.bottom}
canvasX={canvasRect.x + canvasRect.width * 0.382}
canvasY={300}
/>
);
}
if (step === 8) {
return (<End {...props } />);
return <End {...props} />;
}
return null;
}
Expand All @@ -157,9 +218,15 @@ export const Guidance: React.FC = () => {
return 'none';
}

return !isGuidanceFinished &&
<div className={styles.guidance} style={{ display: step >= 0 && step <= 8 ? 'unset' : 'none' }}>
<div className={styles.mask} style={{ clipPath: getClipPath() }} />
{ getGuidanceUI() }
</div>;
return (
!isGuidanceFinished && (
<div
className={styles.guidance}
style={{ display: step >= 0 && step <= 8 ? 'unset' : 'none' }}
>
<div className={styles.mask} style={{ clipPath: getClipPath() }} />
{getGuidanceUI()}
</div>
)
);
};
32 changes: 26 additions & 6 deletions client/src/components/guidance/spread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,41 @@ import styles from './index.module.less';

/**
* 新手引导 - 扩散
* @returns
* @returns
*/
export const Spread: React.FC<StepUIProps> = ({ prev, next, end, x = 0, y = 0 }) => {
export const Spread: React.FC<StepUIProps> = ({
prev,
next,
end,
x = 0,
y = 0,
}) => {
return (
<div className={styles.spread} style={{ top: y, left: x }}>
<div className={styles.container}>
<img className={styles.background} style={{ width: 430 }} src={Assets.spread} />
<img className={styles.gif} src={Assets.spreadGif} style={{ top: 82, left: 77, maxWidth: 246 }} />
<img
className={styles.background}
style={{ width: 430 }}
src={Assets.spread}
/>
<img
className={styles.gif}
src={Assets.spreadGif}
style={{ top: 105, left: 92, width: '238px', height: '206px' }}
/>
<div className={styles.btnContainer} style={{ top: 356, left: 245 }}>
<div className={styles.nextBtn}>
<img className={styles.btnBackground} src={Assets.btnNext} />
<div className={styles.nextText} onClick={next}>下一步</div>
<div className={styles.nextText} onClick={next}>
下一步
</div>
</div>
</div>
<div className={styles.close} onClick={end} style={{ top: 0, left: 358 }}>
<div
className={styles.close}
onClick={end}
style={{ top: 0, left: 358 }}
>
<img src={Assets.close} />
</div>
</div>
Expand Down
Loading