From a1aededecb73b1a00b1fb26b3562593367142d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Mon, 28 Aug 2017 13:45:25 +0800 Subject: [PATCH] NoticeBar: add component && doc --- build/bin/build-entry.js | 3 +- components.json | 3 +- docs/examples-docs/notice-bar.md | 71 +++++++++++++++++++++ docs/src/ExamplesDocsApp.vue | 1 - docs/src/doc.config.js | 4 ++ docs/src/examples.js | 6 +- docs/src/index.js | 2 +- package.json | 2 +- packages/index.js | 47 ++------------ packages/notice-bar/index.vue | 92 ++++++++++++++++++++++++++++ packages/vant-css/src/index.css | 1 + packages/vant-css/src/notice-bar.css | 36 +++++++++++ yarn.lock | 6 +- 13 files changed, 221 insertions(+), 53 deletions(-) create mode 100644 docs/examples-docs/notice-bar.md create mode 100644 packages/notice-bar/index.vue create mode 100644 packages/vant-css/src/notice-bar.css diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index 6294590f1..34d111e49 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -34,8 +34,7 @@ export { }; export default { install, - version, -{{list}} + version }; `; diff --git a/components.json b/components.json index dd4b25daa..705772a32 100644 --- a/components.json +++ b/components.json @@ -36,5 +36,6 @@ "uploader": "./packages/uploader/index.js", "swipe": "./packages/swipe/index.js", "swipe-item": "./packages/swipe-item/index.js", - "datetime-picker": "./packages/datetime-picker/index.js" + "datetime-picker": "./packages/datetime-picker/index.js", + "notice-bar": "./packages/notice-bar/index.js" } diff --git a/docs/examples-docs/notice-bar.md b/docs/examples-docs/notice-bar.md new file mode 100644 index 000000000..50b954b9b --- /dev/null +++ b/docs/examples-docs/notice-bar.md @@ -0,0 +1,71 @@ + + +## NoticeBar 通告栏 + +### 使用指南 +``` javascript +import { NoticeBar } from 'vant'; + +Vue.component(NoticeBar.name, NoticeBar); +``` + +### 代码演示 + +#### 基础用法 + +:::demo 基础用法 +```html + + 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 + +``` +::: + +#### 禁用滚动 +文字内容多于一行时,可通过`scrollable`参数控制是否开启滚动 + +:::demo 禁用滚动 +```html + + 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 + +``` +::: + +#### 通告栏模式 +默认模式为空,支持`closeable`和`link`。 + +:::demo 通告栏模式 +```html + + + 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 + + + + + 足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。 + +``` +::: + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| mode | 通告栏模式 | String | `''` | `closeable` `link` | +| delay | 动画延迟时间,单位秒 | Number | `1` | | +| scrollable | 是否滚动 | Boolean | `true` | | +| speed | 滚动速率,单位px | Number | `40` | | + +### Event + +| 事件名 | 说明 | 参数 | +|-----------|-----------|-----------| +| click | 点击事件回调 | - | diff --git a/docs/src/ExamplesDocsApp.vue b/docs/src/ExamplesDocsApp.vue index c8753bf7f..85337be4a 100644 --- a/docs/src/ExamplesDocsApp.vue +++ b/docs/src/ExamplesDocsApp.vue @@ -7,7 +7,6 @@ diff --git a/packages/vant-css/src/index.css b/packages/vant-css/src/index.css index d18b5a74d..6a7bfa8df 100644 --- a/packages/vant-css/src/index.css +++ b/packages/vant-css/src/index.css @@ -30,3 +30,4 @@ @import './toast.css'; @import './uploader.css'; @import './swipe.css'; +@import './notice-bar.css'; diff --git a/packages/vant-css/src/notice-bar.css b/packages/vant-css/src/notice-bar.css new file mode 100644 index 000000000..67f912a1a --- /dev/null +++ b/packages/vant-css/src/notice-bar.css @@ -0,0 +1,36 @@ +@import './common/var.css'; + +.van-notice-bar { + color: #f60; + padding: 9px 10px; + font-size: 12px; + line-height: 1.5; + background-color: #fff7cc; + + &--withicon { + position: relative; + padding-right: 30px; + } + + &__icon { + top: 10px; + right: 10px; + position: absolute; + font-size: 15px; + line-height: 1; + cursor: pointer; + } + + &__content-wrap { + height: 18px; + overflow: hidden; + position: relative; + } + + &__content { + position: absolute; + white-space: nowrap; + transition-property: left; + transition-timing-function: linear; + } +} diff --git a/yarn.lock b/yarn.lock index b2c4b198a..65dac4f42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7959,9 +7959,9 @@ yeast@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" -zan-doc@^0.2.3: - version "0.2.3" - resolved "https://registry.npmjs.org/zan-doc/-/zan-doc-0.2.3.tgz#79a8a4b6b5377e5900fd9a37034bb481ab281cf8" +zan-doc@^0.2.5: + version "0.2.5" + resolved "https://registry.npmjs.org/zan-doc/-/zan-doc-0.2.5.tgz#4f82e1b75db1a348b57436cd1d4ffb607bc18562" dependencies: cheerio "0.22.0" decamelize "^1.2.0"