Skip to content

Conversation

thinkasany
Copy link
Member

@thinkasany thinkasany commented Dec 25, 2024

🤔 This is a ...

  • 🆕 New feature

RFC: #51885

Name Description Components
label Label element used to describe the table's th Descriptions
content Content element used to describe the table's td Descriptions
Language Changelog
🇺🇸 English feat: ConfigProvider support classNames and styles for Descriptions
🇨🇳 Chinese feat: ConfigProvider 支持配置Descriptions 组件的classNamesstyles

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Contributor

github-actions bot commented Dec 25, 2024

👁 Visual Regression Report for PR #52120 Failed ❌

🎯 Target branch: feature (3c1f56c)
📖 View Full Report ↗︎

Expected (Branch feature) Actual (Current PR) Diff
button-color-variant.dark.png button-color-variant.dark.png button-color-variant.dark.css-var.png button-color-variant.dark.css-var.png
button-debug-color-variant.compact.png button-debug-color-variant.compact.png button-debug-color-variant.compact.css-var.png button-debug-color-variant.compact.css-var.png
button-debug-color-variant.dark.png button-debug-color-variant.dark.png button-debug-color-variant.dark.css-var.png button-debug-color-variant.dark.css-var.png
button-debug-color-variant.default.png button-debug-color-variant.default.png button-debug-color-variant.default.css-var.png button-debug-color-variant.default.css-var.png
checkbox-custom-line-width.compact.png checkbox-custom-line-width.compact.png checkbox-custom-line-width.compact.css-var.png checkbox-custom-line-width.compact.css-var.png
checkbox-custom-line-width.dark.png checkbox-custom-line-width.dark.png checkbox-custom-line-width.dark.css-var.png checkbox-custom-line-width.dark.css-var.png
checkbox-custom-line-width.default.png checkbox-custom-line-width.default.png checkbox-custom-line-width.default.css-var.png checkbox-custom-line-width.default.css-var.png
checkbox-debug-line.compact.png checkbox-debug-line.compact.png checkbox-debug-line.compact.css-var.png checkbox-debug-line.compact.css-var.png

Warning

There are more diffs not shown in the table. Please check the Full Report for details.


Important

There are 35 diffs found in this PR: 🔄 35 changed.
Please check all items:

  • Checked all diffs in the full report
  • Visual diff is acceptable

Copy link
Contributor

github-actions bot commented Dec 25, 2024

Preview is ready

Copy link

Walkthrough

This pull request introduces a new feature to the ConfigProvider in the Ant Design library, allowing it to support classNames and styles for the Descriptions component. This enhancement provides more flexibility in styling and customizing the appearance of the Descriptions component.

Changes

Files Summary
components/config-provider/context.ts Added DescriptionsConfig type to include classNames and styles for Descriptions.
components/config-provider/index.en-US.md, components/config-provider/index.zh-CN.md Updated documentation to reflect the new classNames and styles support for Descriptions.
components/descriptions/Cell.tsx Integrated DescriptionsContext to apply classNames and styles to Descriptions cells.
components/descriptions/DescriptionsContext.ts Added new context properties for styles and classNames.
components/descriptions/Item.ts Added styles and classNames properties to Descriptions items.
components/descriptions/Row.tsx Updated to use new styles and classNames properties for rendering.
components/descriptions/tests/index.test.tsx Added tests to verify custom styles and classNames application.
components/descriptions/demo/_semantic.tsx Added a new demo showcasing semantic DOM usage with Descriptions.
components/descriptions/index.en-US.md, components/descriptions/index.zh-CN.md Updated documentation with semantic DOM example.
components/descriptions/index.tsx Enhanced Descriptions component to support styles and classNames.

{notEmpty(label) && <span style={labelStyle}>{label}</span>}
{notEmpty(content) && <span style={contentStyle}>{content}</span>}
{notEmpty(label) && <span style={{ ...labelStyle, ...styles?.label }}>{label}</span>}
{notEmpty(content) && <span style={{ ...labelStyle, ...styles?.content }}>{content}</span>}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that labelStyle is used for label and contentStyle for content. The current code mistakenly uses labelStyle for both.

Copy link

pkg-pr-new bot commented Dec 25, 2024

Copy link

codecov bot commented Dec 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (3c1f56c) to head (9575a82).
Report is 1 commits behind head on feature.

Additional details and impacted files
@@            Coverage Diff            @@
##           feature    #52120   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          763       763           
  Lines        13735     13744    +9     
  Branches      3587      3590    +3     
=========================================
+ Hits         13735     13744    +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thinkasany thinkasany marked this pull request as draft December 25, 2024 09:52
@thinkasany thinkasany marked this pull request as ready for review December 26, 2024 02:59
contentStyle?: React.CSSProperties;
styles?: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 里带上你这个变更的描述,我更新到 RFC 里去~

en: {
root: 'root element',
label: 'label element',
content: 'content element',
Copy link
Member

@zombieJ zombieJ Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

少了 title extra,另外需要确认一下 title 是否是一个好名字,还是应该用 header

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要不然 header 和 title 都开了,这两个语义的区别是是否包含padding,用户可以通过 header 调整padding,只关心具体字体相关的样式的话,选择使用title。
image

image

Copy link

codecov bot commented Dec 26, 2024

Bundle Report

Changes will decrease total bundle size by 6.23MB (-64.91%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.37MB 6.23MB (-64.91%) ⬇️

const App: React.FC = () => {
const [locale] = useLocale(locales);
return (
<SemanticPreview
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考 input 的形式再加一个表单形式的预览

@@ -0,0 +1,62 @@
import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

似乎占地有点多,加个 Switch 切换算了

};

return (
<div ref={divRef} style={{ width: 240, height: 100 }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要写死这个 width,现在看太小了:
截屏2024-12-31 11 46 12

至少也来 calc(100% - 32) & minWidth: 250 配合一下

<Descriptions
title="User Info"
items={items}
extra={'extra'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{`extra`} => "extra",话说这个能改成 Button 之类的东西么。extra 文字视觉上看起来怪怪的

};

return (
<div ref={divRef} style={{ width: '100%', height: 100 }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 height 不对呀,不需要这个高度的。另外可以做成上对齐的不,中间对齐的看起来还是比较怪异。

@zombieJ zombieJ merged commit 0745996 into ant-design:feature Jan 2, 2025
40 checks passed
@zombieJ zombieJ mentioned this pull request Jan 6, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants