Home / File/ card.ts — astro Source File

card.ts — astro Source File

Architecture documentation for card.ts, a typescript file in the astro codebase. 1 imports, 0 dependents.

File typescript DevToolbar ToolbarClient 1 imports 1 classes

Entity Profile

Dependency Diagram

graph LR
  d4065da0_74c3_5b02_1edc_8fe4548c9edf["card.ts"]
  844d479d_bd2c_31dd_1673_36b5e7e8016a["../settings.js"]
  d4065da0_74c3_5b02_1edc_8fe4548c9edf --> 844d479d_bd2c_31dd_1673_36b5e7e8016a
  style d4065da0_74c3_5b02_1edc_8fe4548c9edf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { settings } from '../settings.js';

const styles = ['purple', 'gray', 'red', 'green', 'yellow', 'blue'] as const;

type CardStyle = (typeof styles)[number];

export class DevToolbarCard extends HTMLElement {
	link?: string | undefined | null;
	clickAction?: () => void | (() => Promise<void>);
	shadowRoot: ShadowRoot;

	_cardStyle: CardStyle = 'purple';

	get cardStyle() {
		return this._cardStyle;
	}

	set cardStyle(value) {
		if (!styles.includes(value)) {
			settings.logger.error(
				`Invalid style: ${value}, expected one of ${styles.join(', ')}, got ${value}.`,
			);
			return;
		}
		this._cardStyle = value;
		this.updateStyle();
	}

	static observedAttributes = ['card-style'];

	constructor() {
		super();
		this.shadowRoot = this.attachShadow({ mode: 'open' });

		this.link = this.getAttribute('link');
	}

	attributeChangedCallback() {
		if (this.hasAttribute('card-style'))
			this.cardStyle = this.getAttribute('card-style') as CardStyle;

		this.updateStyle();
	}

	updateStyle() {
		const style = this.shadowRoot.querySelector<HTMLStyleElement>('#selected-style');

		if (style) {
			style.innerHTML = `
				:host {
					--hover-background: var(--${this.cardStyle}-hover-background);
					--hover-border: var(--${this.cardStyle}-hover-border);
				}
			`;
		}
	}

	connectedCallback() {
		const element = this.link ? 'a' : this.clickAction ? 'button' : 'div';

// ... (74 more lines)

Domain

Subdomains

Classes

Types

Dependencies

  • ../settings.js

Frequently Asked Questions

What does card.ts do?
card.ts is a source file in the astro codebase, written in typescript. It belongs to the DevToolbar domain, ToolbarClient subdomain.
What does card.ts depend on?
card.ts imports 1 module(s): ../settings.js.
Where is card.ts in the architecture?
card.ts is located at packages/astro/src/runtime/client/dev-toolbar/ui-library/card.ts (domain: DevToolbar, subdomain: ToolbarClient, directory: packages/astro/src/runtime/client/dev-toolbar/ui-library).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free