diff --git a/src/components/carousel/carousel-item.vue b/src/components/carousel/carousel-item.vue new file mode 100644 index 00000000..7381afc4 --- /dev/null +++ b/src/components/carousel/carousel-item.vue @@ -0,0 +1,34 @@ + + diff --git a/src/components/carousel/carousel.vue b/src/components/carousel/carousel.vue new file mode 100644 index 00000000..dbd4560a --- /dev/null +++ b/src/components/carousel/carousel.vue @@ -0,0 +1,238 @@ + + diff --git a/src/components/carousel/index.js b/src/components/carousel/index.js new file mode 100644 index 00000000..688b6268 --- /dev/null +++ b/src/components/carousel/index.js @@ -0,0 +1,5 @@ +import Carousel from './carousel.vue'; +import CarouselItem from './carousel-item.vue'; + +Carousel.Item = CarouselItem; +export default Carousel; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 944a1645..15e1c9cf 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,7 @@ import Badge from './components/badge'; import Breadcrumb from './components/breadcrumb'; import Button from './components/button'; import Card from './components/card'; +import Carousel from './components/carousel'; import Cascader from './components/cascader'; import Checkbox from './components/checkbox'; import Circle from './components/circle'; @@ -53,6 +54,8 @@ const iview = { iButton: Button, ButtonGroup: Button.Group, Card, + Carousel, + CarouselItem: Carousel.Item, Cascader, Checkbox, CheckboxGroup: Checkbox.Group, diff --git a/src/styles/components/carousel.less b/src/styles/components/carousel.less new file mode 100644 index 00000000..066f12f6 --- /dev/null +++ b/src/styles/components/carousel.less @@ -0,0 +1,175 @@ +@carousel-prefix-cls: ~"@{css-prefix}carousel"; +@carousel-item-prefix-cls: ~"@{css-prefix}carousel-item"; + +.@{carousel-prefix-cls} { + position: relative; + display: block; + box-sizing: border-box; + user-select: none; + touch-action: pan-y; + -webkit-tap-highlight-color: transparent; + + &-track, &-list { + transform: translate3d(0, 0, 0); + } + + &-list { + position: relative; + display: block; + overflow: hidden; + + margin: 0; + padding: 0; + } + + &-track { + position: relative; + top: 0; + left: 0; + display: block; + + overflow: hidden; + + z-index: 1; + } + + &-item { + float: left; + height: 100%; + min-height: 1px; + display: block; + } + + &-arrow { + + border: none; + outline: none; + + padding: 0; + margin: 0; + + width: 36px; + height: 36px; + border-radius: 50%; + + cursor: pointer; + + display: none; + + position: absolute; + top: 50%; + z-index: 10; + transform: translateY(-50%); + + transition: .3s; + background-color: rgba(31, 45, 61, .11); + color: #fff; + + &:hover { + background-color: rgba(31, 45, 61, 0.5); + } + + text-align: center; + font-size: 1em; + + font-family: inherit; + line-height: inherit; + + & > * { + vertical-align: baseline; + } + + &.left { + left: 16px; + } + + &.right { + right: 16px; + } + + &-always { + display: inherit; + } + + &-hover { + display: inherit; + + opacity: 0; + } + } + + &:hover &-arrow-hover { + opacity: 1; + } + + &-dots { + z-index: 10; + + @padding: 7px; + + display: none; + + position: relative; + &-inside { + display: block; + position: absolute; + bottom: 10px - @padding; + } + + &-outside { + display: block; + margin-top: 10px - @padding; + } + + list-style: none; + + text-align: center; + + padding: 0; + width: 100%; + height: 3px + @padding * 2; + + li { + position: relative; + display: inline-block; + + vertical-align: top; + text-align: center; + + margin: 0 2px; + padding: @padding 0; + + cursor: pointer; + + button { + border: 0; + cursor: pointer; + + background: #8391a5; + opacity: 0.3; + + display: block; + width: 16px; + height: 3px; + + border-radius: 1px; + outline: none; + + font-size: 0; + color: transparent; + + -webkit-transition: all .5s; + transition: all .5s; + } + + &:hover > button { + opacity: 0.7; + } + + &.@{carousel-prefix-cls}-active > button { + opacity: 1; + width: 24px; + } + } + } +} diff --git a/src/styles/components/index.less b/src/styles/components/index.less index 10f81742..0c613c25 100644 --- a/src/styles/components/index.less +++ b/src/styles/components/index.less @@ -35,4 +35,5 @@ @import "date-picker"; @import "time-picker"; @import "form"; -@import "rate"; \ No newline at end of file +@import "carousel"; +@import "rate"; diff --git a/test/app.vue b/test/app.vue index 0a1e3cff..08592f56 100644 --- a/test/app.vue +++ b/test/app.vue @@ -47,6 +47,7 @@ li + li {
  • Menu
  • Date
  • Form
  • +
  • Carousel
  • Rate
  • diff --git a/test/main.js b/test/main.js index f67ab015..11a8abb2 100644 --- a/test/main.js +++ b/test/main.js @@ -135,6 +135,11 @@ router.map({ require(['./routers/form.vue'], resolve); } }, + '/carousel': { + component: function (resolve) { + require(['./routers/carousel.vue'], resolve); + } + }, '/rate': { component: function (resolve) { require(['./routers/rate.vue'], resolve); diff --git a/test/routers/carousel.vue b/test/routers/carousel.vue new file mode 100644 index 00000000..0171d80c --- /dev/null +++ b/test/routers/carousel.vue @@ -0,0 +1,206 @@ + +