project init & fix ui
This commit is contained in:
29
miniprogram_npm/tdesign-miniprogram/message/README.en-US.md
Normal file
29
miniprogram_npm/tdesign-miniprogram/message/README.en-US.md
Normal file
@@ -0,0 +1,29 @@
|
||||
:: BASE_DOC ::
|
||||
|
||||
## API
|
||||
### Message Props
|
||||
|
||||
name | type | default | description | required
|
||||
-- | -- | -- | -- | --
|
||||
action | String / Slot | - | operation | N
|
||||
align | String | left | options:left/center。Typescript:`MessageAlignType` `type MessageAlignType = 'left' \| 'center'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
close-btn | String / Boolean / Object / Slot | false | \- | N
|
||||
content | String / Slot | - | \- | N
|
||||
custom-style `v0.25.0` | String | - | \- | N
|
||||
duration | Number | 3000 | \- | N
|
||||
external-classes | Array | - | `['t-class', 't-class-content', 't-class-icon', 't-class-action', 't-class-close-btn']` | N
|
||||
icon | String / Boolean / Object/ Slot | true | Typescript:`boolean \| 'info' \| 'bell'` | N
|
||||
marquee | Boolean / Object | false | Typescript:`boolean \| DrawMarquee` `interface DrawMarquee { speed?: number; loop?: number; delay?: number }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
offset | Array | - | Typescript:`Array<string \| number>` | N
|
||||
theme | String | info | options:info/success/warning/error。Typescript:`MessageThemeList` `type MessageThemeList = 'info' \| 'success' \| 'warning' \| 'error'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
visible | Boolean | false | \- | N
|
||||
default-visible | Boolean | false | uncontrolled property | N
|
||||
z-index | Number | 15000 | \- | N
|
||||
|
||||
### Message Events
|
||||
|
||||
name | params | description
|
||||
-- | -- | --
|
||||
action-btn-click | - | \-
|
||||
close-btn-click | - | \-
|
||||
duration-end | \- | \-
|
||||
70
miniprogram_npm/tdesign-miniprogram/message/README.md
Normal file
70
miniprogram_npm/tdesign-miniprogram/message/README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: Message 消息通知
|
||||
description: 用于轻量级反馈或提示,不会打断用户操作。
|
||||
spline: message
|
||||
isComponent: true
|
||||
---
|
||||
|
||||
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-94%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-89%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-94%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-86%25-blue" /></span>
|
||||
## 引入
|
||||
|
||||
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
|
||||
|
||||
```json
|
||||
"usingComponents": {
|
||||
"t-message": "tdesign-miniprogram/message/message"
|
||||
}
|
||||
```
|
||||
|
||||
### 引入 API
|
||||
|
||||
若以 API 形式调用 Message,则需在页面 `page.js` 中引入组件 API:
|
||||
|
||||
```js
|
||||
import Message from 'tdesign-miniprogram/message/index';
|
||||
```
|
||||
|
||||
## 代码演示
|
||||
|
||||
### 组件类型
|
||||
|
||||
弹窗内容为纯文本、标题和副标题、带输入框,用 API `Message.info` 方法调用反馈类对话框。
|
||||
|
||||
|
||||
{{ base }}
|
||||
|
||||
|
||||
### 组件状态
|
||||
|
||||
消息通知类型为普通(info)、警示(warning)、成功(success)、错误(error)
|
||||
|
||||
{{ theme }}
|
||||
|
||||
## API
|
||||
### Message Props
|
||||
|
||||
名称 | 类型 | 默认值 | 说明 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
action | String / Slot | - | 操作 | N
|
||||
align | String | left | 文本对齐方式。可选项:left/center。TS 类型:`MessageAlignType` `type MessageAlignType = 'left' \| 'center'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
close-btn | String / Boolean / Object / Slot | false | 关闭按钮,可以自定义。值为 true 显示默认关闭按钮,值为 false 不显示关闭按钮。值类型为 string ,如:'user',则显示组件内置图标,为 'slot' 则表示使用插槽。值类型为 object ,则会透传至 icon 组件。| N
|
||||
content | String / Slot | - | 用于自定义消息弹出内容 | N
|
||||
custom-style `v0.25.0` | String | - | 自定义组件样式 | N
|
||||
duration | Number | 3000 | 消息内置计时器,计时到达时会触发 duration-end 事件。单位:毫秒。值为 0 则表示没有计时器。 | N
|
||||
external-classes | Array | - | 样式类名,分别用于设置 组件外层、消息内容、左侧图标、操作按钮、关闭按钮等元素类名。`['t-class', 't-class-content', 't-class-icon', 't-class-action', 't-class-close-btn']` | N
|
||||
icon | String / Boolean / Object / Slot | true | 消息提醒前面的图标,可以自定义。值为 true 则根据 theme 显示对应的图标,值为 false 则不显示图标。值为 true 显示默认关闭按钮,值为 false 不显示关闭按钮。值类型为 string ,如:'info',则显示组件内置图标,为 'slot' 则表示使用插槽。值类型为 object ,则会透传至 icon 组件。| N
|
||||
marquee | Boolean / Object | false | 跑马灯效果。speed 指速度控制;loop 指循环播放次数,值为 -1 表示循环播放,值为 0 表示不循环播放;delay 表示延迟多久开始播放。TS 类型:`boolean \| DrawMarquee` `interface DrawMarquee { speed?: number; loop?: number
|
||||
; delay?: number }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
offset | Array | - | 相对于 placement 的偏移量,默认单位 rpx。示例:[-10, 20] 或 ['10rpx', '8rpx']。TS 类型:`Array<string \| number>` | N
|
||||
theme | String | info | 消息组件风格。可选项:info/success/warning/error。TS 类型:`MessageThemeList` `type MessageThemeList = 'info' \| 'success' \| 'warning' \| 'error'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
visible | Boolean | false | 是否显示,隐藏时默认销毁组件 | N
|
||||
default-visible | Boolean | false | 是否显示,隐藏时默认销毁组件。非受控属性 | N
|
||||
z-index | Number | 15000 | 元素层级,样式默认为 15000 | N
|
||||
|
||||
### Message Events
|
||||
|
||||
名称 | 参数 | 描述
|
||||
-- | -- | --
|
||||
action-btn-click | - | 当操作按钮存在时,用户点击操作按钮时触发
|
||||
close-btn-click | - | 当关闭按钮存在时,用户点击关闭按钮触发
|
||||
duration-end | \- | 计时结束后触发
|
||||
17
miniprogram_npm/tdesign-miniprogram/message/index.d.ts
vendored
Normal file
17
miniprogram_npm/tdesign-miniprogram/message/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
import { MessageProps } from './message.interface';
|
||||
declare type Context = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
|
||||
interface MessageActionOptionsType extends Optional<MessageProps> {
|
||||
context?: Context;
|
||||
selector?: string;
|
||||
}
|
||||
declare const _default: {
|
||||
info(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
success(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
warning(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
error(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
hide(options: MessageActionOptionsType): void;
|
||||
};
|
||||
export default _default;
|
||||
46
miniprogram_npm/tdesign-miniprogram/message/index.js
Normal file
46
miniprogram_npm/tdesign-miniprogram/message/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import { MessageType } from './message.interface';
|
||||
import { getInstance } from '../common/utils';
|
||||
const showMessage = function (options, theme = MessageType.info) {
|
||||
const { context, selector = '#t-message' } = options, otherOptions = __rest(options, ["context", "selector"]);
|
||||
const instance = getInstance(context, selector);
|
||||
if (instance) {
|
||||
instance.resetData(() => {
|
||||
instance.setData(Object.assign({ theme }, otherOptions), instance.show.bind(instance));
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
console.error('未找到组件,请确认 selector && context 是否正确');
|
||||
};
|
||||
export default {
|
||||
info(options) {
|
||||
return showMessage(options, MessageType.info);
|
||||
},
|
||||
success(options) {
|
||||
return showMessage(options, MessageType.success);
|
||||
},
|
||||
warning(options) {
|
||||
return showMessage(options, MessageType.warning);
|
||||
},
|
||||
error(options) {
|
||||
return showMessage(options, MessageType.error);
|
||||
},
|
||||
hide(options) {
|
||||
const { context, selector = '#t-message' } = Object.assign({}, options);
|
||||
const instance = getInstance(context, selector);
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
instance.hide();
|
||||
},
|
||||
};
|
||||
36
miniprogram_npm/tdesign-miniprogram/message/message.d.ts
vendored
Normal file
36
miniprogram_npm/tdesign-miniprogram/message/message.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
import { SuperComponent, ComponentsOptionsType } from '../common/src/index';
|
||||
import { MessageProps } from './message.interface';
|
||||
export default class Message extends SuperComponent {
|
||||
externalClasses: string[];
|
||||
options: ComponentsOptionsType;
|
||||
properties: MessageProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
visible: boolean;
|
||||
loop: number;
|
||||
animation: any[];
|
||||
showAnimation: any[];
|
||||
wrapTop: number;
|
||||
};
|
||||
observers: {
|
||||
marquee(val: any): void;
|
||||
icon(icon: any): void;
|
||||
closeBtn(closeBtn: any): void;
|
||||
};
|
||||
closeTimeoutContext: number;
|
||||
nextAnimationContext: number;
|
||||
resetAnimation: WechatMiniprogram.Animation;
|
||||
ready(): void;
|
||||
memoInitalData(): void;
|
||||
resetData(cb: () => void): void;
|
||||
detached(): void;
|
||||
checkAnimation(): void;
|
||||
clearMessageAnimation(): void;
|
||||
show(): void;
|
||||
hide(): void;
|
||||
reset(): void;
|
||||
handleClose(): void;
|
||||
handleBtnClick(): void;
|
||||
}
|
||||
24
miniprogram_npm/tdesign-miniprogram/message/message.interface.d.ts
vendored
Normal file
24
miniprogram_npm/tdesign-miniprogram/message/message.interface.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
export declare enum MessageType {
|
||||
info = "info",
|
||||
success = "success",
|
||||
warning = "warning",
|
||||
error = "error"
|
||||
}
|
||||
export interface MessageMarquee {
|
||||
speed?: number;
|
||||
loop?: number;
|
||||
delay?: number;
|
||||
}
|
||||
export interface MessageProps {
|
||||
visible?: boolean;
|
||||
content: string;
|
||||
align?: string;
|
||||
theme?: MessageType;
|
||||
icon?: boolean | string;
|
||||
closeBtn?: boolean;
|
||||
action?: string;
|
||||
marquee?: MessageMarquee;
|
||||
offset?: object;
|
||||
duration?: number;
|
||||
zIndex?: number;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export var MessageType;
|
||||
(function (MessageType) {
|
||||
MessageType["info"] = "info";
|
||||
MessageType["success"] = "success";
|
||||
MessageType["warning"] = "warning";
|
||||
MessageType["error"] = "error";
|
||||
})(MessageType || (MessageType = {}));
|
||||
173
miniprogram_npm/tdesign-miniprogram/message/message.js
Normal file
173
miniprogram_npm/tdesign-miniprogram/message/message.js
Normal file
@@ -0,0 +1,173 @@
|
||||
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 { getRect, unitConvert, setIcon } from '../common/utils';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-message`;
|
||||
const SHOW_DURATION = 500;
|
||||
let Message = class Message extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.externalClasses = [
|
||||
`${prefix}-class`,
|
||||
`${prefix}-class-content`,
|
||||
`${prefix}-class-icon`,
|
||||
`${prefix}-class-action`,
|
||||
`${prefix}-class-close-btn`,
|
||||
];
|
||||
this.options = {
|
||||
styleIsolation: 'apply-shared',
|
||||
multipleSlots: true,
|
||||
};
|
||||
this.properties = Object.assign({}, props);
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
visible: false,
|
||||
loop: -1,
|
||||
animation: [],
|
||||
showAnimation: [],
|
||||
wrapTop: -999,
|
||||
};
|
||||
this.observers = {
|
||||
marquee(val) {
|
||||
if (JSON.stringify(val) === '{}') {
|
||||
this.setData({
|
||||
marquee: {
|
||||
speed: 50,
|
||||
loop: -1,
|
||||
delay: 5000,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
icon(icon) {
|
||||
const obj = setIcon('icon', icon, 'error-circle-filled');
|
||||
this.setData(Object.assign({}, obj));
|
||||
},
|
||||
closeBtn(closeBtn) {
|
||||
const obj = setIcon('closeBtn', closeBtn, 'close');
|
||||
this.setData(Object.assign({}, obj));
|
||||
},
|
||||
};
|
||||
this.closeTimeoutContext = 0;
|
||||
this.nextAnimationContext = 0;
|
||||
this.resetAnimation = wx.createAnimation({
|
||||
duration: 0,
|
||||
timingFunction: 'linear',
|
||||
});
|
||||
}
|
||||
ready() {
|
||||
this.memoInitalData();
|
||||
}
|
||||
memoInitalData() {
|
||||
this.initalData = Object.assign(Object.assign({}, this.properties), this.data);
|
||||
}
|
||||
resetData(cb) {
|
||||
this.setData(Object.assign({}, this.initalData), cb);
|
||||
}
|
||||
detached() {
|
||||
this.clearMessageAnimation();
|
||||
}
|
||||
checkAnimation() {
|
||||
if (!this.properties.marquee) {
|
||||
return;
|
||||
}
|
||||
const speeding = this.properties.marquee.speed;
|
||||
if (this.data.loop > 0) {
|
||||
this.data.loop -= 1;
|
||||
}
|
||||
else if (this.data.loop === 0) {
|
||||
this.setData({ animation: this.resetAnimation.translateX(0).step().export() });
|
||||
return;
|
||||
}
|
||||
if (this.nextAnimationContext) {
|
||||
this.clearMessageAnimation();
|
||||
}
|
||||
const warpID = `#${name}__text-wrap`;
|
||||
const nodeID = `#${name}__text`;
|
||||
Promise.all([getRect(this, nodeID), getRect(this, warpID)]).then(([nodeRect, wrapRect]) => {
|
||||
this.setData({
|
||||
animation: this.resetAnimation.translateX(wrapRect.width).step().export(),
|
||||
}, () => {
|
||||
const durationTime = ((nodeRect.width + wrapRect.width) / speeding) * 1000;
|
||||
const nextAnimation = wx
|
||||
.createAnimation({
|
||||
duration: durationTime,
|
||||
})
|
||||
.translateX(-nodeRect.width)
|
||||
.step()
|
||||
.export();
|
||||
setTimeout(() => {
|
||||
this.nextAnimationContext = setTimeout(this.checkAnimation.bind(this), durationTime);
|
||||
this.setData({ animation: nextAnimation });
|
||||
}, 20);
|
||||
});
|
||||
});
|
||||
}
|
||||
clearMessageAnimation() {
|
||||
clearTimeout(this.nextAnimationContext);
|
||||
this.nextAnimationContext = 0;
|
||||
}
|
||||
show() {
|
||||
const { duration, marquee, offset } = this.properties;
|
||||
this.setData({ visible: true, loop: marquee.loop });
|
||||
this.reset();
|
||||
this.checkAnimation();
|
||||
if (duration && duration > 0) {
|
||||
this.closeTimeoutContext = setTimeout(() => {
|
||||
this.hide();
|
||||
this.triggerEvent('durationEnd', { self: this });
|
||||
}, duration);
|
||||
}
|
||||
const wrapID = `#${name}`;
|
||||
getRect(this, wrapID).then((wrapRect) => {
|
||||
this.setData({ wrapTop: -wrapRect.height }, () => {
|
||||
this.setData({
|
||||
showAnimation: wx
|
||||
.createAnimation({ duration: SHOW_DURATION, timingFunction: 'ease' })
|
||||
.translateY(wrapRect.height + unitConvert(offset[0]))
|
||||
.step()
|
||||
.export(),
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
hide() {
|
||||
this.reset();
|
||||
this.setData({
|
||||
showAnimation: wx
|
||||
.createAnimation({ duration: SHOW_DURATION, timingFunction: 'ease' })
|
||||
.translateY(this.data.wrapTop)
|
||||
.step()
|
||||
.export(),
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setData({ visible: false, animation: [] });
|
||||
}, SHOW_DURATION);
|
||||
}
|
||||
reset() {
|
||||
if (this.nextAnimationContext) {
|
||||
this.clearMessageAnimation();
|
||||
}
|
||||
clearTimeout(this.closeTimeoutContext);
|
||||
this.closeTimeoutContext = 0;
|
||||
}
|
||||
handleClose() {
|
||||
this.hide();
|
||||
this.triggerEvent('closeBtnClick');
|
||||
}
|
||||
handleBtnClick() {
|
||||
this.triggerEvent('actionBtnClick', { self: this });
|
||||
}
|
||||
};
|
||||
Message = __decorate([
|
||||
wxComponent()
|
||||
], Message);
|
||||
export default Message;
|
||||
7
miniprogram_npm/tdesign-miniprogram/message/message.json
Normal file
7
miniprogram_npm/tdesign-miniprogram/message/message.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-icon": "../icon/icon",
|
||||
"t-button": "../button/button"
|
||||
}
|
||||
}
|
||||
56
miniprogram_npm/tdesign-miniprogram/message/message.wxml
Normal file
56
miniprogram_npm/tdesign-miniprogram/message/message.wxml
Normal file
@@ -0,0 +1,56 @@
|
||||
<wxs src="./message.wxs" module="this"></wxs>
|
||||
<import src="../common/template/icon.wxml" />
|
||||
|
||||
<block wx:if="{{visible}}">
|
||||
<view
|
||||
class="{{classPrefix}} {{prefix}}-class {{classPrefix}}--{{theme}}"
|
||||
style="{{this.getMessageStyles(zIndex, offset, wrapTop, customStyle)}}"
|
||||
animation="{{showAnimation}}"
|
||||
id="{{classPrefix}}"
|
||||
aria-role="alert"
|
||||
>
|
||||
<view wx:if="{{iconName || !this.isEmptyObj(iconData)}}" class="{{classPrefix}}__icon--left">
|
||||
<slot wx:if="{{iconName === 'slot'}}" name="icon" />
|
||||
<template
|
||||
wx:else
|
||||
is="icon"
|
||||
data="{{tClass: prefix + '-class-icon', ariaHidden: true, name: iconName, ...iconData}}"
|
||||
></template>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="{{classPrefix}}__text-wrap {{marquee ? '{{classPrefix}}__text-nowrap' : ''}}"
|
||||
style="text-align: {{align}}"
|
||||
id="{{classPrefix}}__text-wrap"
|
||||
>
|
||||
<view class="{{classPrefix}}__text {{prefix}}-class-content" id="{{classPrefix}}__text" animation="{{animation}}">
|
||||
<block wx:if="{{content}}">{{content}}</block>
|
||||
<slot name="content"></slot>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<t-button
|
||||
wx:if="{{action}}"
|
||||
t-class="{{classPrefix}}__btn--right {{prefix}}-class-action"
|
||||
theme="primary"
|
||||
variant="text"
|
||||
size="small"
|
||||
bind:tap="handleBtnClick"
|
||||
>{{action}}</t-button
|
||||
>
|
||||
<slot name="action" />
|
||||
|
||||
<view
|
||||
wx:if="{{ closeBtnName || !this.isEmptyObj(closeBtnData)}}"
|
||||
class="{{classPrefix}}__icon--right"
|
||||
bind:tap="handleClose"
|
||||
>
|
||||
<slot wx:if="{{closeBtnName === 'slot'}}" name="close-btn" />
|
||||
<template
|
||||
wx:else
|
||||
is="icon"
|
||||
data="{{tClass: prefix + '-class-close-btn', ariaRole: 'button', ariaLabel: '关闭', name: closeBtnName, ...closeBtnData}}"
|
||||
></template>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
24
miniprogram_npm/tdesign-miniprogram/message/message.wxs
Normal file
24
miniprogram_npm/tdesign-miniprogram/message/message.wxs
Normal file
@@ -0,0 +1,24 @@
|
||||
var isEmptyObj = function (obj) {
|
||||
return JSON.stringify(obj) === '{}';
|
||||
};
|
||||
|
||||
var changeNumToStr = function (arr) {
|
||||
return arr.map(function (item) {
|
||||
return typeof item === 'number' ? item + 'rpx' : item;
|
||||
});
|
||||
};
|
||||
|
||||
var getMessageStyles = function (zIndex, offset, wrapTop, customStyle) {
|
||||
var arr = changeNumToStr(offset);
|
||||
var styleOffset = '';
|
||||
styleOffset += 'top:' + changeNumToStr([wrapTop * 2]) + ';';
|
||||
styleOffset += 'right:' + arr[1] + ';';
|
||||
styleOffset += 'left:' + arr[1] + ';';
|
||||
var zIndexStyle = zIndex ? 'z-index:' + zIndex + ';' : '';
|
||||
return zIndexStyle + styleOffset + customStyle;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getMessageStyles: getMessageStyles,
|
||||
isEmptyObj: isEmptyObj,
|
||||
};
|
||||
92
miniprogram_npm/tdesign-miniprogram/message/message.wxss
Normal file
92
miniprogram_npm/tdesign-miniprogram/message/message.wxss
Normal file
@@ -0,0 +1,92 @@
|
||||
.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-message {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
z-index: 15000;
|
||||
padding: 24rpx 32rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: var(--td-message-border-radius, var(--td-radius-default, 12rpx));
|
||||
line-height: 1;
|
||||
background-color: var(--td-message-bg-color, var(--td-bg-color-container, var(--td-white-color-1, #fff)));
|
||||
box-shadow: var(--td-message-box-shadow, var(--td-shadow-4, 0 2px 8px 0 rgba(0, 0, 0, 0.06)));
|
||||
}
|
||||
.t-message__text {
|
||||
display: inline-block;
|
||||
color: var(--td-message-content-font-color, var(--td-font-gray-1, rgba(0, 0, 0, 0.9)));
|
||||
font-size: var(--td-font-size-base, 28rpx);
|
||||
line-height: 44rpx;
|
||||
}
|
||||
.t-message__text-wrap {
|
||||
flex: 1 1 auto;
|
||||
overflow-x: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.t-message__text-nowrap {
|
||||
word-break: keep-all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.t-message--info {
|
||||
color: var(--td-message-info-color, var(--td-primary-color, #0052d9));
|
||||
}
|
||||
.t-message--success {
|
||||
color: var(--td-message-success-color, var(--td-success-color, var(--td-success-color-5, #00a870)));
|
||||
}
|
||||
.t-message--warning {
|
||||
color: var(--td-message-warning-color, var(--td-warning-color, var(--td-warning-color-5, #ed7b2f)));
|
||||
}
|
||||
.t-message--error {
|
||||
color: var(--td-message-error-color, var(--td-error-color, var(--td-error-color-6, #e34d59)));
|
||||
}
|
||||
.t-message__icon--left,
|
||||
.t-message__icon--right {
|
||||
font-size: 44rpx;
|
||||
}
|
||||
.t-message__icon--left {
|
||||
margin-right: var(--td-spacer, 16rpx);
|
||||
}
|
||||
.t-message__icon--right {
|
||||
color: var(--td-message-close-icon-color, var(--td-font-gray-3, rgba(0, 0, 0, 0.4)));
|
||||
}
|
||||
.t-message__icon--right,
|
||||
.t-message .t-message__btn--right {
|
||||
flex: 0 0 auto;
|
||||
margin-left: var(--td-spacer, 16rpx);
|
||||
}
|
||||
.t-message .t-message__btn--right {
|
||||
font-size: var(--td-font-size-base, 28rpx);
|
||||
line-height: 44rpx;
|
||||
height: 44rpx;
|
||||
border-radius: var(--td-message-border-radius, var(--td-radius-default, 12rpx));
|
||||
padding: 0;
|
||||
}
|
||||
3
miniprogram_npm/tdesign-miniprogram/message/props.d.ts
vendored
Normal file
3
miniprogram_npm/tdesign-miniprogram/message/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdMessageProps } from './type';
|
||||
declare const props: TdMessageProps;
|
||||
export default props;
|
||||
55
miniprogram_npm/tdesign-miniprogram/message/props.js
Normal file
55
miniprogram_npm/tdesign-miniprogram/message/props.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const props = {
|
||||
action: {
|
||||
type: String,
|
||||
},
|
||||
align: {
|
||||
type: String,
|
||||
value: 'left',
|
||||
},
|
||||
closeBtn: {
|
||||
type: null,
|
||||
value: false,
|
||||
},
|
||||
content: {
|
||||
type: String,
|
||||
},
|
||||
customStyle: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
duration: {
|
||||
type: Number,
|
||||
value: 3000,
|
||||
},
|
||||
externalClasses: {
|
||||
type: Array,
|
||||
},
|
||||
icon: {
|
||||
type: null,
|
||||
value: true,
|
||||
},
|
||||
marquee: {
|
||||
type: null,
|
||||
value: false,
|
||||
},
|
||||
offset: {
|
||||
type: Array,
|
||||
},
|
||||
theme: {
|
||||
type: String,
|
||||
value: 'info',
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
defaultVisible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 15000,
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
65
miniprogram_npm/tdesign-miniprogram/message/type.d.ts
vendored
Normal file
65
miniprogram_npm/tdesign-miniprogram/message/type.d.ts
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
export interface TdMessageProps {
|
||||
action?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
align?: {
|
||||
type: StringConstructor;
|
||||
value?: MessageAlignType;
|
||||
};
|
||||
closeBtn?: {
|
||||
type: null;
|
||||
value?: string | boolean;
|
||||
};
|
||||
content?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
customStyle?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
duration?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
externalClasses?: {
|
||||
type: ArrayConstructor;
|
||||
value?: ['t-class', 't-class-content', 't-class-icon', 't-class-action', 't-class-close-btn'];
|
||||
};
|
||||
icon?: {
|
||||
type: null;
|
||||
value?: boolean | 'info' | 'bell';
|
||||
};
|
||||
marquee?: {
|
||||
type: null;
|
||||
value?: boolean | DrawMarquee;
|
||||
};
|
||||
offset?: {
|
||||
type: ArrayConstructor;
|
||||
value?: Array<string | number>;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: MessageThemeList;
|
||||
};
|
||||
visible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
defaultVisible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
zIndex?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
}
|
||||
export declare type MessageAlignType = 'left' | 'center';
|
||||
export interface DrawMarquee {
|
||||
speed?: number;
|
||||
loop?: number;
|
||||
delay?: number;
|
||||
}
|
||||
export declare type MessageThemeList = 'info' | 'success' | 'warning' | 'error';
|
||||
1
miniprogram_npm/tdesign-miniprogram/message/type.js
Normal file
1
miniprogram_npm/tdesign-miniprogram/message/type.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user