ToolbarAppEventTarget Class — astro Architecture
Architecture documentation for the ToolbarAppEventTarget class in helpers.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 7719489a_66d6_a31e_2dbd_67d7bbb35c8a["ToolbarAppEventTarget"] c164d809_878e_5fda_1903_3f6ce5beed21["helpers.ts"] 7719489a_66d6_a31e_2dbd_67d7bbb35c8a -->|defined in| c164d809_878e_5fda_1903_3f6ce5beed21 f0084046_df27_6025_e282_eb5731688de8["constructor()"] 7719489a_66d6_a31e_2dbd_67d7bbb35c8a -->|method| f0084046_df27_6025_e282_eb5731688de8 88879728_c9af_6e16_b073_57c8a4eb7b04["toggleNotification()"] 7719489a_66d6_a31e_2dbd_67d7bbb35c8a -->|method| 88879728_c9af_6e16_b073_57c8a4eb7b04 52a7b830_e65e_f7a0_82d7_cd6b00e8587d["toggleState()"] 7719489a_66d6_a31e_2dbd_67d7bbb35c8a -->|method| 52a7b830_e65e_f7a0_82d7_cd6b00e8587d 4ffe2d7f_fcc7_7443_cb04_a7001922e191["onToggled()"] 7719489a_66d6_a31e_2dbd_67d7bbb35c8a -->|method| 4ffe2d7f_fcc7_7443_cb04_a7001922e191 21b3036c_cb0c_6dd8_ca2f_f93e71e2b803["onToolbarPlacementUpdated()"] 7719489a_66d6_a31e_2dbd_67d7bbb35c8a -->|method| 21b3036c_cb0c_6dd8_ca2f_f93e71e2b803
Relationship Graph
Source Code
packages/astro/src/runtime/client/dev-toolbar/helpers.ts lines 20–78
export class ToolbarAppEventTarget extends EventTarget {
constructor() {
super();
}
/**
* Toggle the notification state of the toolbar
* @param options - The notification options
* @param options.state - The state of the notification
* @param options.level - The level of the notification, optional when state is false
*/
toggleNotification(options: NotificationPayload) {
this.dispatchEvent(
new CustomEvent('toggle-notification', {
detail: {
state: options.state,
level: options.state === true ? options.level : undefined,
} satisfies NotificationPayload,
}),
);
}
/**
* Toggle the app state on or off
* @param options - The app state options
* @param options.state - The new state of the app
*/
toggleState(options: AppStatePayload) {
this.dispatchEvent(
new CustomEvent('toggle-app', {
detail: {
state: options.state,
} satisfies AppStatePayload,
}),
);
}
/**
* Fired when the app is toggled on or off
* @param callback - The callback to run when the event is fired, takes an object with the new state
*/
onToggled(callback: AppToggledEvent) {
this.addEventListener('app-toggled', (evt) => {
if (!(evt instanceof CustomEvent)) return;
callback(evt.detail);
});
}
/**
* Fired when the toolbar placement is updated by the user
* @param callback - The callback to run when the event is fired, takes an object with the new placement
*/
onToolbarPlacementUpdated(callback: ToolbarPlacementUpdatedEvent) {
this.addEventListener('placement-updated', (evt) => {
if (!(evt instanceof CustomEvent)) return;
callback(evt.detail);
});
}
}
Source
Frequently Asked Questions
What is the ToolbarAppEventTarget class?
ToolbarAppEventTarget is a class in the astro codebase, defined in packages/astro/src/runtime/client/dev-toolbar/helpers.ts.
Where is ToolbarAppEventTarget defined?
ToolbarAppEventTarget is defined in packages/astro/src/runtime/client/dev-toolbar/helpers.ts at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free