From c0c2a1894c0e1673bd0f14d1353ff4904706728d Mon Sep 17 00:00:00 2001 From: wanlei Date: Thu, 2 Nov 2017 19:40:49 +0800 Subject: [PATCH] update: [Tooltip] unsolved animation & transition --- components/index.js | 3 + components/tooltip/index.js | 3 + components/tooltip/style/index.js | 2 + components/tooltip/style/index.less | 207 ++++++++++++++++++++++++++++ components/tooltip/tooltip.vue | 179 ++++++++++++++++++++++++ examples/index.js | 5 +- examples/tooltip.vue | 29 ++++ utils/ant-transition.vue | 32 +++++ 8 files changed, 459 insertions(+), 1 deletion(-) create mode 100644 components/tooltip/index.js create mode 100644 components/tooltip/style/index.js create mode 100644 components/tooltip/style/index.less create mode 100644 components/tooltip/tooltip.vue create mode 100644 examples/tooltip.vue create mode 100644 utils/ant-transition.vue diff --git a/components/index.js b/components/index.js index e37bca7b2..28d619cca 100644 --- a/components/index.js +++ b/components/index.js @@ -3,6 +3,7 @@ import './checkbox/style' import './icon/style' import './radio/style' import './grid/style' +import './tooltip/style' export { default as Button } from './button' @@ -13,3 +14,5 @@ export { default as Icon } from './icon' export { default as Radio } from './radio' export { default as Grid } from './grid' + +export { default as ToolTip } from './tooltip' diff --git a/components/tooltip/index.js b/components/tooltip/index.js new file mode 100644 index 000000000..4b5f7d8bc --- /dev/null +++ b/components/tooltip/index.js @@ -0,0 +1,3 @@ +import ToolTip from './tooltip.vue' +export default ToolTip + diff --git a/components/tooltip/style/index.js b/components/tooltip/style/index.js new file mode 100644 index 000000000..cf31ed80f --- /dev/null +++ b/components/tooltip/style/index.js @@ -0,0 +1,2 @@ +import '../../style/index.less' +import './index.less' diff --git a/components/tooltip/style/index.less b/components/tooltip/style/index.less new file mode 100644 index 000000000..a5377f0d3 --- /dev/null +++ b/components/tooltip/style/index.less @@ -0,0 +1,207 @@ +@import "../../style/themes/default"; +@import "../../style/mixins/index"; + +@tooltip-prefix-cls: ~"@{ant-prefix}-tooltip"; + +// Base class +.@{tooltip-prefix-cls} { + position: absolute; + z-index: @zindex-tooltip; + display: block; + visibility: visible; + font-size: @font-size-base; + line-height: @line-height-base; + + &-hidden { + display: none; + } + + &-placement-top, + &-placement-topLeft, + &-placement-topRight { + padding-bottom: @tooltip-distance; + } + &-placement-right, + &-placement-rightTop, + &-placement-rightBottom { + padding-left: @tooltip-distance; + } + &-placement-bottom, + &-placement-bottomLeft, + &-placement-bottomRight { + padding-top: @tooltip-distance; + } + &-placement-left, + &-placement-leftTop, + &-placement-leftBottom { + padding-right: @tooltip-distance; + } +} + +// Wrapper for the tooltip content +.@{tooltip-prefix-cls}-inner { + max-width: @tooltip-max-width; + padding: 8px 10px; + color: @tooltip-color; + text-align: left; + text-decoration: none; + background-color: @tooltip-bg; + border-radius: @border-radius-base; + box-shadow: @box-shadow-base; + min-height: 34px; +} + +// Arrows +.@{tooltip-prefix-cls}-arrow { + position: absolute; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; +} + +.@{tooltip-prefix-cls} { + &-placement-top &-arrow, + &-placement-topLeft &-arrow, + &-placement-topRight &-arrow { + bottom: @tooltip-distance - @tooltip-arrow-width; + border-width: @tooltip-arrow-width @tooltip-arrow-width 0; + border-top-color: @tooltip-arrow-color; + } + + &-placement-top &-arrow { + left: 50%; + margin-left: -@tooltip-arrow-width; + } + + &-placement-topLeft &-arrow { + left: 16px; + } + + &-placement-topRight &-arrow { + right: 16px; + } + + &-placement-right &-arrow, + &-placement-rightTop &-arrow, + &-placement-rightBottom &-arrow { + left: @tooltip-distance - @tooltip-arrow-width; + border-width: @tooltip-arrow-width @tooltip-arrow-width @tooltip-arrow-width 0; + border-right-color: @tooltip-arrow-color; + } + + &-placement-right &-arrow { + top: 50%; + margin-top: -@tooltip-arrow-width; + } + + &-placement-rightTop &-arrow { + top: 8px; + } + + &-placement-rightBottom &-arrow { + bottom: 8px; + } + + &-placement-left &-arrow, + &-placement-leftTop &-arrow, + &-placement-leftBottom &-arrow { + right: @tooltip-distance - @tooltip-arrow-width; + border-width: @tooltip-arrow-width 0 @tooltip-arrow-width @tooltip-arrow-width; + border-left-color: @tooltip-arrow-color; + } + + &-placement-left &-arrow { + top: 50%; + margin-top: -@tooltip-arrow-width; + } + + &-placement-leftTop &-arrow { + top: 8px; + } + + &-placement-leftBottom &-arrow { + bottom: 8px; + } + + &-placement-bottom &-arrow, + &-placement-bottomLeft &-arrow, + &-placement-bottomRight &-arrow { + top: @tooltip-distance - @tooltip-arrow-width; + border-width: 0 @tooltip-arrow-width @tooltip-arrow-width; + border-bottom-color: @tooltip-arrow-color; + } + + &-placement-bottom &-arrow { + left: 50%; + margin-left: -@tooltip-arrow-width; + } + + &-placement-bottomLeft &-arrow { + left: 16px; + } + + &-placement-bottomRight &-arrow { + right: 16px; + } +} + + +/** +modified part ,remove these if needed + */ + +.vc-fade-enter-active, .vc-fade-leave-active { + transition: all 3s; +} +.vc-fade-enter, .vc-fade-leave-to /* .fade-leave-active in below version 2.1.8 */ { + opacity: 0; +} + +.box { + background: red; + width: 100px; + height: 100px; +} +.fade-enter { + opacity: 0; + animation-duration: 0.3s; + animation-fill-mode: both; + animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); + animation-play-state: paused; +} + +.fade-leave { + animation-duration: 0.3s; + animation-fill-mode: both; + animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); + animation-play-state: paused; +} + +.fade-enter.fade-enter-active { + animation-name: rcDialogFadeIn; + animation-play-state: running; +} + +.fade-leave.fade-leave-active { + animation-name: rcDialogFadeOut; + animation-play-state: running; +} + +@keyframes rcDialogFadeIn { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +@keyframes rcDialogFadeOut { + 0% { + opacity: 1; + } + 100% { + opacity: 0; + } +} diff --git a/components/tooltip/tooltip.vue b/components/tooltip/tooltip.vue new file mode 100644 index 000000000..2ca384638 --- /dev/null +++ b/components/tooltip/tooltip.vue @@ -0,0 +1,179 @@ + diff --git a/examples/index.js b/examples/index.js index 4a4d55917..2979fa131 100644 --- a/examples/index.js +++ b/examples/index.js @@ -3,13 +3,15 @@ import Checkbox from './checkbox.vue' import Button from './button.vue' import Radio from './radio.vue' import Grid from './grid.vue' +import ToolTip from './tooltip.vue' // import Dialog from './dialog.vue' import './index.less' -new Vue({ +window.root = new Vue({ el: '#app', template: `
+ @@ -21,5 +23,6 @@ new Vue({ Checkbox, Grid, Radio, + ToolTip, }, }) diff --git a/examples/tooltip.vue b/examples/tooltip.vue new file mode 100644 index 000000000..7b18f08b0 --- /dev/null +++ b/examples/tooltip.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/utils/ant-transition.vue b/utils/ant-transition.vue new file mode 100644 index 000000000..e87ff117c --- /dev/null +++ b/utils/ant-transition.vue @@ -0,0 +1,32 @@ + + +