diff --git a/src/action-sheet/README.zh-CN.md b/src/action-sheet/README.zh-CN.md
index 73ef8a497..a30300fd5 100644
--- a/src/action-sheet/README.zh-CN.md
+++ b/src/action-sheet/README.zh-CN.md
@@ -17,7 +17,7 @@ Vue.use(ActionSheet);
### 基础用法
-`ActionSheet`通过`actions`数组来定义展示的选项,数组的每一项是一个对象,对象属性见文档下方表格。
+动作面板通过`actions`属性来定义选项,数组的每一项是一个对象,对象格式见文档下方表格。
```html
diff --git a/src/share-sheet/README.zh-CN.md b/src/share-sheet/README.zh-CN.md
index 79f02d745..b9b8798ba 100644
--- a/src/share-sheet/README.zh-CN.md
+++ b/src/share-sheet/README.zh-CN.md
@@ -2,7 +2,7 @@
### 介绍
-底部弹起的模态面板,用于展示各分享渠道对应的操作按钮,不包含具体的分享逻辑。2.6 版本开始支持此组件。
+底部弹起的分享面板,用于展示各分享渠道对应的操作按钮,不含具体的分享逻辑。2.6 版本开始支持此组件。
### 引入
@@ -17,17 +17,38 @@ Vue.use(ShareSheet);
### 基础用法
+分享面板通过`options`属性来定义分享选项,数组的每一项是一个对象,对象格式见文档下方表格。
+
```html
-
+
+
```
```js
+import { Toast } from 'vant';
+
export default {
data() {
return {
- options: [],
+ showShare: false,
+ options: [
+ { name: '微信', icon: 'wechat' },
+ { name: '复制链接', icon: 'link' },
+ { name: '分享海报', icon: 'poster' },
+ { name: '二维码', icon: 'qrcode' },
+ ],
};
},
+ methods: {
+ onSelect(option) {
+ Toast(option.name);
+ this.showShare = false;
+ },
+ }
};
```
diff --git a/src/share-sheet/demo/index.vue b/src/share-sheet/demo/index.vue
index ec368bea4..9ffeb697f 100644
--- a/src/share-sheet/demo/index.vue
+++ b/src/share-sheet/demo/index.vue
@@ -6,7 +6,39 @@
:title="t('showSheet')"
@click="showBasicSheet = true"
/>
-
+
+
+
+
+
+
+
+
+
+
+
@@ -16,23 +48,33 @@ export default {
i18n: {
'zh-CN': {
link: '复制链接',
+ title: '立即分享给好友',
wechat: '微信',
poster: '分享海报',
qrcode: '二维码',
+ multiLine: '多行展示',
showSheet: '显示分享面板',
+ withTitle: '展示带标题的面板',
+ description: '描述信息',
},
'en-US': {
link: 'Link',
+ title: 'Share with friends',
wechat: 'Wechat',
poster: 'Poster',
qrcode: 'Qrcode',
+ multiLine: 'Multi Line',
showSheet: 'Show ShareSheet',
+ withTitle: 'Show ShareSheet with title',
+ description: 'Description',
},
},
data() {
return {
showBasicSheet: false,
+ showTitleSheet: false,
+ showMultiRowSheet: false,
};
},
@@ -43,6 +85,24 @@ export default {
{ name: this.t('poster'), icon: 'poster' },
{ name: this.t('qrcode'), icon: 'qrcode' },
];
+
+ this.multiLineOptions = [
+ [{ name: this.t('wechat'), icon: 'wechat' }],
+ [
+ { name: this.t('link'), icon: 'link' },
+ { name: this.t('poster'), icon: 'poster' },
+ { name: this.t('qrcode'), icon: 'qrcode' },
+ ],
+ ];
+ },
+
+ methods: {
+ onSelect(option) {
+ this.$toast(option.name);
+ this.showBasicSheet = false;
+ this.showTitleSheet = false;
+ this.showMultiRowSheet = false;
+ },
},
};
diff --git a/src/share-sheet/index.js b/src/share-sheet/index.js
index 9164d9a1c..b1bb9d9cd 100644
--- a/src/share-sheet/index.js
+++ b/src/share-sheet/index.js
@@ -48,6 +48,22 @@ export default createComponent({
return icon;
},
+ genHeader() {
+ if (!this.title && !this.description) {
+ return;
+ }
+
+ const title = this.slots('title') || this.title;
+ const description = this.slots('description') || this.description;
+
+ return (
+
+ );
+ },
+
genOptions() {
return (
@@ -89,6 +105,7 @@ export default createComponent({
safeAreaInsetBottom={this.safeAreaInsetBottom}
onInput={this.toggle}
>
+ {this.genHeader()}
{this.genOptions()}
{this.genCancelText()}
diff --git a/src/share-sheet/index.less b/src/share-sheet/index.less
index 36e0b4643..ae5b2c55b 100644
--- a/src/share-sheet/index.less
+++ b/src/share-sheet/index.less
@@ -1,9 +1,30 @@
@import '../style/var';
.van-share-sheet {
+ &__header {
+ padding: 12px @padding-md @padding-base;
+ text-align: center;
+ }
+
+ &__title {
+ margin-top: @padding-xs;
+ color: @text-color;
+ font-weight: normal;
+ font-size: @font-size-md;
+ line-height: 20px;
+ }
+
+ &__description {
+ display: block;
+ margin-top: @padding-xs;
+ color: @gray-6;
+ font-size: @font-size-sm;
+ line-height: 16px;
+ }
+
&__options {
display: flex;
- padding: 16px 0 16px 24px;
+ padding: @padding-md 0 @padding-md @padding-lg;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
@@ -11,7 +32,8 @@
// see: https://stackoverflow.com/questions/10054870
&::after {
display: block;
- width: 24px;
+ flex-shrink: 0;
+ width: @padding-lg;
content: '';
}
}
@@ -20,12 +42,12 @@
display: flex;
flex-direction: column;
align-items: center;
- margin-right: 32px;
+ margin-right: @padding-xl;
cursor: pointer;
user-select: none;
&:last-child {
- padding-right: 16px;
+ margin-right: 0;
}
&:active {
@@ -39,16 +61,16 @@
}
&__name {
- margin-top: 8px;
- color: #646566;
- font-size: 12px;
+ margin-top: @padding-xs;
+ color: @gray-7;
+ font-size: @font-size-sm;
}
&__cancel {
display: block;
width: 100%;
padding: 0;
- font-size: 16px;
+ font-size: @font-size-lg;
line-height: 48px;
text-align: center;
background-color: @white;
@@ -57,7 +79,7 @@
&::before {
display: block;
- height: 8px;
+ height: @padding-xs;
background-color: @background-color;
content: ' ';
}
diff --git a/src/share-sheet/test/__snapshots__/demo.spec.js.snap b/src/share-sheet/test/__snapshots__/demo.spec.js.snap
index 8c7cde755..aed70df9a 100644
--- a/src/share-sheet/test/__snapshots__/demo.spec.js.snap
+++ b/src/share-sheet/test/__snapshots__/demo.spec.js.snap
@@ -9,5 +9,19 @@ exports[`renders demo correctly 1`] = `
+
+
`;
diff --git a/src/style/var.less b/src/style/var.less
index 13810ad62..10476237b 100644
--- a/src/style/var.less
+++ b/src/style/var.less
@@ -584,6 +584,8 @@
@rate-icon-full-color: #ffd21e;
@rate-icon-disabled-color: #bdbdbd;
+// ShareSheet
+
// Search
@search-padding: 10px @padding-sm;
@search-background-color: @white;