diff --git a/packages/discuz-design/components/button/README.md b/packages/discuz-design/components/button/README.md
index 58a796310eea11f5c41ccf3c256cfc3e458b7650..6b6b0fdf864144067599ff29be55f24ec1880bd8 100644
--- a/packages/discuz-design/components/button/README.md
+++ b/packages/discuz-design/components/button/README.md
@@ -1,15 +1,25 @@
# Button
## 组件说明
+常用的操作按钮。
## 示例
-### 示例
-[示例](./__examples__/example1.jsx)
+### WEB示例
+[基础用法](./__examples__/web/base.tsx)
+[禁用状态](./__examples__/web/disabled.tsx)
+[不同尺寸](./__examples__/web/size.tsx)
+[加载中](./__examples__/web/loading.tsx)
+[htmlType](./__examples__/web/htmlType.tsx)
-### 示例2
-[示例2](./__examples__/example2.jsx)
+### 小程序示例
+[基础用法](./__examples__/mini/base.tsx)
+[禁用状态](./__examples__/mini/disabled.tsx)
+[不同尺寸](./__examples__/mini/size.tsx)
+[加载中](./__examples__/mini/loading.tsx)
+[openType](./__examples__/mini/openType.tsx)
## API参数
+[API参数](./interface.ts)
diff --git a/packages/discuz-design/components/button/__examples__/mini/base.tsx b/packages/discuz-design/components/button/__examples__/mini/base.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..417d56e1751b8714b3df358d910b5cc4cef1d189
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/mini/base.tsx
@@ -0,0 +1,18 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function Base() {
+ const onClick = (e) => {
+ console.log('click', e);
+ };
+
+ return (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/__examples__/mini/disabled.tsx b/packages/discuz-design/components/button/__examples__/mini/disabled.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..e20b32c958004e1b58156dcd85ac3c957a0d0c45
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/mini/disabled.tsx
@@ -0,0 +1,16 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function Disabled() {
+ return (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/__examples__/mini/example1.jsx b/packages/discuz-design/components/button/__examples__/mini/loading.tsx
similarity index 35%
rename from packages/discuz-design/components/button/__examples__/mini/example1.jsx
rename to packages/discuz-design/components/button/__examples__/mini/loading.tsx
index 04b84122c2a64585269a9abb2392fe9a36d75064..b353606497759c6dfb6625474e3f001dca01f7f5 100644
--- a/packages/discuz-design/components/button/__examples__/mini/example1.jsx
+++ b/packages/discuz-design/components/button/__examples__/mini/loading.tsx
@@ -1,6 +1,10 @@
import Button from '../../index';
import React from 'react';
-export default function Example1() {
- return ;
+export default function Loading() {
+ return (
+ <>
+
+ >
+ );
}
diff --git a/packages/discuz-design/components/button/__examples__/mini/openType.tsx b/packages/discuz-design/components/button/__examples__/mini/openType.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..303cae80305306db1a2514babe3a1f65f73b6a04
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/mini/openType.tsx
@@ -0,0 +1,22 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function HtmlType() {
+ const onContact = (e) => {
+ console.log('onContact', e);
+ };
+
+ return (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/__examples__/mini/size.tsx b/packages/discuz-design/components/button/__examples__/mini/size.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..6797a903fd49708dc2bbb337308e53748217b650
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/mini/size.tsx
@@ -0,0 +1,21 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function Size() {
+ return (
+ <>
+
+
+
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/__examples__/web/base.tsx b/packages/discuz-design/components/button/__examples__/web/base.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..417d56e1751b8714b3df358d910b5cc4cef1d189
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/web/base.tsx
@@ -0,0 +1,18 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function Base() {
+ const onClick = (e) => {
+ console.log('click', e);
+ };
+
+ return (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/__examples__/web/disabled.tsx b/packages/discuz-design/components/button/__examples__/web/disabled.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..e20b32c958004e1b58156dcd85ac3c957a0d0c45
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/web/disabled.tsx
@@ -0,0 +1,16 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function Disabled() {
+ return (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/__examples__/web/htmlType.tsx b/packages/discuz-design/components/button/__examples__/web/htmlType.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..8d096daa3acad920911c08e9656b02db0a7b96c1
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/web/htmlType.tsx
@@ -0,0 +1,10 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function HtmlType() {
+ return (
+ <>
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/__examples__/web/example1.tsx b/packages/discuz-design/components/button/__examples__/web/loading.tsx
similarity index 35%
rename from packages/discuz-design/components/button/__examples__/web/example1.tsx
rename to packages/discuz-design/components/button/__examples__/web/loading.tsx
index 04b84122c2a64585269a9abb2392fe9a36d75064..b353606497759c6dfb6625474e3f001dca01f7f5 100644
--- a/packages/discuz-design/components/button/__examples__/web/example1.tsx
+++ b/packages/discuz-design/components/button/__examples__/web/loading.tsx
@@ -1,6 +1,10 @@
import Button from '../../index';
import React from 'react';
-export default function Example1() {
- return ;
+export default function Loading() {
+ return (
+ <>
+
+ >
+ );
}
diff --git a/packages/discuz-design/components/button/__examples__/web/size.tsx b/packages/discuz-design/components/button/__examples__/web/size.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..6797a903fd49708dc2bbb337308e53748217b650
--- /dev/null
+++ b/packages/discuz-design/components/button/__examples__/web/size.tsx
@@ -0,0 +1,21 @@
+import Button from '../../index';
+import React from 'react';
+
+export default function Size() {
+ return (
+ <>
+
+
+
+
+ >
+ );
+}
diff --git a/packages/discuz-design/components/button/adapters/index.ts b/packages/discuz-design/components/button/adapters/index.ts
index 55de76647de1c7eb4873aea382fa29f5033ea83e..a7c86a585db11819c71ddc91ed329a026d6db621 100644
--- a/packages/discuz-design/components/button/adapters/index.ts
+++ b/packages/discuz-design/components/button/adapters/index.ts
@@ -1,9 +1,7 @@
import { baseAdapterFactory } from '../../../extends/baseAdapter';
export const ButtonLogicalAdapter = baseAdapterFactory({
- defaultAdapter: {
- haha: () => {},
- },
+ defaultAdapter: {},
adapterImplement() {
if (process.env.DISCUZ_ENV === 'web') {
return require('./web').ButtonWebAdapter;
diff --git a/packages/discuz-design/components/button/adapters/mini.ts b/packages/discuz-design/components/button/adapters/mini.ts
index 456697bd5bc0c9d14bfb752d2451c30cd01ea5f8..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/packages/discuz-design/components/button/adapters/mini.ts
+++ b/packages/discuz-design/components/button/adapters/mini.ts
@@ -1,7 +0,0 @@
-export const ButtonMiniAdapter = {
- haha() {
- this.setState({
- test: 345,
- });
- },
-};
diff --git a/packages/discuz-design/components/button/adapters/web.ts b/packages/discuz-design/components/button/adapters/web.ts
index 9c1d8c7050d7dd5f882ef8a083e7603bed2a1da4..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/packages/discuz-design/components/button/adapters/web.ts
+++ b/packages/discuz-design/components/button/adapters/web.ts
@@ -1,5 +0,0 @@
-export const ButtonWebAdapter = {
- haha() {
- console.log(this.state);
- },
-};
diff --git a/packages/discuz-design/components/button/index.tsx b/packages/discuz-design/components/button/index.tsx
index f081e21e344a6c864bf1ec32d3fac3cdde8a38a1..3f1e86d080d5f2acd96abe2cad252b6a02c104c9 100644
--- a/packages/discuz-design/components/button/index.tsx
+++ b/packages/discuz-design/components/button/index.tsx
@@ -1,48 +1,27 @@
-import React from "react";
-import { baseComponentFactory } from "../../extends/baseComponent";
-import { ButtonViewAdapter } from "./layouts/index";
-import { ButtonLogicalAdapter } from "./adapters/index";
+import React from 'react';
+import { baseComponentFactory } from '../../extends/baseComponent';
+import { ButtonViewAdapter } from './layouts/index';
+import { ButtonLogicalAdapter } from './adapters/index';
+import { MiniButtonProps, WebButtonProps } from './interface';
-interface ButtonProps {}
+interface ButtonProps extends MiniButtonProps, WebButtonProps {}
-interface ButtonState {
- test: number;
-}
+interface ButtonState {}
-interface ButtonLayoutProps {
- onClick: any;
- content: any;
-}
+interface ButtonLayoutProps {}
-interface ButtonAdapter {
- haha: any;
- test: any;
-}
+interface ButtonAdapter {}
-export default class Button extends baseComponentFactory<
- ButtonProps,
- ButtonState,
- ButtonLayoutProps,
- ButtonAdapter
->({
+export default class Button extends baseComponentFactory({
viewAdapter: ButtonViewAdapter,
logicalAdapter: ButtonLogicalAdapter,
}) {
- constructor(props) {
- super(props);
- this.state = {
- test: 23456,
+ render() {
+ const composeProps = {
+ ...this.props,
};
- }
-
- handleClick = () => {
- this.adapter.haha();
- };
- render() {
const { RenderComponent } = this;
- return (
-
- );
+ return {this.props.children};
}
}
diff --git a/packages/discuz-design/components/button/interface.ts b/packages/discuz-design/components/button/interface.ts
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8f7f855c83976c77d6afc0e5f359b1d54978b209 100644
--- a/packages/discuz-design/components/button/interface.ts
+++ b/packages/discuz-design/components/button/interface.ts
@@ -0,0 +1,101 @@
+import { StyledProps } from 'utils/_type/StyledProps';
+
+/**
+ * 基本的按钮属性
+ */
+export interface BaseButtonProps extends StyledProps {
+ /**
+ * 按钮类型
+ *
+ * - `large` 大尺寸
+ * - `medium` 中尺寸
+ * - `small` 中小尺寸
+ * - `mini` 小尺寸
+ *
+ * @default "medium"
+ */
+ size?: 'large' | 'medium' | 'small' | 'mini';
+
+ /**
+ * 按钮类型
+ *
+ * - `primary` 蓝色主要按钮
+ * - `dashed` 虚线按钮
+ * - 默认白色按钮
+ *
+ * @default
+ */
+ type?: 'primary' | 'dashed';
+
+ /**
+ * 设置按钮为禁用状态
+ *
+ * 禁用状态下,不会响应 `onClick` 回调
+ * */
+ disabled?: boolean;
+
+ /**
+ * 设置按钮为加载状态
+ */
+ loading?: boolean;
+
+ /**
+ * 点击回调函数
+ */
+ onClick?: (event) => void;
+}
+
+/**
+ * 小程序端专有属性
+ * 参考微信小程序文档 https://developers.weixin.qq.com/miniprogram/dev/component/button.html
+ */
+export interface MiniButtonProps extends BaseButtonProps {
+ openType?:
+ | 'contact'
+ | 'contactShare'
+ | 'share'
+ | 'getRealnameAuthInfo'
+ | 'getAuthorize'
+ | 'getPhoneNumber'
+ | 'getUserInfo'
+ | 'lifestyle'
+ | 'launchApp'
+ | 'openSetting'
+ | 'feedback';
+
+ onGetUserInfo?: (event) => void;
+
+ onContact?: (event) => void;
+
+ onGetPhoneNumber?: (event) => void;
+
+ onError?: (event) => void;
+
+ onOpenSetting?: (event) => void;
+
+ formType?: 'submit' | 'reset';
+
+ // lang?: 'zh_CN' | 'zh_TW' | 'en';
+
+ sessionFrom?: string;
+
+ sendMessageTitle?: string;
+
+ sendMessagePath?: string;
+
+ sendMessageImg?: string;
+
+ showMessageCard?: boolean;
+
+ appParameter?: string;
+}
+
+/**
+ * web端专有属性
+ */
+export interface WebButtonProps extends BaseButtonProps {
+ /**
+ * 原生 `