未验证 提交 447e7852 编写于 作者: S simpleStyle 提交者: GitHub

feat: button组件支持原生小程序和H5的button特性 (#433)

上级 076a1b77
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`should match snapshot 1`] = `
<DocumentFragment>
<div
<div>
<button
class="nut-button nut-button--primary nut-button--normal nut-button--round aa"
iconclassprefix="nut-icon"
iconfontclassname="nutui-iconfont"
style="margin: 8px;"
>
<div
class="nut-button__warp"
>
主要按钮
<div
class="text"
>
主要按钮
</div>
</div>
</div>
</DocumentFragment>
</button>
</div>
`;
......@@ -8,12 +8,13 @@ import { useState } from 'react'
import { Button } from '../button'
test('should match snapshot', () => {
const { asFragment } = render(
const { container } = render(
<Button className="aa" style={{ margin: 8 }} type="primary" shape="round">
主要按钮
</Button>
)
expect(asFragment()).toMatchSnapshot()
expect(container.firstChild?.nodeName).toBe('BUTTON')
expect(container).toMatchSnapshot()
})
test('should children correctly', () => {
......
......@@ -133,7 +133,8 @@ export const Button: FunctionComponent<Partial<ButtonProps>> = (props) => {
}
return (
<div
// eslint-disable-next-line react/button-has-type
<button
className={`${btnName} ${className}`}
style={{ ...btnStyle, ...style }}
{...rest}
......@@ -158,7 +159,7 @@ export const Button: FunctionComponent<Partial<ButtonProps>> = (props) => {
)}
<div className="text">{children}</div>
</div>
</div>
</button>
)
}
......
......@@ -134,7 +134,8 @@ export const Button: FunctionComponent<Partial<ButtonProps>> = (props) => {
}
return (
<div
// eslint-disable-next-line react/button-has-type
<button
className={`${btnName} ${className}`}
style={{ ...btnStyle, ...style }}
{...rest}
......@@ -159,7 +160,7 @@ export const Button: FunctionComponent<Partial<ButtonProps>> = (props) => {
)}
<div className="text">{children}</div>
</div>
</div>
</button>
)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册