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

feat(Guide): support hideButton props #3403

Merged
merged 1 commit into from
Dec 26, 2024
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
5 changes: 4 additions & 1 deletion src/guide/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
back-button-props | Object | - | Typescript:`ButtonProps` | N
current | Number | - | \- | N
default-current | Number | undefined | uncontrolled property | N
finish-button-props | Object | - | Typescript:`ButtonProps` | N
hide-back | Boolean | false | \- | N
hide-counter | Boolean | false | \- | N
hide-skip | Boolean | false | \- | N
highlight-padding | Number | 16 | \- | N
Expand All @@ -31,6 +33,7 @@ change | `(current: number, context?: { total: number })` | \-
finish | `(detail: { current: number, total: number })` | \-
next-step-click | `(detail: { next: number, current: number, total: number })` | \-
skip | `(detail: { current: number, total: number })` | \-

### Guide External Classes

className | Description
Expand Down Expand Up @@ -58,7 +61,7 @@ finish-button-props | Object | - | Typescript:`ButtonProps` | N
highlight-padding | Number | - | \- | N
mode | String | - | options: popover/dialog | N
next-button-props | Object | - | Typescript:`ButtonProps` | N
offset | Array | - | this api is in discussing. do not use it.。Typescript:`Array<string \| number>` | N
offset | Array | - | this api is in discussing. do not use it。Typescript:`Array<string \| number>` | N
placement | String | 'top' | Typescript:`StepPopoverPlacement ` `type StepPopoverPlacement = 'top'\|'left'\|'right'\|'bottom'\|'top-left'\|'top-right'\|'bottom-left'\|'bottom-right'\|'left-top'\|'left-bottom'\|'right-top'\|'right-bottom'\|'center'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/guide/type.ts) | N
show-overlay | Boolean | true | \- | N
skip-button-props | Object | - | Typescript:`ButtonProps` | N
Expand Down
9 changes: 6 additions & 3 deletions src/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ isComponent: true
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
back-button-props | Object | - | 透传 返回 的全部属性,示例:`{ content: '返回', theme: 'default' }`。TS 类型:`ButtonProps` | N
back-button-props | Object | - | 透传 返回按钮 的全部属性,示例:`{ content: '返回', theme: 'default' }`。TS 类型:`ButtonProps` | N
current | Number | - | 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景 | N
finish-button-props | Object | - | 透传 完成 的全部属性,示例:`{ content: '完成', theme: 'primary' }`。TS 类型:`ButtonProps` | N
default-current | Number | undefined | 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景。非受控属性 | N
finish-button-props | Object | - | 透传 完成按钮 的全部属性,示例:`{ content: '完成', theme: 'primary' }`。TS 类型:`ButtonProps` | N
hide-back | Boolean | false | 是否隐藏返回按钮 | N
hide-counter | Boolean | false | 是否隐藏计数 | N
hide-skip | Boolean | false | 是否隐藏跳过按钮 | N
highlight-padding | Number | 16 | 高亮框的内边距,单位rpx | N
mode | String | popover | 引导框的类型。可选项:popover/dialog | N
next-button-props | Object | - | 透传 下一步按钮 的全部属性,示例:{ content: '下一步', theme: 'primary' }。TS 类型:`ButtonProps`,[Button API Documents](./button?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/guide/type.ts) | N
show-overlay | Boolean | true | 是否出现遮罩层 | N
skip-button-props | Object | - | 透传 跳过按钮 的全部属性,{ content: '跳过', theme: 'default' }。TS 类型:`ButtonProps` | N
steps | Array | - | 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等。TS 类型:`Array<GuideStep>` | N
steps | Array | - | 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等。TS 类型:`Array<GuideStep>` | N
using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N
z-index | Number | 999999 | 提示框的层级 | N

Expand All @@ -79,6 +81,7 @@ change | `(current: number, context?: { total: number })` | 当前步骤发生
finish | `(detail: { current: number, total: number })` | 点击完成按钮时触发
next-step-click | `(detail: { next: number, current: number, total: number })` | 点击下一步时触发
skip | `(detail: { current: number, total: number })` | 点击跳过按钮时触发

### Guide External Classes

类名 | 描述
Expand Down
7 changes: 5 additions & 2 deletions src/guide/content.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
<view wx:if="{{body}}" class="{{prefix}}-class-body {{classPrefix}}__body--{{modeType}}">{{body}}</view>
<slot wx:else name="body-{{current}}" />
</view>
<view class="{{prefix}}-class-footer {{classPrefix}}__footer {{classPrefix}}__footer--{{modeType}}">
<view
wx:if="{{current !== -1}}"
class="{{prefix}}-class-footer {{classPrefix}}__footer {{classPrefix}}__footer--{{modeType}}"
>
<template is="button" wx:if="{{current < steps.length - 1 && !hideSkip}}" data="{{...skipButton}}" />
<template is="button" wx:else data="{{...backButton}}" />
<template is="button" wx:elif="{{current === steps.length - 1 && !hideBack}}" data="{{...backButton}}" />
<template is="button" wx:if="{{current < steps.length - 1}}" data="{{...nextButton}}" />
<template is="button" wx:else data="{{...finishButton}}" />
</view>
Expand Down
7 changes: 7 additions & 0 deletions src/guide/guide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export default class Guide extends SuperComponent {
modeType: '',
};

controlledProps = [
{
key: 'current',
event: 'change',
},
];

observers = {
async 'steps, current, showOverlay'() {
this._init();
Expand Down
2 changes: 1 addition & 1 deletion src/guide/guide.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
>
<template
is="content"
data="{{ prefix, classPrefix, title, body, steps, current, modeType, hideSkip, ...buttonProps }}"
data="{{ prefix, classPrefix, title, body, steps, current, modeType, hideSkip, hideBack, ...buttonProps }}"
/>
</view>
</view>
Expand Down
16 changes: 13 additions & 3 deletions src/guide/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@

import { TdGuideProps } from './type';
const props: TdGuideProps = {
/** 透传 返回 的全部属性,示例:`{ content: '返回', theme: 'default' }` */
/** 透传 返回按钮 的全部属性,示例:`{ content: '返回', theme: 'default' }` */
backButtonProps: {
type: Object,
},
/** 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景 */
current: {
type: Number,
value: null,
},
/** 透传 完成 的全部属性,示例:`{ content: '完成', theme: 'primary' }` */
/** 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景,非受控属性 */
defaultCurrent: {
type: Number,
},
/** 透传 完成按钮 的全部属性,示例:`{ content: '完成', theme: 'primary' }` */
finishButtonProps: {
type: Object,
},
/** 是否隐藏返回按钮 */
hideBack: {
type: Boolean,
value: false,
},
/** 是否隐藏计数 */
hideCounter: {
type: Boolean,
Expand Down Expand Up @@ -51,7 +61,7 @@ const props: TdGuideProps = {
skipButtonProps: {
type: Object,
},
/** 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等 */
/** 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等 */
steps: {
type: Array,
},
Expand Down
21 changes: 18 additions & 3 deletions src/guide/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ButtonProps } from '../button/index';

export interface TdGuideProps {
/**
* 透传 返回 的全部属性,示例:`{ content: '返回', theme: 'default' }`
* 透传 返回按钮 的全部属性,示例:`{ content: '返回', theme: 'default' }`
*/
backButtonProps?: {
type: ObjectConstructor;
Expand All @@ -22,12 +22,27 @@ export interface TdGuideProps {
value?: number;
};
/**
* 透传 完成 的全部属性,示例:`{ content: '完成', theme: 'primary' }`
* 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景,非受控属性
*/
defaultCurrent?: {
type: NumberConstructor;
value?: number;
};
/**
* 透传 完成按钮 的全部属性,示例:`{ content: '完成', theme: 'primary' }`
*/
finishButtonProps?: {
type: ObjectConstructor;
value?: ButtonProps;
};
/**
* 是否隐藏返回按钮
* @default false
*/
hideBack?: {
type: BooleanConstructor;
value?: boolean;
};
/**
* 是否隐藏计数
* @default false
Expand Down Expand Up @@ -83,7 +98,7 @@ export interface TdGuideProps {
value?: ButtonProps;
};
/**
* 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等
* 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等
*/
steps?: {
type: ArrayConstructor;
Expand Down
Loading