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
20 changes: 16 additions & 4 deletions app/components/editing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useBlocker, useFetcher, type FormProps } from "react-router";
import { ConfirmDialog } from "./confirm-dialog";
import { IconButton } from "./icon-button";
import { Modal } from "./modal";
import { useWorkspacePlayback } from "./workspace-player";

const DialogActions = createContext<{
cancel: () => void;
Expand Down Expand Up @@ -240,11 +241,20 @@ export function PreviewLink({
label?: string;
}) {
const editors = useContext(Editing);
const workspace = useWorkspacePlayback();
const trigger = useRef<HTMLAnchorElement>(null);
const [labels, setLabels] = useState<string[] | null>(null);
const [busy, setBusy] = useState(false);
const [error, setError] = useState("");
const open = () => window.open(href, "_blank", "noopener,noreferrer");
const pauseDemoForPreview = () => {
// A preview can open in a separate web view, leaving the workspace mounted.
workspace?.getSnapshot().playback?.pause();
};
const open = (preview?: Window | null) => {
pauseDemoForPreview();
if (preview) preview.location.replace(href);
else window.open(href, "_blank", "noopener,noreferrer");
};
const close = () => {
if (!busy) setLabels(null);
};
Expand All @@ -264,7 +274,10 @@ export function PreviewLink({
const dirty = [...(editors?.values() || [])].filter((editor) =>
editor.dirty(),
);
if (!dirty.length) return;
if (!dirty.length) {
pauseDemoForPreview();
return;
}
event.preventDefault();
setLabels(dirty.map((editor) => editor.label));
setError("");
Expand Down Expand Up @@ -320,8 +333,7 @@ export function PreviewLink({
return;
}
}
if (preview) preview.location.replace(href);
else open();
open(preview);
setLabels(null);
} finally {
setBusy(false);
Expand Down
2 changes: 2 additions & 0 deletions app/components/workspace-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ export function WorkspacePlayerProvider({ children }: { children: ReactNode }) {
useEffect(() => {
const clearCache = attachAudioCacheSession();
window.addEventListener("wavecase-access-revoked", workspace.dispose);
window.addEventListener("pagehide", workspace.dispose);
return () => {
window.removeEventListener("wavecase-access-revoked", workspace.dispose);
window.removeEventListener("pagehide", workspace.dispose);
workspace.dispose();
clearCache();
};
Expand Down
17 changes: 11 additions & 6 deletions app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
--space-6: 32px;
--space-7: 48px;
--page-gutter: clamp(18px, 4vw, 72px);
--page-inset-top: env(safe-area-inset-top, 0px);
--page-inset-bottom: env(safe-area-inset-bottom, 0px);
scroll-padding-top: var(--page-inset-top);
scroll-padding-bottom: var(--page-inset-bottom);
color-scheme: dark;
font:
var(--text-md) / var(--leading-normal) system-ui,
Expand All @@ -57,6 +61,7 @@ body {
margin: 0;
min-height: 100vh;
min-height: 100dvh;
padding-block: var(--page-inset-top) var(--page-inset-bottom);
display: flex;
flex-direction: column;
}
Expand Down Expand Up @@ -537,10 +542,10 @@ button:hover:not(:disabled),

/* Released music has its own artwork-led public presentation. */
:root:has(.release-mini) {
scroll-padding-bottom: calc(150px + env(safe-area-inset-bottom));
scroll-padding-bottom: calc(150px + var(--page-inset-bottom));
}
body:has(.release-mini) {
padding-bottom: calc(150px + env(safe-area-inset-bottom));
padding-bottom: calc(150px + var(--page-inset-bottom));
}
.release-mini {
position: fixed;
Expand All @@ -553,7 +558,7 @@ body:has(.release-mini) {
flex-wrap: wrap;
gap: var(--space-3);
padding: var(--space-3) var(--page-gutter);
padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
padding-bottom: calc(var(--space-3) + var(--page-inset-bottom));
background: var(--color-surface);
border-top: 1px solid var(--color-border-control);
box-shadow: 0 -8px 30px #0005;
Expand Down Expand Up @@ -1054,8 +1059,8 @@ main:has(.workspace) {
color: inherit;
border: 0;
border-right: 1px solid var(--color-border);
padding: max(var(--space-4), env(safe-area-inset-top)) var(--space-4)
max(var(--space-4), env(safe-area-inset-bottom));
padding: calc(var(--space-4) + var(--page-inset-top)) var(--space-4)
calc(var(--space-4) + var(--page-inset-bottom));
overscroll-behavior: contain;
}
body:has(.workspace-drawer[open]) {
Expand Down Expand Up @@ -1154,7 +1159,7 @@ body:has(.workspace-drawer[open]) {

.account-menu {
position: absolute;
inset: 78px var(--page-gutter) auto auto;
inset: calc(78px + var(--page-inset-top)) var(--page-gutter) auto auto;
margin: 0;
min-width: 180px;
padding: var(--space-2);
Expand Down
Loading