From e4edc3444df6235878f430e9b2a4b3b4ef595cd0 Mon Sep 17 00:00:00 2001 From: JarvisArt <38420763+JarvisArt@users.noreply.github.com> Date: Wed, 11 Jan 2023 12:10:20 +0800 Subject: [PATCH] demo: collapse custom demo supports dark mode (#40144) * demo: collapse custom demo supports dark mode * chore: remove className * demo: update collapse custom --- .../__snapshots__/demo-extend.test.ts.snap | 12 +++-- .../__tests__/__snapshots__/demo.test.ts.snap | 12 +++-- components/collapse/demo/custom.md | 18 ------- components/collapse/demo/custom.tsx | 49 ++++++++++++------- 4 files changed, 46 insertions(+), 45 deletions(-) diff --git a/components/collapse/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/collapse/__tests__/__snapshots__/demo-extend.test.ts.snap index 7e40b33e1f..57840337f4 100644 --- a/components/collapse/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/collapse/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -589,10 +589,12 @@ exports[`renders ./components/collapse/demo/collapsible.tsx extend context corre exports[`renders ./components/collapse/demo/custom.tsx extend context correctly 1`] = `
- [data-theme="dark"] .site-collapse-custom-collapse .site-collapse-custom-panel { - background: rgba(255,255,255,0.04); - border: 0px; - } - diff --git a/components/collapse/demo/custom.tsx b/components/collapse/demo/custom.tsx index 468da79118..0c525f4e53 100644 --- a/components/collapse/demo/custom.tsx +++ b/components/collapse/demo/custom.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { CaretRightOutlined } from '@ant-design/icons'; -import { Collapse } from 'antd'; +import { Collapse, theme } from 'antd'; const { Panel } = Collapse; @@ -10,23 +10,34 @@ const text = ` it can be found as a welcome guest in many households across the world. `; -const App: React.FC = () => ( - } - className="site-collapse-custom-collapse" - > - -

{text}

-
- -

{text}

-
- -

{text}

-
-
-); +const App: React.FC = () => { + const { token } = theme.useToken(); + + const panelStyle = { + marginBottom: 24, + background: token.colorFillAlter, + borderRadius: token.borderRadiusLG, + border: 'none', + }; + + return ( + } + style={{ background: token.colorBgContainer }} + > + +

{text}

+
+ +

{text}

+
+ +

{text}

+
+
+ ); +}; export default App;