mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
feat(help): in-app help center with per-screen guides and pictures
A help icon on every screen opens a panel with the screen's overview, its sub-screens, task guides with a framed picture per step, search across guides and the wiki, and a switch to any other screen's help. Guides exist for the dashboard, Vacay, Atlas, Collections, Journey (list, journal, studio), Settings (all tabs), Admin (all tabs) and the trip frame; the trip's own screens are in progress. Pictures are produced by Playwright (client/e2e/help), texts in all 23 languages.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import React from 'react'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
|
||||
/**
|
||||
* The one pill the help center is built from: section markers, counters,
|
||||
* breadcrumbs, step numbers. Tones map onto the appearance tokens so a user's
|
||||
* accent reaches every badge, and a badge can nest another (`count`) for the
|
||||
* "3 steps" pattern without a second component.
|
||||
*/
|
||||
export type HelpBadgeTone = 'neutral' | 'accent' | 'soft' | 'success' | 'warning' | 'outline'
|
||||
|
||||
const TONES: Record<HelpBadgeTone, string> = {
|
||||
neutral: 'bg-surface-tertiary text-content-secondary',
|
||||
accent: 'bg-accent text-accent-text',
|
||||
soft: 'bg-accent-subtle text-accent-on',
|
||||
success: 'bg-success-soft text-success',
|
||||
warning: 'bg-warning-soft text-warning',
|
||||
outline: 'border border-edge bg-surface-card text-content-secondary',
|
||||
}
|
||||
|
||||
/** The nested counter inverts against its parent so it reads as a badge in a badge. */
|
||||
const COUNT_TONES: Record<HelpBadgeTone, string> = {
|
||||
neutral: 'bg-surface-card text-content',
|
||||
accent: 'bg-accent-text text-accent',
|
||||
soft: 'bg-surface-card text-content',
|
||||
success: 'bg-surface-card text-success',
|
||||
warning: 'bg-surface-card text-warning',
|
||||
outline: 'bg-surface-tertiary text-content',
|
||||
}
|
||||
|
||||
export default function HelpBadge({
|
||||
tone = 'neutral',
|
||||
icon: Icon,
|
||||
count,
|
||||
uppercase = false,
|
||||
children,
|
||||
className = '',
|
||||
}: {
|
||||
tone?: HelpBadgeTone
|
||||
icon?: LucideIcon
|
||||
/** A nested badge on the right, e.g. a number. */
|
||||
count?: React.ReactNode
|
||||
uppercase?: boolean
|
||||
children?: React.ReactNode
|
||||
className?: string
|
||||
}): React.ReactElement {
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center gap-1.5 h-7 rounded-full pl-2.5 text-caption font-semibold leading-none whitespace-nowrap ${
|
||||
count === undefined ? 'pr-2.5' : 'pr-1'
|
||||
} ${uppercase ? 'uppercase tracking-[0.08em]' : ''} ${TONES[tone]} ${className}`}
|
||||
>
|
||||
{Icon && <Icon className="w-3.5 h-3.5 flex-shrink-0" />}
|
||||
{children}
|
||||
{count !== undefined && (
|
||||
<span className={`inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full text-caption font-bold ${COUNT_TONES[tone]}`}>
|
||||
{count}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user