Skip to content

Commit 7f8f2c8

Browse files
finnurbrekiDevtools-frontend LUCI CQ
authored andcommitted
[GreenDev]: Add sparky icon for annotations.
Bug: 461427169 Change-Id: I37639f55b869fe6be433c5c8b384130ec9df954b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7228371 Reviewed-by: Alina Varkki <[email protected]> Auto-Submit: Finnur Thorarinsson <[email protected]> Commit-Queue: Alina Varkki <[email protected]>
1 parent ebd1c5d commit 7f8f2c8

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ grd_files_bundled_sources = [
276276
"front_end/Images/smart-assistant.svg",
277277
"front_end/Images/snippet.svg",
278278
"front_end/Images/spark-info.svg",
279+
"front_end/Images/spark.svg",
279280
"front_end/Images/speculative-loads.svg",
280281
"front_end/Images/speedster-badge.svg",
281282
"front_end/Images/star.svg",

config/gni/devtools_image_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ devtools_svg_sources = [
274274
"smart-assistant.svg",
275275
"snippet.svg",
276276
"spark-info.svg",
277+
"spark.svg",
277278
"speculative-loads.svg",
278279
"speedster-badge.svg",
279280
"star.svg",

front_end/Images/src/spark.svg

Lines changed: 10 additions & 0 deletions
Loading

front_end/ui/legacy/TabbedPane.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,11 +1203,21 @@ export class TabbedPaneTab {
12031203
if (!this.#tabElement) {
12041204
return;
12051205
}
1206-
const iconElement = this.#tabElement.querySelector('.ai-icon');
1206+
const iconElement = this.#tabElement.querySelector('.spark');
12071207
if (iconVisible) {
12081208
if (!iconElement) {
1209-
const closeButton = this.#tabElement.querySelector('.close-button');
1210-
this.#tabElement.insertBefore(this.createTabAnnotationIcon(), closeButton);
1209+
const spark = this.createTabAnnotationIcon();
1210+
this.#tabElement.appendChild(spark);
1211+
1212+
const parentRect = this.#tabElement.parentElement?.getBoundingClientRect();
1213+
if (!parentRect) {
1214+
return;
1215+
}
1216+
const containerRect = this.tabElement.getBoundingClientRect();
1217+
const iconWidth = spark.getBoundingClientRect().width;
1218+
// Position the icon so that its right edge is at the container's right edge.
1219+
const x = containerRect.x - parentRect.x + containerRect.width - iconWidth;
1220+
(spark as HTMLElement).style.left = `${x}px`;
12111221
}
12121222
} else {
12131223
iconElement?.remove();
@@ -1393,17 +1403,14 @@ export class TabbedPaneTab {
13931403
return tabElement as HTMLElement;
13941404
}
13951405

1396-
private createTabAnnotationIcon(): HTMLDivElement {
1397-
// TODO(finnur): Replace the ai-icon with the squiggly svg once it becomes available.
1398-
const iconContainer = document.createElement('div');
1399-
iconContainer.classList.add('ai-icon');
1406+
private createTabAnnotationIcon(): Icon {
14001407
const tabAnnotationIcon = new Icon();
1401-
tabAnnotationIcon.name = 'smart-assistant';
1408+
tabAnnotationIcon.name = 'spark';
14021409
tabAnnotationIcon.classList.add('small');
1403-
iconContainer.appendChild(tabAnnotationIcon);
1404-
iconContainer.setAttribute('title', i18nString(UIStrings.panelContainsAnnotation));
1405-
iconContainer.setAttribute('aria-label', i18nString(UIStrings.panelContainsAnnotation));
1406-
return iconContainer;
1410+
tabAnnotationIcon.classList.add('spark');
1411+
tabAnnotationIcon.setAttribute('title', i18nString(UIStrings.panelContainsAnnotation));
1412+
tabAnnotationIcon.setAttribute('aria-label', i18nString(UIStrings.panelContainsAnnotation));
1413+
return tabAnnotationIcon;
14071414
}
14081415

14091416
private createCloseIconButton(): Buttons.Button.Button {

front_end/ui/legacy/tabbedPane.css

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,9 @@
521521
}
522522
}
523523

524-
.tabbed-pane-header-tab.ai .ai-icon {
525-
background-color: var(--sys-color-primary);
526-
border-radius: 50%;
527-
margin-left: 4px;
528-
}
524+
.spark {
525+
position: absolute;
526+
top: 2px;
529527

530-
.tabbed-pane-header-tab.ai .ai-icon devtools-icon {
531-
color: var(--sys-color-on-primary);
528+
--icon-default: var(--sys-color-primary);
532529
}

0 commit comments

Comments
 (0)