Skip to content

Commit 23bb452

Browse files
authored
UX Improvements (#31)
* logo as link * pass index to scene builder * remove scene shortcuts * monaco editor UX * author note * tweaks * tweaks * changelog and pr template
1 parent 7ecf248 commit 23bb452

16 files changed

Lines changed: 397 additions & 244 deletions

.github/pull_request_template.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- Thank you for contributing to mol-view-stories -->
2+
3+
# Description
4+
5+
6+
## Actions
7+
8+
- [ ] Added description of changes to the `[Unreleased]` section of `CHANGELOG.md`

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file, following the suggestions of [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to [Semantic Versioning](http://semver.org/).
3+
4+
## [Unreleased]
5+
6+
## [v1.0.0]
7+
8+
- Initial release

src/app/page.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ export default function Home() {
188188
</div>
189189
</section>
190190
<Features />
191-
<div className='text-right text-sm text-muted-foreground py-6 mt-10'>
192-
Version {APP_VERSION}
193-
</div>
191+
<div className='text-right text-sm text-muted-foreground py-6 mt-10'>Version {APP_VERSION}</div>
194192
</Main>
195193
</>
196194
);

src/app/state/actions.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ export function newStory() {
9191
}
9292

9393
const createStateProvider = (code: string) => {
94-
return new Function('builder', code);
94+
return new Function('builder', 'index', code);
9595
};
9696

97-
async function getMVSSnapshot(story: Story, scene: SceneData) {
97+
async function getMVSSnapshot(story: Story, scene: SceneData, index: number) {
9898
try {
9999
const stateProvider = createStateProvider(`
100100
async function _run_builder() {
@@ -103,7 +103,7 @@ async function _run_builder() {
103103
return _run_builder();
104104
`);
105105
const builder = MVSData.createBuilder();
106-
await stateProvider(builder);
106+
await stateProvider(builder, index);
107107
if (scene.camera) {
108108
builder.camera({
109109
position: adjustedCameraPosition(scene.camera),
@@ -139,8 +139,9 @@ export async function getMVSData(story: Story, scenes: SceneData[] = story.scene
139139
const snapshots: Snapshot[] = [];
140140

141141
// TODO: not sure if Promise.all would be better here.
142-
for (const scene of scenes) {
143-
const snapshot = await getMVSSnapshot(story, scene);
142+
for (let index = 0; index < scenes.length; index++) {
143+
const scene = scenes[index];
144+
const snapshot = await getMVSSnapshot(story, scene, index);
144145
snapshots.push(snapshot);
145146
}
146147
const index: MVSData = {

src/app/state/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export type StoryContainer = {
3636

3737
export type StoryMetadata = {
3838
title: string;
39+
author_note?: string;
3940
};
4041

4142
export type Story = {

src/app/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const APP_VERSION = '1.0.0-beta.1';
1+
export const APP_VERSION = '1.0.0-beta.2';

src/components/common.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip';
77
import { useRouter, usePathname } from 'next/navigation';
88
import { useUnsavedChanges } from '@/hooks/useUnsavedChanges';
99
import { ConfirmDialog } from './ui/confirm-dialog';
10+
import Link from 'next/link';
1011

1112
function HeaderLogo() {
1213
const router = useRouter();
@@ -15,12 +16,10 @@ function HeaderLogo() {
1516
const [showDialog, setShowDialog] = React.useState(false);
1617
const handleClick = (e: React.MouseEvent) => {
1718
// Only intercept if on /builder
18-
if (pathname.startsWith('/builder') && hasUnsavedChanges) {
19+
if (pathname.includes('/builder') && hasUnsavedChanges) {
1920
e.preventDefault();
2021
disableUnsavedChanges(); // Disable browser alerts
2122
setShowDialog(true);
22-
} else {
23-
router.push('/');
2423
}
2524
};
2625
const handleConfirm = () => {
@@ -29,15 +28,15 @@ function HeaderLogo() {
2928
};
3029
return (
3130
<>
32-
<button
33-
type='button'
31+
<Link
32+
href='/'
3433
onClick={handleClick}
3534
className='flex items-center gap-2 text-xl font-bold text-foreground hover:text-foreground/80 transition-colors bg-transparent border-none p-0 cursor-pointer'
3635
style={{ background: 'none', border: 'none' }}
3736
>
3837
<Image src='/favicon.ico' alt='MolViewStories' width={24} height={24} className='w-6 h-6' />
3938
MolViewStories
40-
</button>
39+
</Link>
4140
<ConfirmDialog
4241
open={showDialog}
4342
onOpenChange={setShowDialog}
@@ -113,7 +112,6 @@ export function Main({ children, className }: { children: React.ReactNode; class
113112
export function PressToSave() {
114113
return (
115114
<div className='text-xs text-muted-foreground mb-2'>
116-
Press{' '}
117115
<span className='bg-muted text-muted-foreground pointer-events-none inline-flex h-5 items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 select-none'>
118116
<span>Ctrl/⌘/Alt + S/Enter</span>
119117
</span>{' '}
@@ -122,6 +120,17 @@ export function PressToSave() {
122120
);
123121
}
124122

123+
export function PressToCodeComplete() {
124+
return (
125+
<div className='text-xs text-muted-foreground mb-2'>
126+
<span className='bg-muted text-muted-foreground pointer-events-none inline-flex h-5 items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 select-none'>
127+
<span>Ctrl + Space</span>
128+
</span>{' '}
129+
for code completion
130+
</div>
131+
);
132+
}
133+
125134
export function TooltipWrapper({
126135
children,
127136
tooltip,

0 commit comments

Comments
 (0)