From f65f9a20b7fb20917725fdc641319037b823f69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=BF=AA=E7=94=9F?= <2046353594@qq.com> Date: Mon, 17 Oct 2022 18:36:17 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20init=20shark=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/components/src/shake/index.ts | 4 ++++ packages/components/src/shake/shake.vue | 0 packages/components/src/shake/types.ts | 0 3 files changed, 4 insertions(+) create mode 100644 packages/components/src/shake/index.ts create mode 100644 packages/components/src/shake/shake.vue create mode 100644 packages/components/src/shake/types.ts diff --git a/packages/components/src/shake/index.ts b/packages/components/src/shake/index.ts new file mode 100644 index 0000000..33b18fb --- /dev/null +++ b/packages/components/src/shake/index.ts @@ -0,0 +1,4 @@ +import shake from './shake.vue' +import { withInstall } from '@kitty-ui/utils' +const Shake = withInstall(shake) +export default Shake diff --git a/packages/components/src/shake/shake.vue b/packages/components/src/shake/shake.vue new file mode 100644 index 0000000..e69de29 diff --git a/packages/components/src/shake/types.ts b/packages/components/src/shake/types.ts new file mode 100644 index 0000000..e69de29 -- Gitee From 417fcd13d6dae077837619518bcee63f353ae255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=BF=AA=E7=94=9F?= <2046353594@qq.com> Date: Tue, 18 Oct 2022 18:54:01 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90shake=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=8A=A8=E7=94=BB,=E8=B0=83=E6=95=B4dragger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/app.vue | 7 +++-- packages/components/index.ts | 7 +++-- packages/components/src/index.ts | 1 + packages/components/src/shake/shake.vue | 21 +++++++++++++ .../components/src/shake/style/index.less | 31 +++++++++++++++++++ packages/components/src/upload/dragger.vue | 2 +- packages/components/src/upload/types.ts | 13 -------- packages/components/src/upload/upload.vue | 15 +++++---- 8 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 packages/components/src/shake/style/index.less delete mode 100644 packages/components/src/upload/types.ts diff --git a/examples/app.vue b/examples/app.vue index bd10ef3..fe874b0 100644 --- a/examples/app.vue +++ b/examples/app.vue @@ -1,11 +1,12 @@ + diff --git a/packages/components/src/shake/style/index.less b/packages/components/src/shake/style/index.less new file mode 100644 index 0000000..c586fe0 --- /dev/null +++ b/packages/components/src/shake/style/index.less @@ -0,0 +1,31 @@ +@keyframes shake { + + 10%, + 90% { + transform: translate3d(-1px, 0, 0); + } + + 20%, + 80% { + transform: translate3d(2px, 0, 0); + } + + 30%, + 70% { + transform: translate3d(-4px, 0, 0); + } + + 40%, + 60% { + transform: translate3d(4px, 0, 0); + } + + 50%, + 50% { + transform: translate3d(-4px, 0, 0); + } +} + +.k-shake.k-shakeactive { + animation: shake 1s linear; +} \ No newline at end of file diff --git a/packages/components/src/upload/dragger.vue b/packages/components/src/upload/dragger.vue index a59a887..09163c8 100644 --- a/packages/components/src/upload/dragger.vue +++ b/packages/components/src/upload/dragger.vue @@ -34,7 +34,7 @@ const onDragover = (e: Event) => { if (timer.value !== null) { clearTimeout(timer.value); } - timer.value = setTimeout(() => { + timer.value = window.setTimeout(() => { isEnter.value = false; timer.value = null; }, 100); diff --git a/packages/components/src/upload/types.ts b/packages/components/src/upload/types.ts deleted file mode 100644 index 76e1deb..0000000 --- a/packages/components/src/upload/types.ts +++ /dev/null @@ -1,13 +0,0 @@ - -import { ExtractPropTypes } from 'vue' - - -export const uploadType = { - multiple: Boolean, - accept: String, - drag: Boolean -} - -export type UploadType = ExtractPropTypes - - diff --git a/packages/components/src/upload/upload.vue b/packages/components/src/upload/upload.vue index 58433d7..067dad5 100644 --- a/packages/components/src/upload/upload.vue +++ b/packages/components/src/upload/upload.vue @@ -21,7 +21,6 @@ diff --git a/package.json b/package.json index d674388..9124e1c 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "docs:serve": "pnpm run --filter ./site docs:serve", "exm:dev": "pnpm run --filter ./examples dev", "test": "pnpm run --filter ./packages/components test", - "coverage": "pnpm run --filter ./packages/components vitest run --coverage" + "coverage": "pnpm run --filter ./packages/components coverage" }, "devDependencies": { "@types/gulp": "^4.0.9", diff --git a/packages/components/index.ts b/packages/components/index.ts index 36f17d3..65cf05a 100644 --- a/packages/components/index.ts +++ b/packages/components/index.ts @@ -3,7 +3,6 @@ export * from './src/index' import { App } from 'vue' export default { install: (app: App) => { - for (const comkey in components) { app.use((components as any)[comkey]) // app.component((components as any)[comkey].name, (components as any)[comkey]) diff --git a/packages/components/src/shake/__tests__/shake.test.ts b/packages/components/src/shake/__tests__/shake.test.ts new file mode 100644 index 0000000..d8c68eb --- /dev/null +++ b/packages/components/src/shake/__tests__/shake.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from "vitest"; +import { mount } from '@vue/test-utils' +import shake from '../shake.vue' +// The component to test + + +describe('test shake', () => { + it("should render slot", () => { + const wrapper = mount(shake, { + slots: { + default: 'Hello world' + } + }) + + // Assert the rendered text of the component + expect(wrapper.text()).toContain('Hello world') + }) + it("should have class", () => { + const wrapper = mount(shake, { + props: { + modelValue: true + } + }) + expect(wrapper.classes()).toContain('k-shakeactive') + }) +}) \ No newline at end of file diff --git a/packages/components/src/shake/shake.vue b/packages/components/src/shake/shake.vue index 4e02f51..e233e39 100644 --- a/packages/components/src/shake/shake.vue +++ b/packages/components/src/shake/shake.vue @@ -1,5 +1,5 @@ @@ -11,11 +11,26 @@ export default defineComponent({ }); -- Gitee From cad1c35f8474a30da848c41724c8f0ecd3bfef69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=BF=AA=E7=94=9F?= <2046353594@qq.com> Date: Wed, 19 Oct 2022 11:34:52 +0800 Subject: [PATCH 4/5] fix --- packages/components/src/shake/shake.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/src/shake/shake.vue b/packages/components/src/shake/shake.vue index 4e02f51..88dea2b 100644 --- a/packages/components/src/shake/shake.vue +++ b/packages/components/src/shake/shake.vue @@ -13,7 +13,7 @@ export default defineComponent({ +