Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export const buttonProps = {
type: String as PropType<Type>,
default: 'default',
},
iconPlacement: {
type: String as PropType<'left' | 'right'>,
default: 'left',
},
} as const satisfies ComponentObjectPropsOptions;

export type ButtonProps = ExtractPublicPropTypes<typeof buttonProps>;
Expand Down Expand Up @@ -108,12 +112,11 @@ export default defineComponent({
>
{props.loading
? (
<LoadingOutlined class={loadingIconClassName} />
<LoadingOutlined class={loadingIconClassName} />
)
: (
slots.icon?.()
)}
: props.iconPlacement !== 'right' && <span class={`${prefixCls}-icon`}>{slots.icon?.()}</span> }
{slots.default?.()}
{props.iconPlacement === 'right' && <span class={[`${prefixCls}-icon`, 'is-right']}>{slots.icon?.()}</span> }
</button>
);
},
Expand Down
8 changes: 7 additions & 1 deletion components/button/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,14 @@
&-long {
width: 100%;
}
& > .@{fes-icon-cls} {
&-icon {
display: inline-flex;
align-items: center;
margin-right: 4px;
&.is-right {
margin-right: 0;
margin-left: 4px;
}
}

&-large {
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/components/button/icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<FButton>
<template #icon> <ProductOutlined /> </template>Default
</FButton>
<FButton type="primary">
<FButton type="primary" iconPlacement="right">
<template #icon> <ProductOutlined /> </template>Primary
</FButton>
<FButton type="text">
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/components/button/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ long.vue
| long | 按钮按钮宽度为父元素宽度 | boolean | `false` |
| throttle | 节流 | number | `300` |
| type | 设置按钮类型,可选值为 `primary` `text` `link` `info` `success` `warning` `danger` | string | `default` |
| iconPlacement | icon位置,可选值为 `left` `right` | string | `left` |

## Slots

Expand Down