From 7b919ce8900edf0e9fb671e3c30e0fabeb543a2e Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 18 Mar 2019 20:02:19 +0800 Subject: [PATCH] [new feature] NoticeBar: add wrapable prop (#2992) --- packages/notice-bar/demo/index.vue | 34 ++++++++++++------- packages/notice-bar/en-US.md | 25 +++++++++----- packages/notice-bar/index.js | 21 +++++++++--- packages/notice-bar/index.less | 32 ++++++++++++----- .../test/__snapshots__/demo.spec.js.snap | 21 ++++++++---- packages/notice-bar/zh-CN.md | 31 ++++++++++++----- 6 files changed, 116 insertions(+), 48 deletions(-) diff --git a/packages/notice-bar/demo/index.vue b/packages/notice-bar/demo/index.vue index ec31da013..2a33e692c 100644 --- a/packages/notice-bar/demo/index.vue +++ b/packages/notice-bar/demo/index.vue @@ -7,14 +7,7 @@ /> - - - - - + + + + + + + + + @@ -31,13 +39,15 @@ export default { i18n: { 'zh-CN': { - title2: '禁用滚动', - title3: '通告栏模式', + unscrollable: '禁用滚动', + mode: '通告栏模式', + wrapable: '文本换行', text: '足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。' }, 'en-US': { - title2: 'Disable scroll', - title3: 'Mode', + mode: 'Mode', + wrapable: 'Wrapable', + unscrollable: 'Disable scroll', text: 'Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily.' } } diff --git a/packages/notice-bar/en-US.md b/packages/notice-bar/en-US.md index 566ef2891..a22e4f813 100644 --- a/packages/notice-bar/en-US.md +++ b/packages/notice-bar/en-US.md @@ -18,14 +18,6 @@ Vue.use(NoticeBar); /> ``` -#### Disable scroll - -```html - - Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily. - -``` - #### Mode ```html @@ -38,6 +30,22 @@ Vue.use(NoticeBar); ``` +#### Disable scroll + +```html + + Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily. + +``` + +#### Wrapable + +```html + + Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily. + +``` + ### API | Attribute | Description | Type | Default | @@ -46,6 +54,7 @@ Vue.use(NoticeBar); | delay | Animation delay (s) | `Number` | `1` | | speed | Scroll speed (px/s) | `Number` | `50` | | scrollable | Whether to scroll content | `Boolean` | `true` | +| wrapable | Whether to enable text wrap | `Boolean` | `false` | - | | left-icon | Left Icon | `String` | - | | color | Text color | `String` | `#f60` | | background | Background color | `String` | `#fff7cc` | diff --git a/packages/notice-bar/index.js b/packages/notice-bar/index.js index 8b497a645..1d4d00fc3 100644 --- a/packages/notice-bar/index.js +++ b/packages/notice-bar/index.js @@ -9,6 +9,7 @@ export default sfc({ mode: String, color: String, leftIcon: String, + wrapable: Boolean, background: String, delay: { type: [String, Number], @@ -94,17 +95,23 @@ export default sfc({ return (
{ this.$emit('click'); }} > - {this.leftIcon && } + {this.leftIcon && ( + + )}
- {iconName && } + {iconName && ( + + )}
); } diff --git a/packages/notice-bar/index.less b/packages/notice-bar/index.less index 7583d52e0..26e8dde79 100644 --- a/packages/notice-bar/index.less +++ b/packages/notice-bar/index.less @@ -11,14 +11,9 @@ color: @orange-dark; background-color: @orange-light; - &--withicon { - position: relative; - padding-right: 40px; - } - &__left-icon { font-size: 16px; - min-width: 20px; + min-width: 22px; } &__right-icon { @@ -47,10 +42,31 @@ &__play { animation: van-notice-bar-play linear both; + + &--infinite { + animation: van-notice-bar-play-infinite linear infinite both; + } } - &__play--infinite { - animation: van-notice-bar-play-infinite linear infinite both; + &--wrapable { + height: auto; + padding: 8px 15px; + + .van-notice-bar { + &__wrap { + height: auto; + } + + &__content { + position: relative; + white-space: normal; + } + } + } + + &--withicon { + position: relative; + padding-right: 40px; } } diff --git a/packages/notice-bar/test/__snapshots__/demo.spec.js.snap b/packages/notice-bar/test/__snapshots__/demo.spec.js.snap index 5997cc99e..af8525b55 100644 --- a/packages/notice-bar/test/__snapshots__/demo.spec.js.snap +++ b/packages/notice-bar/test/__snapshots__/demo.spec.js.snap @@ -10,13 +10,6 @@ exports[`renders demo correctly 1`] = `
-
-
-
-
足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。
-
-
-
@@ -31,5 +24,19 @@ exports[`renders demo correctly 1`] = `
+
+
+
+
足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。
+
+
+
+
+
+
+
足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。
+
+
+
`; diff --git a/packages/notice-bar/zh-CN.md b/packages/notice-bar/zh-CN.md index 9ce6aba84..877c28359 100644 --- a/packages/notice-bar/zh-CN.md +++ b/packages/notice-bar/zh-CN.md @@ -18,16 +18,8 @@ Vue.use(NoticeBar); /> ``` -#### 禁用滚动 -文字内容多于一行时,可通过`scrollable`参数控制是否开启滚动 - -```html - - 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 - -``` - #### 通告栏模式 + 默认模式为空,支持`closeable`和`link`。 ```html @@ -42,6 +34,26 @@ Vue.use(NoticeBar); ``` +#### 禁用滚动 + +文字内容多于一行时,可通过`scrollable`参数控制是否开启滚动 + +```html + + 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 + +``` + +#### 文本换行 + +禁用滚动时,可以设置`wrapable`来开启文本换行 + +```html + + 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 + +``` + ### API | 参数 | 说明 | 类型 | 默认值 | 版本 | @@ -50,6 +62,7 @@ Vue.use(NoticeBar); | delay | 动画延迟时间 (s) | `Number` | `1` | - | | speed | 滚动速率 (px/s) | `Number` | `50` | - | | scrollable | 是否在长度溢出时滚动播放 | `Boolean` | `true` | - | +| wrapable | 是否开启文本换行,只在禁用滚动时生效 | `Boolean` | `false` | 1.6.11 | | left-icon | 左侧图标名称或图片链接,可选值见 Icon 组件 | `String` | - | - | | color | 文本颜色 | `String` | `#f60` | - | | background | 滚动条背景 | `String` | `#fff7cc` | - |