MCPcopy Create free account
hub / github.com/FastLED/FastLED / createHelp

Function createHelp

src/platforms/wasm/compiler/modules/ui/ui_manager.ts:476–707  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

474}
475
476function createHelp(element) {
477 const helpContainer = document.createElement('div');
478 helpContainer.className = 'ui-help-container';
479 helpContainer.id = `help-${element.id}`;
480
481 // Create help button
482 const helpButton = document.createElement('button');
483 helpButton.className = 'ui-help-button';
484 helpButton.textContent = '?';
485 helpButton.setAttribute('type', 'button');
486 helpButton.setAttribute('aria-label', 'Help');
487
488 // Prepare content for tooltip and popup
489 const markdownContent = element.markdownContent || '';
490 const tooltipText = markdownContent.length > 200
491 ? `${markdownContent.substring(0, 200).trim()}...`
492 : markdownContent;
493
494 // Convert markdown to HTML for popup
495 const htmlContent = markdownToHtml(markdownContent);
496
497 // Create tooltip
498 const tooltip = document.createElement('div');
499 tooltip.className = 'ui-help-tooltip';
500 tooltip.textContent = tooltipText;
501
502 // Add event listeners for tooltip
503 helpButton.addEventListener('mouseenter', () => {
504 if (tooltipText.trim()) {
505 showTooltip(helpButton, tooltip);
506 }
507 });
508
509 helpButton.addEventListener('mouseleave', () => {
510 hideTooltip(tooltip);
511 });
512
513 // Add event listener for popup
514 helpButton.addEventListener('click', (e) => {
515 e.preventDefault();
516 e.stopPropagation();
517 showHelpPopup(htmlContent);
518 });
519
520 // Assemble the help container
521 helpContainer.appendChild(helpButton);
522
523 // Append tooltip to document body so it can appear above everything
524 document.body.appendChild(tooltip);
525
526 // Add styles if not already present
527 if (!document.querySelector('#ui-help-styles')) {
528 const style = document.createElement('style');
529 style.id = 'ui-help-styles';
530 style.textContent = `
531 .ui-help-container {
532 position: relative;
533 display: inline-block;

Callers 1

createControlElementMethod · 0.85

Calls 7

markdownToHtmlFunction · 0.85
showTooltipFunction · 0.85
hideTooltipFunction · 0.85
showHelpPopupFunction · 0.85
trimMethod · 0.80
substringMethod · 0.80
addEventListenerMethod · 0.45

Tested by

no test coverage detected