Skip to content
Open
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
23 changes: 0 additions & 23 deletions src/app/demo/DemoShell.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,6 @@
}
}

.banner {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
padding: 12px 24px;
background: colors.$color-primary-lightest;
border-bottom: 1px solid colors.$color-border;
color: colors.$color-primary-dark;
font-size: 14px;
a {
color: inherit;
text-decoration: underline;
}
}

.actions {
display: flex;
align-items: center;
Expand All @@ -78,9 +61,3 @@
padding: 24px;
text-align: center;
}

@media print {
.banner {
display: none;
}
}
16 changes: 16 additions & 0 deletions src/app/demo/DemoShell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,19 @@ it('unmounts the old workspace when another tab rotates its credentials', async
await waitFor(() => expect(persistSession).toHaveBeenCalledWith('other-tab-token', 'other-tab-space'));
expect(screen.getByText('Real EPOCA application')).toBeInTheDocument();
});

it('opens and closes the guide without resetting a returning workspace', async () => {
vi.mocked(requestDemoSession).mockResolvedValueOnce(session());
const user = userEvent.setup();
render(
<DemoShell>
<p>Real EPOCA application</p>
</DemoShell>,
);
await user.click(await screen.findByRole('button', { name: 'Quick guide' }));
expect(await screen.findByRole('dialog', { name: 'Try EPOCA in a few minutes' })).toBeInTheDocument();
await user.click(screen.getByRole('button', { name: 'Got it' }));
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
expect(screen.getByText('Real EPOCA application')).toBeInTheDocument();
expect(requestDemoSession).toHaveBeenCalledTimes(1);
});
25 changes: 8 additions & 17 deletions src/app/demo/DemoShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useAuth } from '@/modules/auth/AuthProvider';
import { useCallback, useEffect, useRef, useState, type PropsWithChildren } from 'react';
import { isAxiosError } from 'axios';
import { DemoGuide } from './DemoGuide';
import { DemoToolbar } from './DemoToolbar';
import styles from './DemoShell.module.scss';
import { requestDemoSession, type DemoSession } from './requests';

Expand Down Expand Up @@ -143,23 +144,13 @@ export function DemoShell({ children }: PropsWithChildren): JSX.Element {

return (
<>
<aside className={styles.banner} aria-label="Demo workspace">
<div>
<strong>EPOCA demo</strong>
<span> Your private sample workspace · expires after 24h</span>
</div>
<div className={styles.actions}>
<Button label="Quick guide" size="small" variant="outlined" onClick={() => setShowGuide(true)} />
<Button
label="Reset demo"
size="small"
variant="outlined"
disabled={busy}
onClick={() => setConfirmReset(true)}
/>
<a href="https://kozikowski.it/projects/epoca">Portfolio</a>
</div>
</aside>
<DemoToolbar
projectName="EPOCA"
portfolioUrl="https://kozikowski.it/projects/epoca"
busy={busy}
onOpenGuide={() => setShowGuide(true)}
onReset={() => setConfirmReset(true)}
/>
{error && (
<p className={styles.notice} role="alert">
{error}
Expand Down
190 changes: 190 additions & 0 deletions src/app/demo/DemoToolbar.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
@font-face {
font-family: 'Portfolio Demo';
src: url('./fonts/montserrat-400-latin-pl.woff2') format('woff2');
font-style: normal;
font-weight: 400;
font-display: swap;
}

@font-face {
font-family: 'Portfolio Demo';
src: url('./fonts/montserrat-500-latin-pl.woff2') format('woff2');
font-style: normal;
font-weight: 500;
font-display: swap;
}

.toolbar {
box-sizing: border-box;
padding: 12px 24px 10px;
border-top: 3px solid #ea3323;
border-bottom: 1px solid #c4c0c0;
background: #fff;
color: #0d0d0d;
color-scheme: light;
font:
400 13px / 1.5 'Portfolio Demo',
sans-serif;
}

.row,
.identity,
.actions {
display: flex;
align-items: center;
gap: 12px;
}

.row {
flex-wrap: wrap;
justify-content: space-between;
gap: 8px 24px;
}

.identity {
flex-wrap: wrap;
min-width: 0;
gap: 6px 12px;
}

.portfolio {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 44px;
color: #c52719;
font:
500 14px / 1.4 'Portfolio Demo',
sans-serif;
text-decoration: none;
text-underline-offset: 4px;
}

.portfolio:hover {
color: #c52719;
text-decoration: underline;
}

.project {
padding-left: 12px;
border-left: 1px solid #c4c0c0;
font-weight: 500;
overflow-wrap: anywhere;
}

.badge {
padding: 3px 6px;
background: #f4f3f0;
color: #444;
font-size: 10px;
font-weight: 500;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}

.actions button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
box-sizing: border-box;
min-height: 44px;
padding: 8px 12px;
border: 1px solid #c4c0c0;
border-radius: 2px;
background: #fff;
color: #0d0d0d;
font:
500 13px / 1.4 'Portfolio Demo',
sans-serif;
text-transform: none;
letter-spacing: normal;
cursor: pointer;
}

.actions button:hover:not(:disabled) {
border-color: #c52719;
background: #f4f3f0;
color: #c52719;
}

.actions button:disabled {
opacity: 0.5;
cursor: wait;
}

.toolbar svg {
flex: 0 0 18px;
width: 18px;
height: 18px;
stroke-linecap: round;
stroke-linejoin: round;
}

.toolbar :focus-visible {
outline: 2px solid #c52719;
outline-offset: 3px;
}

.details {
display: flex;
flex-wrap: wrap;
gap: 2px 16px;
margin-top: 4px;
color: #444;
font-size: 11px;
overflow-wrap: anywhere;
}

@media (max-width: 699px) {
.toolbar {
padding: 8px 16px 10px;
}

.row {
align-items: stretch;
}

.identity,
.actions {
width: 100%;
}

.identity {
gap: 4px 10px;
}

.portfolio {
margin-right: auto;
}

.project {
padding-left: 0;
border-left: 0;
}

.badge {
display: none;
}

.actions {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
}

.actions button {
padding-inline: 8px;
}

.details {
margin-top: 8px;
}
}

@media print {
.toolbar {
display: none;
}
}
58 changes: 58 additions & 0 deletions src/app/demo/DemoToolbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { ReactNode, Ref } from 'react';
import styles from './DemoToolbar.module.scss';

type DemoToolbarProps = {
projectName: string;
portfolioUrl: string;
busy: boolean;
onOpenGuide: () => void;
onReset: () => void;
guideButtonRef?: Ref<HTMLButtonElement>;
details?: ReactNode;
};

export function DemoToolbar({
projectName,
portfolioUrl,
busy,
onOpenGuide,
onReset,
guideButtonRef,
details,
}: Readonly<DemoToolbarProps>): JSX.Element {
return (
<nav className={styles.toolbar} aria-label="Demo navigation">
<div className={styles.row}>
<div className={styles.identity}>
<a className={styles.portfolio} href={portfolioUrl} aria-label="Back to portfolio — kozikowski.it">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" aria-hidden="true">
<path d="m12 5-7 7 7 7M5 12h14" />
</svg>
kozikowski.it
</a>
<span className={styles.project}>{projectName}</span>
<span className={styles.badge}>Live demo</span>
</div>
<div className={styles.actions}>
<button type="button" ref={guideButtonRef} disabled={busy} onClick={onOpenGuide}>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<path d="M9.5 9a2.5 2.5 0 0 1 5 0c0 1.5-2.5 2-2.5 3.5M12 15.5v1" />
</svg>
Quick guide
</button>
<button type="button" disabled={busy} onClick={onReset}>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" aria-hidden="true">
<path d="M3 4v6h6M3.5 10a8.5 8.5 0 1 1 .5 5" />
</svg>
Reset demo
</button>
</div>
</div>
<div className={styles.details}>
<span>Private workspace · Fictional data · Up to 24 hours</span>
{details}
</div>
</nav>
);
}
Loading
Loading