Commit 39726ce6 authored by hewenhao's avatar hewenhao

feat: update

parent e88426fd
.contentWrap { .contentWrap {
border-radius: 16px;
position: absolute; position: absolute;
z-index: 9999998; z-index: 9999998;
opacity: 1; opacity: 1;
box-shadow: rgb(33 33 33 / 50%) 0px 0px 0px 5000PX; box-shadow: rgba(0,0,0, .6) 0px 0px 0px 5000PX;
} }
.content { .content {
......
import { View, type ViewProps, RootPortal } from '@tarojs/components' import { View, RootPortal } from '@tarojs/components'
import { type PropsWithChildren, useState, useMemo, useRef, useEffect, type ReactNode } from 'react' import { useState, useMemo, useRef, useEffect, type ReactNode, type ComponentType } from 'react'
import { createSelectorQuery, usePageScroll } from '@tarojs/taro' import { createSelectorQuery, usePageScroll } from '@tarojs/taro'
import classNames from 'classnames'
import styles from './index.module.scss' import styles from './index.module.scss'
type UserGuideProps = { type GetProps<T> = T extends ComponentType<infer P> ? P : {}
type UserGuideProps<T extends ComponentType<any>> = {
onFinish?: () => void; onFinish?: () => void;
isActive?: boolean; isActive?: boolean;
compnent?: T;
onClickConent?: () => void; onClickConent?: () => void;
verticalPadding?: number; verticalPadding?: number;
horizonPadding?: number; horizonPadding?: number;
guideContent?: ReactNode; guideContent?: ReactNode;
} wrapClass?: string;
} & GetProps<T>
const UserGuideView = (props: PropsWithChildren<UserGuideProps & ViewProps>) => { function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserGuideProps<T>) {
const { isActive, children, guideContent, verticalPadding = 0, horizonPadding = 0, onClickConent, ...rest } = props const { isActive, wrapClass, guideContent, verticalPadding = 0, horizonPadding = 0, onFinish, onClickConent, compnent: Comp = View, ...rest } = props
const [rect, setRect] = useState({ width: 80, height: 80, top: 0, left: 0 }) const [rect, setRect] = useState({ width: 80, height: 80, top: 0, left: 0 })
const [_isActive, setIsActive] = useState(false) const [_isActive, setIsActive] = useState(false)
const scrollRef = useRef(0) const scrollRef = useRef(0)
...@@ -53,12 +58,10 @@ const UserGuideView = (props: PropsWithChildren<UserGuideProps & ViewProps>) => ...@@ -53,12 +58,10 @@ const UserGuideView = (props: PropsWithChildren<UserGuideProps & ViewProps>) =>
return ( return (
<> <>
<View {...rest} ref={domRef}> <Comp {...(rest as GetProps<T>)} ref={domRef} />
{children}
</View>
{_isActive && ( {_isActive && (
<RootPortal> <RootPortal>
<View className={styles.contentWrap} catchMove style={style}> <View className={classNames(styles.contentWrap, wrapClass)} catchMove style={style}>
<View className={styles.content} onClick={onClickConent}> <View className={styles.content} onClick={onClickConent}>
</View> </View>
{guideContent} {guideContent}
......
import { View } from '@tarojs/components'
import styles from './index.module.scss'
const Wrong = () => {
return (
<View>123123</View>
)
}
export default Wrong
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
} }
} }
.guide_wrap {
border-radius: 50%;
border: 2px dashed #fff;
}
.clear { .clear {
position: relative; position: relative;
......
import { View, Image } from '@tarojs/components' import { View, Image, ViewProps } from '@tarojs/components'
import assets from '@/assets/oss/assets-round' import assets from '@/assets/oss/assets-round'
import classNames from 'classnames' import classNames from 'classnames'
import { cs } from '@/styles' import { cs } from '@/styles'
...@@ -118,7 +118,18 @@ const StageComp = (props: StageProps) => { ...@@ -118,7 +118,18 @@ const StageComp = (props: StageProps) => {
case StageStatus.CURRENT: { case StageStatus.CURRENT: {
return ( return (
<Image src={getUnlockedIcon(stage.type).u} className={getIconClassNames(stage.type)} /> <UserGuideView
src={getUnlockedIcon(stage.type).u}
compnent={Image}
className={getIconClassNames(stage.type)}
isActive={stage.status === StageStatus.CURRENT}
verticalPadding={4}
horizonPadding={4}
wrapClass={styles.guide_wrap}
guideContent={(
<View style={{ color: '#ffffff' }}>123123123234234234sdfsdf sdfsdfsdf sdf sdf sdf sdf sdfsd fsd </View>
)}
></UserGuideView>
) )
} }
...@@ -155,21 +166,15 @@ const StageComp = (props: StageProps) => { ...@@ -155,21 +166,15 @@ const StageComp = (props: StageProps) => {
} }
return ( return (
<UserGuideView <View
className={classNames(props.className, cs.bounce_btn)} className={classNames(props.className, cs.bounce_btn)}
hoverClass={cs.bounce_btn_hover} hoverClass={cs.bounce_btn_hover}
id={stage.status === StageStatus.CURRENT ? CurrentRoundId : undefined} id={stage.status === StageStatus.CURRENT ? CurrentRoundId : undefined}
onClick={handleClick} onClick={handleClick}
isActive={stage.status === StageStatus.CURRENT}
verticalPadding={15}
horizonPadding={15}
guideContent={(
<View style={{ color: '#ffffff' }}>123123123234234234sdfsdf sdfsdfsdf sdf sdf sdf sdf sdfsd fsd </View>
)}
> >
{renderRound(isReady)} {renderRound(isReady)}
<View className={styles.roundName}>{stage.name}</View> <View className={styles.roundName}>{stage.name}</View>
</UserGuideView> </View>
) )
} }
......
...@@ -43,24 +43,24 @@ ...@@ -43,24 +43,24 @@
padding: 28px; padding: 28px;
} }
.modal_2 { // .modal_2 {
position: absolute; // position: absolute;
top: -260px; // top: -260px;
width: 500px; // width: 500px;
height: 260px; // height: 260px;
background-image: url(https://cdn.jkwljy.com/pk-math/2tGxMZeki8g2zJdm36HkhuqnvpMS/500x260); // background-image: url(https://cdn.jkwljy.com/pk-math/2tGxMZeki8g2zJdm36HkhuqnvpMS/500x260);
background-size: 100% 100%; // background-size: 100% 100%;
box-sizing: border-box; // box-sizing: border-box;
padding: 32px 28px; // padding: 32px 28px;
} // }
.modal_1 { // .modal_1 {
position: absolute; // position: absolute;
top: -180px; // top: -180px;
width: 500px; // width: 500px;
height: 180px; // height: 180px;
background-image: url(https://cdn.jkwljy.com/pk-math/eFWwoxVC4mzX1hZZojv23VEh9hz/500x180); // background-image: url(https://cdn.jkwljy.com/pk-math/eFWwoxVC4mzX1hZZojv23VEh9hz/500x180);
background-size: 100% 100%; // background-size: 100% 100%;
box-sizing: border-box; // box-sizing: border-box;
padding: 48px 28px; // padding: 48px 28px;
} // }
...@@ -9,23 +9,22 @@ import styles from './scene-1.module.scss' ...@@ -9,23 +9,22 @@ import styles from './scene-1.module.scss'
const Text1 = [ const Text1 = [
{ text: '嗨,' }, { text: '嗨,' },
{ text: '你好!' }, { text: '我是帮助很多同学们爱上数学的阿喵老师。' },
{ text: '我是高斯。' },
] ]
const Text2 = [ // const Text2 = [
{ text: '别看我是一只猫,' }, // { text: '别看我是一只猫,' },
{ text: '我可是一名远近闻名的数学大师呢。' }, // { text: '我可是一名远近闻名的数学大师呢。' },
] // ]
// text="我已经帮助很多同学,喜欢上数学,提升数学能力了。" // // text="我已经帮助很多同学,喜欢上数学,提升数学能力了。"
const Text3 = [ // const Text3 = [
{ text: '我已经帮助很多同学' }, // { text: '我已经帮助很多同学' },
{ text: '喜欢上数学,' }, // { text: '喜欢上数学,' },
{ text: '提升数学能力了。' }, // { text: '提升数学能力了。' },
] // ]
// text="在开始前,我可以问几个问题互相了解一下吗?" // text="在开始前,我可以问几个问题互相了解一下吗?"
const Text4 = [ const Text2 = [
{ text: '在开始前,' }, { text: '在开始前,' },
{ text: '我可以问几个问题,' }, { text: '我可以问几个问题,' },
{ text: '互相了解一下吗?' }, { text: '互相了解一下吗?' },
...@@ -59,13 +58,13 @@ const Scene1 = ({ onNext }: Scene1Props) => { ...@@ -59,13 +58,13 @@ const Scene1 = ({ onNext }: Scene1Props) => {
handleEnd(1) handleEnd(1)
}, [handleEnd]) }, [handleEnd])
const fn2 = useCallback(() => { // const fn2 = useCallback(() => {
handleEnd(2) // handleEnd(2)
}, [handleEnd]) // }, [handleEnd])
const fn3 = useCallback(() => { // const fn3 = useCallback(() => {
handleEnd(3) // handleEnd(3)
}, [handleEnd]) // }, [handleEnd])
return ( return (
<View className={cs.viewport}> <View className={cs.viewport}>
...@@ -80,11 +79,11 @@ const Scene1 = ({ onNext }: Scene1Props) => { ...@@ -80,11 +79,11 @@ const Scene1 = ({ onNext }: Scene1Props) => {
</View> </View>
<View className={styles.dialog}> <View className={styles.dialog}>
{current === 0 && ( {current === 0 && (
<View className={styles.modal_1}> <View className={styles.modal_3}>
<TextPrinter textList={Text1} onEnd={fn1}></TextPrinter> <TextPrinter textList={Text1} onEnd={fn1}></TextPrinter>
</View> </View>
)} )}
{current === 1 && ( {/* {current === 1 && (
<View className={styles.modal_2}> <View className={styles.modal_2}>
<TextPrinter textList={Text2} onEnd={fn2} /> <TextPrinter textList={Text2} onEnd={fn2} />
</View> </View>
...@@ -96,11 +95,11 @@ const Scene1 = ({ onNext }: Scene1Props) => { ...@@ -96,11 +95,11 @@ const Scene1 = ({ onNext }: Scene1Props) => {
onEnd={fn3} onEnd={fn3}
/> />
</View> </View>
)} )} */}
{current === 3 && ( {current === 1 && (
<View className={styles.modal_3}> <View className={styles.modal_3}>
<TextPrinter <TextPrinter
textList={Text4} textList={Text2}
onEnd={fn} onEnd={fn}
/> />
</View> </View>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment