Skip to content

Commit 0264da9

Browse files
authored
fix(module:colorpicker): remove inline style (CSP compliant) (#8874)
1 parent 58797c7 commit 0264da9

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

components/color-picker/src/components/gradient.component.ts

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { generateColor } from '../util/util';
1616
template: `
1717
<div
1818
class="ant-color-picker-gradient"
19-
style="position: absolute; inset: 0"
2019
[style.background]="'linear-gradient(' + direction + ', ' + gradientColors + ')'"
2120
>
2221
<ng-content></ng-content>

components/color-picker/src/components/palette.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Component } from '@angular/core';
1010
selector: 'color-palette',
1111
standalone: true,
1212
template: `
13-
<div class="ant-color-picker-palette" style="position: relative">
13+
<div class="ant-color-picker-palette">
1414
<ng-content></ng-content>
1515
</div>
1616
`

components/color-picker/src/components/picker.component.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,13 @@ function getPosition(e: EventType): { pageX: number; pageY: number } {
5252
<color-palette>
5353
<div
5454
#transform
55-
style="position: absolute; z-index: 1;"
55+
class="ant-color-picker-transform"
5656
[style.left]="offsetValue.x + 'px'"
5757
[style.top]="offsetValue.y + 'px'"
5858
>
5959
<color-handler [color]="toRgbString()" />
6060
</div>
61-
<div
62-
class="ant-color-picker-saturation"
63-
style="
64-
background-image: linear-gradient(0deg, #000, transparent),
65-
linear-gradient(90deg, #fff, hsla(0, 0%, 100%, 0));
66-
"
67-
[style.background-color]="toHsb()"
68-
></div>
61+
<div class="ant-color-picker-saturation" [style.background-color]="toHsb()"></div>
6962
</color-palette>
7063
</div>
7164
`

components/color-picker/src/components/slider.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function getPosition(e: EventType): { pageX: number; pageY: number } {
5454
<color-palette>
5555
<div
5656
#transform
57-
style="position: absolute; z-index: 1;"
57+
class="ant-color-picker-transform"
5858
[style.left]="offsetValue.x + 'px'"
5959
[style.top]="offsetValue.y + 'px'"
6060
>

components/color-picker/style/index.less

+15
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
}
2727
}
2828

29+
&-gradient {
30+
position: absolute;
31+
inset: 0;
32+
}
33+
34+
&-palette {
35+
position: relative;
36+
}
37+
2938
&-select {
3039
.@{color-picker-prefix-cls}-palette {
3140
min-height: 160px;
@@ -46,9 +55,15 @@
4655
right: 0;
4756
bottom: 0;
4857
left: 0;
58+
background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsla(0deg, 0%, 100%, 0));
4959
border-radius: inherit;
5060
}
5161

62+
&-transform {
63+
position: absolute;
64+
z-index: 1;
65+
}
66+
5267
&-handler {
5368
box-sizing: border-box;
5469
width: 16px;

0 commit comments

Comments
 (0)