Browse Source

feat: migrate less to token for Rate (#42135)

* feat: rename rate token

* docs: add component-token demo
pull/42390/merge
muxin 2 years ago
committed by GitHub
parent
commit
0ea9c88048
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 299
      components/rate/__tests__/__snapshots__/demo-extend.test.ts.snap
  2. 299
      components/rate/__tests__/__snapshots__/demo.test.ts.snap
  3. 7
      components/rate/demo/component-token.md
  4. 20
      components/rate/demo/component-token.tsx
  5. 1
      components/rate/index.en-US.md
  6. 1
      components/rate/index.zh-CN.md
  7. 52
      components/rate/style/index.tsx
  8. 10
      docs/react/migrate-less-variables.en-US.md
  9. 10
      docs/react/migrate-less-variables.zh-CN.md

299
components/rate/__tests__/__snapshots__/demo-extend.test.ts.snap

@ -1861,6 +1861,305 @@ Array [
]
`;
exports[`renders components/rate/demo/component-token.tsx extend context correctly 1`] = `
<ul
class="ant-rate"
role="radiogroup"
tabindex="0"
>
<li
class="ant-rate-star ant-rate-star-full"
>
<div
aria-checked="true"
aria-posinset="1"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-full"
>
<div
aria-checked="true"
aria-posinset="2"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-zero"
>
<div
aria-checked="true"
aria-posinset="3"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-zero"
>
<div
aria-checked="false"
aria-posinset="4"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-zero"
>
<div
aria-checked="false"
aria-posinset="5"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
</ul>
`;
exports[`renders components/rate/demo/disabled.tsx extend context correctly 1`] = `
<ul
class="ant-rate ant-rate-disabled"

299
components/rate/__tests__/__snapshots__/demo.test.ts.snap

@ -1861,6 +1861,305 @@ Array [
]
`;
exports[`renders components/rate/demo/component-token.tsx correctly 1`] = `
<ul
class="ant-rate"
role="radiogroup"
tabindex="0"
>
<li
class="ant-rate-star ant-rate-star-full"
>
<div
aria-checked="true"
aria-posinset="1"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-full"
>
<div
aria-checked="true"
aria-posinset="2"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-zero"
>
<div
aria-checked="true"
aria-posinset="3"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-zero"
>
<div
aria-checked="false"
aria-posinset="4"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
<li
class="ant-rate-star ant-rate-star-zero"
>
<div
aria-checked="false"
aria-posinset="5"
aria-setsize="5"
role="radio"
tabindex="0"
>
<div
class="ant-rate-star-first"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
<div
class="ant-rate-star-second"
>
<span
aria-label="star"
class="anticon anticon-star"
role="img"
>
<svg
aria-hidden="true"
data-icon="star"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"
/>
</svg>
</span>
</div>
</div>
</li>
</ul>
`;
exports[`renders components/rate/demo/disabled.tsx correctly 1`] = `
<ul
class="ant-rate ant-rate-disabled"

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

@ -0,0 +1,7 @@
## zh-CN
Component Token Debug.
## en-US
Component Token Debug.

20
components/rate/demo/component-token.tsx

@ -0,0 +1,20 @@
import { ConfigProvider, Rate } from 'antd';
import React from 'react';
/** Test usage. Do not use in your production. */
export default () => (
<ConfigProvider
theme={{
components: {
Rate: {
starColor: 'blue',
starSize: 40,
starHoverScale: 'scale(2)',
starBg: 'red',
},
},
}}
>
<Rate defaultValue={2.5} />
</ConfigProvider>
);

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

@ -25,6 +25,7 @@ Rate component.
<code src="./demo/clear.tsx">Clear star</code>
<code src="./demo/character.tsx">Other Character</code>
<code src="./demo/character-function.tsx">Customize character</code>
<code src="./demo/component-token.tsx" debug>Component Token</code>
## API

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

@ -26,6 +26,7 @@ demo:
<code src="./demo/clear.tsx">清除</code>
<code src="./demo/character.tsx">其他字符</code>
<code src="./demo/character-function.tsx">自定义字符</code>
<code src="./demo/component-token.tsx" debug>组件 Token</code>
## API

52
components/rate/style/index.tsx

@ -1,16 +1,16 @@
import type { CSSObject } from '@ant-design/cssinjs';
import { resetComponent } from '../../style';
import type { FullToken, GenerateStyle } from '../../theme/internal';
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
import { resetComponent } from '../../style';
export type ComponentToken = {};
export type ComponentToken = {
starColor: string;
starSize: number;
starHoverScale: CSSObject['transform'];
starBg: string;
};
interface RateToken extends FullToken<'Rate'> {
rateStarColor: string;
rateStarSize: number;
rateStarHoverScale: CSSObject['transform'];
defaultColor: string;
}
interface RateToken extends FullToken<'Rate'> {}
const genRateStarStyle: GenerateStyle<RateToken, CSSObject> = (token) => {
const { componentCls } = token;
@ -30,7 +30,7 @@ const genRateStarStyle: GenerateStyle<RateToken, CSSObject> = (token) => {
transition: `all ${token.motionDurationMid}, outline 0s`,
'&:hover': {
transform: token.rateStarHoverScale,
transform: token.starHoverScale,
},
'&:focus': {
@ -38,13 +38,13 @@ const genRateStarStyle: GenerateStyle<RateToken, CSSObject> = (token) => {
},
'&:focus-visible': {
outline: `${token.lineWidth}px dashed ${token.rateStarColor}`,
transform: token.rateStarHoverScale,
outline: `${token.lineWidth}px dashed ${token.starColor}`,
transform: token.starHoverScale,
},
},
'&-first, &-second': {
color: token.defaultColor,
color: token.starBg,
transition: `all ${token.motionDurationMid}`,
userSelect: 'none',
@ -90,8 +90,8 @@ const genRateStyle: GenerateStyle<RateToken> = (token) => {
display: 'inline-block',
margin: 0,
padding: 0,
color: token.rateStarColor,
fontSize: token.rateStarSize,
color: token.starColor,
fontSize: token.starSize,
lineHeight: 'unset',
listStyle: 'none',
outline: 'none',
@ -122,14 +122,16 @@ const genRateStyle: GenerateStyle<RateToken> = (token) => {
};
// ============================== Export ==============================
export default genComponentStyleHook('Rate', (token) => {
const { colorFillContent } = token;
const rateToken = mergeToken<RateToken>(token, {
rateStarColor: token.yellow6,
rateStarSize: token.controlHeightLG * 0.5,
rateStarHoverScale: 'scale(1.1)',
defaultColor: colorFillContent,
});
return [genRateStyle(rateToken)];
});
export default genComponentStyleHook(
'Rate',
(token) => {
const rateToken = mergeToken<RateToken>(token, {});
return [genRateStyle(rateToken)];
},
(token) => ({
starColor: token.yellow6,
starSize: token.controlHeightLG * 0.5,
starHoverScale: 'scale(1.1)',
starBg: token.colorFillContent,
}),
);

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

@ -138,7 +138,15 @@ This document contains the correspondence between all the less variables related
<!-- ### Radio -->
<!-- ### Rate -->
## Rate
<!-- prettier-ignore -->
| Less variables | Component Token | Note |
| --- | --- | --- |
| `@rate-star-color` | `starColor` | - |
| `@rate-star-bg` | `starBg` | - |
| `@rate-star-size` | `starSize` | - |
| `@rate-star-hover-scale` | `starHoverScale` | - |
### Result

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

@ -138,7 +138,15 @@ title: Less 变量迁移 Design Token
<!-- ### Radio 单选框 -->
<!-- ### Rate 评分 -->
## Rate 评分
<!-- prettier-ignore -->
| less 变量 | Component Token | 备注 |
| --- | --- | --- |
| `@rate-star-color` | `starColor` | - |
| `@rate-star-bg` | `starBg` | - |
| `@rate-star-size` | `starSize` | - |
| `@rate-star-hover-scale` | `starHoverScale` | - |
### Result 结果

Loading…
Cancel
Save