Adding In-App Help Tooltips
This guide explains how to add helpful tooltips to screens in the 4SCH application. The tooltip system pulls help text from documentation, ensuring in-app help and documentation stay in sync.
How the System Worksโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ /docs/docs/guides/*.md โ
โ (Markdown files with help_keys frontmatter) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ php artisan help:generate
โโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ public/assets/user-guide/inline-help.json โ
โ (Auto-generated JSON file) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ HelpService loads & caches
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ <x-help-tooltip key="..." /> โ
โ (Blade component renders tooltip in views) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Step 1: Add Help Content to Documentationโ
Add help_keys to the frontmatter of relevant markdown files in /docs/docs/guides/.
Example: Adding Help for Term Examsโ
File: docs/docs/guides/continuous-assessment.md
---
sidebar_position: 12
title: Continuous Assessment Guide
help_keys:
term_exams:
intro: "Term Exams organize your assessments and CA calculations."
name: "Give it a clear name like 'Term 1 Exam'."
start_date: "When this assessment period begins."
end_date: "When this assessment period ends. Must be after start date."
ca_config:
intro: "Configure CA weightages. Total must equal 100%."
weightage: "Percentage weight (0-100) of this CA component."
---
Best Practices for Help Textโ
Do:
- โ Keep text short (1-2 sentences ideal)
- โ Use friendly, end-user language
- โ Provide examples when helpful
- โ Explain why, not just what
- โ Include constraints (e.g., "Must equal 100%")
Don't:
- โ Don't use technical jargon
- โ Don't write paragraphs (use docs guides for that)
- โ Don't repeat the field label
- โ Don't include HTML (will be escaped)
Step 2: Generate the Help JSONโ
After adding/updating help_keys in documentation, regenerate the JSON:
cd /path/to/staging.4sch.com
php artisan help:generate
Expected output:
๐ Generating inline help content from documentation...
๐ Scanning: /path/to/docs/docs
๐ Found 25 markdown files
โ guides/continuous-assessment.md: 12 keys
โ guides/offline-exams.md: 8 keys
๐ Summary:
โข Files processed: 25
โข Files with help_keys: 2
โข Total help keys: 20
โข Output path: public/assets/user-guide/inline-help.json
โ
Help content generated successfully!
๐๏ธ Cache cleared
Useful Command Optionsโ
# Dry run (preview without writing)
php artisan help:generate --dry-run
# Custom docs path
php artisan help:generate --docs-path=/custom/docs
# Custom output path
php artisan help:generate --output=/custom/path/inline-help.json
Step 3: Add Tooltips to Viewsโ
Use the <x-help-tooltip> component anywhere in your Blade templates.
Basic Usageโ
<label>{{ __('start_date') }} <x-help-tooltip key="term_exams.start_date" /></label>
Component Propertiesโ
| Prop | Type | Default | Description |
|---|---|---|---|
key | string | null | Help content key (e.g., 'term_exams.name') |
text | string | null | Direct help text (overrides key lookup) |
placement | string | 'top' | Tooltip position: top, bottom, left, right |
icon | string | 'mdi-help-circle-outline' | Material Design icon |
class | string | '' | Additional CSS classes |
showWhen | bool | true | Conditionally show tooltip |
Examplesโ
Basic Tooltipโ
<x-help-tooltip key="term_exams.name" />
With Custom Placementโ
<x-help-tooltip key="ca_config.intro" placement="bottom" />
Direct Text (No Key Lookup)โ
<x-help-tooltip text="This field is auto-calculated based on CA scores" />
Conditional Displayโ
<x-help-tooltip key="advanced_setting" :showWhen="$user->isAdmin()" />
Custom Stylingโ
<x-help-tooltip key="term_exams.name" class="text-primary" />
Common Placement Patternsโ
1. Page Title Tooltipโ
<h3 class="page-title">
{{ __('manage_term_exams') }}
<x-help-tooltip key="term_exams.intro" placement="right" />
</h3>
2. Form Field Labelโ
<label>
{{ __('field_name') }}
<span class="text-danger">*</span>
<x-help-tooltip key="screen.field_name" />
</label>
3. Card Headerโ
<div class="card-header">
<h6>{{ __('section_title') }} <x-help-tooltip key="screen.section" /></h6>
</div>
4. Modal Titleโ
<h5 class="modal-title">
{{ __('configure_settings') }}
<x-help-tooltip key="screen.settings" placement="bottom" />
</h5>
Step 4: Test Your Tooltipsโ
Manual Testingโ
- Refresh the page in your browser
- Hover over the help icon (small circle with question mark)
- Verify the tooltip appears with correct text
- Check positioning - tooltip shouldn't overflow viewport
Common Issuesโ
Tooltip Not Showingโ
Cause: Help key not found in inline-help.json
Fix:
- Check the key exists in your docs frontmatter
- Run
php artisan help:generate - Clear cache:
php artisan cache:clear
Wrong Text Displayedโ
Cause: Cache not refreshed after updating docs
Fix:
php artisan help:generate
php artisan cache:clear
Tooltip Position Cut Offโ
Cause: Default placement doesn't fit
Fix: Use placement prop:
<x-help-tooltip key="..." placement="left" />
Coverage Guidelinesโ
Phase 1: Critical Admin Screensโ
Priority screens to cover first:
- โ
Term Exams (
terms/index) - โ CA Configuration modal
- โ
Manage Exams (
exams/index) - โณ Schools, Classes, Subjects
- โณ Students, Staff, Grades
- โณ Sessions, Semesters
What Deserves a Tooltip?โ
Always add tooltips to:
- โ Page titles (intro/overview)
- โ
Required form fields (
*marked) - โ Configuration options with constraints
- โ Fields with non-obvious behavior
- โ Settings affecting calculations
- โ Permissions and access controls
Skip tooltips for:
- โ Self-explanatory fields (Name, Email, Address)
- โ Read-only displays
- โ Standard buttons (Save, Cancel, Close)
- โ Static informational text
Adding a New Screen's Tooltipsโ
Step-by-Step Workflowโ
- Identify the screen and its key fields
- Open the relevant docs guide (or create one)
- Add
help_keysto frontmatter:help_keys:
screen_name:
intro: "What this screen is for"
field_1: "Help for field 1"
field_2: "Help for field 2" - Generate JSON:
php artisan help:generate - Edit the Blade view:
<h3>{{ __('page_title') }} <x-help-tooltip key="screen_name.intro" placement="right" /></h3>
<label>{{ __('field_1') }} <x-help-tooltip key="screen_name.field_1" /></label> - Test in browser
- Commit your changes
Maintenanceโ
When to Update Help Textโ
Update help_keys when:
- ๐ Field behavior changes
- ๐ New constraints are added
- ๐ User feedback indicates confusion
- ๐ New features added
Build Hookโ
The help generation can be automated in deployment:
// composer.json
{
"scripts": {
"post-update-cmd": [
"@php artisan help:generate"
]
}
}
Architecture Referenceโ
File Locationsโ
| File | Purpose |
|---|---|
app/Services/HelpService.php | Loads and caches help content |
app/Console/Commands/GenerateHelpContent.php | Artisan command for generation |
resources/views/components/help-tooltip.blade.php | Reusable tooltip component |
public/assets/user-guide/inline-help.json | Generated help content (don't edit manually) |
resources/views/layouts/footer_js.blade.php | Global tooltip initialization |
Translation Supportโ
Help text is currently in English. To add translations:
-
Add language-specific help_keys:
help_keys:
en:
term_exams:
name: "Give it a clear name..."
fr:
term_exams:
name: "Donnez-lui un nom clair..." -
Update
HelpServiceto useapp()->getLocale()
Related Documentationโ
Need Help?โ
If you have questions about adding tooltips:
- Check existing tooltip implementations in
terms/index.blade.php - Review the CA Configuration modal for complex examples
- Open an issue if you find bugs in the help system
Tip: Good tooltips reduce support burden and improve user experience. Take time to write helpful, clear help text! ๐ก