Home / Function/ constructor() — astro Function Reference

constructor() — astro Function Reference

Architecture documentation for the constructor() function in select.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  bbee4572_910a_a607_9667_3d845497e9bb["constructor()"]
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1["DevToolbarSelect"]
  bbee4572_910a_a607_9667_3d845497e9bb -->|defined in| 937950d6_9d1e_50fa_0b42_45d8c1f9fbc1
  style bbee4572_910a_a607_9667_3d845497e9bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/runtime/client/dev-toolbar/ui-library/select.ts lines 26–84

	constructor() {
		super();
		this.shadowRoot = this.attachShadow({ mode: 'open' });
		this.shadowRoot.innerHTML = `
      <style>
        :host {
          --purple-text: rgba(224, 204, 250, 1);
					--purple-border: rgba(113, 24, 226, 1);

          --gray-text: rgba(191, 193, 201, 1);
					--gray-border:rgba(191, 193, 201, 1);

					--red-text: rgba(249, 196, 215, 1);
					--red-border: rgba(179, 62, 102, 1);

					--green-text: rgba(213, 249, 196, 1);
					--green-border: rgba(61, 125, 31, 1);

					--yellow-text: rgba(249, 233, 196, 1);
					--yellow-border: rgba(181, 138, 45, 1);

					--blue-text: rgba(189, 195, 255, 1);
					--blue-border: rgba(54, 69, 217, 1);

          --text-color: var(--gray-text);
          --border-color: var(--gray-border);
        }
        select {
          appearance: none;
          text-align-last: center;
          display: inline-block;
          font-family: system-ui, sans-serif;
          font-size: 14px;
          padding: 4px 24px 4px 8px;
          border: 1px solid var(--border-color);
          border-radius: 4px;
          color: var(--text-color);
          background-color: transparent;
          background-image:
            linear-gradient(45deg, transparent 50%, var(--text-color) 50%),
            linear-gradient(135deg, var(--text-color) 50%, transparent 50%);
          background-position:
            calc(100% - 12px) calc(1em - 2px),
            calc(100% - 8px) calc(1em - 2px);
          background-size: 4px 4px;
          background-repeat: no-repeat;
        }
      </style>
      <style id="selected-style"></style>
      <slot></slot>
    `;
		this.element = document.createElement('select');
		this.shadowRoot.addEventListener('slotchange', (event) => {
			if (event.target instanceof HTMLSlotElement) {
				// Manually add slotted elements to <select> because it only accepts <option> as children and escapes other elements including <slot>
				this.element.append(...event.target.assignedNodes());
			}
		});
	}

Domain

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the astro codebase, defined in packages/astro/src/runtime/client/dev-toolbar/ui-library/select.ts.
Where is constructor() defined?
constructor() is defined in packages/astro/src/runtime/client/dev-toolbar/ui-library/select.ts at line 26.

Analyze Your Own Codebase

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

Try Supermodel Free