-
Notifications
You must be signed in to change notification settings - Fork 138
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
feat(comp:carousel): add carousel component #634
Conversation
This preview will be available after the AzureCI is passed. |
Codecov Report
@@ Coverage Diff @@
## main #634 +/- ##
==========================================
+ Coverage 83.09% 83.64% +0.55%
==========================================
Files 370 393 +23
Lines 9338 9849 +511
Branches 2154 2268 +114
==========================================
+ Hits 7759 8238 +479
- Misses 1579 1611 +32
Continue to review full report at Codecov.
|
} | ||
|
||
export interface CarouselBindings { | ||
next: () => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
少了个 goto
@@ -0,0 +1,11 @@ | |||
.vertical-center () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.vertical-center () { | |
.carousel-vertical-center () { |
transform: translateY(-50%); | ||
} | ||
|
||
.horizontal-center () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.horizontal-center () { | |
.carousel-horizontal-center () { |
const dot = | ||
slots.dot?.({ activeIndex: activeIndex.value }) ?? | ||
Array.from({ length: length.value }).map((_, index: number) => { | ||
const isActive = index + 1 === activeIndex.value | ||
const itemClass = { | ||
[`${prefixCls}-dot-item`]: true, | ||
[`${prefixCls}-dot-item--active`]: isActive, | ||
} | ||
return <div class={itemClass} onClick={() => onClick(index)} onMouseenter={() => onMouseenter(index)}></div> | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const dot = | |
slots.dot?.({ activeIndex: activeIndex.value }) ?? | |
Array.from({ length: length.value }).map((_, index: number) => { | |
const isActive = index + 1 === activeIndex.value | |
const itemClass = { | |
[`${prefixCls}-dot-item`]: true, | |
[`${prefixCls}-dot-item--active`]: isActive, | |
} | |
return <div class={itemClass} onClick={() => onClick(index)} onMouseenter={() => onMouseenter(index)}></div> | |
}) | |
const dots = Array.from({ length: length.value }).map((_, index: number) => { | |
const isActive = index + 1 === activeIndex.value | |
const itemClass = { | |
[`${prefixCls}-dot-item`]: true, | |
[`${prefixCls}-dot-item--active`]: isActive, | |
} | |
const children = slots.dot ? slots.dot({index, isActive}) : <button>{index}<button> | |
return <li class={itemClass} onClick={() => onClick(index)} onMouseenter={() => onMouseenter(index)}>{children}</li> | |
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个插槽不应该是真对整个区域吧,而就是 dot 的内容? 否则 还得自己加 item 的 class, 比较麻烦。
</div> | ||
</> | ||
)} | ||
{dotPlacement.value !== 'none' && <div class={dotClass.value}>{dot}</div>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{dotPlacement.value !== 'none' && <div class={dotClass.value}>{dot}</div>} | |
{dotPlacement.value !== 'none' && <ul class={dotClass.value}>{dots}</ul>} |
其实我更建议把这个代码拆成一个子组件。
category: components | ||
type: 数据展示 | ||
title: Carousel | ||
subtitle: 走马灯(轮播图) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subtitle: 走马灯(轮播图) | |
subtitle: 轮播图 |
759786a
to
ef791ec
Compare
ef791ec
to
29ae7a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fix #230
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
add carousel component
What is the new behavior?
IxCarousel
CarouselProps
autoplayTime
number
0
0
时不开启自动轮播dotPlacement
'top' | 'start' | 'bottom' | 'end' | 'none'
'bottom'
'none'
时不显示面板指示点showArrow
prev
、next
按钮boolean
false
trigger
'click' | 'hover'
'click'
onChange
(prevIndex: number, nextIndex: number) => void
CarouselSlots
default
dot
activeIndex: number
activeIndex
表示当前激活的面板索引arrow
type: 'prev' | 'next'
CarseouselMethods
goTo(slideIndex: number)
(slideIndex: number) => void
next()
prev()
Other information