audit-ui.ts — astro Source File
Architecture documentation for audit-ui.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d8edbadc_4bcf_95cc_05c1_73dd76db87a8["audit-ui.ts"] 6e91fe0d_c6ce_0cca_abd3_06b774edbe23["./toolbar.js"] d8edbadc_4bcf_95cc_05c1_73dd76db87a8 --> 6e91fe0d_c6ce_0cca_abd3_06b774edbe23 36c86db7_583c_6a41_001d_26ecc3b5189e["./utils/highlight.js"] d8edbadc_4bcf_95cc_05c1_73dd76db87a8 --> 36c86db7_583c_6a41_001d_26ecc3b5189e 7fecc1f7_6786_be13_5f20_8914b287345d["../annotations.js"] d8edbadc_4bcf_95cc_05c1_73dd76db87a8 --> 7fecc1f7_6786_be13_5f20_8914b287345d 64d5b0f9_0840_9b1a_91b0_2250f9b130b6["../index.js"] d8edbadc_4bcf_95cc_05c1_73dd76db87a8 --> 64d5b0f9_0840_9b1a_91b0_2250f9b130b6 c19ed93d_c905_8e8a_abab_010a7ccd1966["../rules/index.js"] d8edbadc_4bcf_95cc_05c1_73dd76db87a8 --> c19ed93d_c905_8e8a_abab_010a7ccd1966 a0e7eef3_2348_71cb_bd73_9658fb1fac9a["./audit-list-item.js"] d8edbadc_4bcf_95cc_05c1_73dd76db87a8 --> a0e7eef3_2348_71cb_bd73_9658fb1fac9a fc634da7_3e72_de83_7395_a46311dd837e["html-escaper"] d8edbadc_4bcf_95cc_05c1_73dd76db87a8 --> fc634da7_3e72_de83_7395_a46311dd837e style d8edbadc_4bcf_95cc_05c1_73dd76db87a8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { escape as escapeHTML } from 'html-escaper';
import type { DevToolbarMetadata } from '../../../../../../types/public/toolbar.js';
import {
attachTooltipToHighlight,
createHighlight,
getElementsPositionInDocument,
} from '../../utils/highlight.js';
import { getAnnotationsForElement } from '../annotations.js';
import type { Audit } from '../index.js';
import { type ResolvedAuditRule, resolveAuditRule } from '../rules/index.js';
import type { DevToolbarAuditListItem } from './audit-list-item.js';
function truncate(val: string, maxLength: number): string {
return val.length > maxLength ? val.slice(0, maxLength - 1) + '…' : val;
}
export function createAuditUI(audit: Audit, audits: Audit[]) {
const rect = audit.auditedElement.getBoundingClientRect();
const highlight = createHighlight(rect, 'warning', { 'data-audit-code': audit.rule.code });
const resolvedAuditRule = resolveAuditRule(audit.rule, audit.auditedElement);
const tooltip = buildAuditTooltip(resolvedAuditRule, audit.auditedElement);
const card = buildAuditCard(resolvedAuditRule, highlight, audit.auditedElement, audits);
// If a highlight is hovered or focused, highlight the corresponding card for it
(['focus', 'mouseover'] as const).forEach((event) => {
const attribute = event === 'focus' ? 'active' : 'hovered';
highlight.addEventListener(event, () => {
if (event === 'focus') {
audits.forEach((adt) => {
if (adt.card) adt.card.toggleAttribute('active', false);
});
if (!card.isManualFocus) card.scrollIntoView();
card.toggleAttribute('active', true);
} else {
card.toggleAttribute(attribute, true);
}
});
});
highlight.addEventListener('mouseout', () => {
card.toggleAttribute('hovered', false);
});
// Set the highlight/tooltip as being fixed position the highlighted element
// is fixed. We do this so that we don't mistakenly take scroll position
// into account when setting the tooltip/highlight positioning.
//
// We only do this once due to how expensive computed styles are to calculate,
// and are unlikely to change. If that turns out to be wrong, reconsider this.
const { isFixed } = getElementsPositionInDocument(audit.auditedElement);
if (isFixed) {
tooltip.style.position = highlight.style.position = 'fixed';
}
attachTooltipToHighlight(highlight, tooltip, audit.auditedElement);
return { highlight, card };
}
// ... (119 more lines)
Domain
Subdomains
Dependencies
- ../annotations.js
- ../index.js
- ../rules/index.js
- ./audit-list-item.js
- ./toolbar.js
- ./utils/highlight.js
- html-escaper
Source
Frequently Asked Questions
What does audit-ui.ts do?
audit-ui.ts is a source file in the astro codebase, written in typescript. It belongs to the DevToolbar domain, ToolbarClient subdomain.
What functions are defined in audit-ui.ts?
audit-ui.ts defines 5 function(s): buildAuditCard, buildAuditTooltip, createAuditUI, simpleRenderMarkdown, truncate.
What does audit-ui.ts depend on?
audit-ui.ts imports 7 module(s): ../annotations.js, ../index.js, ../rules/index.js, ./audit-list-item.js, ./toolbar.js, ./utils/highlight.js, html-escaper.
Where is audit-ui.ts in the architecture?
audit-ui.ts is located at packages/astro/src/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.ts (domain: DevToolbar, subdomain: ToolbarClient, directory: packages/astro/src/runtime/client/dev-toolbar/apps/audit/ui).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free