From f11c3c3a086f2b32eedb14425c14b4b4054f1cd9 Mon Sep 17 00:00:00 2001 From: muxin <434980373@qq.com> Date: Fri, 19 May 2023 18:26:31 +0800 Subject: [PATCH] feat: migrate less to token for Anchor (#42141) * feat: rename anchor token * docs: add component-token demo * fix: update token --- .../__snapshots__/demo-extend.test.ts.snap | 79 +++++++++++++++++++ .../__snapshots__/demo.test.tsx.snap | 78 ++++++++++++++++++ components/anchor/demo/component-token.md | 7 ++ components/anchor/demo/component-token.tsx | 46 +++++++++++ components/anchor/index.en-US.md | 1 + components/anchor/index.zh-CN.md | 1 + components/anchor/style/index.ts | 44 ++++++----- docs/react/migrate-less-variables.en-US.md | 11 ++- docs/react/migrate-less-variables.zh-CN.md | 11 ++- 9 files changed, 256 insertions(+), 22 deletions(-) create mode 100644 components/anchor/demo/component-token.md create mode 100644 components/anchor/demo/component-token.tsx diff --git a/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap index 78716d458b..f9b2a14f97 100644 --- a/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -79,6 +79,85 @@ exports[`renders components/anchor/demo/basic.tsx extend context correctly 1`] = `; +exports[`renders components/anchor/demo/component-token.tsx extend context correctly 1`] = ` +
Set Anchor scroll offset
Listening for anchor link change
Deprecated JSX demo
+Component Token
## API
diff --git a/components/anchor/index.zh-CN.md b/components/anchor/index.zh-CN.md
index 2a393c4bb6..bed0635ec4 100644
--- a/components/anchor/index.zh-CN.md
+++ b/components/anchor/index.zh-CN.md
@@ -31,6 +31,7 @@ group:
设置锚点滚动偏移量
监听锚点链接改变
废弃的 JSX 示例
+组件 Token
## API
diff --git a/components/anchor/style/index.ts b/components/anchor/style/index.ts
index 6f9520da6d..8d7cb3b221 100644
--- a/components/anchor/style/index.ts
+++ b/components/anchor/style/index.ts
@@ -1,15 +1,16 @@
import type { CSSObject } from '@ant-design/cssinjs';
+import { resetComponent, textEllipsis } from '../../style';
import type { FullToken, GenerateStyle } from '../../theme/internal';
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
-import { resetComponent, textEllipsis } from '../../style';
-export interface ComponentToken {}
+export interface ComponentToken {
+ linkPaddingBlock: number;
+ linkPaddingInlineStart: number;
+}
interface AnchorToken extends FullToken<'Anchor'> {
holderOffsetBlock: number;
- anchorPaddingBlock: number;
anchorPaddingBlockSecondary: number;
- anchorPaddingInline: number;
anchorBallSize: number;
anchorTitleBlock: number;
}
@@ -34,16 +35,14 @@ const genSharedAnchorStyle: GenerateStyle