From cdf9b4660f84535ff89019c02b4077202a6916e4 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Tue, 6 Jun 2023 16:11:18 +0800 Subject: [PATCH] refactor: menu token rename (#42848) * refactor: menu token rename * chore: update snapshot * chore: UPDATE TEST CASE * fix: fix gap as 4px * fix: popup transform origin --- components/layout/__tests__/token.test.tsx | 41 +- .../__snapshots__/demo-extend.test.ts.snap | 360 ++++++++++++++++++ .../__snapshots__/demo.test.tsx.snap | 174 +++++++++ components/menu/demo/component-token.md | 7 + components/menu/demo/component-token.tsx | 87 +++++ components/menu/demo/menu-v4.tsx | 14 +- components/menu/index.en-US.md | 1 + components/menu/index.zh-CN.md | 1 + components/menu/style/index.tsx | 166 ++++++-- components/menu/style/theme.tsx | 111 +++--- components/menu/style/vertical.tsx | 14 +- .../theme/util/genComponentStyleHook.ts | 24 +- 12 files changed, 892 insertions(+), 108 deletions(-) create mode 100755 components/menu/demo/component-token.md create mode 100644 components/menu/demo/component-token.tsx diff --git a/components/layout/__tests__/token.test.tsx b/components/layout/__tests__/token.test.tsx index bcaa883099..b663aa6cde 100644 --- a/components/layout/__tests__/token.test.tsx +++ b/components/layout/__tests__/token.test.tsx @@ -7,7 +7,7 @@ import Menu from '../../menu'; const { Header } = Layout; describe('Layout.Token', () => { - it('theme should work', () => { + it('legacy theme should work', () => { const { container } = render( { colorBgHeader: '#FF0000', }, Menu: { + // keep this deprecated one colorItemBg: '#00FF00', }, }, @@ -38,6 +39,44 @@ describe('Layout.Token', () => { , ); + expect(container.querySelector('.ant-layout-header')).toHaveStyle({ + backgroundColor: '#FF0000', + }); + expect(container.querySelector('.ant-menu')).toHaveStyle({ + backgroundColor: '#00FF00', + }); + }); + it('theme should work', () => { + const { container } = render( + +
+ { + const key = index + 1; + return { + key, + label: `nav ${key}`, + }; + })} + /> +
+
, + ); + expect(container.querySelector('.ant-layout-header')).toHaveStyle({ backgroundColor: '#FF0000', }); diff --git a/components/menu/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/menu/__tests__/__snapshots__/demo-extend.test.ts.snap index 4f0d7d4a90..ae3cec84dc 100644 --- a/components/menu/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/menu/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -1,5 +1,365 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`renders components/menu/demo/component-token.tsx extend context correctly 1`] = ` +Array [ + , +