diff --git a/components/Button/__test__/__snapshots__/button.spec.ts.snap b/components/Button/__test__/__snapshots__/button.spec.ts.snap
index 9632651b..d43da5a1 100644
--- a/components/Button/__test__/__snapshots__/button.spec.ts.snap
+++ b/components/Button/__test__/__snapshots__/button.spec.ts.snap
@@ -1,11 +1,21 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
+exports[`Test: KButton > props: button lg size 1`] = `""`;
+
+exports[`Test: KButton > props: button md size 1`] = `""`;
+
+exports[`Test: KButton > props: button size 1`] = `""`;
+
+exports[`Test: KButton > props: button sm size 1`] = `""`;
+
exports[`Test: KButton > props: circle 1`] = `""`;
exports[`Test: KButton > props: disabled 1`] = `""`;
exports[`Test: KButton > props: icon 1`] = `""`;
+exports[`Test: KButton > props: isBorder 1`] = `""`;
+
exports[`Test: KButton > props: round 1`] = `""`;
exports[`Test: KButton > props: to 1`] = `" "`;
diff --git a/components/Button/__test__/button.spec.ts b/components/Button/__test__/button.spec.ts
index 7927a71f..bc762601 100644
--- a/components/Button/__test__/button.spec.ts
+++ b/components/Button/__test__/button.spec.ts
@@ -155,6 +155,56 @@ describe('Test: KButton', () => {
expect(host.innerHTML).matchSnapshot();
});
+ test('props: button md size', async () => {
+ const instance = new KButton({
+ target: host,
+ props: {
+ size: 'md'
+ }
+ });
+ expect(instance).toBeTruthy();
+ expect(!(host as HTMLElement)!.innerHTML.includes('k-button--sm')).toBeTruthy();
+ expect(!(host as HTMLElement)!.innerHTML.includes('k-button--lg')).toBeTruthy();
+ expect(host.innerHTML).matchSnapshot();
+ });
+
+ test('props: button sm size', async () => {
+ const instance = new KButton({
+ target: host,
+ props: {
+ size: 'sm'
+ }
+ });
+ expect(instance).toBeTruthy();
+ expect((host as HTMLElement)!.innerHTML.includes('k-button--sm')).toBeTruthy();
+ expect(host.innerHTML).matchSnapshot();
+ });
+
+ test('props: button lg size', async () => {
+ const instance = new KButton({
+ target: host,
+ props: {
+ size: 'lg'
+ }
+ });
+ expect(instance).toBeTruthy();
+ expect((host as HTMLElement)!.innerHTML.includes('k-button--lg')).toBeTruthy();
+ expect(host.innerHTML).matchSnapshot();
+ });
+
+ test('props: isBorder', async () => {
+ const instance = new KButton({
+ target: host,
+ props: {
+ isBorder: true,
+ type: 'primary'
+ }
+ });
+ expect(instance).toBeTruthy();
+ expect((host as HTMLElement)!.innerHTML.includes('k-button--primary__border')).toBeTruthy();
+ expect(host.innerHTML).matchSnapshot();
+ });
+
test('event: should trigger click event', async () => {
const mockFn = vi.fn();
const instance = new KButton({
diff --git a/components/Button/src/index.svelte b/components/Button/src/index.svelte
index bffae4a0..396c6cf1 100644
--- a/components/Button/src/index.svelte
+++ b/components/Button/src/index.svelte
@@ -11,6 +11,8 @@
export let attrs = {}
export let type: IKunTypePro = 'primary'
export let disabled = false
+ export let size: 'md' | 'sm' | 'lg' = 'md'
+ export let isBorder = false
// todo: button size
const dispatch = createEventDispatcher()
@@ -28,8 +30,17 @@
{
[`${prefixCls}__active ${prefixCls}__focus ${prefixCls}__hover`]: !disabled,
'k-cur-disabled k-button--disabled': disabled,
- 'k-button--circle': circle
+ 'k-button--circle': circle,
+ 'k-button--circle--sm': circle && size === 'sm',
+ 'k-button--circle--lg': circle && size === 'lg',
},
+ {
+ 'k-button--sm': size === 'sm',
+ 'k-button--lg': size === 'lg'
+ },
+ {
+ [`k-button--${type}__border`]: isBorder
+ },
cls
)
$: attrsInner = extend(attrs, to ? { href: to } : {})
diff --git a/docs/components/KButton.md b/docs/components/KButton.md
index 758fadb3..abc70885 100644
--- a/docs/components/KButton.md
+++ b/docs/components/KButton.md
@@ -44,6 +44,20 @@ Use the icon attribute to add icon.