Skip to content

Commit

Permalink
fix(module:colorpicker): remove inline style (CSP compliant) (#8874)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt authored Nov 15, 2024
1 parent 58797c7 commit 0264da9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { generateColor } from '../util/util';
template: `
<div
class="ant-color-picker-gradient"
style="position: absolute; inset: 0"
[style.background]="'linear-gradient(' + direction + ', ' + gradientColors + ')'"
>
<ng-content></ng-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Component } from '@angular/core';
selector: 'color-palette',
standalone: true,
template: `
<div class="ant-color-picker-palette" style="position: relative">
<div class="ant-color-picker-palette">
<ng-content></ng-content>
</div>
`
Expand Down
11 changes: 2 additions & 9 deletions components/color-picker/src/components/picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,13 @@ function getPosition(e: EventType): { pageX: number; pageY: number } {
<color-palette>
<div
#transform
style="position: absolute; z-index: 1;"
class="ant-color-picker-transform"
[style.left]="offsetValue.x + 'px'"
[style.top]="offsetValue.y + 'px'"
>
<color-handler [color]="toRgbString()" />
</div>
<div
class="ant-color-picker-saturation"
style="
background-image: linear-gradient(0deg, #000, transparent),
linear-gradient(90deg, #fff, hsla(0, 0%, 100%, 0));
"
[style.background-color]="toHsb()"
></div>
<div class="ant-color-picker-saturation" [style.background-color]="toHsb()"></div>
</color-palette>
</div>
`
Expand Down
2 changes: 1 addition & 1 deletion components/color-picker/src/components/slider.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function getPosition(e: EventType): { pageX: number; pageY: number } {
<color-palette>
<div
#transform
style="position: absolute; z-index: 1;"
class="ant-color-picker-transform"
[style.left]="offsetValue.x + 'px'"
[style.top]="offsetValue.y + 'px'"
>
Expand Down
15 changes: 15 additions & 0 deletions components/color-picker/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
}
}

&-gradient {
position: absolute;
inset: 0;
}

&-palette {
position: relative;
}

&-select {
.@{color-picker-prefix-cls}-palette {
min-height: 160px;
Expand All @@ -46,9 +55,15 @@
right: 0;
bottom: 0;
left: 0;
background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsla(0deg, 0%, 100%, 0));
border-radius: inherit;
}

&-transform {
position: absolute;
z-index: 1;
}

&-handler {
box-sizing: border-box;
width: 16px;
Expand Down

0 comments on commit 0264da9

Please sign in to comment.