Add click switch to Indicator

This commit is contained in:
2023-09-22 17:02:15 +08:00
parent 970f70d470
commit f744748a85
3 changed files with 19 additions and 3 deletions

View File

@@ -9,6 +9,7 @@
.item {
flex: auto;
cursor: pointer;
.dot {
width: 10px;
@@ -19,10 +20,15 @@
color: constants.$font-secondary-color;
style: solid;
};
transition: all .2s;
}
:hover {
background-color: constants.$focus-color;
}
}
.active>* {
background-color: constants.$font-secondary-color;
.active > * {
background-color: constants.$font-secondary-color !important;
}
}

View File

@@ -2,3 +2,4 @@ $main-color: #00D4FF;
$background-color: #F5F5F5;
$font-main-color: #4D4D4D;
$font-secondary-color: #9E9E9E;
$focus-color: #DDDDDD

View File

@@ -126,6 +126,11 @@ const Home: React.FC = () => {
}
}
const handleIndicatorSwitch = (index: number) => {
setCurrentContent(index)
handleScrollToContent(index)()
}
const content = [
{
backgroundColor: '#FBFBFB',
@@ -153,7 +158,11 @@ const Home: React.FC = () => {
</div>
<div hidden={navbarHidden} className={'indicator'}>
<Indicator total={content.length} current={currentContent} />
<Indicator
total={content.length}
current={currentContent}
onSwitch={handleIndicatorSwitch}
/>
</div>
</>
)