Browse Source

feat: less to component token for List (#42041)

* feat: less variables to component token for List

* Update migrate-less-variables.en-US.md

* feat: recover less variables

* feat: add debug demo

* chore: update snapshot

* chore: rename

* chore: rename && fix ts && recover itemPaddingLG

---------

Co-authored-by: zhangjianxiong <zhangjx@tsintergy.com>
Co-authored-by: MadCcc <1075746765@qq.com>
pull/42518/head
Zack Chang 2 years ago
committed by GitHub
parent
commit
a5069624bf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 654
      components/list/__tests__/__snapshots__/demo-extend.test.ts.snap
  2. 659
      components/list/__tests__/__snapshots__/demo.test.ts.snap
  3. 7
      components/list/demo/component-token.md
  4. 113
      components/list/demo/component-token.tsx
  5. 1
      components/list/index.en-US.md
  6. 1
      components/list/index.zh-CN.md
  7. 75
      components/list/style/index.ts
  8. 17
      docs/react/migrate-less-variables.en-US.md
  9. 17
      docs/react/migrate-less-variables.zh-CN.md

654
components/list/__tests__/__snapshots__/demo-extend.test.ts.snap

@ -167,6 +167,660 @@ exports[`renders components/list/demo/basic.tsx extend context correctly 1`] = `
</div>
`;
exports[`renders components/list/demo/component-token.tsx extend context correctly 1`] = `
Array [
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Default Size
</span>
</div>,
<div
class="ant-list ant-list-split ant-list-bordered ant-list-something-after-last-item"
>
<div
class="ant-list-header"
>
<div>
Header
</div>
</div>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
Los Angeles battles huge wildfires.
</li>
</ul>
</div>
</div>
<div
class="ant-list-footer"
>
<div>
Footer
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Small Size
</span>
</div>,
<div
class="ant-list ant-list-sm ant-list-split ant-list-bordered ant-list-something-after-last-item"
>
<div
class="ant-list-header"
>
<div>
Header
</div>
</div>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item"
>
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item"
>
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item"
>
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item"
>
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item"
>
Los Angeles battles huge wildfires.
</li>
</ul>
</div>
</div>
<div
class="ant-list-footer"
>
<div>
Footer
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Large Size
</span>
</div>,
<div
class="ant-list ant-list-lg ant-list-split ant-list-bordered ant-list-something-after-last-item"
>
<div
class="ant-list-header"
>
<div>
Header
</div>
</div>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item"
>
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item"
>
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item"
>
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item"
>
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item"
>
Los Angeles battles huge wildfires.
</li>
</ul>
</div>
</div>
<div
class="ant-list-footer"
>
<div>
Footer
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Meta
</span>
</div>,
<div
class="ant-list ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=0"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 1
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=1"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 2
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=2"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 3
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=3"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 4
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Vertical
</span>
</div>,
<div
class="ant-list ant-list-vertical ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=0"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 1
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=1"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 2
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=2"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 3
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=3"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 4
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Empty Text
</span>
</div>,
<div
class="ant-list ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="ant-list-empty-text"
>
<div
class="ant-empty ant-empty-normal"
>
<div
class="ant-empty-image"
>
<svg
height="41"
viewBox="0 0 64 41"
width="64"
xmlns="http://www.w3.org/2000/svg"
>
<g
fill="none"
fill-rule="evenodd"
transform="translate(0 1)"
>
<ellipse
cx="32"
cy="33"
fill="#f5f5f5"
rx="32"
ry="7"
/>
<g
fill-rule="nonzero"
stroke="#d9d9d9"
>
<path
d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
/>
<path
d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"
fill="#fafafa"
/>
</g>
</g>
</svg>
</div>
<div
class="ant-empty-description"
>
No data
</div>
</div>
</div>
</div>
</div>
</div>,
]
`;
exports[`renders components/list/demo/grid.tsx extend context correctly 1`] = `
<div
class="ant-list ant-list-split ant-list-grid"

659
components/list/__tests__/__snapshots__/demo.test.ts.snap

@ -167,6 +167,665 @@ exports[`renders components/list/demo/basic.tsx correctly 1`] = `
</div>
`;
exports[`renders components/list/demo/component-token.tsx correctly 1`] = `
Array [
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Default Size
</span>
</div>,
<div
class="ant-list ant-list-split ant-list-bordered ant-list-something-after-last-item"
>
<div
class="ant-list-header"
>
<div>
Header
</div>
</div>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
<!-- -->
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
<!-- -->
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
<!-- -->
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
<!-- -->
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<span
class="ant-typography"
>
<mark>
[ITEM]
</mark>
</span>
<!-- -->
Los Angeles battles huge wildfires.
</li>
</ul>
</div>
</div>
<div
class="ant-list-footer"
>
<div>
Footer
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Small Size
</span>
</div>,
<div
class="ant-list ant-list-sm ant-list-split ant-list-bordered ant-list-something-after-last-item"
>
<div
class="ant-list-header"
>
<div>
Header
</div>
</div>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item"
>
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item"
>
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item"
>
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item"
>
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item"
>
Los Angeles battles huge wildfires.
</li>
</ul>
</div>
</div>
<div
class="ant-list-footer"
>
<div>
Footer
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Large Size
</span>
</div>,
<div
class="ant-list ant-list-lg ant-list-split ant-list-bordered ant-list-something-after-last-item"
>
<div
class="ant-list-header"
>
<div>
Header
</div>
</div>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item"
>
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item"
>
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item"
>
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item"
>
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item"
>
Los Angeles battles huge wildfires.
</li>
</ul>
</div>
</div>
<div
class="ant-list-footer"
>
<div>
Footer
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Meta
</span>
</div>,
<div
class="ant-list ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=0"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 1
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=1"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 2
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=2"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 3
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=3"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 4
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Vertical
</span>
</div>,
<div
class="ant-list ant-list-vertical ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<ul
class="ant-list-items"
>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=0"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 1
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=1"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 2
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=2"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 3
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
<li
class="ant-list-item ant-list-item-no-flex"
>
<div
class="ant-list-item-meta"
>
<div
class="ant-list-item-meta-avatar"
>
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<img
src="https://xsgames.co/randomusers/avatar.php?g=pixel&key=3"
/>
</span>
</div>
<div
class="ant-list-item-meta-content"
>
<h4
class="ant-list-item-meta-title"
>
<a
href="https://ant.design"
>
Ant Design Title 4
</a>
</h4>
<div
class="ant-list-item-meta-description"
>
Ant Design, a design language for background applications, is refined by Ant UED Team
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>,
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-left"
role="separator"
>
<span
class="ant-divider-inner-text"
>
Empty Text
</span>
</div>,
<div
class="ant-list ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="ant-list-empty-text"
>
<div
class="ant-empty ant-empty-normal"
>
<div
class="ant-empty-image"
>
<svg
height="41"
viewBox="0 0 64 41"
width="64"
xmlns="http://www.w3.org/2000/svg"
>
<g
fill="none"
fill-rule="evenodd"
transform="translate(0 1)"
>
<ellipse
cx="32"
cy="33"
fill="#f5f5f5"
rx="32"
ry="7"
/>
<g
fill-rule="nonzero"
stroke="#d9d9d9"
>
<path
d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
/>
<path
d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"
fill="#fafafa"
/>
</g>
</g>
</svg>
</div>
<div
class="ant-empty-description"
>
No data
</div>
</div>
</div>
</div>
</div>
</div>,
]
`;
exports[`renders components/list/demo/grid.tsx correctly 1`] = `
<div
class="ant-list ant-list-split ant-list-grid"

7
components/list/demo/component-token.md

@ -0,0 +1,7 @@
## zh-CN
自定义组件 Token。
## en-US
Custom component token.

113
components/list/demo/component-token.tsx

@ -0,0 +1,113 @@
import { Avatar, ConfigProvider, Divider, List, Typography } from 'antd';
import React from 'react';
const data = [
'Racing car sprays burning fuel into crowd.',
'Japanese princess to wed commoner.',
'Australian walks 100km after outback crash.',
'Man charged over missing wedding girl.',
'Los Angeles battles huge wildfires.',
];
const data1 = [
{
title: 'Ant Design Title 1',
},
{
title: 'Ant Design Title 2',
},
{
title: 'Ant Design Title 3',
},
{
title: 'Ant Design Title 4',
},
];
const App: React.FC = () => (
<ConfigProvider
theme={{
components: {
List: {
headerBg: 'pink',
footerBg: 'pink',
emptyTextPadding: 32,
itemPadding: '26px',
itemPaddingSM: '16px',
itemPaddingLG: '36px',
metaMarginBottom: 20,
avatarMarginRight: 20,
titleMarginBottom: 10,
descriptionFontSize: 20,
},
},
}}
>
<Divider orientation="left">Default Size</Divider>
<List
header={<div>Header</div>}
footer={<div>Footer</div>}
bordered
dataSource={data}
renderItem={(item) => (
<List.Item>
<Typography.Text mark>[ITEM]</Typography.Text> {item}
</List.Item>
)}
/>
<Divider orientation="left">Small Size</Divider>
<List
size="small"
header={<div>Header</div>}
footer={<div>Footer</div>}
bordered
dataSource={data}
renderItem={(item) => <List.Item>{item}</List.Item>}
/>
<Divider orientation="left">Large Size</Divider>
<List
size="large"
header={<div>Header</div>}
footer={<div>Footer</div>}
bordered
dataSource={data}
renderItem={(item) => <List.Item>{item}</List.Item>}
/>
<Divider orientation="left">Meta</Divider>
<List
itemLayout="horizontal"
dataSource={data1}
renderItem={(item, index) => (
<List.Item>
<List.Item.Meta
avatar={
<Avatar src={`https://xsgames.co/randomusers/avatar.php?g=pixel&key=${index}`} />
}
title={<a href="https://ant.design">{item.title}</a>}
description="Ant Design, a design language for background applications, is refined by Ant UED Team"
/>
</List.Item>
)}
/>
<Divider orientation="left">Vertical</Divider>
<List
itemLayout="vertical"
dataSource={data1}
renderItem={(item, index) => (
<List.Item>
<List.Item.Meta
avatar={
<Avatar src={`https://xsgames.co/randomusers/avatar.php?g=pixel&key=${index}`} />
}
title={<a href="https://ant.design">{item.title}</a>}
description="Ant Design, a design language for background applications, is refined by Ant UED Team"
/>
</List.Item>
)}
/>
<Divider orientation="left">Empty Text</Divider>
<List />
</ConfigProvider>
);
export default App;

1
components/list/index.en-US.md

@ -25,6 +25,7 @@ A list can be used to display content related to a single subject. The content c
<code src="./demo/responsive.tsx">Responsive grid list</code>
<code src="./demo/infinite-load.tsx">Scrolling loaded</code>
<code src="./demo/virtual-list.tsx">virtual list</code>
<code src="./demo/component-token.tsx" debug>custom component token</code>
## API

1
components/list/index.zh-CN.md

@ -26,6 +26,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*tBzwQ7raKX8AAA
<code src="./demo/responsive.tsx">响应式的栅格列表</code>
<code src="./demo/infinite-load.tsx">滚动加载</code>
<code src="./demo/virtual-list.tsx">滚动加载无限长列表</code>
<code src="./demo/component-token.tsx" debug>自定义组件 token</code>
## API

75
components/list/style/index.ts

@ -1,18 +1,26 @@
import type { CSSObject } from '@ant-design/cssinjs';
import type { CSSProperties } from 'react';
import { resetComponent } from '../../style';
import type { FullToken, GenerateStyle } from '../../theme/internal';
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
export interface ComponentToken {
contentWidth: number;
itemPaddingLG: string;
itemPaddingSM: string;
itemPadding: string;
headerBg: string;
footerBg: string;
emptyTextPadding: CSSProperties['padding'];
metaMarginBottom: CSSProperties['marginBottom'];
avatarMarginRight: CSSProperties['marginRight'];
titleMarginBottom: CSSProperties['marginBottom'];
descriptionFontSize: number;
}
interface ListToken extends FullToken<'List'> {
listBorderedCls: string;
minHeight: number;
listItemPaddingLG: string;
listItemPaddingSM: string;
listItemPadding: string;
}
const genBorderedStyle = (token: ListToken): CSSObject => {
@ -21,8 +29,8 @@ const genBorderedStyle = (token: ListToken): CSSObject => {
componentCls,
paddingLG,
margin,
padding,
listItemPaddingSM,
itemPaddingSM,
itemPaddingLG,
marginLG,
borderRadiusLG,
} = token;
@ -40,13 +48,13 @@ const genBorderedStyle = (token: ListToken): CSSObject => {
},
[`${listBorderedCls}${componentCls}-sm`]: {
[`${componentCls}-item,${componentCls}-header,${componentCls}-footer`]: {
padding: listItemPaddingSM,
padding: itemPaddingSM,
},
},
[`${listBorderedCls}${componentCls}-lg`]: {
[`${componentCls}-item,${componentCls}-header,${componentCls}-footer`]: {
padding: `${padding}px ${paddingLG}px`,
padding: itemPaddingLG,
},
},
};
@ -110,16 +118,23 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
paddingSM,
marginLG,
padding,
listItemPadding,
itemPadding,
colorPrimary,
listItemPaddingSM,
listItemPaddingLG,
itemPaddingSM,
itemPaddingLG,
paddingXS,
margin,
colorText,
colorTextDescription,
motionDurationSlow,
lineWidth,
headerBg,
footerBg,
emptyTextPadding,
metaMarginBottom,
avatarMarginRight,
titleMarginBottom,
descriptionFontSize,
} = token;
const alignCls: any = {};
@ -136,8 +151,13 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
'*': {
outline: 'none',
},
[`${componentCls}-header`]: {
background: headerBg,
},
[`${componentCls}-footer`]: {
background: footerBg,
},
[`${componentCls}-header, ${componentCls}-footer`]: {
background: 'transparent',
paddingBlock: paddingSM,
},
@ -167,7 +187,7 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: listItemPadding,
padding: itemPadding,
color: colorText,
[`${componentCls}-item-meta`]: {
@ -177,7 +197,7 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
maxWidth: '100%',
[`${componentCls}-item-meta-avatar`]: {
marginInlineEnd: padding,
marginInlineEnd: avatarMarginRight,
},
[`${componentCls}-item-meta-content`]: {
@ -204,7 +224,7 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
[`${componentCls}-item-meta-description`]: {
color: colorTextDescription,
fontSize: token.fontSize,
fontSize: descriptionFontSize,
lineHeight: token.lineHeight,
},
},
@ -250,7 +270,7 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
},
[`${componentCls}-empty-text`]: {
padding,
padding: emptyTextPadding,
color: token.colorTextDisabled,
fontSize: token.fontSize,
textAlign: 'center',
@ -281,11 +301,11 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
},
[`${componentCls}-item-meta`]: {
marginBlockEnd: padding,
marginBlockEnd: metaMarginBottom,
[`${componentCls}-item-meta-title`]: {
marginBlockStart: 0,
marginBlockEnd: paddingSM,
marginBlockEnd: titleMarginBottom,
color: colorText,
fontSize: token.fontSizeLG,
lineHeight: token.lineHeightLG,
@ -328,10 +348,10 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
borderBlockEnd: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
},
[`${componentCls}-lg ${componentCls}-item`]: {
padding: listItemPaddingLG,
padding: itemPaddingLG,
},
[`${componentCls}-sm ${componentCls}-item`]: {
padding: listItemPaddingSM,
padding: itemPaddingSM,
},
// Horizontal
[`${componentCls}:not(${componentCls}-vertical)`]: {
@ -351,14 +371,21 @@ export default genComponentStyleHook(
const listToken = mergeToken<ListToken>(token, {
listBorderedCls: `${token.componentCls}-bordered`,
minHeight: token.controlHeightLG,
listItemPadding: `${token.paddingContentVertical}px 0`,
listItemPaddingSM: `${token.paddingContentVerticalSM}px ${token.paddingContentHorizontal}px`,
listItemPaddingLG: `${token.paddingContentVerticalLG}px ${token.paddingContentHorizontalLG}px`,
});
return [genBaseStyle(listToken), genBorderedStyle(listToken), genResponsiveStyle(listToken)];
},
{
(token) => ({
contentWidth: 220,
},
itemPadding: `${token.paddingContentVertical}px 0`,
itemPaddingSM: `${token.paddingContentVerticalSM}px ${token.paddingContentHorizontal}px`,
itemPaddingLG: `${token.paddingContentVerticalLG}px ${token.paddingContentHorizontalLG}px`,
headerBg: 'transparent',
footerBg: 'transparent',
emptyTextPadding: token.padding,
metaMarginBottom: token.padding,
avatarMarginRight: token.padding,
titleMarginBottom: token.paddingSM,
descriptionFontSize: token.fontSize,
}),
);

17
docs/react/migrate-less-variables.en-US.md

@ -141,7 +141,22 @@ This document contains the correspondence between all the less variables related
<!-- ### Layout -->
<!-- ### List -->
### List
<!-- prettier-ignore -->
| Less variables | Component Token | Note |
| --- | --- | --- |
| `@list-header-background` | `headerBg` | - |
| `@list-footer-background` | `footerBg` | - |
| `@list-empty-text-padding` | `emptyTextPadding` | - |
| `@list-item-padding` | `itemPadding` | - |
| `@list-item-padding-sm` | `itemPaddingSM` | - |
| `@list-item-padding-lg` | `itemPaddingLG` | - |
| `@list-item-meta-margin-bottom` | `metaMarginBottom` | - |
| `@list-item-meta-avatar-margin-right` | `avatarMarginRight` | - |
| `@list-item-meta-title-margin-bottom` | `titleMarginBottom` | - |
| `@list-customize-card-bg` | - | Deprecated for style change |
| `@list-item-meta-description-font-size` | `descriptionFontSize` | - |
<!-- ### Mentions -->

17
docs/react/migrate-less-variables.zh-CN.md

@ -139,7 +139,22 @@ title: Less 变量迁移 Design Token
<!-- ### Layout 布局 -->
<!-- ### List 列表 -->
### List 列表
<!-- prettier-ignore -->
| less 变量 | Component Token | 备注 |
| --- | --- | --- |
| `@list-header-background` | `headerBg` | - |
| `@list-footer-background` | `footerBg` | - |
| `@list-empty-text-padding` | `emptyTextPadding` | - |
| `@list-item-padding` | `itemPadding` | - |
| `@list-item-padding-sm` | `itemPaddingSM` | - |
| `@list-item-padding-lg` | `itemPaddingLG` | - |
| `@list-item-meta-margin-bottom` | `metaMarginBottom` | - |
| `@list-item-meta-avatar-margin-right` | `avatarMarginRight` | - |
| `@list-item-meta-title-margin-bottom` | `titleMarginBottom` | - |
| `@list-customize-card-bg` | - | 由于样式变化已废弃 |
| `@list-item-meta-description-font-size` | `descriptionFontSize` | - |
<!-- ### Mentions 提及 -->

Loading…
Cancel
Save