Home / File/ toggle.ts — astro Source File

toggle.ts — astro Source File

Architecture documentation for toggle.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
  fbf62f91_0f51_5711_770e_0eb69709dc4b["toggle.ts"]
  844d479d_bd2c_31dd_1673_36b5e7e8016a["../settings.js"]
  fbf62f91_0f51_5711_770e_0eb69709dc4b --> 844d479d_bd2c_31dd_1673_36b5e7e8016a
  style fbf62f91_0f51_5711_770e_0eb69709dc4b 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 ToggleStyle = (typeof styles)[number];

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;
// ... (78 more lines)

Domain

Subdomains

Types

Dependencies

  • ../settings.js

Frequently Asked Questions

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