Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(color-picker): 修复切换预览颜色时,通道按钮位置不变的问题 #2880

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/color-picker/hooks/useStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const useStyles = (params: TdColorSliderStyleParams, panelRectRef) => {
if (!width) {
return;
}
const left = Math.round((Number(value) / Number(maxValue)) * width);
const left = Math.round((Number(value) / Number(maxValue)) * 100);
setStyles({
left: `${left}px`,
left: `${left}%`,
color: color.rgb,
});
// eslint-disable-next-line
Expand Down
32 changes: 16 additions & 16 deletions test/snap/__snapshots__/csr.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -53718,7 +53718,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/enable-alpha.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand All @@ -53738,7 +53738,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/enable-alpha.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 134px; color: rgb(0, 82, 217);"
style="left: 80%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -54497,7 +54497,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/enable-alpha.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand All @@ -54517,7 +54517,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/enable-alpha.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 134px; color: rgb(0, 82, 217);"
style="left: 80%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -55337,7 +55337,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/panel.jsx 1`] =
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -56071,7 +56071,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/panel.jsx 1`] =
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -56879,7 +56879,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/recent-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -57786,7 +57786,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/recent-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -58555,7 +58555,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/recent-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -59462,7 +59462,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/recent-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -60428,7 +60428,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/status-readonly.
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -61219,7 +61219,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/status-readonly.
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -62084,7 +62084,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/swatch-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -62460,7 +62460,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/swatch-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -62769,7 +62769,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/swatch-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down Expand Up @@ -63145,7 +63145,7 @@ exports[`csr snapshot test > csr test src/color-picker/_example/swatch-color.jsx
<span
class="t-color-picker__thumb"
role="slider"
style="left: 101px; color: rgb(0, 82, 217);"
style="left: 60%; color: rgb(0, 82, 217);"
tabindex="0"
/>
</div>
Expand Down
Loading