Skip to content

Commit

Permalink
fix(color-picker): 修复切换预览颜色时,通道按钮位置不变的问题 (#2880)
Browse files Browse the repository at this point in the history
  • Loading branch information
fennghuang committed May 7, 2024
1 parent e0f8070 commit 28fc974
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
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

0 comments on commit 28fc974

Please sign in to comment.