From c157a3f9eab05eb46f80fbd10ef2e019d4cef003 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sat, 13 Jan 2024 14:27:42 +0800 Subject: [PATCH] demo: update Watermark demo (#46899) * feat: CP support Table expandIcon * revert * demo: update demo --- .../config-provider/__tests__/style.test.tsx | 5 +- .../__snapshots__/demo-extend.test.ts.snap | 616 +++++++++--------- .../__tests__/__snapshots__/demo.test.ts.snap | 616 +++++++++--------- components/watermark/demo/custom.tsx | 57 +- components/watermark/demo/image.md | 2 +- components/watermark/demo/multi-line.md | 2 +- components/watermark/demo/portal.tsx | 41 +- components/watermark/index.en-US.md | 4 +- components/watermark/index.zh-CN.md | 4 +- 9 files changed, 639 insertions(+), 708 deletions(-) diff --git a/components/config-provider/__tests__/style.test.tsx b/components/config-provider/__tests__/style.test.tsx index 355fad352407..1d189171ca3d 100644 --- a/components/config-provider/__tests__/style.test.tsx +++ b/components/config-provider/__tests__/style.test.tsx @@ -958,7 +958,10 @@ describe('ConfigProvider support style and className props', () => { it('Should Table className & style works', () => { const { container } = render( - +
, ); const element = container.querySelector('.ant-table-wrapper'); diff --git a/components/watermark/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/watermark/__tests__/__snapshots__/demo-extend.test.ts.snap index fe051078a8d9..d06367c7676a 100644 --- a/components/watermark/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/watermark/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -18,7 +18,7 @@ exports[`renders components/watermark/demo/basic.tsx extend context correctly 2` exports[`renders components/watermark/demo/custom.tsx extend context correctly 1`] = `
示例图片 @@ -54,7 +54,7 @@ exports[`renders components/watermark/demo/custom.tsx extend context correctly 1
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -863,99 +858,95 @@ exports[`renders components/watermark/demo/custom.tsx extend context correctly 1
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -996,102 +987,97 @@ exports[`renders components/watermark/demo/custom.tsx extend context correctly 1 class="ant-form-item-control-input-content" >
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -1100,98 +1086,94 @@ exports[`renders components/watermark/demo/custom.tsx extend context correctly 1
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -1243,44 +1225,32 @@ exports[`renders components/watermark/demo/multi-line.tsx extend context correct exports[`renders components/watermark/demo/portal.tsx extend context correctly 1`] = ` Array [
-
- -
-
+ Show in Modal + + + -
-
+ Show in Drawer + + + -
+ + Not Show in Drawer + +
,
示例图片
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -430,99 +425,95 @@ exports[`renders components/watermark/demo/custom.tsx correctly 1`] = `
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -563,102 +554,97 @@ exports[`renders components/watermark/demo/custom.tsx correctly 1`] = ` class="ant-form-item-control-input-content" >
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -667,98 +653,94 @@ exports[`renders components/watermark/demo/custom.tsx correctly 1`] = `
-
- + + + + - + + -
-
- -
+ +
+
+
@@ -801,44 +783,32 @@ exports[`renders components/watermark/demo/multi-line.tsx correctly 1`] = ` exports[`renders components/watermark/demo/portal.tsx correctly 1`] = ` Array [
-
- -
-
+ Show in Modal + + + -
-
+ Show in Drawer + + + -
+ + Not Show in Drawer + +
,
; @@ -29,23 +29,17 @@ const App: React.FC = () => { }); const { content, color, fontSize, zIndex, rotate, gap, offset } = config; - const watermarkProps = useMemo( - () => ({ - content, - font: { - color: typeof color === 'string' ? color : color.toRgbString(), - fontSize, - }, - zIndex, - rotate, - gap, - offset, - }), - [config], - ); + const watermarkProps: WatermarkProps = { + content, + zIndex, + rotate, + gap, + offset, + font: { color: typeof color === 'string' ? color : color.toRgbString(), fontSize }, + }; return ( -
+ @@ -73,24 +67,13 @@ const App: React.FC = () => { 示例图片 { - + - + - + - + -
+ ); }; diff --git a/components/watermark/demo/image.md b/components/watermark/demo/image.md index a1ace81b1464..4cd9573dc85a 100644 --- a/components/watermark/demo/image.md +++ b/components/watermark/demo/image.md @@ -4,4 +4,4 @@ ## en-US -Specify the image address via 'image'. To ensure that the image is high definition and not stretched, set the width and height, and upload at least twice the width and height of the logo image address. +Specify the image address via `image`. To ensure that the image is high definition and not stretched, set the width and height, and upload at least twice the width and height of the logo image address. diff --git a/components/watermark/demo/multi-line.md b/components/watermark/demo/multi-line.md index 1207f337976c..8f6ade4eaedb 100644 --- a/components/watermark/demo/multi-line.md +++ b/components/watermark/demo/multi-line.md @@ -4,4 +4,4 @@ ## en-US -Use 'content' to set a string array to specify multi-line text watermark content. +Use `content` to set a string array to specify multi-line text watermark content. diff --git a/components/watermark/demo/portal.tsx b/components/watermark/demo/portal.tsx index 64bd52e82ef4..bd9e3391d64a 100644 --- a/components/watermark/demo/portal.tsx +++ b/components/watermark/demo/portal.tsx @@ -1,19 +1,15 @@ import React from 'react'; -import { Button, Drawer, Modal, Space, Watermark } from 'antd'; +import { Button, Drawer, Flex, Modal, Watermark } from 'antd'; -const placeholder = ( -
- A mock height -
-); +const style: React.CSSProperties = { + height: 300, + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + backgroundColor: 'rgba(150, 150, 150, 0.2)', +}; + +const placeholder =
A mock height
; const App: React.FC = () => { const [showModal, setShowModal] = React.useState(false); @@ -26,12 +22,17 @@ const App: React.FC = () => { return ( <> - - - - - - + + + + + This component is available since `antd@5.0.0`. + ### Watermark | Property | Description | Type | Default | Version | diff --git a/components/watermark/index.zh-CN.md b/components/watermark/index.zh-CN.md index efeef1145a82..60acffaac56e 100644 --- a/components/watermark/index.zh-CN.md +++ b/components/watermark/index.zh-CN.md @@ -10,7 +10,7 @@ demo: tag: New --- -给页面的某个区域加上水印。 +给页面的某个区域加上水印。自 `5.0.0` 版本开始提供该组件。 ## 何时使用 @@ -30,6 +30,8 @@ tag: New 通用属性参考:[通用属性](/docs/react/common-props) +> 自 `antd@5.0.0` 版本开始提供该组件。 + ### Watermark | 参数 | 说明 | 类型 | 默认值 | 版本 |