Skip to content

Commit 16d21de

Browse files
feat(modal): Add a close button element in semantic
1 parent 15ef740 commit 16d21de

5 files changed

Lines changed: 109 additions & 1 deletion

File tree

components/modal/__tests__/__snapshots__/demo-semantic.test.tsx.snap

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,104 @@ exports[`renders components/modal/demo/_semantic.tsx correctly 1`] = `
868868
</div>
869869
</div>
870870
</li>
871+
<li
872+
class="acss-1ehfz5v"
873+
>
874+
<div
875+
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-small ant-flex-vertical"
876+
>
877+
<div
878+
class="ant-flex css-var-test-id ant-flex-align-center ant-flex-justify-space-between ant-flex-gap-small"
879+
>
880+
<div
881+
class="ant-flex css-var-test-id ant-flex-align-center ant-flex-gap-small"
882+
>
883+
<h5
884+
class="ant-typography css-var-test-id"
885+
style="margin: 0px;"
886+
>
887+
close
888+
</h5>
889+
<span
890+
class="ant-tag ant-tag-filled ant-tag-blue css-var-test-id"
891+
>
892+
6.4.0
893+
</span>
894+
</div>
895+
<div
896+
class="ant-flex css-var-test-id ant-flex-align-center ant-flex-gap-small"
897+
>
898+
<button
899+
aria-hidden="true"
900+
class="ant-btn css-var-test-id ant-btn-default ant-btn-color-default ant-btn-variant-text ant-btn-sm ant-btn-icon-only"
901+
type="button"
902+
>
903+
<span
904+
class="ant-btn-icon"
905+
>
906+
<span
907+
aria-label="pushpin"
908+
class="anticon anticon-pushpin"
909+
role="img"
910+
>
911+
<svg
912+
aria-hidden="true"
913+
data-icon="pushpin"
914+
fill="currentColor"
915+
focusable="false"
916+
height="1em"
917+
viewBox="64 64 896 896"
918+
width="1em"
919+
>
920+
<path
921+
d="M878.3 392.1L631.9 145.7c-6.5-6.5-15-9.7-23.5-9.7s-17 3.2-23.5 9.7L423.8 306.9c-12.2-1.4-24.5-2-36.8-2-73.2 0-146.4 24.1-206.5 72.3a33.23 33.23 0 00-2.7 49.4l181.7 181.7-215.4 215.2a15.8 15.8 0 00-4.6 9.8l-3.4 37.2c-.9 9.4 6.6 17.4 15.9 17.4.5 0 1 0 1.5-.1l37.2-3.4c3.7-.3 7.2-2 9.8-4.6l215.4-215.4 181.7 181.7c6.5 6.5 15 9.7 23.5 9.7 9.7 0 19.3-4.2 25.9-12.4 56.3-70.3 79.7-158.3 70.2-243.4l161.1-161.1c12.9-12.8 12.9-33.8 0-46.8zM666.2 549.3l-24.5 24.5 3.8 34.4a259.92 259.92 0 01-30.4 153.9L262 408.8c12.9-7.1 26.3-13.1 40.3-17.9 27.2-9.4 55.7-14.1 84.7-14.1 9.6 0 19.3.5 28.9 1.6l34.4 3.8 24.5-24.5L608.5 224 800 415.5 666.2 549.3z"
922+
/>
923+
</svg>
924+
</span>
925+
</span>
926+
</button>
927+
<button
928+
aria-hidden="true"
929+
class="ant-btn css-var-test-id ant-btn-text ant-btn-color-default ant-btn-variant-text ant-btn-sm ant-btn-icon-only"
930+
type="button"
931+
>
932+
<span
933+
class="ant-btn-icon"
934+
>
935+
<span
936+
aria-label="info-circle"
937+
class="anticon anticon-info-circle"
938+
role="img"
939+
>
940+
<svg
941+
aria-hidden="true"
942+
data-icon="info-circle"
943+
fill="currentColor"
944+
focusable="false"
945+
height="1em"
946+
viewBox="64 64 896 896"
947+
width="1em"
948+
>
949+
<path
950+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
951+
/>
952+
<path
953+
d="M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"
954+
/>
955+
</svg>
956+
</span>
957+
</span>
958+
</button>
959+
</div>
960+
</div>
961+
<div
962+
class="ant-typography css-var-test-id"
963+
style="margin: 0px; font-size: 12px;"
964+
>
965+
预览关闭按钮元素,设置按钮的基础样式
966+
</div>
967+
</div>
968+
</li>
871969
</ul>
872970
</div>
873971
</div>

components/modal/__tests__/semantic.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('Modal.Semantic', () => {
2626
title: 'custom-title',
2727
body: 'custom-body',
2828
footer: 'custom-footer',
29+
close: 'custom-close',
2930
};
3031

3132
const customStyles = {
@@ -36,6 +37,7 @@ describe('Modal.Semantic', () => {
3637
title: { padding: '50px' },
3738
body: { padding: '60px' },
3839
footer: { padding: '70px' },
40+
close: { color: 'rgb(255,255,255)' },
3941
};
4042

4143
render(<Modal classNames={customClassNames} styles={customStyles} open title="title" />);
@@ -47,6 +49,7 @@ describe('Modal.Semantic', () => {
4749
const titleElement = document.querySelector<HTMLElement>('.ant-modal-title');
4850
const bodyElement = document.querySelector<HTMLElement>('.ant-modal-body');
4951
const footerElement = document.querySelector<HTMLElement>('.ant-modal-footer');
52+
const closeElement = document.querySelector<HTMLElement>('.ant-modal-close');
5053

5154
// check classNames
5255
expect(rootElement).toHaveClass('custom-root');
@@ -56,6 +59,7 @@ describe('Modal.Semantic', () => {
5659
expect(titleElement).toHaveClass('custom-title');
5760
expect(bodyElement).toHaveClass('custom-body');
5861
expect(footerElement).toHaveClass('custom-footer');
62+
expect(closeElement).toHaveClass('custom-close');
5963

6064
// check styles
6165
expect(rootElement).toHaveStyle({ padding: customStyles.root.padding });
@@ -65,6 +69,7 @@ describe('Modal.Semantic', () => {
6569
expect(titleElement).toHaveStyle({ padding: customStyles.title.padding });
6670
expect(bodyElement).toHaveStyle({ padding: customStyles.body.padding });
6771
expect(footerElement).toHaveStyle({ padding: customStyles.footer.padding });
72+
expect(closeElement).toHaveStyle({ color: customStyles.close.color });
6873
});
6974

7075
it('Modal should apply dynamic classNames and styles from props function', () => {

components/modal/demo/_semantic.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const locales = {
1616
title: '标题元素,包含外边距、颜色、字体权重、字体大小、行高、文字换行等标题文字样式',
1717
body: '内容元素,包含内容区域的背景色、内边距等内容展示样式',
1818
footer: '底部元素,包含底部的背景色、内边距、上边框、圆角等底部区域样式',
19+
close: '预览关闭按钮元素,设置按钮的基础样式',
1920
},
2021
en: {
2122
root: 'Root element with relative positioning, top position, width, max-width, margins, bottom padding and other basic layout styles for modal container',
@@ -30,6 +31,7 @@ const locales = {
3031
body: 'Body element with content area background color, padding and other content display styles',
3132
footer:
3233
'Footer element with footer background color, padding, top border, border-radius and other footer area styles',
34+
close: 'Preview close button element, sets basic button styles',
3335
},
3436
};
3537

@@ -67,6 +69,7 @@ const App: React.FC = () => {
6769
{ name: 'title', desc: locale.title, version: '6.0.0' },
6870
{ name: 'body', desc: locale.body, version: '5.13.0' },
6971
{ name: 'footer', desc: locale.footer, version: '5.13.0' },
72+
{ name: 'close', desc: locale.close, version: '6.4.0' },
7073
]}
7174
>
7275
<BlockModal title="Title" closable={false} open getContainer={false} width={400}>

components/modal/interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type ModalSemanticType = {
1818
title?: string;
1919
wrapper?: string;
2020
mask?: string;
21+
close?: string;
2122
};
2223
styles?: {
2324
root?: React.CSSProperties;
@@ -28,6 +29,7 @@ export type ModalSemanticType = {
2829
title?: React.CSSProperties;
2930
wrapper?: React.CSSProperties;
3031
mask?: React.CSSProperties;
32+
close?: React.CSSProperties;
3133
};
3234
};
3335

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"@rc-component/checkbox": "~2.0.0",
118118
"@rc-component/collapse": "~1.2.0",
119119
"@rc-component/color-picker": "~3.1.1",
120-
"@rc-component/dialog": "~1.8.4",
120+
"@rc-component/dialog": "~1.9.0",
121121
"@rc-component/drawer": "~1.4.2",
122122
"@rc-component/dropdown": "~1.0.2",
123123
"@rc-component/form": "~1.7.1",

0 commit comments

Comments
 (0)