Home / Class/ DevToolbarToggle Class — astro Architecture

DevToolbarToggle Class — astro Architecture

Architecture documentation for the DevToolbarToggle class in toggle.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  8a84a891_ea62_56c8_0c0a_767465d852c4["DevToolbarToggle"]
  fbf62f91_0f51_5711_770e_0eb69709dc4b["toggle.ts"]
  8a84a891_ea62_56c8_0c0a_767465d852c4 -->|defined in| fbf62f91_0f51_5711_770e_0eb69709dc4b
  0576d686_72ce_a5ef_f456_95d87f88f28e["toggleStyle()"]
  8a84a891_ea62_56c8_0c0a_767465d852c4 -->|method| 0576d686_72ce_a5ef_f456_95d87f88f28e
  fe441d5c_2d33_1643_768c_e4b7e3e4c596["constructor()"]
  8a84a891_ea62_56c8_0c0a_767465d852c4 -->|method| fe441d5c_2d33_1643_768c_e4b7e3e4c596
  fb15b2de_53c4_f893_a9a7_bc6b918b6d3a["attributeChangedCallback()"]
  8a84a891_ea62_56c8_0c0a_767465d852c4 -->|method| fb15b2de_53c4_f893_a9a7_bc6b918b6d3a
  65bced3c_5cdf_2f87_978a_35119d4e60e1["updateStyle()"]
  8a84a891_ea62_56c8_0c0a_767465d852c4 -->|method| 65bced3c_5cdf_2f87_978a_35119d4e60e1
  1873a26d_332d_3df2_d007_7d21cb41d8e8["connectedCallback()"]
  8a84a891_ea62_56c8_0c0a_767465d852c4 -->|method| 1873a26d_332d_3df2_d007_7d21cb41d8e8
  bf96702d_5d8a_b8f8_e720_1df4272fc2b3["value()"]
  8a84a891_ea62_56c8_0c0a_767465d852c4 -->|method| bf96702d_5d8a_b8f8_e720_1df4272fc2b3

Relationship Graph

Source Code

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

export class DevToolbarToggle extends HTMLElement {
	shadowRoot: ShadowRoot;
	input: HTMLInputElement;
	_toggleStyle: ToggleStyle = 'gray';

	get toggleStyle() {
		return this._toggleStyle;
	}

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

	static observedAttributes = ['toggle-style'];

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

		this.shadowRoot.innerHTML = `
		<style>
			:host {
				--purple-bg-on: rgba(113, 24, 226, 1);
				--purple-border-off: rgba(113, 24, 226, 1);
				--purple-border-on: rgba(224, 204, 250, 1);

				--gray-bg-on: rgba(61, 125, 31, 1);
				--gray-border-off: rgba(145, 152, 173, 1);
				--gray-border-on: rgba(213, 249, 196, 1);

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

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

				--yellow-bg-on: rgba(181, 138, 45, 1);
				--yellow-border-off: rgba(181, 138, 45, 1);
				--yellow-border-on: rgba(255, 236, 179, 1);

				--blue-bg-on: rgba(54, 69, 217, 1);
				--blue-border-off: rgba(54, 69, 217, 1);
				--blue-border-on: rgba(189, 195, 255, 1);
			}

			input {
				appearance: none;
				width: 32px;
				height: 20px;
				border: 1px solid var(--border-off);
				transition: background-color 0.2s ease, border-color 0.2s ease;
				border-radius: 9999px;
			}

			input::after {
				content: '';
				width: 16px;
				display: inline-block;
				height: 16px;
				background-color: var(--border-off);
				border-radius: 9999px;
				transition: transform 0.2s ease, background-color 0.2s ease;
				top: 1px;
				left: 1px;
				position: relative;
			}

			@media (forced-colors: active) {
				input::after {
					border: 1px solid black;
					top: 0px;
					left: 0px;
				}
			}

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free