Paragraph {i + 1} of a long, document-like modal body.
+ ))} + > + ), + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement); + await userEvent.click(canvas.getByRole('button', { name: 'Open modal' })); + const dialog = canvas.getByRole('dialog', { name: 'Code reference' }); + // The dialog stays within the viewport; its body scrolls instead. + await expect(dialog.getBoundingClientRect().height).toBeLessThanOrEqual(window.innerHeight); + const body = within(dialog).getByText( + 'Paragraph 1 of a long, document-like modal body.', + ).parentElement!; + await expect(body.scrollHeight).toBeGreaterThan(body.clientHeight); + await expect(within(dialog).getByRole('button', { name: 'Confirm' })).toBeVisible(); + }, +}; diff --git a/client/src/components/modals/CodeHelpModal.module.css b/client/src/components/modals/CodeHelpModal.module.css new file mode 100644 index 0000000..e64428f --- /dev/null +++ b/client/src/components/modals/CodeHelpModal.module.css @@ -0,0 +1,20 @@ +.helpButton { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 2px; + border: none; + border-radius: var(--radius-sm); + background: none; + color: var(--color-text-muted); + cursor: pointer; +} + +.helpButton:hover { + color: var(--color-primary); +} + +.helpButton:focus-visible { + outline: none; + box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35); +} diff --git a/client/src/components/modals/CodeHelpModal.tsx b/client/src/components/modals/CodeHelpModal.tsx new file mode 100644 index 0000000..2f11032 --- /dev/null +++ b/client/src/components/modals/CodeHelpModal.tsx @@ -0,0 +1,54 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { CircleHelp, X } from 'lucide-react'; +import { Modal, Button, MarkdownContent } from '../../ui'; +import content from './code-help.md?raw'; +import styles from './CodeHelpModal.module.css'; + +export interface CodeHelpModalProps { + open: boolean; + onClose: () => void; +} + +/** Reference for the script runtime (`context`, `expect`, ...) available to step and snippet code. */ +export function CodeHelpModal({ open, onClose }: CodeHelpModalProps) { + const { t } = useTranslation(); + + return ( +