Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/rebuild/design/design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,8 @@ Hero #top app icon (64, 80 from 768) · H1 "TablePro 0.85" (Home's size) · "
- **After the click.** The DMG action, in the hero or the Mac band, gives way in place to "Your download has started.
If it didn't, download again." (the same link, `download-retry`) and three numbered steps, and takes focus. Only when
a release source answered; with none the button opens GitHub's latest release and nothing claims a download.
- **Commands** wrap at spaces with a hanging indent, and a long URL after a slash, so nothing scrolls on a phone. The
copy button says Copy and Copied.
- **Commands** keep one line each and the block scrolls sideways, as a terminal does (owner, 2026-11-08). The copy
button says Copy and Copied.
- **QR code** of the App Store URL, drawn on the server by `lib/qr.ts` (byte mode, level M), black on white in both
themes with its quiet zone. Hidden below 640px and on an iPhone or iPad. `tests/js/qr.test.ts` decodes it.
- **Ids.** `#mac`, `#linux`, `#ios` are the bands; `#updates` (Security's "Download and updates") lands on the Mac
Expand Down
28 changes: 4 additions & 24 deletions resources/js/components/download/command-block.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Fragment } from 'react';
import { CodeBlock } from '@/components/ui/code';
import { useI18n } from '@/i18n';

const WHOLE_TOKEN = 32;

interface CommandBlockProps {
// One command per line, exactly as copied: no prompt.
lines: string[];
Expand All @@ -13,32 +10,15 @@ interface CommandBlockProps {
className?: string;
}

// One copy button takes every line. A line wraps at a space, its continuation indented so it never reads as the next
// command. Tokens are kept whole, since a browser would break one after a hyphen; a long one (a URL) may also break
// after a slash, so it wraps on a phone instead of scrolling.
// One copy button takes every line. A command keeps its line and the block scrolls sideways, as a terminal would, so
// a wrapped URL never reads as two commands (owner, 2026-11-08).
export default function CommandBlock({ lines, title, label, onCopied, className }: CommandBlockProps) {
const { m } = useI18n();

return (
<CodeBlock label={label} title={title} copyLabels={m.controls.copy} copySize="md" copyValue={lines.join('\n')} onCopied={onCopied} className={className}>
<pre className="type-mono p-4 break-normal whitespace-pre-wrap text-foreground">
<code>
{lines.map((line, index) => (
<span key={index} className="block pl-[2ch] -indent-[2ch]">
{line.split(' ').map((token, position) => (
<Fragment key={position}>
{position > 0 && ' '}
{(token.length > WHOLE_TOKEN ? token.split(/(?<=\/)(?!\/)/) : [token]).map((part, at) => (
<Fragment key={at}>
{at > 0 && <wbr />}
<span className="whitespace-nowrap">{part}</span>
</Fragment>
))}
</Fragment>
))}
</span>
))}
</code>
<pre className="type-mono w-max min-w-full p-4 whitespace-pre text-foreground">
<code>{lines.join('\n')}</code>
</pre>
</CodeBlock>
);
Expand Down
8 changes: 7 additions & 1 deletion tests/Feature/Pages/DownloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,17 @@ function downloadHeroFor(Dom\HTMLDocument $document, string $device): array

$expected = collect($linux['destinations'])->filter(fn(array $destination): bool => isset($destination['commands']))->map(fn(array $destination): array => $destination['commands'])->values()->all();
$blocks = array_map(
fn(Dom\Element $block): array => array_map(fn(Dom\Element $line): string => (string) $line->textContent, iterator_to_array($block->querySelectorAll('pre code > span'))),
fn(Dom\Element $block): array => explode("\n", (string) $block->querySelector('pre code')?->textContent),
iterator_to_array($document->querySelectorAll('#linux [role="region"]')),
);
$headings = array_map(fn(Dom\Element $heading): string => downloadText($heading), iterator_to_array($document->querySelectorAll('#linux h3')));

// A command keeps its line and the block scrolls sideways (owner, 2026-11-08).
foreach ($document->querySelectorAll('#linux pre') as $pre) {
expect(in_array('whitespace-pre', explode(' ', (string) $pre->getAttribute('class')), true))->toBeTrue('a command block wraps its lines')
->and($pre->querySelectorAll('wbr'))->toHaveCount(0);
}

expect($blocks)->toBe($expected)
->and($headings)->toBe(['Ubuntu 26.04 and 26.10', 'Fedora 44 and 45', 'Other distributions, with Flatpak'])
->and(downloadText($document->querySelector('#linux h2 + span')))->toBe('Beta')
Expand Down