From 8900246bea8f918e7810b49c3bbde6904294b989 Mon Sep 17 00:00:00 2001 From: yoyo <15014217605@163.com> Date: Tue, 27 Feb 2024 10:09:00 +0800 Subject: [PATCH] feat(slider): [slider] marks supported, input range supported (#1429) * feat(slider): marks supported, input range supported * feat(slider): slider smb theme * feat(slider): slider demo * feat(slider): slider test --- examples/sites/demos/apis/slider.js | 15 +++- .../pc/app/slider/marks-composition-api.vue | 20 +++++ .../sites/demos/pc/app/slider/marks.spec.ts | 12 +++ examples/sites/demos/pc/app/slider/marks.vue | 27 ++++++ .../app/slider/show-input-composition-api.vue | 2 + .../sites/demos/pc/app/slider/show-input.vue | 4 +- .../demos/pc/app/slider/show-iput.spec.ts | 18 +++- .../demos/pc/app/slider/webdoc/slider.js | 12 +++ packages/renderless/src/slider/index.ts | 86 +++++++++++++++---- packages/renderless/src/slider/vue.ts | 11 ++- packages/renderless/types/slider.type.ts | 29 +++++-- packages/theme/src/slider/index.less | 59 +++++++++++-- packages/theme/src/slider/smb-theme.js | 34 +++++++- packages/theme/src/slider/vars.less | 19 ++++ packages/theme/src/theme.config.js | 1 + .../vue/src/slider/__tests__/slider.test.tsx | 33 ++++++- packages/vue/src/slider/src/index.ts | 5 ++ packages/vue/src/slider/src/pc.vue | 36 ++++++-- 18 files changed, 375 insertions(+), 48 deletions(-) create mode 100644 examples/sites/demos/pc/app/slider/marks-composition-api.vue create mode 100644 examples/sites/demos/pc/app/slider/marks.spec.ts create mode 100644 examples/sites/demos/pc/app/slider/marks.vue diff --git a/examples/sites/demos/apis/slider.js b/examples/sites/demos/apis/slider.js index 3c0227006..1d56414c7 100644 --- a/examples/sites/demos/apis/slider.js +++ b/examples/sites/demos/apis/slider.js @@ -111,8 +111,8 @@ export default { type: 'boolean', defaultValue: 'false', desc: { - 'zh-CN': '是否显示输入框,仅在非范围选择时有效', - 'en-US': 'Indicates whether to display the text box. This parameter is valid only for non-range selection' + 'zh-CN': '是否显示输入框', + 'en-US': 'Indicates whether to display the text box.' }, mode: ['pc', 'mobile', 'mobile-first'], pcDemo: 'show-input', @@ -203,6 +203,17 @@ export default { mode: ['mobile'], mobileDemo: '' }, + { + name: 'marks', + type: `{ [key:number]: string }`, + defaultValue: '', + desc: { + 'zh-CN': '

设置滑杆的刻度值

', + 'en-US': 'Set the scale value of the slide bar' + }, + mode: ['pc'], + pcDemo: 'marks' + }, { name: 'vertical', type: 'boolean', diff --git a/examples/sites/demos/pc/app/slider/marks-composition-api.vue b/examples/sites/demos/pc/app/slider/marks-composition-api.vue new file mode 100644 index 000000000..45e0849fb --- /dev/null +++ b/examples/sites/demos/pc/app/slider/marks-composition-api.vue @@ -0,0 +1,20 @@ + + + diff --git a/examples/sites/demos/pc/app/slider/marks.spec.ts b/examples/sites/demos/pc/app/slider/marks.spec.ts new file mode 100644 index 000000000..4b674503b --- /dev/null +++ b/examples/sites/demos/pc/app/slider/marks.spec.ts @@ -0,0 +1,12 @@ +import { test, expect } from '@playwright/test' + +test('刻度标记', async ({ page }) => { + page.on('pageerror', (exception) => expect(exception).toBeNull()) + await page.goto('slider#marks') + + const points = page.locator('.tiny-slider-container .tiny-slider__mark-point') + + await expect(points.nth(0)).toHaveAttribute('style', /left: 10%/) + await expect(points.nth(1)).toHaveAttribute('style', /left: 40%/) + await expect(points.nth(2)).toHaveAttribute('style', /left: 50%/) +}) diff --git a/examples/sites/demos/pc/app/slider/marks.vue b/examples/sites/demos/pc/app/slider/marks.vue new file mode 100644 index 000000000..ff6632dbf --- /dev/null +++ b/examples/sites/demos/pc/app/slider/marks.vue @@ -0,0 +1,27 @@ + + + diff --git a/examples/sites/demos/pc/app/slider/show-input-composition-api.vue b/examples/sites/demos/pc/app/slider/show-input-composition-api.vue index a25d3c08e..02f72a3de 100644 --- a/examples/sites/demos/pc/app/slider/show-input-composition-api.vue +++ b/examples/sites/demos/pc/app/slider/show-input-composition-api.vue @@ -1,5 +1,6 @@ diff --git a/examples/sites/demos/pc/app/slider/show-input.vue b/examples/sites/demos/pc/app/slider/show-input.vue index 70ea0f3f3..49f509aa7 100644 --- a/examples/sites/demos/pc/app/slider/show-input.vue +++ b/examples/sites/demos/pc/app/slider/show-input.vue @@ -1,5 +1,6 @@