project init

This commit is contained in:
limqhz
2022-11-16 16:49:45 +08:00
parent 82dbb842ba
commit 597b107cf7
78 changed files with 1234 additions and 2524 deletions

View File

@@ -1,57 +0,0 @@
---
title: Cell 单元格
description: 用于各个类别行的信息展示。
spline: data
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-cell": "tdesign-miniprogram/cell/cell"
}
```
## 代码演示
### 单行单元格
<img src="https://tdesign.gtimg.com/miniprogram/readme/cell-1.png" width="375px" height="50%">
{{ base }}
### 多行单元格
<img src="https://tdesign.gtimg.com/miniprogram/readme/cell-2.png" width="375px" height="50%">
{{ multiple }}
## API
### Cell Props
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
align | String | middle | 内容的对齐方式默认居中对齐。可选项top/middle/bottom | N
arrow | Boolean | false | 是否显示右侧箭头 | N
bordered | Boolean | true | 是否显示下边框 | N
description | String / Slot | - | 下方内容描述 | N
external-classes | Array | - | 组件类名,分别用于设置 组件外层类名、标题类名、下方描述内容类名、右侧说明文字类名、激活态类名、图片类名、左侧内容、左侧图标类名、右侧内容、右侧图标类名 等。`['t-class', 't-class-title', 't-class-description', 't-class-note', 't-class-hover', 't-class-image', 't-class-left', 't-class-left-icon', 't-class-right', 't-class-right-icon']` | N
hover | Boolean | - | 是否开启点击反馈 | N
image | String / Slot | - | 主图 | N
jump-type | String | navigateTo | 链接跳转类型。可选项switchTab/reLaunch/redirectTo/navigateTo | N
left-icon | String / Slot | - | 左侧图标,出现在单元格标题的左侧 | N
note | String / Slot | - | 和标题同行的说明文字 | N
required | Boolean | false | 是否显示表单必填星号 | N
right-icon | String / Slot | - | 最右侧图标 | N
title | String / Slot | - | 标题 | N
url | String | - | 点击后跳转链接地址。如果值为空,则表示不需要跳转 | N
### Cell Events
名称 | 参数 | 描述
-- | -- | --
click | - | 右侧内容

View File

@@ -1,14 +0,0 @@
import { SuperComponent } from '../common/src/index';
export default class Cell extends SuperComponent {
externalClasses: string[];
options: {
multipleSlots: boolean;
};
properties: import("./type").TdCellProps;
data: {
prefix: string;
classPrefix: string;
};
onClick(e: any): void;
jumpLink(urlKey?: string, link?: string): void;
}

View File

@@ -1,51 +0,0 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { SuperComponent, wxComponent } from '../common/src/index';
import config from '../common/config';
import props from './props';
const { prefix } = config;
const name = `${prefix}-cell`;
let Cell = class Cell extends SuperComponent {
constructor() {
super(...arguments);
this.externalClasses = [
`${prefix}-class`,
`${prefix}-class-title`,
`${prefix}-class-description`,
`${prefix}-class-note`,
`${prefix}-class-hover`,
`${prefix}-class-image`,
`${prefix}-class-left`,
`${prefix}-class-left-icon`,
`${prefix}-class-right`,
`${prefix}-class-right-icon`,
];
this.options = {
multipleSlots: true,
};
this.properties = props;
this.data = {
prefix,
classPrefix: name,
};
}
onClick(e) {
this.triggerEvent('click', e.detail);
this.jumpLink();
}
jumpLink(urlKey = 'url', link = 'jumpType') {
const url = this.data[urlKey];
const jumpType = this.data[link];
if (url) {
wx[jumpType]({ url });
}
}
};
Cell = __decorate([
wxComponent()
], Cell);
export default Cell;

View File

@@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"t-icon": "../icon/icon"
}
}

View File

@@ -1,40 +0,0 @@
<view
class="{{prefix}}-class {{classPrefix}} {{ hover ? classPrefix + '--hover' : ''}} {{ !bordered ? classPrefix + '--borderless' : ''}} {{classPrefix}}--{{align}}"
hover-class="{{classPrefix}}--hover-class"
hover-stay-time="70"
bind:tap="onClick"
>
<view class="{{classPrefix}}__left {{prefix}}-class-left">
<t-icon wx:if="{{ leftIcon }}" name="{{leftIcon}}" class="{{classPrefix}}__left-icon {{prefix}}-class-left-icon" />
<slot name="left-icon" />
<image wx:if="{{ image }}" class="{{classPrefix}}__left-image {{prefix}}-class-image" src="{{ image }}" />
<slot name="image" />
</view>
<view class="{{classPrefix}}__title {{prefix}}-class-title">
<view class="{{classPrefix}}__title-text">
<block wx:if="{{ title }}"> {{ title}} </block>
<slot name="title" />
<block wx:if="{{required}}">
<text decode class="{{classPrefix}}--required">&nbsp;*</text>
</block>
</view>
<view class="{{classPrefix}}__description {{prefix}}-class-description">
<view wx:if="{{ description }}" class="{{classPrefix}}__description-text">{{description}}</view>
<slot name="description" />
</view>
</view>
<view class="{{classPrefix}}__note {{prefix}}-class-note">
<text wx:if="{{ note }}">{{note}}</text>
<slot name="note" />
</view>
<view class="{{classPrefix}}__right {{prefix}}-class-right">
<t-icon wx:if="{{ arrow }}" name="chevron-right" class="{{classPrefix}}__right-icon {{prefix}}-class-right-icon" />
<block wx:else>
<t-icon name="{{rightIcon}}" class="{{classPrefix}}__right-icon {{prefix}}-class-right-icon" />
<slot name="right-icon" />
</block>
</view>
</view>

View File

@@ -1,121 +0,0 @@
.t-float-left {
float: left;
}
.t-float-right {
float: right;
}
@keyframes tdesign-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.hotspot-expanded.relative {
position: relative;
}
.hotspot-expanded::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
transform: scale(1.5);
}
.t-cell {
position: relative;
display: flex;
box-sizing: border-box;
width: 100%;
padding: 24rpx 32rpx;
font-size: 32rpx;
line-height: 48rpx;
color: rgba(0, 0, 0, 0.9);
background-color: #ffffff;
}
.t-cell::after {
position: absolute;
box-sizing: border-box;
content: ' ';
pointer-events: none;
right: 0;
left: 0;
bottom: 0;
border-bottom: 1px solid #e7e7e7;
transform: scaleY(0.5);
left: 32rpx;
}
.t-cell--borderless::after {
display: none;
}
.t-cell__description {
font-size: 28rpx;
line-height: 44rpx;
color: rgba(0, 0, 0, 0.4);
}
.t-cell__description-text {
margin-top: 8rpx;
}
.t-cell__note {
display: flex;
align-items: center;
justify-content: flex-end;
overflow: hidden;
color: rgba(0, 0, 0, 0.4);
}
.t-cell__title,
.t-cell__note {
flex: 1 1 auto;
}
.t-cell__title:empty,
.t-cell__note:empty {
display: none;
}
.t-cell__title-text {
display: flex;
}
.t-cell__left,
.t-cell__right {
display: flex;
align-items: center;
font-size: 48rpx;
line-height: 48rpx;
}
.t-cell__left :not(:empty) {
margin-right: 16rpx;
}
.t-cell__left-icon {
font-size: 48rpx;
}
.t-cell__left-image {
height: 112rpx;
width: 112rpx;
}
.t-cell__right {
margin-left: 8rpx;
color: #bbb;
}
.t-cell__right-icon {
color: #bbb;
font-size: 48rpx;
line-height: 48rpx;
}
.t-cell--hover.t-cell--hover-class {
background-color: #f2f3f5;
}
.t-cell--required {
font-size: 32rpx;
color: #e34d59;
}
.t-cell--middle {
align-items: center;
}
.t-cell--top {
align-items: flex-start;
}
.t-cell--bottom {
align-items: flex-end;
}

View File

@@ -1,3 +0,0 @@
import { TdCellProps } from './type';
declare const props: TdCellProps;
export default props;

View File

@@ -1,51 +0,0 @@
const props = {
align: {
type: String,
value: 'middle',
},
arrow: {
type: Boolean,
value: false,
},
bordered: {
type: Boolean,
value: true,
},
description: {
type: String,
},
externalClasses: {
type: Array,
},
hover: {
type: Boolean,
},
image: {
type: String,
},
jumpType: {
type: String,
value: 'navigateTo',
},
leftIcon: {
type: String,
},
note: {
type: String,
},
required: {
type: Boolean,
value: false,
},
rightIcon: {
type: String,
},
title: {
type: String,
},
url: {
type: String,
value: '',
},
};
export default props;

View File

@@ -1,72 +0,0 @@
export interface TdCellProps {
align?: {
type: StringConstructor;
value?: 'top' | 'middle' | 'bottom';
required?: boolean;
};
arrow?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
bordered?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
description?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
externalClasses?: {
type: ArrayConstructor;
value?: ['t-class', 't-class-title', 't-class-note', 't-class-description', 't-class-thumb', 't-class-hover', 't-class-left', 't-class-right'];
required?: boolean;
};
hover?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
image?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
jumpType?: {
type: StringConstructor;
value?: 'switchTab' | 'reLaunch' | 'redirectTo' | 'navigateTo';
required?: boolean;
};
leftIcon?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
note?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
required?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
rightIcon?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
title?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
url?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
}

View File

@@ -1 +0,0 @@
export {};