Skip to content
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
12 changes: 2 additions & 10 deletions packages/main/src/ColorPaletteItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,18 @@ class ColorPaletteItem extends UI5Element implements IColorPaletteItem {
onBeforeRendering() {
this._disabled = !this.value;
this.onPhone = isPhone();
this.setAttribute("style", `background-color: ${this.value}`);

// since height is dynamically determined by padding-block-start
const itemHeight = this.offsetHeight + 4; // adding 4px for the offsets on top and bottom
this.style.setProperty(getScopedVarName("--_ui5_color_palette_item_height"), `${itemHeight}px`);

this.style.setProperty(getScopedVarName("--_ui5-color-palette-item-background-color"), `${this.value}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we address the CSP Violation ? Even though right now it sets scoped-variable, malicious link still could be inserted through it. Maybe some sort of sanitization would work ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed offline, we'll go for it as it is for now. If any concerns arise, we'll investigate it further.

}

get colorLabel() {
return ColorPaletteItem.i18nBundle.getText(COLORPALETTE_COLOR_LABEL);
}

get styles() {
// Remove after deleting the hbs template, it's added in the jsx template
return {
root: {
"background-color": this.value,
},
};
}

get classes() {
// Remove after deleting the hbs template, it's added in the jsx template
return {
Expand Down
3 changes: 0 additions & 3 deletions packages/main/src/ColorPaletteItemTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export default function ColorPaletteItemTemplate(this: ColorPaletteItem) {
return (
<div
class="ui5-cp-item"
style={{
"background-color": this.value,
}}
tabindex={parseInt(this.forcedTabIndex)}
role="button"
aria-label={`${this.colorLabel} - ${this.index}: ${this.value}`}
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/themes/ColorPaletteItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
display: inline-block;
margin: var(--_ui5_color-palette-item-margin);
box-sizing: border-box;
background-color: var(--_ui5-color-palette-item-background-color);
}

:host(:not([_disabled]):hover),
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/themes/base/ColorPalette-parameters.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
--_ui5-color-palette-item-mobile-focus-inset: 0.625rem;
--_ui5_color-palette-item-mobile-focus-sides-inset: 0.25rem 0.25rem;
--_ui5_color-palette-item-after-mobile-focus-border: var(--_ui5_color-palette-item-after-focus-color);
--_ui5-color-palette-item-background-color: transparent;
}
Loading