generated from xkeshav/astro-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Help Menu Implementation Plan (GitHub/Twitter/Confluence Style)
Overview
This plan outlines how to create a help menu that opens when the "?" key is pressed, similar to GitHub, Twitter, or Confluence. The solution will use minimal dependencies - just HTML, CSS, and vanilla JavaScript.
Features
- Opens when user presses "?" key
- Displays a searchable list of help topics
- Organized into categories ("Places to go", "Keyboard shortcuts", etc.)
- Clean, modern UI with animations
- Accessible via keyboard navigation
- Mobile-responsive design

Implementation Steps
1. HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Application</title>
<link rel="stylesheet" href="help-menu.css">
</head>
<body>
<!-- Your main app content here -->
<!-- Help Menu Overlay -->
<div id="help-menu" class="help-menu hidden">
<div class="help-menu-container">
<div class="help-menu-header">
<h2>Help</h2>
<button id="close-help" class="close-button" aria-label="Close help menu">×</button>
</div>
<div class="help-menu-search">
<input type="text" placeholder="Search help..." id="help-search">
</div>
<div class="help-menu-content">
<div class="help-menu-section">
<h3>Places to Go</h3>
<ul class="help-menu-links">
<li><a href="/documentation">Documentation</a></li>
<li><a href="/api">API Reference</a></li>
<li><a href="/community">Community Forum</a></li>
<li><a href="/support">Support Center</a></li>
</ul>
</div>
<div class="help-menu-section">
<h3>Keyboard Shortcuts</h3>
<ul class="help-menu-links">
<li><kbd>?</kbd> - Show this help menu</li>
<li><kbd>ESC</kbd> - Close help menu</li>
<li><kbd>/</kbd> - Focus search</li>
<li><kbd>G</kbd> + <kbd>H</kbd> - Go to Home</li>
</ul>
</div>
</div>
</div>
</div>
<script src="help-menu.js"></script>
</body>
</html>
2. CSS Styling (help-menu.css)
/* Help Menu Styles */
.hidden {
display: none !important;
}
.help-menu {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
display: flex;
justify-content: center;
align-items: center;
animation: fadeIn 0.2s ease-out;
}
.help-menu-container {
background-color: white;
border-radius: 8px;
width: 80%;
max-width: 600px;
max-height: 80vh;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
overflow: hidden;
animation: slideUp 0.2s ease-out;
}
.help-menu-header {
padding: 16px 24px;
border-bottom: 1px solid #e1e4e8;
display: flex;
justify-content: space-between;
align-items: center;
}
.help-menu-header h2 {
margin: 0;
font-size: 20px;
font-weight: 600;
}
.close-button {
background: none;
border: none;
font-size: 24px;
cursor: pointer;
padding: 4px 8px;
color: #586069;
}
.close-button:hover {
color: #24292e;
}
.help-menu-search {
padding: 16px 24px;
border-bottom: 1px solid #e1e4e8;
}
.help-menu-search input {
width: 100%;
padding: 8px 12px;
border: 1px solid #e1e4e8;
border-radius: 6px;
font-size: 14px;
}
.help-menu-content {
padding: 16px 24px;
overflow-y: auto;
max-height: calc(80vh - 150px);
}
.help-menu-section {
margin-bottom: 24px;
}
.help-menu-section h3 {
margin: 0 0 12px 0;
font-size: 16px;
font-weight: 600;
color: #24292e;
}
.help-menu-links {
list-style: none;
padding: 0;
margin: 0;
}
.help-menu-links li {
padding: 6px 0;
}
.help-menu-links a {
color: #0366d6;
text-decoration: none;
}
.help-menu-links a:hover {
text-decoration: underline;
}
.help-menu-links kbd {
display: inline-block;
padding: 3px 5px;
font-size: 11px;
line-height: 10px;
color: #444d56;
vertical-align: middle;
background-color: #fafbfc;
border: 1px solid #d1d5da;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #d1d5da;
}
/* Animations */
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
/* Responsive adjustments */
@media (max-width: 768px) {
.help-menu-container {
width: 90%;
}
}
3. JavaScript (help-menu.js)
document.addEventListener('DOMContentLoaded', function() {
const helpMenu = document.getElementById('help-menu');
const closeButton = document.getElementById('close-help');
const helpSearch = document.getElementById('help-search');
// Open help menu when "?" is pressed
document.addEventListener('keydown', function(e) {
// Check if "?" was pressed and no input/textarea is focused
if (e.key === '?' && !['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName)) {
e.preventDefault();
openHelpMenu();
}
// Close help menu when ESC is pressed
if (e.key === 'Escape' && !helpMenu.classList.contains('hidden')) {
e.preventDefault();
closeHelpMenu();
}
});
// Close button click handler
closeButton.addEventListener('click', closeHelpMenu);
// Close when clicking outside the menu
helpMenu.addEventListener('click', function(e) {
if (e.target === helpMenu) {
closeHelpMenu();
}
});
function openHelpMenu() {
helpMenu.classList.remove('hidden');
helpSearch.focus();
document.body.style.overflow = 'hidden'; // Prevent scrolling
}
function closeHelpMenu() {
helpMenu.classList.add('hidden');
document.body.style.overflow = ''; // Re-enable scrolling
}
// Optional: Implement search functionality
helpSearch.addEventListener('input', function() {
const searchTerm = this.value.toLowerCase();
const sections = document.querySelectorAll('.help-menu-section');
sections.forEach(section => {
const sectionTitle = section.querySelector('h3').textContent.toLowerCase();
const links = section.querySelectorAll('li');
let hasVisibleItems = false;
links.forEach(link => {
const text = link.textContent.toLowerCase();
if (text.includes(searchTerm) || sectionTitle.includes(searchTerm)) {
link.style.display = '';
hasVisibleItems = true;
} else {
link.style.display = 'none';
}
});
section.style.display = hasVisibleItems ? '' : 'none';
});
});
});
Enhancement Ideas
-
Keyboard Navigation:
- Add arrow key navigation through help items
- Enter to follow links
-
Recent/Popular Topics:
- Track and display frequently accessed help items
-
Dynamic Content Loading:
- Load help content from a JSON file or API
-
Theming:
- Add dark mode support
-
Localization:
- Support for multiple languages
-
Analytics:
- Track which help items are accessed most
Testing Plan
-
Unit Tests:
- Test help menu opens on "?" key press
- Test menu closes on ESC and click outside
- Test search functionality filters correctly
-
Browser Testing:
- Chrome, Firefox, Safari, Edge
- Mobile browsers (iOS, Android)
-
Accessibility Testing:
- Keyboard navigation
- Screen reader compatibility
- Color contrast
-
Performance Testing:
- Load time impact
- Memory usage with menu open
This implementation provides a lightweight, framework-free solution that mimics the functionality of help menus in popular platforms while maintaining simplicity and performance.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request