Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(Guide): init #1238

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions site/docs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@ export const docs = [
component: () => import('@/dialog/dialog.md'),
componentEn: () => import('@/dialog/dialog.en-US.md'),
},
{
title: 'Guide 引导',
titleEn: 'Guide',
name: 'guide',
path: '/mobile-vue/components/guide',
component: () => import('@/guide/guide.md'),
componentEn: () => import('@/guide/guide.en-US.md'),
},
{
title: 'Popover 弹出气泡',
titleEn: 'Popover',
Expand Down
11 changes: 8 additions & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type OptionData = {
} & PlainObject;

export type TreeOptionData<T = string | number> = {
children?: Array<TreeOptionData<T>>;
children?: Array<TreeOptionData<T>> | boolean;
/** option label content */
label?: string | TNode;
/** option search text */
Expand All @@ -68,6 +68,11 @@ export type HorizontalAlignEnum = 'left' | 'center' | 'right';

export type VerticalAlignEnum = 'top' | 'middle' | 'bottom';

export enum LayoutEnum {
VERTICAL = 'vertical',
HORIZONTAL = 'horizontal',
}

export type ClassName = { [className: string]: any } | ClassName[] | string;

export type CSSSelector = string;
Expand Down Expand Up @@ -119,7 +124,7 @@ export type InfinityScroll = TScroll;

export interface ScrollToElementParams {
/** 跳转元素下标 */
index: number;
index?: number;
/** 跳转元素距离顶部的距离 */
top?: number;
/** 单个元素高度非固定场景下,即 isFixedRowHeight = false。延迟设置元素位置,一般用于依赖不同高度异步渲染等场景,单位:毫秒 */
Expand All @@ -128,5 +133,5 @@ export interface ScrollToElementParams {
}

export interface ComponentScrollToElementParams extends ScrollToElementParams {
key: string | number;
key?: string | number;
}
16 changes: 16 additions & 0 deletions src/guide/demos/mobile.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div class="tdesign-mobile-demo">
<h1 class="title">Guide 引导</h1>
<p class="summary">按钮用于开启一个闭环的操作任务,如“删除”对象、“购买”商品等。</p>
<tdesign-demo-block title="01 组件类型" summary="基础引导">
<span>User guide 触发新手引导</span>
</tdesign-demo-block>
</div>
</template>
<script lang="ts" setup></script>

<style scoped>
.tdesign-mobile-demo {
background-color: #fff;
}
</style>
54 changes: 54 additions & 0 deletions src/guide/guide.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
:: BASE_DOC ::

## API

### Guide Props

name | type | default | description | required
-- | -- | -- | -- | --
counter | Slot / Function | - | Typescript:`TNode<{ current: number; total: number }>`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
current | Number | - | `v-model` and `v-model:current` is supported | N
defaultCurrent | Number | - | uncontrolled property | N
finishButtonProps | Object | - | Typescript:`ButtonProps` | N
hideCounter | Boolean | false | \- | N
hideSkip | Boolean | false | \- | N
highlightPadding | Number | 8 | \- | N
mode | String | popup | options: popup/dialog | N
nextButtonProps | Object | - | Typescript:`ButtonProps`,[Button API Documents](./button?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/guide/type.ts) | N
showOverlay | Boolean | true | \- | N
skipButtonProps | Object | - | Typescript:`ButtonProps` | N
steps | Array | - | Typescript:`Array<GuideStep>` | N
zIndex | Number | 999999 | \- | N
onChange | Function | | Typescript:`(current: number, context?: { e: MouseEvent, total: number }) => void`<br/> | N
onFinish | Function | | Typescript:`(context: { e: MouseEvent, current: number, total: number }) => void`<br/> | N
onNextStepClick | Function | | Typescript:`(context: { e: MouseEvent, next: number, current: number, total: number }) => void`<br/> | N
onSkip | Function | | Typescript:`(context: { e: MouseEvent, current: number, total: number }) => void`<br/> | N

### Guide Events

name | params | description
-- | -- | --
change | `(current: number, context?: { e: MouseEvent, total: number })` | \-
finish | `(context: { e: MouseEvent, current: number, total: number })` | \-
next-step-click | `(context: { e: MouseEvent, next: number, current: number, total: number })` | \-
skip | `(context: { e: MouseEvent, current: number, total: number })` | \-

### GuideStep

name | type | default | description | required
-- | -- | -- | -- | --
body | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
content | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
element | String / Function | - | required。Typescript:`AttachNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | Y
highlightContent | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
highlightPadding | Number | - | \- | N
mode | String | - | options: popup/dialog | N
nextButtonProps | Object | - | Typescript:`ButtonProps` | N
offset | Array | - | this api is in discussing. do not use it.。Typescript:`Array<string \| number>` | N
placement | String | 'top' | Typescript:`StepPopupPlacement \| StepDialogPlacement` `type StepPopupPlacement = 'top'\|'left'\|'right'\|'bottom'\|'top-left'\|'top-right'\|'bottom-left'\|'bottom-right'\|'left-top'\|'left-bottom'\|'right-top'\|'right-bottom'` `type StepDialogPlacement = 'top'\|'center' `。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/guide/type.ts) | N
popupProps | Object | - | Popup component props if `mode = popup`。Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/guide/type.ts) | N
prevButtonProps | Object | - | Typescript:`ButtonProps` | N
showOverlay | Boolean | true | \- | N
skipButtonProps | Object | - | Typescript:`ButtonProps` | N
stepOverlayClass | String | - | \- | N
title | String | - | \- | N
54 changes: 54 additions & 0 deletions src/guide/guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
:: BASE_DOC ::

## API

### Guide Props

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
counter | Slot / Function | - | 用于自定义渲染计数部分。TS 类型:`TNode<{ current: number; total: number }>`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
current | Number | - | 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景。支持语法糖 `v-model` 或 `v-model:current` | N
defaultCurrent | Number | - | 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景。非受控属性 | N
finishButtonProps | Object | - | 透传 完成 的全部属性,示例:`{ content: '完成', theme: 'primary' }`。TS 类型:`ButtonProps` | N
hideCounter | Boolean | false | 是否隐藏计数 | N
hideSkip | Boolean | false | 是否隐藏跳过按钮 | N
highlightPadding | Number | 8 | 高亮框的内边距 | N
mode | String | popup | 引导框的类型。可选项:popup/dialog | N
nextButtonProps | Object | - | 透传 下一步按钮 的全部属性,示例:{ content: '下一步', theme: 'primary' }。TS 类型:`ButtonProps`,[Button API Documents](./button?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/guide/type.ts) | N
showOverlay | Boolean | true | 是否出现遮罩层 | N
skipButtonProps | Object | - | 透传 跳过按钮 的全部属性,{ content: '跳过', theme: 'default' }。TS 类型:`ButtonProps` | N
steps | Array | - | 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等。。TS 类型:`Array<GuideStep>` | N
zIndex | Number | 999999 | 提示框的层级 | N
onChange | Function | | TS 类型:`(current: number, context?: { e: MouseEvent, total: number }) => void`<br/>当前步骤发生变化时触发 | N
onFinish | Function | | TS 类型:`(context: { e: MouseEvent, current: number, total: number }) => void`<br/>点击完成按钮时触发 | N
onNextStepClick | Function | | TS 类型:`(context: { e: MouseEvent, next: number, current: number, total: number }) => void`<br/>点击下一步时触发 | N
onSkip | Function | | TS 类型:`(context: { e: MouseEvent, current: number, total: number }) => void`<br/>点击跳过按钮时触发 | N

### Guide Events

名称 | 参数 | 描述
-- | -- | --
change | `(current: number, context?: { e: MouseEvent, total: number })` | 当前步骤发生变化时触发
finish | `(context: { e: MouseEvent, current: number, total: number })` | 点击完成按钮时触发
next-step-click | `(context: { e: MouseEvent, next: number, current: number, total: number })` | 点击下一步时触发
skip | `(context: { e: MouseEvent, current: number, total: number })` | 点击跳过按钮时触发

### GuideStep

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
body | String / Slot / Function | - | 当前步骤提示框的内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
content | Slot / Function | - | 用户自定义引导弹框的内容,一旦存在,此时除 `placement`、`offset`和`element` 外,其它属性全部失效)。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
element | String / Function | - | 必需。高亮的节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'#tdesign' 或 () => document.querySelector('#tdesign')。TS 类型:`AttachNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | Y
highlightContent | Slot / Function | - | 用户自定义的高亮框 (仅当 `mode` 为 `popup` 时生效)。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
highlightPadding | Number | - | 高亮框的内边距 | N
mode | String | - | 引导框的类型。可选项:popup/dialog | N
nextButtonProps | Object | - | 用于自定义当前引导框的下一步按钮的内容。TS 类型:`ButtonProps` | N
offset | Array | - | 【讨论确认中】相对于 placement 的偏移量,示例:[-10, 20] 或 ['10px', '8px']。TS 类型:`Array<string \| number>` | N
placement | String | 'top' | 引导框相对于高亮元素出现的位置。TS 类型:`StepPopupPlacement \| StepDialogPlacement` `type StepPopupPlacement = 'top'\|'left'\|'right'\|'bottom'\|'top-left'\|'top-right'\|'bottom-left'\|'bottom-right'\|'left-top'\|'left-bottom'\|'right-top'\|'right-bottom'` `type StepDialogPlacement = 'top'\|'center' `。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/guide/type.ts) | N
popupProps | Object | - | 透传全部属性到 Popup 组件。`mode=popup` 时有效。TS 类型:`PopupProps`,[Popup API Documents](./popup?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/guide/type.ts) | N
prevButtonProps | Object | - | 用于自定义当前引导框的上一步按钮的内容。TS 类型:`ButtonProps` | N
showOverlay | Boolean | true | 是否出现遮罩层 | N
skipButtonProps | Object | - | 用于自定义当前步骤引导框的跳过按钮的内容。TS 类型:`ButtonProps` | N
stepOverlayClass | String | - | 覆盖引导框的类名 | N
title | String | - | 当前步骤的标题内容 | N
80 changes: 80 additions & 0 deletions src/guide/props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdGuideProps } from './type';
import { PropType } from 'vue';

export default {
/** 用于自定义渲染计数部分 */
counter: {
type: Function as PropType<TdGuideProps['counter']>,
},
/** 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景 */
current: {
type: Number,
default: undefined,
},
modelValue: {
type: Number,
default: undefined,
},
/** 当前步骤,即整个引导的进度。-1 则不展示,用于需要中断展示的场景,非受控属性 */
defaultCurrent: {
type: Number,
},
/** 透传 完成 的全部属性,示例:`{ content: '完成', theme: 'primary' }` */
finishButtonProps: {
type: Object as PropType<TdGuideProps['finishButtonProps']>,
},
/** 是否隐藏计数 */
hideCounter: Boolean,
/** 是否隐藏跳过按钮 */
hideSkip: Boolean,
/** 高亮框的内边距 */
highlightPadding: {
type: Number,
default: 8,
},
/** 引导框的类型 */
mode: {
type: String as PropType<TdGuideProps['mode']>,
default: 'popup' as TdGuideProps['mode'],
validator(val: TdGuideProps['mode']): boolean {
if (!val) return true;
return ['popup', 'dialog'].includes(val);
},
},
/** 透传 下一步按钮 的全部属性,示例:{ content: '下一步', theme: 'primary' } */
nextButtonProps: {
type: Object as PropType<TdGuideProps['nextButtonProps']>,
},
/** 是否出现遮罩层 */
showOverlay: {
type: Boolean,
default: true,
},
/** 透传 跳过按钮 的全部属性,{ content: '跳过', theme: 'default' } */
skipButtonProps: {
type: Object as PropType<TdGuideProps['skipButtonProps']>,
},
/** 用于定义每个步骤的内容,包括高亮的节点、相对位置和具体的文案内容等。 */
steps: {
type: Array as PropType<TdGuideProps['steps']>,
},
/** 提示框的层级 */
zIndex: {
type: Number,
default: 999999,
},
/** 当前步骤发生变化时触发 */
onChange: Function as PropType<TdGuideProps['onChange']>,
/** 点击完成按钮时触发 */
onFinish: Function as PropType<TdGuideProps['onFinish']>,
/** 点击下一步时触发 */
onNextStepClick: Function as PropType<TdGuideProps['onNextStepClick']>,
/** 点击跳过按钮时触发 */
onSkip: Function as PropType<TdGuideProps['onSkip']>,
};
Loading
Loading