Home / Class/ DevToolbarSelect Class — astro Architecture

DevToolbarSelect Class — astro Architecture

Architecture documentation for the DevToolbarSelect class in select.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1["DevToolbarSelect"]
  5a53f3d3_65e4_d21e_5fe1_1d14aa0ae789["select.ts"]
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1 -->|defined in| 5a53f3d3_65e4_d21e_5fe1_1d14aa0ae789
  5dceb0c3_79f1_ff35_225c_b77b010296fe["selectStyle()"]
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1 -->|method| 5dceb0c3_79f1_ff35_225c_b77b010296fe
  bbee4572_910a_a607_9667_3d845497e9bb["constructor()"]
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1 -->|method| bbee4572_910a_a607_9667_3d845497e9bb
  135f7f9d_9e0e_7e2e_11c4_3171da9c2300["connectedCallback()"]
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1 -->|method| 135f7f9d_9e0e_7e2e_11c4_3171da9c2300
  5546828e_db58_c36d_1f36_20808ed57e1d["attributeChangedCallback()"]
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1 -->|method| 5546828e_db58_c36d_1f36_20808ed57e1d
  460b5a9d_00a2_547d_5983_3d27ee441c6f["updateStyle()"]
  937950d6_9d1e_50fa_0b42_45d8c1f9fbc1 -->|method| 460b5a9d_00a2_547d_5983_3d27ee441c6f

Relationship Graph

Source Code

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

export class DevToolbarSelect extends HTMLElement {
	shadowRoot: ShadowRoot;
	element: HTMLSelectElement;
	_selectStyle: SelectStyle = 'gray';

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

	static observedAttributes = ['select-style'];

	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());
			}
		});
	}

	connectedCallback() {
		this.element.name = 'dev-toolbar-select';

Domain

Frequently Asked Questions

What is the DevToolbarSelect class?
DevToolbarSelect is a class in the astro codebase, defined in packages/astro/src/runtime/client/dev-toolbar/ui-library/select.ts.
Where is DevToolbarSelect defined?
DevToolbarSelect is defined in packages/astro/src/runtime/client/dev-toolbar/ui-library/select.ts at line 7.

Analyze Your Own Codebase

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

Try Supermodel Free