mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
chore: add Button.shape 'default' definition (#32004)
* feat: add Button.shape 'default' * fix: ignore shape when falsy value * fix: generate className only when shape match * fix: remove necessary .ant-btn-default and update snapshot
This commit is contained in:
parent
b5fffcab87
commit
008242b35e
@ -1184,7 +1184,7 @@ Array [
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -1192,7 +1192,7 @@ Array [
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
@ -78,7 +78,7 @@ function spaceChildren(children: React.ReactNode, needInserted: boolean) {
|
|||||||
|
|
||||||
const ButtonTypes = tuple('default', 'primary', 'ghost', 'dashed', 'link', 'text');
|
const ButtonTypes = tuple('default', 'primary', 'ghost', 'dashed', 'link', 'text');
|
||||||
export type ButtonType = typeof ButtonTypes[number];
|
export type ButtonType = typeof ButtonTypes[number];
|
||||||
const ButtonShapes = tuple('circle', 'round');
|
const ButtonShapes = tuple('default', 'circle', 'round');
|
||||||
export type ButtonShape = typeof ButtonShapes[number];
|
export type ButtonShape = typeof ButtonShapes[number];
|
||||||
const ButtonHTMLTypes = tuple('submit', 'button', 'reset');
|
const ButtonHTMLTypes = tuple('submit', 'button', 'reset');
|
||||||
export type ButtonHTMLType = typeof ButtonHTMLTypes[number];
|
export type ButtonHTMLType = typeof ButtonHTMLTypes[number];
|
||||||
@ -94,6 +94,7 @@ export function convertLegacyProps(type?: LegacyButtonType): ButtonProps {
|
|||||||
export interface BaseButtonProps {
|
export interface BaseButtonProps {
|
||||||
type?: ButtonType;
|
type?: ButtonType;
|
||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
|
/** @default default */
|
||||||
shape?: ButtonShape;
|
shape?: ButtonShape;
|
||||||
size?: SizeType;
|
size?: SizeType;
|
||||||
loading?: boolean | { delay?: number };
|
loading?: boolean | { delay?: number };
|
||||||
@ -137,7 +138,7 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
|
|||||||
prefixCls: customizePrefixCls,
|
prefixCls: customizePrefixCls,
|
||||||
type,
|
type,
|
||||||
danger,
|
danger,
|
||||||
shape,
|
shape = 'default',
|
||||||
size: customizeSize,
|
size: customizeSize,
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
@ -241,7 +242,7 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
|
|||||||
prefixCls,
|
prefixCls,
|
||||||
{
|
{
|
||||||
[`${prefixCls}-${type}`]: type,
|
[`${prefixCls}-${type}`]: type,
|
||||||
[`${prefixCls}-${shape}`]: shape,
|
[`${prefixCls}-${shape}`]: shape !== 'default' && shape,
|
||||||
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
||||||
[`${prefixCls}-icon-only`]: !children && children !== 0 && !!iconType,
|
[`${prefixCls}-icon-only`]: !children && children !== 0 && !!iconType,
|
||||||
[`${prefixCls}-background-ghost`]: ghost && !isUnborderedButtonType(type),
|
[`${prefixCls}-background-ghost`]: ghost && !isUnborderedButtonType(type),
|
||||||
|
@ -40,7 +40,7 @@ Different button styles can be generated by setting Button properties. The recom
|
|||||||
| htmlType | Set the original html `type` of `button`, see: [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | |
|
| htmlType | Set the original html `type` of `button`, see: [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | |
|
||||||
| icon | Set the icon component of button | ReactNode | - | |
|
| icon | Set the icon component of button | ReactNode | - | |
|
||||||
| loading | Set the loading status of button | boolean \| { delay: number } | false | |
|
| loading | Set the loading status of button | boolean \| { delay: number } | false | |
|
||||||
| shape | Can be set button shape | `circle` \| `round` | - | |
|
| shape | Can be set button shape | `default` \| `circle` \| `round` | 'default' | |
|
||||||
| size | Set the size of button | `large` \| `middle` \| `small` | `middle` | |
|
| size | Set the size of button | `large` \| `middle` \| `small` | `middle` | |
|
||||||
| target | Same as target attribute of a, works when href is specified | string | - | |
|
| target | Same as target attribute of a, works when href is specified | string | - | |
|
||||||
| type | Can be set to `primary` `ghost` `dashed` `link` `text` `default` | string | `default` | |
|
| type | Can be set to `primary` `ghost` `dashed` `link` `text` `default` | string | `default` | |
|
||||||
|
@ -43,7 +43,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/fNUKzY1sk/Button.svg
|
|||||||
| htmlType | 设置 `button` 原生的 `type` 值,可选值请参考 [HTML 标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | |
|
| htmlType | 设置 `button` 原生的 `type` 值,可选值请参考 [HTML 标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | |
|
||||||
| icon | 设置按钮的图标组件 | ReactNode | - | |
|
| icon | 设置按钮的图标组件 | ReactNode | - | |
|
||||||
| loading | 设置按钮载入状态 | boolean \| { delay: number } | false | |
|
| loading | 设置按钮载入状态 | boolean \| { delay: number } | false | |
|
||||||
| shape | 设置按钮形状 | `circle` \| `round` | - | |
|
| shape | 设置按钮形状 | `default` \| `circle` \| `round` | 'default' | |
|
||||||
| size | 设置按钮大小 | `large` \| `middle` \| `small` | `middle` | |
|
| size | 设置按钮大小 | `large` \| `middle` \| `small` | `middle` | |
|
||||||
| target | 相当于 a 链接的 target 属性,href 存在时生效 | string | - | |
|
| target | 相当于 a 链接的 target 属性,href 存在时生效 | string | - | |
|
||||||
| type | 设置按钮类型 | `primary` \| `ghost` \| `dashed` \| `link` \| `text` \| `default` | `default` | |
|
| type | 设置按钮类型 | `primary` \| `ghost` \| `dashed` \| `link` \| `text` \| `default` | `default` | |
|
||||||
|
@ -12665,7 +12665,7 @@ exports[`ConfigProvider components Dropdown configProvider 1`] = `
|
|||||||
class="config-btn-group config-dropdown-button"
|
class="config-btn-group config-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="config-btn config-btn-default"
|
class="config-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -12673,7 +12673,7 @@ exports[`ConfigProvider components Dropdown configProvider 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="config-btn config-btn-default config-btn-icon-only config-dropdown-trigger"
|
class="config-btn config-btn-icon-only config-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -12704,7 +12704,7 @@ exports[`ConfigProvider components Dropdown configProvider componentSize large 1
|
|||||||
class="config-btn-group config-dropdown-button"
|
class="config-btn-group config-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="config-btn config-btn-default config-btn-lg"
|
class="config-btn config-btn-lg"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -12712,7 +12712,7 @@ exports[`ConfigProvider components Dropdown configProvider componentSize large 1
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="config-btn config-btn-default config-btn-lg config-btn-icon-only config-dropdown-trigger"
|
class="config-btn config-btn-lg config-btn-icon-only config-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -12743,7 +12743,7 @@ exports[`ConfigProvider components Dropdown configProvider componentSize middle
|
|||||||
class="config-btn-group config-dropdown-button"
|
class="config-btn-group config-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="config-btn config-btn-default"
|
class="config-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -12751,7 +12751,7 @@ exports[`ConfigProvider components Dropdown configProvider componentSize middle
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="config-btn config-btn-default config-btn-icon-only config-dropdown-trigger"
|
class="config-btn config-btn-icon-only config-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -12782,7 +12782,7 @@ exports[`ConfigProvider components Dropdown configProvider virtual and dropdownM
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -12790,7 +12790,7 @@ exports[`ConfigProvider components Dropdown configProvider virtual and dropdownM
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -12821,7 +12821,7 @@ exports[`ConfigProvider components Dropdown normal 1`] = `
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -12829,7 +12829,7 @@ exports[`ConfigProvider components Dropdown normal 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -12860,7 +12860,7 @@ exports[`ConfigProvider components Dropdown prefixCls 1`] = `
|
|||||||
class="ant-btn-group prefix-Dropdown"
|
class="ant-btn-group prefix-Dropdown"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -12868,7 +12868,7 @@ exports[`ConfigProvider components Dropdown prefixCls 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
@ -103,7 +103,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -111,7 +111,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -144,7 +144,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -152,7 +152,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -185,7 +185,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
disabled=""
|
disabled=""
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
@ -194,7 +194,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
disabled=""
|
disabled=""
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
@ -228,7 +228,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@ -236,7 +236,7 @@ exports[`renders ./components/dropdown/demo/dropdown-button.md correctly 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-btn-loading ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-btn-loading ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
@ -5,11 +5,11 @@ exports[`DropdownButton rtl render component should be rendered correctly in RTL
|
|||||||
class="ant-btn-group ant-btn-group-rtl ant-dropdown-button"
|
class="ant-btn-group ant-btn-group-rtl ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-rtl"
|
class="ant-btn ant-btn-rtl"
|
||||||
type="button"
|
type="button"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-btn-rtl ant-dropdown-trigger ant-dropdown-rtl"
|
class="ant-btn ant-btn-icon-only ant-btn-rtl ant-dropdown-trigger ant-dropdown-rtl"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -40,11 +40,11 @@ exports[`DropdownButton should support href like Button 1`] = `
|
|||||||
class="ant-btn-group ant-dropdown-button"
|
class="ant-btn-group ant-dropdown-button"
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
class="ant-btn ant-btn-default"
|
class="ant-btn"
|
||||||
href="https://ant.design"
|
href="https://ant.design"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-default ant-btn-icon-only ant-dropdown-trigger"
|
class="ant-btn ant-btn-icon-only ant-dropdown-trigger"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
Loading…
Reference in New Issue
Block a user