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
47 changes: 15 additions & 32 deletions src/components/HomeCards/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
import {useEffect, useState} from 'react';
import Link from '@docusaurus/Link';
import CodeBlock from '@theme/CodeBlock';
import {PLATFORMS, detectPlatform} from '@site/src/lib/installer';
import styles from './styles.module.css';

function quickStartSnippet(command) {
return `# Install\n${command}\n\n# Debug\nphp your-script.php`;
}

/* Shows the command for the visitor's own OS. The page is prerendered without
knowing it, so this starts on the Unix command and corrects itself after
mounting -- detecting in an effect rather than during render keeps the first
client render identical to the server's, which is what hydration compares. */
function QuickStartSnippet() {
const [platform, setPlatform] = useState('macos');

useEffect(() => {
const detected = detectPlatform();
if (detected) {
setPlatform(detected);
}
}, []);

const active = PLATFORMS.find((p) => p.id === platform) ?? PLATFORMS[0];

return (
<CodeBlock language={active.language}>
{quickStartSnippet(active.command)}
</CodeBlock>
);
}
const quickStartSteps = [
'Install it with one command',
'Start your editor listening',
'Set a breakpoint',
'Run your code as usual',
];

const keyFeatures = [
'Always on — no trigger to set',
Expand Down Expand Up @@ -65,9 +42,15 @@ export default function HomeCards() {
title="Quick Start"
linkTo="/getting-started/quick-start"
linkLabel="View quick start guide">
<p>Install it. There is nothing to configure.</p>
<QuickStartSnippet />
<p>Start your editor listening, set a breakpoint, run your code.</p>
<p>Four steps, and nothing to configure.</p>
<ol className={styles.stepList}>
{quickStartSteps.map((step, i) => (
<li key={step}>
<span className={styles.step}>{i + 1}</span>
{step}
</li>
))}
</ol>
</Card>
<Card
icon={
Expand Down
34 changes: 29 additions & 5 deletions src/components/HomeCards/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,33 @@
}
}

/* The installer URL is longer than the card is wide. Wrapping keeps the whole
command visible and copyable rather than clipping it at the card edge. */
.cardBody :global(.theme-code-block) code {
white-space: pre-wrap;
overflow-wrap: anywhere;
/* Numbered steps in the Quick Start card, mirroring the check badges beside the
Key Features list so the two cards read as a pair. */
.stepList {
list-style: none;
padding: 0;
margin: 0;
}

.stepList li {
display: flex;
align-items: baseline;
gap: 0.5rem;
padding: 0.25rem 0;
}

.step {
display: inline-flex;
align-items: center;
justify-content: center;
width: 1.1rem;
height: 1.1rem;
flex-shrink: 0;
border-radius: 50%;
background-color: var(--ifm-color-primary);
color: #fff;
font-size: 0.7rem;
font-weight: 700;
position: relative;
top: 0.15rem;
}
Loading