Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/dialog/complete doc #83

Merged
merged 2 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions src/button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,33 @@ isComponent: true
### Button Props

| 名称 | 类型 | 默认值 | 说明 | 必传 |
| ---------------------- | ----------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| block | Boolean | false | 是否为块级元素 | N |
| disabled | Boolean | false | 是否禁用按钮 | N |
| external-classes | Array | - | 组件类名。`['t-class', 't-class-icon']` | N |
| ghost | Boolean | false | 是否为幽灵按钮(镂空按钮) | N |
| icon | String | - | 图标名称 | N |
| loading | Boolean | false | 是否显示为加载状态 | N |
| shape | String | square | 按钮形状,有二种:方形、圆角方形。可选项:square/round | N |
| size | String | medium | 组件尺寸。可选项:small/medium/large。TS 类型:`SizeEnum` | N |
| theme | String | undefined | 组件风格,依次为品牌色、危险色。可选项:default/primary/danger | N |
| type | String | - | 同小程序的 formType。可选项:submit/reset | N |
| variant | String | base | 按钮形式,基础、线框、文字。可选项:base/outline/text | N |
| -- | -- | -- | -- | -- |
| block | Boolean | false | 是否为块级元素| N |
| content | String/Slot | '' | 按钮内容 | N |
| disabled | Boolean | false | 是否禁用按钮| N |
| external-classes | Array | - | 组件类名。`['t-class', 't-class-icon']`| N |
| ghost | Boolean | false | 是否为幽灵按钮(镂空按钮)| N |
| icon | String | - | 图标名称| N |
| loading | Boolean | false | 是否显示为加载状态| N |
| shape | String | square | 按钮形状,有二种:方形、圆角方形。可选项:square/round| N |
| size | String | medium | 组件尺寸。可选项:small/medium/large。TS 类型:`SizeEnum`| N |
| theme | String | undefined | 组件风格,依次为品牌色、危险色。可选项:default/primary/danger| N |
| type | String | - | 同小程序的 formType。可选项:submit/reset| N |
| variant | String | base | 按钮形式,基础、线框、文字。可选项:base/outline/text| N |
| open-type | String | - | 微信开放能力 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:contact/share/getPhoneNumber/getUserInfo/launchApp/openSetting/feedback | N |
| hover-stop-propagation | Boolean | false | 指定是否阻止本节点的祖先节点出现点击态 | N |
| hover-start-time | Number | 20 | 按住后多久出现点击态,单位毫秒 | N |
| hover-stay-time | Number | 70 | 手指松开后点击态保留时间,单位毫秒 | N |
| hover-stop-propagation | Boolean | false | 指定是否阻止本节点的祖先节点出现点击态| N |
| hover-start-time | Number | 20 | 按住后多久出现点击态,单位毫秒| N |
| hover-stay-time | Number | 70 | 手指松开后点击态保留时间,单位毫秒| N |
| lang | String | en | 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:en/zh_CN/zh_TW | N |
| session-from | String | - | 会话来源,open-type=contact 时有效 | N |
| send-message-title | String | 当前标题 | 会话内消息卡片标题,open-type=contact 时有效 | N |
| send-message-path | String | 当前分享路径 | 会话内消息卡片点击跳转小程序路径,open-type=contact 时有效 | N |
| send-message-img | String | 截图 | 会话内消息卡片图片,open-type=contact 时有效 | N |
| app-parameter | String | - | 打开 APP 时,向 APP 传递的参数,open-type=launchApp 时有效 | N |
| show-message-card | Boolean | false | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示可能要发送的小程序提示,用户点击后可以快速发送小程序消息,open-type=contact 时有效 | N |
| bindgetuserinfo | Eventhandle | - | 用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与<a href="../api/open-api/user-info/wx.getUserInfo.html">wx.getUserInfo</a>返回的一致,open-type=getUserInfo 时有效 | N |
| bindcontact | Eventhandle | - | 客服消息回调,open-type=contact 时有效 | N |
| bindgetphonenumber | Eventhandle | - | 获取用户手机号回调,open-type=getPhoneNumber 时有效 | N |
| binderror | Eventhandle | - | 当使用开放能力时,发生错误的回调,open-type=launchApp 时有效 | N |
| bindopensetting | Eventhandle | - | 在打开授权设置页后回调,open-type=openSetting 时有效 | N |
| bindlaunchapp | Eventhandle | - | 打开 APP 成功的回调,open-type=launchApp 时有效 | N |
| session-from | String | - | 会话来源,open-type=contact 时有效 | N |
| send-message-title | String | 当前标题 | 会话内消息卡片标题,open-type=contact 时有效 | N |
| send-message-path | String | 当前分享路径 | 会话内消息卡片点击跳转小程序路径,open-type=contact 时有效 | N |
| send-message-img | String | 截图 | 会话内消息卡片图片,open-type=contact 时有效 | N |
| app-parameter | String | - | 打开 APP 时,向 APP 传递的参数,open-type=launchApp 时有效 | N |
| show-message-card | Boolean | false | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示可能要发送的小程序提示,用户点击后可以快速发送小程序消息,open-type=contact 时有效 | N |
| bindgetuserinfo | Eventhandle | - | 用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与<a href="../api/open-api/user-info/wx.getUserInfo.html">wx.getUserInfo</a>返回的一致,open-type=getUserInfo 时有效 | N |
| bindcontact | Eventhandle | - | 客服消息回调,open-type=contact | N |
| bindgetphonenumber | Eventhandle | - | 获取用户手机号回调,open-type=getPhoneNumber 时有效 | N |
| binderror | Eventhandle | - | 当使用开放能力时,发生错误的回调,open-type=launchApp 时有效 | N |
| bindopensetting | Eventhandle | - | 在打开授权设置页后回调,open-type=openSetting 时有效 | N |
| bindlaunchapp | Eventhandle | - | 打开 APP 成功的回调,open-type=launchApp 时有效 | N |
2 changes: 1 addition & 1 deletion src/button/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
}
}

&.@{prefix}-size {
&--size {
&-l {
display: flex;
margin: 0 32rpx;
Expand Down
2 changes: 1 addition & 1 deletion src/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class Button extends SuperComponent {
name,
`${prefix}-class`,
`${name}--${this.data.theme || 'default'}`,
`${prefix}-size-${this.data.size.slice(0, 1)}`,
`${name}--size-${this.data.size.slice(0, 1)}`,
];

classList.push(`${name}--${this.data.shape}`);
Expand Down
2 changes: 2 additions & 0 deletions src/button/button.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@
class="{{classPrefix}}__icon {{prefix}}-class-icon"
></t-icon>
<slot />
<slot name="content" />
{{content || ''}}
</button>
5 changes: 5 additions & 0 deletions src/button/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const props: TdButtonProps = {
type: Boolean,
value: false,
},
/** 按钮内容 */
content: {
type: String,
value: '',
},
/** 是否禁用按钮 */
disabled: {
type: Boolean,
Expand Down
8 changes: 8 additions & 0 deletions src/button/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export interface TdButtonProps {
value?: boolean;
required?: boolean;
};
/**
* 按钮内容
*/
content?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
/**
* 是否禁用按钮
* @default false
Expand Down
30 changes: 30 additions & 0 deletions src/common/template/button.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template name="button">
<t-button
t-class="{{externalClass}}"
disabled="{{disabled}}"
data-type="{{type}}"
icon="{{icon}}"
loading="{{loading}}"
theme="{{theme}}"
open-type="{{openType}}"
hover-stop-propagation="{{hoverStopPropagation}}"
hover-start-time="{{hoverStartTime}}"
hover-stay-time="{{hoverStayTime}}"
lang="{{lang}}"
session-from="{{sessionFrom}}"
send-message-title="{{sendMessageTitle}}"
send-message-path="{{sendMessagePath}}"
send-message-img="{{sendMessageImg}}"
app-parameter="{{appParameter}}"
show-message-card="{{showMessageCard}}"
bind:tap="onTplButtonTap"
bind:getuserinfo="onTplButtonTap"
bind:contact="onTplButtonTap"
bind:getphonenumber="onTplButtonTap"
bind:error="onTplButtonTap"
bind:opensetting="onTplButtonTap"
bind:launchapp="onTplButtonTap"
>
{{content}}
</t-button>
</template>
Loading