From 5cdcc89e219e1a2b26df9bc8ead63570010eaf8d Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Mon, 22 Apr 2024 11:33:23 +0800 Subject: [PATCH] refactor(indexes): sfc to tsx (#1327) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(indexes): sfc to tsx * refactor(indexes): sfc to tsx * test: 临时屏蔽toMatchSnapshot * chore: test update --- .../__test__/__snapshots__/demo.test.jsx.snap | 91 +++++++++---------- .../__snapshots__/index.test.jsx.snap | 49 +++++----- src/indexes/index.ts | 4 +- src/indexes/indexes-anchor.tsx | 30 ++++++ src/indexes/indexes-anchor.vue | 32 ------- src/indexes/indexes.en-US.md | 5 +- src/indexes/indexes.md | 10 +- src/indexes/{indexes.vue => indexes.tsx} | 79 ++++++++-------- 8 files changed, 139 insertions(+), 161 deletions(-) create mode 100644 src/indexes/indexes-anchor.tsx delete mode 100644 src/indexes/indexes-anchor.vue rename src/indexes/{indexes.vue => indexes.tsx} (81%) diff --git a/src/indexes/__test__/__snapshots__/demo.test.jsx.snap b/src/indexes/__test__/__snapshots__/demo.test.jsx.snap index 99ca4fc79..b4696bb79 100644 --- a/src/indexes/__test__/__snapshots__/demo.test.jsx.snap +++ b/src/indexes/__test__/__snapshots__/demo.test.jsx.snap @@ -15,64 +15,64 @@ exports[`Indexes > Indexes baseVue demo works fine 1`] = ` class="t-indexes__sidebar-item" data-index="A" > - A - + A +
- B - + B +
- C - + C +
- D - + D +
- E - + E +
- F - + F +
- G - + G +
- J - + J +
- K - + K +
@@ -89,8 +89,7 @@ exports[`Indexes > Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes baseVue demo works fine 1`] = `
- - +
Indexes customVue demo works fine 1`] = ` class="t-indexes__sidebar-item" data-index="1" > - 1 - + 1 +
- 3 - + 3 +
- 5 - + 5 +
- 7 - + 7 +
- 8 - + 8 +
- 10 - + 10 +
- # - + # +
diff --git a/src/indexes/__test__/__snapshots__/index.test.jsx.snap b/src/indexes/__test__/__snapshots__/index.test.jsx.snap index 9523fbd05..0b128cb56 100644 --- a/src/indexes/__test__/__snapshots__/index.test.jsx.snap +++ b/src/indexes/__test__/__snapshots__/index.test.jsx.snap @@ -12,50 +12,50 @@ exports[`Indexes & IndexesAnchor > render 1`] = ` class="t-indexes__sidebar-item" data-index="1" > - 1 - + 1 +
- 3 - + 3 +
- 5 - + 5 +
- 7 - + 7 +
- 8 - + 8 +
- 10 - + 10 +
- # - + # +
@@ -71,8 +71,7 @@ exports[`Indexes & IndexesAnchor > render 1`] = `
- - +
render 1`] = `
- - +
render 1`] = `
- - +
render 1`] = `
- - +
render 1`] = `
- - +
render 1`] = `
- - +
render 1`] = `
- - +
( +
+
+
{readerTNodeJSX('default')}
+
{props.index}
+
+
+ ); + }, +}); diff --git a/src/indexes/indexes-anchor.vue b/src/indexes/indexes-anchor.vue deleted file mode 100644 index 8c0c1f2dc..000000000 --- a/src/indexes/indexes-anchor.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - diff --git a/src/indexes/indexes.en-US.md b/src/indexes/indexes.en-US.md index 4eec154b2..f81edd617 100644 --- a/src/indexes/indexes.en-US.md +++ b/src/indexes/indexes.en-US.md @@ -19,14 +19,15 @@ name | params | description change | `(index: string \| number)` | \- select | `(index: string \| number)` | \- + ### IndexesAnchor Props name | type | default | description | required -- | -- | -- | -- | -- index | String / Number | - | \- | N +### CSS 变量 -### CSS Variables The component provides the following CSS variables, which can be used to customize styles. Name | Default Value | Description -- | -- | -- @@ -48,4 +49,4 @@ Name | Default Value | Description --td-indexes-anchor-bg-color | @bg-color-secondarycontainer | - --td-indexes-anchor-color | @font-gray-1 | - --td-indexes-anchor-font-size | 14px | - ---td-indexes-anchor-line-height | 22px | - +--td-indexes-anchor-line-height | 22px | - \ No newline at end of file diff --git a/src/indexes/indexes.md b/src/indexes/indexes.md index 7a1387811..b6ddab3f8 100644 --- a/src/indexes/indexes.md +++ b/src/indexes/indexes.md @@ -1,9 +1,10 @@ :: BASE_DOC :: ## API + ### Indexes Props -名称 | 类型 | 默认值 | 说明 | 必传 +名称 | 类型 | 默认值 | 描述 | 必传 -- | -- | -- | -- | -- indexList | Array | - | 索引字符列表。不传默认 `A-Z`。TS 类型:`string [] \| number[]` | N sticky | Boolean | true | 索引是否吸顶,默认为true。TS 类型:`Boolean` | N @@ -18,14 +19,15 @@ onSelect | Function | | TS 类型:`(index: string \| number) => void`
点 change | `(index: string \| number)` | 索引发生变更时触发事件 select | `(index: string \| number)` | 点击侧边栏时触发事件 + ### IndexesAnchor Props -名称 | 类型 | 默认值 | 说明 | 必传 +名称 | 类型 | 默认值 | 描述 | 必传 -- | -- | -- | -- | -- index | String / Number | - | 索引字符 | N - ### CSS 变量 + 组件提供了下列 CSS 变量,可用于自定义样式。 名称 | 默认值 | 描述 -- | -- | -- @@ -47,4 +49,4 @@ index | String / Number | - | 索引字符 | N --td-indexes-anchor-bg-color | @bg-color-secondarycontainer | - --td-indexes-anchor-color | @font-gray-1 | - --td-indexes-anchor-font-size | 14px | - ---td-indexes-anchor-line-height | 22px | - +--td-indexes-anchor-line-height | 22px | - \ No newline at end of file diff --git a/src/indexes/indexes.vue b/src/indexes/indexes.tsx similarity index 81% rename from src/indexes/indexes.vue rename to src/indexes/indexes.tsx index 46bbb3695..f2a9281a1 100644 --- a/src/indexes/indexes.vue +++ b/src/indexes/indexes.tsx @@ -1,35 +1,9 @@ - - -