Skip to main content
Glama
nrwl

Nx MCP Server

Official
by nrwl
icon.ts1.96 kB
import { html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { EditorContext } from '../contexts/editor-context'; @customElement('icon-element') export class Icon extends EditorContext(LitElement) { @property() icon: string; @property() color = ''; @property({ type: Boolean }) applyFillColor = false; @property() size = ''; override render() { if (this.editor === 'intellij') { return html`<img src="./icons/${this.icon}.svg" class="h-[${this.size ?? '1.25rem'}]" @load="${this.applyColorToSVG}" ></img>`; } else { let spanStyle = 'text-align: center;'; // Use size prop if provided, otherwise default if (this.size) { spanStyle += ` font-size: ${this.size};`; } else { spanStyle += ' font-size: 0.9rem;'; } spanStyle += ` color: ${this.color};`; return html`<span class="codicon codicon-${this.icon}" style="${spanStyle}" ></span>`; } } // we have to parse the svg file and forcefully update the color for intellij async applyColorToSVG() { if (!this.color) { return; } const svgResponse = await fetch(`./icons/${this.icon}.svg`); const svgData = await svgResponse.text(); const parser = new DOMParser(); const parsedSvg = parser.parseFromString(svgData, 'image/svg+xml'); const allPaths = parsedSvg.querySelectorAll('path'); allPaths.forEach((path) => { if (this.applyFillColor) { path.setAttribute('fill', this.color); } path.setAttribute('stroke', this.color); }); const imgElement = this.querySelector('img'); if (imgElement) { imgElement.remove(); } parsedSvg.documentElement.classList.add('h-[1.25rem]'); this.appendChild(parsedSvg.documentElement); } protected override createRenderRoot(): Element | ShadowRoot { return this; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nrwl/nx-console'

If you have feedback or need assistance with the MCP directory API, please join our Discord server