-
-
Notifications
You must be signed in to change notification settings - Fork 784
perf: add marks dot classname #842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
978d5a9
6e82204
a67708a
fc1efee
c140c81
edc0647
8dc1f33
7a3fe19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import * as React from 'react'; | |
import type { InternalMarkObj } from '../Marks'; | ||
import SliderContext from '../context'; | ||
import Dot from './Dot'; | ||
import classNames from 'classnames'; | ||
|
||
export interface StepsProps { | ||
prefixCls: string; | ||
|
@@ -15,14 +16,17 @@ export default function Steps(props: StepsProps) { | |
const { prefixCls, marks, dots, style, activeStyle } = props; | ||
const { min, max, step } = React.useContext(SliderContext); | ||
|
||
const stepDots = React.useMemo(() => { | ||
const { stepDots, marksValue } = React.useMemo(() => { | ||
const dotSet = new Set<number>(); | ||
|
||
// Add marks | ||
marks.forEach((mark) => { | ||
dotSet.add(mark.value); | ||
}); | ||
|
||
// Set marksValue | ||
const uniqueMarksValue = Array.from(dotSet); | ||
|
||
// Fill dots | ||
if (dots && step !== null) { | ||
let current = min; | ||
|
@@ -32,20 +36,31 @@ export default function Steps(props: StepsProps) { | |
} | ||
} | ||
|
||
return Array.from(dotSet); | ||
return { | ||
marksValue: uniqueMarksValue, | ||
stepDots: Array.from(dotSet), | ||
}; | ||
}, [min, max, step, dots, marks]); | ||
|
||
return ( | ||
<div className={`${prefixCls}-step`}> | ||
{stepDots.map((dotValue) => ( | ||
<Dot | ||
prefixCls={prefixCls} | ||
key={dotValue} | ||
value={dotValue} | ||
style={style} | ||
activeStyle={activeStyle} | ||
/> | ||
))} | ||
{stepDots.map((dotValue) => { | ||
// Check whether it is a marks dot | ||
const isMarksDot = marksValue.indexOf(dotValue) >= 0; | ||
|
||
return ( | ||
<Dot | ||
prefixCls={prefixCls} | ||
className={classNames({ | ||
[`${prefixCls}-marks-dot`]: isMarksDot, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [`${prefixCls}-marks-dot`]: isMarksDot,
+markedDot, @MadCcc An additional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, current design do not need a className to style dot with mark. It's better to append customized className to this element. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I'll write it down when I have time. |
||
})} | ||
key={dotValue} | ||
value={dotValue} | ||
style={style} | ||
activeStyle={activeStyle} | ||
/> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.