Skip to main content

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โ€‹

PropTypeDefaultDescription
keystringnullHelp content key (e.g., 'term_exams.name')
textstringnullDirect help text (overrides key lookup)
placementstring'top'Tooltip position: top, bottom, left, right
iconstring'mdi-help-circle-outline'Material Design icon
classstring''Additional CSS classes
showWhenbooltrueConditionally 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โ€‹

  1. Refresh the page in your browser
  2. Hover over the help icon (small circle with question mark)
  3. Verify the tooltip appears with correct text
  4. Check positioning - tooltip shouldn't overflow viewport

Common Issuesโ€‹

Tooltip Not Showingโ€‹

Cause: Help key not found in inline-help.json

Fix:

  1. Check the key exists in your docs frontmatter
  2. Run php artisan help:generate
  3. 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โ€‹

  1. Identify the screen and its key fields
  2. Open the relevant docs guide (or create one)
  3. Add help_keys to frontmatter:
    help_keys:
    screen_name:
    intro: "What this screen is for"
    field_1: "Help for field 1"
    field_2: "Help for field 2"
  4. Generate JSON: php artisan help:generate
  5. 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>
  6. Test in browser
  7. 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โ€‹

FilePurpose
app/Services/HelpService.phpLoads and caches help content
app/Console/Commands/GenerateHelpContent.phpArtisan command for generation
resources/views/components/help-tooltip.blade.phpReusable tooltip component
public/assets/user-guide/inline-help.jsonGenerated help content (don't edit manually)
resources/views/layouts/footer_js.blade.phpGlobal tooltip initialization

Translation Supportโ€‹

Help text is currently in English. To add translations:

  1. 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..."
  2. Update HelpService to use app()->getLocale()

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! ๐Ÿ’ก