project init & fix ui
This commit is contained in:
23
miniprogram_npm/tdesign-miniprogram/link/README.en-US.md
Normal file
23
miniprogram_npm/tdesign-miniprogram/link/README.en-US.md
Normal file
@@ -0,0 +1,23 @@
|
||||
:: BASE_DOC ::
|
||||
|
||||
## API
|
||||
### Link Props
|
||||
|
||||
name | type | default | description | required
|
||||
-- | -- | -- | -- | --
|
||||
content | String / Slot | - | \- | N
|
||||
navigator-props | Object | - | \- | N
|
||||
prefix-icon | String / Object / Slot | - | \- | N
|
||||
size | String | medium | options:small/medium/large。Typescript:`SizeEnum` | N
|
||||
status | String | normal | options:normal/active/disabled | N
|
||||
suffix-icon | String / Object / Slot | - | \- | N
|
||||
theme | String | default | options:default/primary/danger/warning/success | N
|
||||
underline | Boolean | - | \- | N
|
||||
|
||||
### Link Events
|
||||
|
||||
name | params | description
|
||||
-- | -- | --
|
||||
complete | \- | \-
|
||||
fail | \- | \-
|
||||
success | \- | \-
|
||||
81
miniprogram_npm/tdesign-miniprogram/link/README.md
Normal file
81
miniprogram_npm/tdesign-miniprogram/link/README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
---
|
||||
title: Link 链接
|
||||
description: 文字超链接用于跳转一个新页面,如当前项目跳转,友情链接等。
|
||||
spline: navigation
|
||||
isComponent: true
|
||||
---
|
||||
|
||||
<div style="background: #ecf2fe; display: flex; align-items: center; line-height: 20px; padding: 14px 24px; border-radius: 3px; color: #555a65">
|
||||
<svg fill="none" viewBox="0 0 16 16" width="16px" height="16px" style="margin-right: 5px">
|
||||
<path fill="#0052d9" d="M8 15A7 7 0 108 1a7 7 0 000 14zM7.4 4h1.2v1.2H7.4V4zm.1 2.5h1V12h-1V6.5z" fillOpacity="0.9"></path>
|
||||
</svg>
|
||||
该组件于 0.32.0 版本上线,请留意版本。
|
||||
</div>
|
||||
|
||||
## 引入
|
||||
|
||||
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
|
||||
|
||||
```json
|
||||
"usingComponents": {
|
||||
"t-link": "tdesign-miniprogram/link/link",
|
||||
}
|
||||
```
|
||||
|
||||
## 代码演示
|
||||
|
||||
### 组件类型
|
||||
|
||||
基础文字链接
|
||||
|
||||
{{ content }}
|
||||
|
||||
下划线文字链接
|
||||
|
||||
{{ underline }}
|
||||
|
||||
前置图标文字链接
|
||||
|
||||
{{ prefix }}
|
||||
|
||||
后置图标文字链接
|
||||
|
||||
{{ suffix }}
|
||||
|
||||
### 组件状态
|
||||
|
||||
不同主题
|
||||
|
||||
{{ theme }}
|
||||
|
||||
禁用状态
|
||||
|
||||
{{ status }}
|
||||
|
||||
### 组件样式
|
||||
|
||||
链接尺寸
|
||||
|
||||
{{ size }}
|
||||
|
||||
## API
|
||||
### Link Props
|
||||
|
||||
名称 | 类型 | 默认值 | 说明 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
content | String / Slot | - | 链接内容 | N
|
||||
navigator-props | Object | - | 与 navigator 原生组件属性保持一致,具体使用参考:https://developers.weixin.qq.com/miniprogram/dev/component/navigator.html。 | N
|
||||
prefix-icon | String / Object / Slot | - | 前置图标 | N
|
||||
size | String | medium | 尺寸。可选项:small/medium/large。TS 类型:`SizeEnum` | N
|
||||
status | String | normal | 组件状态。可选项:normal/active/disabled | N
|
||||
suffix-icon | String / Object / Slot | - | 前置图标 | N
|
||||
theme | String | default | 组件风格,依次为默认色、品牌色、危险色、警告色、成功色。可选项:default/primary/danger/warning/success | N
|
||||
underline | Boolean | - 是否显示链接下划线 | N
|
||||
|
||||
### Link Events
|
||||
|
||||
名称 | 参数 | 描述
|
||||
-- | -- | --
|
||||
complete | \- | 页面链接执行完成后触发(失败或成功均会触发)
|
||||
fail | \- | 页面链接跳转失败后触发
|
||||
success | \- | 页面链接跳转成功后触发
|
||||
23
miniprogram_npm/tdesign-miniprogram/link/link.d.ts
vendored
Normal file
23
miniprogram_npm/tdesign-miniprogram/link/link.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
export default class Link extends SuperComponent {
|
||||
externalClasses: any[];
|
||||
properties: import("./type").TdLinkProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
};
|
||||
observers: {
|
||||
'theme, status, size, underline, navigatorProps'(): void;
|
||||
prefixIcon(prefixIcon: any): void;
|
||||
suffixIcon(suffixIcon: any): void;
|
||||
};
|
||||
lifetimes: {
|
||||
attached(): void;
|
||||
};
|
||||
methods: {
|
||||
setClass(): void;
|
||||
onSuccess(e: any): void;
|
||||
onFail(e: any): void;
|
||||
onComplete(e: any): void;
|
||||
};
|
||||
}
|
||||
69
miniprogram_npm/tdesign-miniprogram/link/link.js
Normal file
69
miniprogram_npm/tdesign-miniprogram/link/link.js
Normal file
@@ -0,0 +1,69 @@
|
||||
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';
|
||||
import { setIcon } from '../common/utils';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-link`;
|
||||
let Link = class Link extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.externalClasses = [];
|
||||
this.properties = props;
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
};
|
||||
this.observers = {
|
||||
'theme, status, size, underline, navigatorProps'() {
|
||||
this.setClass();
|
||||
},
|
||||
prefixIcon(prefixIcon) {
|
||||
const obj = setIcon('prefixIcon', prefixIcon, '');
|
||||
this.setData(Object.assign({}, obj));
|
||||
},
|
||||
suffixIcon(suffixIcon) {
|
||||
const obj = setIcon('suffixIcon', suffixIcon, '');
|
||||
this.setData(Object.assign({}, obj));
|
||||
},
|
||||
};
|
||||
this.lifetimes = {
|
||||
attached() {
|
||||
this.setClass();
|
||||
},
|
||||
};
|
||||
this.methods = {
|
||||
setClass() {
|
||||
const { theme, status, size, underline, navigatorProps } = this.properties;
|
||||
const classList = [name, `${name}--${status}-${theme}`, `${name}--${size}`];
|
||||
if (underline) {
|
||||
classList.push(`${name}--underline`);
|
||||
}
|
||||
if ((navigatorProps && !navigatorProps.url) || status === 'disabled') {
|
||||
classList.push(`${name}--disabled`);
|
||||
}
|
||||
this.setData({
|
||||
className: classList.join(' '),
|
||||
});
|
||||
},
|
||||
onSuccess(e) {
|
||||
this.triggerEvent('success', e);
|
||||
},
|
||||
onFail(e) {
|
||||
this.triggerEvent('fail', e);
|
||||
},
|
||||
onComplete(e) {
|
||||
this.triggerEvent('complete', e);
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
Link = __decorate([
|
||||
wxComponent()
|
||||
], Link);
|
||||
export default Link;
|
||||
6
miniprogram_npm/tdesign-miniprogram/link/link.json
Normal file
6
miniprogram_npm/tdesign-miniprogram/link/link.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-icon": "../icon/icon"
|
||||
}
|
||||
}
|
||||
44
miniprogram_npm/tdesign-miniprogram/link/link.wxml
Normal file
44
miniprogram_npm/tdesign-miniprogram/link/link.wxml
Normal file
@@ -0,0 +1,44 @@
|
||||
<import src="../common/template/icon.wxml" />
|
||||
<wxs src="../common/utils.wxs" module="_" />
|
||||
|
||||
<navigator
|
||||
class="{{className}} {{prefix}}-class"
|
||||
target="{{navigatorProps.target}}"
|
||||
url="{{navigatorProps.url}}"
|
||||
open-type="{{navigatorProps.openType || 'navigate'}}"
|
||||
delta="{{navigatorProps.delta}}"
|
||||
app-id="{{navigatorProps.appId}}"
|
||||
path="{{navigatorProps.path}}"
|
||||
extra-data="{{navigatorProps.extraData}}"
|
||||
version="{{navigatorProps.version}}"
|
||||
short-link="{{navigatorProps.shortLink}}"
|
||||
hover-class="{{navigatorProps.hoverClass}}"
|
||||
hover-stop-propagation="navigatorProps.hoverStopPropagation"
|
||||
hover-start-time="{{navigatorProps.hoverStartTime}}"
|
||||
hover-stay-time="{{navigatorProps.hoverStayTime}}"
|
||||
bindsuccess="onSuccess"
|
||||
bindfail="onFail"
|
||||
bindcomplete="onComplete"
|
||||
aria-disabled="{{status === 'disabled'}}"
|
||||
>
|
||||
<view wx:if="{{prefixIconName || _.isNoEmptyObj(prefixIconData)}}" class="{{classPrefix}}__prefix-icon">
|
||||
<slot wx:if="{{prefixIconName === 'slot'}}" name="prefix-icon" />
|
||||
<template
|
||||
wx:else
|
||||
is="icon"
|
||||
data="{{tClass: prefix + '-class-prefix-icon', name: prefixIconName, ariaHidden: true, ...prefixIconData}}"
|
||||
/>
|
||||
</view>
|
||||
<view class="{{classPrefix}}__content {{prefix}}-class-content">
|
||||
<block wx:if="{{content}}">{{content}}</block>
|
||||
<slot name="content" />
|
||||
</view>
|
||||
<view wx:if="{{suffixIconName || _.isNoEmptyObj(suffixIconData)}}" class="{{classPrefix}}__suffix-icon">
|
||||
<slot wx:if="{{suffixIconName === 'slot'}}" name="suffix-icon" />
|
||||
<template
|
||||
wx:else
|
||||
is="icon"
|
||||
data="{{tClass: prefix + '-class-suffix-icon', name: suffixIconName, ariaHidden: true, ...suffixIconData}}"
|
||||
/>
|
||||
</view>
|
||||
</navigator>
|
||||
163
miniprogram_npm/tdesign-miniprogram/link/link.wxss
Normal file
163
miniprogram_npm/tdesign-miniprogram/link/link.wxss
Normal file
@@ -0,0 +1,163 @@
|
||||
.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-link--small .t-link__content {
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.t-link--small .t-link__prefix-icon,
|
||||
.t-link--small .t-link__suffix-icon {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.t-link--medium .t-link__content {
|
||||
font-size: 28rpx;
|
||||
line-height: 44rpx;
|
||||
}
|
||||
.t-link--medium .t-link__prefix-icon,
|
||||
.t-link--medium .t-link__suffix-icon {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.t-link--large .t-link__content {
|
||||
font-size: 32rpx;
|
||||
line-height: 48rpx;
|
||||
}
|
||||
.t-link--large .t-link__prefix-icon,
|
||||
.t-link--large .t-link__suffix-icon {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
.t-link--normal-primary {
|
||||
color: var(--td-link-normal-primary-color, var(--td-brand-color, var(--td-primary-color-8, #0052d9)));
|
||||
}
|
||||
.t-link--normal-primary.t-link--underline::after {
|
||||
border-color: var(--td-link-normal-primary-color, var(--td-brand-color, var(--td-primary-color-8, #0052d9)));
|
||||
}
|
||||
.t-link--normal-success {
|
||||
color: var(--td-link-normal-success-color, var(--td-success-color, var(--td-success-color-5, #00a870)));
|
||||
}
|
||||
.t-link--normal-success.t-link--underline::after {
|
||||
border-color: var(--td-link-normal-success-color, var(--td-success-color, var(--td-success-color-5, #00a870)));
|
||||
}
|
||||
.t-link--normal-warning {
|
||||
color: var(--td-link-normal-warning-color, var(--td-warning-color, var(--td-warning-color-5, #ed7b2f)));
|
||||
}
|
||||
.t-link--normal-warning.t-link--underline::after {
|
||||
border-color: var(--td-link-normal-warning-color, var(--td-warning-color, var(--td-warning-color-5, #ed7b2f)));
|
||||
}
|
||||
.t-link--normal-default {
|
||||
color: var(--td-link-normal-default-color, var(--td-font-gray-1, rgba(0, 0, 0, 0.9)));
|
||||
}
|
||||
.t-link--normal-default.t-link--underline::after {
|
||||
border-color: var(--td-link-normal-default-color, var(--td-font-gray-1, rgba(0, 0, 0, 0.9)));
|
||||
}
|
||||
.t-link--normal-danger {
|
||||
color: var(--td-link-normal-danger-color, var(--td-error-color, var(--td-error-color-6, #e34d59)));
|
||||
}
|
||||
.t-link--normal-danger.t-link--underline::after {
|
||||
border-color: var(--td-link-normal-danger-color, var(--td-error-color, var(--td-error-color-6, #e34d59)));
|
||||
}
|
||||
.t-link--active-primary {
|
||||
color: var(--td-link-active-primary-color, var(--td-brand-color-active, var(--td-primary-color-9, #0034b5)));
|
||||
}
|
||||
.t-link--active-primary.t-link--underline::after {
|
||||
border-color: var(--td-link-active-primary-color, var(--td-brand-color-active, var(--td-primary-color-9, #0034b5)));
|
||||
}
|
||||
.t-link--active-success {
|
||||
color: var(--td-link-active-success-color, var(--td-success-color-active, var(--td-success-color-6, #078d5c)));
|
||||
}
|
||||
.t-link--active-success.t-link--underline::after {
|
||||
border-color: var(--td-link-active-success-color, var(--td-success-color-active, var(--td-success-color-6, #078d5c)));
|
||||
}
|
||||
.t-link--active-warning {
|
||||
color: var(--td-link-active-warning-color, var(--td-warning-color-active, var(--td-warning-color-6, #d35a21)));
|
||||
}
|
||||
.t-link--active-warning.t-link--underline::after {
|
||||
border-color: var(--td-link-active-warning-color, var(--td-warning-color-active, var(--td-warning-color-6, #d35a21)));
|
||||
}
|
||||
.t-link--active-default {
|
||||
color: var(--td-link-active-default-color, var(--td-brand-color-active, var(--td-primary-color-9, #0034b5)));
|
||||
}
|
||||
.t-link--active-default.t-link--underline::after {
|
||||
border-color: var(--td-link-active-default-color, var(--td-brand-color-active, var(--td-primary-color-9, #0034b5)));
|
||||
}
|
||||
.t-link--active-danger {
|
||||
color: var(--td-link-active-danger-color, var(--td-error-color-active, var(--td-error-color-7, #c9353f)));
|
||||
}
|
||||
.t-link--active-danger.t-link--underline::after {
|
||||
border-color: var(--td-link-active-danger-color, var(--td-error-color-active, var(--td-error-color-7, #c9353f)));
|
||||
}
|
||||
.t-link--disabled-primary {
|
||||
color: var(--td-link-disabled-primary-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #bbd3fb)));
|
||||
}
|
||||
.t-link--disabled-primary.t-link--underline::after {
|
||||
border-color: var(--td-link-disabled-primary-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #bbd3fb)));
|
||||
}
|
||||
.t-link--disabled-success {
|
||||
color: var(--td-link-disabled-success-color, var(--td-success-color-disabled, var(--td-success-color-3, #85dbbe)));
|
||||
}
|
||||
.t-link--disabled-success.t-link--underline::after {
|
||||
border-color: var(--td-link-disabled-success-color, var(--td-success-color-disabled, var(--td-success-color-3, #85dbbe)));
|
||||
}
|
||||
.t-link--disabled-warning {
|
||||
color: var(--td-link-disabled-warning-color, var(--td-warning-color-disabled, var(--td-warning-color-3, #f7c797)));
|
||||
}
|
||||
.t-link--disabled-warning.t-link--underline::after {
|
||||
border-color: var(--td-link-disabled-warning-color, var(--td-warning-color-disabled, var(--td-warning-color-3, #f7c797)));
|
||||
}
|
||||
.t-link--disabled-default {
|
||||
color: var(--td-link-disabled-default-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, 0.26))));
|
||||
}
|
||||
.t-link--disabled-default.t-link--underline::after {
|
||||
border-color: var(--td-link-disabled-default-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, 0.26))));
|
||||
}
|
||||
.t-link--disabled-danger {
|
||||
color: var(--td-link-disabled-danger-color, var(--td-error-color-disabled, var(--td-error-color-3, #f8b9be)));
|
||||
}
|
||||
.t-link--disabled-danger.t-link--underline::after {
|
||||
border-color: var(--td-link-disabled-danger-color, var(--td-error-color-disabled, var(--td-error-color-3, #f8b9be)));
|
||||
}
|
||||
.t-link {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.t-link--underline::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 0;
|
||||
bottom: 0;
|
||||
opacity: 1;
|
||||
border-bottom: 1px solid #cd0be7;
|
||||
}
|
||||
.t-link__prefix-icon + .t-link__content:not(:empty) {
|
||||
padding-left: 8rpx;
|
||||
}
|
||||
.t-link__content:not(:empty) + .t-link__suffix-icon {
|
||||
padding-left: 8rpx;
|
||||
}
|
||||
3
miniprogram_npm/tdesign-miniprogram/link/props.d.ts
vendored
Normal file
3
miniprogram_npm/tdesign-miniprogram/link/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdLinkProps } from './type';
|
||||
declare const props: TdLinkProps;
|
||||
export default props;
|
||||
30
miniprogram_npm/tdesign-miniprogram/link/props.js
Normal file
30
miniprogram_npm/tdesign-miniprogram/link/props.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const props = {
|
||||
content: {
|
||||
type: String,
|
||||
},
|
||||
navigatorProps: {
|
||||
type: Object,
|
||||
},
|
||||
prefixIcon: {
|
||||
type: null,
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
value: 'medium',
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
value: 'normal',
|
||||
},
|
||||
suffixIcon: {
|
||||
type: null,
|
||||
},
|
||||
theme: {
|
||||
type: String,
|
||||
value: 'default',
|
||||
},
|
||||
underline: {
|
||||
type: Boolean,
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
35
miniprogram_npm/tdesign-miniprogram/link/type.d.ts
vendored
Normal file
35
miniprogram_npm/tdesign-miniprogram/link/type.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { SizeEnum } from '../common/common';
|
||||
export interface TdLinkProps {
|
||||
content?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
navigatorProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: object;
|
||||
};
|
||||
prefixIcon?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
size?: {
|
||||
type: StringConstructor;
|
||||
value?: SizeEnum;
|
||||
};
|
||||
status?: {
|
||||
type: StringConstructor;
|
||||
value?: 'normal' | 'active' | 'disabled';
|
||||
};
|
||||
suffixIcon?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: 'default' | 'primary' | 'danger' | 'warning' | 'success';
|
||||
};
|
||||
underline?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/link/type.js
Normal file
1
miniprogram_npm/tdesign-miniprogram/link/type.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user