Skip to content

Commit ed5f1a8

Browse files
committed
Removes inline styles from webviews
- Improves CSP compatibility by moving inline style attributes into component stylesheets/classes - Tightens style CSP handling across environments while keeping nonce support enabled - Preserves dynamic file icon colors without relying on blocked inline style attributes
1 parent 50febf2 commit ed5f1a8

17 files changed

Lines changed: 114 additions & 44 deletions

src/webviews/apps/plus/graph/components/gl-commit-box.css.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export const commitBoxStyles = css`
2929
justify-content: space-between;
3030
}
3131
32+
.compose-icon {
33+
color: var(--vscode-charts-purple, #7c3aed);
34+
}
35+
3236
.amend-checkbox {
3337
margin-block: 0;
3438
font-size: var(--gl-font-base);

src/webviews/apps/plus/graph/components/gl-commit-box.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ export class GlCommitBox extends LitElement {
5959
${this.renderAmendToggle()}
6060
${showCompose
6161
? html`<gl-button appearance="secondary" @click=${this.onCompose}>
62-
<code-icon
63-
icon="wand"
64-
slot="prefix"
65-
style="color: var(--vscode-charts-purple, #7c3aed);"
66-
></code-icon>
62+
<code-icon class="compose-icon" icon="wand" slot="prefix"></code-icon>
6763
Compose
6864
</gl-button>`
6965
: nothing}

src/webviews/apps/plus/graph/components/gl-details-multicommit-panel.css.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { css } from 'lit';
33
export { panelActionInputStyles, panelHostStyles } from './shared-panel.css.js';
44

55
export const multiCommitPanelStyles = css`
6+
:host {
7+
--mode-header-bg: var(--titlebar-bg, var(--vscode-sideBar-background, var(--color-background)));
8+
}
9+
610
.compare-metadata {
711
display: flex;
812
align-items: center;

src/webviews/apps/plus/graph/components/gl-details-multicommit-panel.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,7 @@ export class GlDetailsMultiCommitPanel extends LitElement {
333333
this.aiEnabled && this.experimentalFeaturesEnabled
334334
? (['review', 'compare'] as const)
335335
: (['compare'] as const);
336-
return html`<gl-details-header
337-
.activeMode=${this.activeMode}
338-
.loading=${this.loading}
339-
.modes=${modes}
340-
style="--mode-header-bg: var(--titlebar-bg, var(--vscode-sideBar-background, var(--color-background)))"
341-
>
336+
return html`<gl-details-header .activeMode=${this.activeMode} .loading=${this.loading} .modes=${modes}>
342337
<span class="compare-header__title">Comparing References</span>
343338
</gl-details-header>`;
344339
}

src/webviews/apps/plus/graph/components/gl-details-wip-header.css.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { css } from 'lit';
33
export const detailsWipHeaderStyles = css`
44
:host {
55
display: contents;
6+
--mode-header-bg: var(--titlebar-bg, var(--color-background--level-05));
7+
--mode-header-tint: 20%;
68
}
79
810
.graph-details-header__title-group {

src/webviews/apps/plus/graph/components/gl-details-wip-header.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export class GlDetailsWipHeader extends LitElement {
6767
.activeMode=${this.activeMode}
6868
.loading=${this.loading}
6969
.modes=${this.computeWipModes()}
70-
style="--mode-header-bg: var(--titlebar-bg, var(--color-background--level-05)); --mode-header-tint: 20%"
7170
>
7271
<div class="graph-details-header__title-group">
7372
<span class="graph-details-header__wip-title"

src/webviews/apps/plus/graph/components/gl-graph-details-panel.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,18 +508,15 @@ export class GlGraphDetailsPanel extends SignalWatcher(LitElement) {
508508
<div class="details-skeleton__header">
509509
<div class="details-skeleton__avatar"></div>
510510
<div class="details-skeleton__lines">
511-
<div class="details-skeleton__line" style="width: 60%"></div>
512-
<div
513-
class="details-skeleton__line details-skeleton__line--short"
514-
style="width: 40%"
515-
></div>
511+
<div class="details-skeleton__line"></div>
512+
<div class="details-skeleton__line details-skeleton__line--short"></div>
516513
</div>
517514
</div>
518515
<div class="details-skeleton__bar"></div>
519516
<div class="details-skeleton__body">
520-
<div class="details-skeleton__line" style="width: 90%"></div>
521-
<div class="details-skeleton__line" style="width: 70%"></div>
522-
<div class="details-skeleton__line details-skeleton__line--short" style="width: 50%"></div>
517+
<div class="details-skeleton__line"></div>
518+
<div class="details-skeleton__line"></div>
519+
<div class="details-skeleton__line details-skeleton__line--short"></div>
523520
</div>
524521
</div>`}
525522
</div>`;

src/webviews/apps/plus/graph/graph-header.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ export class GlGraphHeader extends SignalWatcher(LitElement) {
148148
opacity: 0.5;
149149
cursor: not-allowed;
150150
}
151+
152+
.minimap-toggle-icon {
153+
transform: rotate(180deg);
154+
}
151155
`,
152156
];
153157

@@ -1289,8 +1293,8 @@ export class GlGraphHeader extends SignalWatcher(LitElement) {
12891293
@click=${() => this.handleMinimapToggled()}
12901294
>
12911295
<code-icon
1296+
class="minimap-toggle-icon"
12921297
icon=${config?.minimap && this.minimapVisible ? 'layout-panel' : 'layout-panel-off'}
1293-
style="transform: rotate(180deg)"
12941298
></code-icon>
12951299
</gl-button>
12961300
${(() => {

src/webviews/apps/plus/graph/graph-wrapper/gl-graph.react.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ export const GlGraphReact = memo((initProps: GraphWrapperInitProps) => {
695695
)}${props.searchResults.hasMore ? '+' : ''}`}
696696
</span>
697697
<a
698-
style={{ marginLeft: '0.5rem' }}
699698
className="graph-footer__link"
700699
onClick={e => {
701700
e.preventDefault();

src/webviews/apps/plus/graph/graph.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,10 @@ web-graph {
12761276
font-style: italic;
12771277
}
12781278

1279+
& .graph-footer__message + .graph-footer__link {
1280+
margin-left: 0.5rem;
1281+
}
1282+
12791283
& .graph-footer__link {
12801284
color: var(--vscode-textLink-foreground);
12811285
cursor: pointer;
@@ -1615,6 +1619,23 @@ web-graph {
16151619
height: 8px;
16161620
}
16171621

1622+
&__lines > &__line:nth-child(1) {
1623+
width: 60%;
1624+
}
1625+
&__lines > &__line:nth-child(2) {
1626+
width: 40%;
1627+
}
1628+
1629+
&__body > &__line:nth-child(1) {
1630+
width: 90%;
1631+
}
1632+
&__body > &__line:nth-child(2) {
1633+
width: 70%;
1634+
}
1635+
&__body > &__line:nth-child(3) {
1636+
width: 50%;
1637+
}
1638+
16181639
&__bar {
16191640
height: 28px;
16201641
border-radius: 4px;

0 commit comments

Comments
 (0)