File tree Expand file tree Collapse file tree 9 files changed +61
-2
lines changed
Expand file tree Collapse file tree 9 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -906,9 +906,11 @@ export class MainMenuItem implements UI.Toolbar.Provider {
906906
907907 const aiPreregisteredView = UI . ViewManager . getRegisteredViewExtensionForID ( 'freestyler' ) ;
908908 if ( aiPreregisteredView ) {
909+ const additionalElement = UI . UIUtils . maybeCreateNewBadge ( 'ai-asisstance' ) ;
909910 contextMenu . defaultSection ( ) . appendItem ( aiPreregisteredView . title ( ) , ( ) => {
910911 void UI . ViewManager . ViewManager . instance ( ) . showView ( 'freestyler' , true , false ) ;
911- } , { jslogContext : 'freestyler' } ) ;
912+ UI . UIUtils . PromotionManager . instance ( ) . recordFeatureInteraction ( 'ai-asisstance' ) ;
913+ } , { additionalElement, jslogContext : 'freestyler' } ) ;
912914 }
913915
914916 if ( dockController . dockSide ( ) === UI . DockController . DockState . UNDOCKED ) {
Original file line number Diff line number Diff line change @@ -115,6 +115,10 @@ const UIStrings = {
115115 *@description Text to cancel something
116116 */
117117 cancel : 'Cancel' ,
118+ /**
119+ *@description Text for the new badge appearing next to some menu items
120+ */
121+ new : 'NEW' ,
118122} as const ;
119123const str_ = i18n . i18n . registerUIStrings ( 'ui/legacy/UIUtils.ts' , UIStrings ) ;
120124const i18nString = i18n . i18n . getLocalizedString . bind ( undefined , str_ ) ;
@@ -2119,3 +2123,28 @@ export class PromotionManager {
21192123 return false ;
21202124 }
21212125}
2126+
2127+ /**
2128+ * Creates a `<div>` element with the localized text NEW.
2129+ *
2130+ * The element is automatically styled correctly, as long as the core styles (in particular
2131+ * `inspectorCommon.css` is injected into the current document / shadow root). The lit
2132+ * equivalent of calling this method is:
2133+ *
2134+ * ```js
2135+ * const jslog = VisualLogging.badge('new-badge');
2136+ * html`<div class='new-badge' jsog=${jslog}>i18nString(UIStrings.new)</div>`
2137+ *
2138+ * @returns the newly created `HTMLDivElement` for the new badge.
2139+ */
2140+ export function maybeCreateNewBadge ( promotionId : string ) : HTMLDivElement | undefined {
2141+ const promotionManager = PromotionManager . instance ( ) ;
2142+ if ( promotionManager . maybeShowPromotion ( promotionId ) ) {
2143+ const badge = document . createElement ( 'div' ) ;
2144+ badge . className = 'new-badge' ;
2145+ badge . textContent = i18nString ( UIStrings . new ) ;
2146+ badge . setAttribute ( 'jslog' , `${ VisualLogging . badge ( 'new-badge' ) } ` ) ;
2147+ return badge ;
2148+ }
2149+ return undefined ;
2150+ }
Original file line number Diff line number Diff line change @@ -344,6 +344,13 @@ export class CommandMenuProvider extends Provider {
344344 UI . UIUtils . createTextChild ( titleElement , command . title ) ;
345345 FilteredListWidget . highlightRanges ( titleElement , query , true ) ;
346346
347+ if ( command . promoteFeature ) {
348+ const badge = UI . UIUtils . maybeCreateNewBadge ( 'ai-asisstance' ) ;
349+ if ( badge ) {
350+ titleElement . parentElement ?. insertBefore ( badge , subtitleElement ) ;
351+ }
352+ }
353+
347354 subtitleElement . textContent = command . shortcut ;
348355
349356 const deprecationWarning = command . deprecationWarning ;
Original file line number Diff line number Diff line change @@ -136,8 +136,10 @@ devtools-text-prompt {
136136
137137.filtered-list-widget-item .one-row {
138138 line-height : var (--sys-typescale-body3-line-height );
139+ align-items : center;
139140 align-content : center;
140141 display : flex;
142+ gap : var (--sys-size-4 );
141143}
142144
143145.filtered-list-widget-item .one-row .filtered-list-widget-title {
Original file line number Diff line number Diff line change @@ -526,6 +526,19 @@ dt-icon-label {
526526 background-color : var (--sys-color-purple-bright );
527527}
528528
529+ .new-badge {
530+ width : fit-content;
531+ height : var (--sys-size-7 );
532+ line-height : var (--sys-size-7 );
533+ border-radius : var (--sys-shape-corner-extra-small );
534+ padding : 0 var (--sys-size-3 );
535+ background-color : var (--sys-color-primary );
536+ color : var (--sys-color-on-primary );
537+ font-weight : var (--ref-typeface-weight-bold );
538+ font-size : 9px ;
539+ text-align : center;
540+ }
541+
529542.expandable-inline-button {
530543 background-color : var (--sys-color-cdt-base-container );
531544 color : var (--sys-color-on-surface );
Original file line number Diff line number Diff line change 4040 background-color : var (--sys-color-state-hover-on-subtle );
4141 }
4242
43+ & .new-badge {
44+ margin-left : var (--sys-size-4 );
45+ }
46+
4347 & devtools-icon {
4448 width : var (--sys-size-8 );
4549 height : var (--sys-size-8 );
Original file line number Diff line number Diff line change @@ -2570,6 +2570,7 @@ export const knownContextValues = new Set([
25702570 'never-pause-here' ,
25712571 'new-attribute' ,
25722572 'new-authenticator' ,
2573+ 'new-badge' ,
25732574 'new-file' ,
25742575 'next' ,
25752576 'next-page' ,
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ export enum VisualElements {
6161 Gutter = 22 ,
6262 MetricsBox = 23 ,
6363 MetricsBoxPart = 24 ,
64- /* 25 used to be DOMBreakpointsPane, but free to grab now */
64+ Badge = 25 ,
6565 DOMBreakpoint = 26 ,
6666 /* 27 used to be ElementPropertiesPane, but free to grab now */
6767 /* 28 used to be EventListenersPane, but free to grab now */
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ export function setHighlightedVe(veKey: string|null): void {
5757export const action = LoggingConfig . makeConfigStringBuilder . bind ( null , 'Action' ) ;
5858export const adorner = LoggingConfig . makeConfigStringBuilder . bind ( null , 'Adorner' ) ;
5959export const animationClip = LoggingConfig . makeConfigStringBuilder . bind ( null , 'AnimationClip' ) ;
60+ export const badge = LoggingConfig . makeConfigStringBuilder . bind ( null , 'Badge' ) ;
6061export const bezierCurveEditor = LoggingConfig . makeConfigStringBuilder . bind ( null , 'BezierCurveEditor' ) ;
6162export const bezierPresetCategory = LoggingConfig . makeConfigStringBuilder . bind ( null , 'BezierPresetCategory' ) ;
6263export const breakpointMarker = LoggingConfig . makeConfigStringBuilder . bind ( null , 'BreakpointMarker' ) ;
You can’t perform that action at this time.
0 commit comments