Skip to content

Commit e6aaa1b

Browse files
feat(tour): add a close button element for semantic (ant-design#57268)
Co-authored-by: 遇见同学 <1875694521@qq.com>
1 parent cd7e1f4 commit e6aaa1b

6 files changed

Lines changed: 113 additions & 3 deletions

File tree

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

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ exports[`renders components/tour/demo/_semantic.tsx correctly 1`] = `
3737
>
3838
<button
3939
aria-label="Close"
40-
class="ant-tour-close"
40+
class="ant-tour-close semantic-mark-close"
4141
type="button"
4242
>
4343
<span
@@ -512,6 +512,104 @@ exports[`renders components/tour/demo/_semantic.tsx correctly 1`] = `
512512
</div>
513513
</div>
514514
</li>
515+
<li
516+
class="acss-1ehfz5v"
517+
>
518+
<div
519+
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-small ant-flex-vertical"
520+
>
521+
<div
522+
class="ant-flex css-var-test-id ant-flex-align-center ant-flex-justify-space-between ant-flex-gap-small"
523+
>
524+
<div
525+
class="ant-flex css-var-test-id ant-flex-align-center ant-flex-gap-small"
526+
>
527+
<h5
528+
class="ant-typography css-var-test-id"
529+
style="margin: 0px;"
530+
>
531+
close
532+
</h5>
533+
<span
534+
class="ant-tag ant-tag-filled ant-tag-blue css-var-test-id"
535+
>
536+
6.4.0
537+
</span>
538+
</div>
539+
<div
540+
class="ant-flex css-var-test-id ant-flex-align-center ant-flex-gap-small"
541+
>
542+
<button
543+
aria-hidden="true"
544+
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"
545+
type="button"
546+
>
547+
<span
548+
class="ant-btn-icon"
549+
>
550+
<span
551+
aria-label="pushpin"
552+
class="anticon anticon-pushpin"
553+
role="img"
554+
>
555+
<svg
556+
aria-hidden="true"
557+
data-icon="pushpin"
558+
fill="currentColor"
559+
focusable="false"
560+
height="1em"
561+
viewBox="64 64 896 896"
562+
width="1em"
563+
>
564+
<path
565+
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"
566+
/>
567+
</svg>
568+
</span>
569+
</span>
570+
</button>
571+
<button
572+
aria-hidden="true"
573+
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"
574+
type="button"
575+
>
576+
<span
577+
class="ant-btn-icon"
578+
>
579+
<span
580+
aria-label="info-circle"
581+
class="anticon anticon-info-circle"
582+
role="img"
583+
>
584+
<svg
585+
aria-hidden="true"
586+
data-icon="info-circle"
587+
fill="currentColor"
588+
focusable="false"
589+
height="1em"
590+
viewBox="64 64 896 896"
591+
width="1em"
592+
>
593+
<path
594+
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"
595+
/>
596+
<path
597+
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"
598+
/>
599+
</svg>
600+
</span>
601+
</span>
602+
</button>
603+
</div>
604+
</div>
605+
<div
606+
class="ant-typography css-var-test-id"
607+
style="margin: 0px; font-size: 12px;"
608+
>
609+
关闭按钮元素,设置绝对定位、尺寸、颜色、悬浮态和交互反馈等关闭按钮样式
610+
</div>
611+
</div>
612+
</li>
515613
<li
516614
class="acss-1ehfz5v"
517615
>

components/tour/__tests__/semantic.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('Tour.Semantic', () => {
99
const customClassnames: TourProps['classNames'] = (_info) => ({
1010
mask: _info?.props.type === 'primary' ? 'primary-mask-fn' : 'primary-mask-fn',
1111
actions: 'custom-actions-fn',
12+
close: 'custom-close-fn',
1213
title: 'custom-title-fn',
1314
header: 'custom-header-fn',
1415
section: 'custom-section-fn',
@@ -23,6 +24,7 @@ describe('Tour.Semantic', () => {
2324
const customStyles: TourProps['styles'] = (_info) => ({
2425
mask: { color: _info?.props.type === 'primary' ? 'white' : 'black' },
2526
actions: { color: 'blue' },
27+
close: { color: 'pink' },
2628
title: { fontSize: '20px' },
2729
header: { backgroundColor: 'gray' },
2830
section: { margin: _info?.props.type === 'primary' ? '10px' : '5px' },
@@ -78,6 +80,7 @@ describe('Tour.Semantic', () => {
7880
const footerElement = document.querySelector<HTMLElement>('.ant-tour-footer');
7981
const descriptionElement = document.querySelector<HTMLElement>('.ant-tour-description');
8082
const coverElement = document.querySelector<HTMLElement>('.ant-tour-cover');
83+
const closeElement = document.querySelector<HTMLElement>('.ant-tour-close');
8184
const indicatorElement = document.querySelector<HTMLElement>('.ant-tour-indicator');
8285
const indicatorsElement = document.querySelector<HTMLElement>('.ant-tour-indicators');
8386
const rootElement = document.querySelector<HTMLElement>('.ant-tour-mask');
@@ -90,6 +93,7 @@ describe('Tour.Semantic', () => {
9093
expect(footerElement).toHaveClass('primary-footer-fn');
9194
expect(descriptionElement).toHaveClass('custom-description-fn');
9295
expect(coverElement).toHaveClass('custom-cover-fn');
96+
expect(closeElement).toHaveClass('custom-close-fn');
9397
expect(indicatorElement).toHaveClass('custom-indicator-fn');
9498
expect(indicatorsElement).toHaveClass('custom-indicators-fn');
9599
expect(rootElement).toHaveClass('custom-root-fn');
@@ -102,6 +106,7 @@ describe('Tour.Semantic', () => {
102106
expect(footerElement).toHaveStyle({ borderTopWidth: '1px' });
103107
expect(descriptionElement).toHaveStyle({ fontStyle: 'italic' });
104108
expect(coverElement).toHaveStyle({ color: 'rgb(255, 0, 0)' });
109+
expect(closeElement).toHaveStyle({ color: 'rgb(255, 192, 203)' });
105110
expect(indicatorElement).toHaveStyle({ color: 'rgb(0, 128, 0)' });
106111
expect(indicatorsElement).toHaveStyle({ color: 'rgb(255, 255, 0)' });
107112
expect(rootElement).toHaveStyle({ backgroundColor: 'rgb(255, 255, 0)' });

components/tour/demo/_semantic.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const locales = {
99
cn: {
1010
root: '引导根容器,设置绝对定位、层级控制、最大宽度、可见性、箭头背景色变量、主题样式等容器样式',
1111
cover: '卡片封面区域,设置文本居中对齐、内边距、图片宽度等图片展示样式',
12+
close: '关闭按钮元素,设置绝对定位、尺寸、颜色、悬浮态和交互反馈等关闭按钮样式',
1213
section:
1314
'卡片主要内容区域,设置文本对齐、边框圆角、盒阴影、相对定位、背景色、边框、背景裁剪等卡片样式',
1415
footer: '卡片底部操作区域,设置内边距、文本右对齐、边框圆角、Flex布局等底部容器样式',
@@ -25,6 +26,8 @@ const locales = {
2526
root: 'Tour root container with absolute positioning, z-index control, max width, visibility, arrow background color variable, theme styles and other container styles',
2627
cover:
2728
'Card cover area with text center alignment, padding, image width and other image display styles',
29+
close:
30+
'Close button element with absolute positioning, size, color, hover state and other interactive feedback styles',
2831
section:
2932
'Card main content area with text alignment, border radius, box shadow, relative positioning, background color, border, background clip and other card styles',
3033
footer:
@@ -102,6 +105,7 @@ const App: React.FC = () => {
102105
{ name: 'mask', desc: locale.mask, version: '6.0.0' },
103106
{ name: 'section', desc: locale.section, version: '6.0.0' },
104107
{ name: 'cover', desc: locale.cover, version: '6.0.0' },
108+
{ name: 'close', desc: locale.close, version: '6.4.0' },
105109
{ name: 'header', desc: locale.header, version: '6.0.0' },
106110
{ name: 'title', desc: locale.title, version: '6.0.0' },
107111
{ name: 'description', desc: locale.description, version: '6.0.0' },

components/tour/interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type TourSemanticType = {
1010
classNames?: {
1111
root?: string;
1212
cover?: string;
13+
close?: string;
1314
mask?: string;
1415
section?: string;
1516
footer?: string;
@@ -23,6 +24,7 @@ export type TourSemanticType = {
2324
styles?: {
2425
root?: React.CSSProperties;
2526
cover?: React.CSSProperties;
27+
close?: React.CSSProperties;
2628
mask?: React.CSSProperties;
2729
section?: React.CSSProperties;
2830
footer?: React.CSSProperties;

components/tour/panelRender.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const TourPanel: React.FC<TourPanelProps> = (props) => {
5656
<button
5757
type="button"
5858
onClick={onClose}
59-
className={`${prefixCls}-close`}
59+
className={clsx(`${prefixCls}-close`, classNames.close)}
60+
style={styles.close}
6061
aria-label={contextLocaleGlobal?.close}
6162
{...ariaProps}
6263
>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"@rc-component/tabs": "~1.8.0",
145145
"@rc-component/textarea": "~1.2.0",
146146
"@rc-component/tooltip": "~1.4.0",
147-
"@rc-component/tour": "~2.3.0",
147+
"@rc-component/tour": "~2.4.0",
148148
"@rc-component/tree": "~1.2.4",
149149
"@rc-component/tree-select": "~1.8.0",
150150
"@rc-component/trigger": "^3.9.0",

0 commit comments

Comments
 (0)