Skip to content

Commit 8f1654c

Browse files
authored
Merge pull request #52 from hackclub/staging
Ability to disable model previews
2 parents 4c93bd9 + ab39858 commit 8f1654c

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

src/lib/components/Spinny3DPreview.svelte

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
import { onDestroy, onMount } from 'svelte';
55
import fileSizeFromUrl from '$lib/utils';
66
7-
let { identifier, modelUrl, lineColor = 0x94857d, sizeCutoff = 2.5 * 1024 * 1024 } = $props();
7+
let {
8+
identifier,
9+
modelUrl,
10+
lineColor = 0x94857d,
11+
sizeCutoff = 2.5 * 1024 * 1024,
12+
respectLocalStorage = true
13+
} = $props();
814
915
let loadedPercent: number = $state(0);
1016
let showLoadButton: boolean = $state(false);
@@ -380,7 +386,11 @@
380386
fileSizeFromUrl(modelUrl).then((size) => {
381387
fileSize = size;
382388
383-
if (size <= sizeCutoff) {
389+
if (
390+
size <= sizeCutoff &&
391+
((respectLocalStorage && window.localStorage.getItem('enableModelRendering') !== 'false') ||
392+
!respectLocalStorage)
393+
) {
384394
loadModel();
385395
} else {
386396
showLoadButton = true;
@@ -435,7 +445,9 @@
435445
loadModel();
436446
}}
437447
>
438-
Load ({Math.round((fileSize / 1024 / 1024) * 10) / 10} MiB)
448+
Load ({fileSize >= 1000 * 1000
449+
? `${Math.round((fileSize / 1000 / 1000) * 10) / 10} MB`
450+
: `${Math.round((fileSize / 1000) * 10) / 10} kB`})
439451
</button>
440452
{:else}
441453
<p>Loading... {Math.round(loadedPercent)}%</p>

src/routes/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@
295295
identifier="keyring"
296296
modelUrl={keyringModel}
297297
sizeCutoff={8 * 1024 * 1024}
298+
respectLocalStorage={false}
298299
/>
299300
</div>
300301
<div class="text-center">

src/routes/dashboard/+page.svelte

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
<script lang="ts">
22
import Head from '$lib/components/Head.svelte';
33
import ChecklistItem from '$lib/components/ChecklistItem.svelte';
4+
import { onMount } from 'svelte';
45
56
let { data } = $props();
7+
8+
let enableModelRendering = $state(true);
9+
10+
onMount(() => {
11+
enableModelRendering = window.localStorage.getItem('enableModelRendering') !== 'false';
12+
});
13+
14+
$effect(() => {
15+
window.localStorage.setItem('enableModelRendering', enableModelRendering.toString());
16+
});
617
</script>
718

819
<Head title="Dashboard" />
@@ -12,8 +23,16 @@
1223
<div class="themed-box flex flex-col gap-0.5 p-3">
1324
<h2 class="text-xl font-bold">Checklist</h2>
1425
<div class="flex flex-col gap-0.5">
15-
<ChecklistItem completed={data.projectCount > 0}><a href="/dashboard/projects/create" class="underline">Create</a> your first project</ChecklistItem>
26+
<ChecklistItem completed={data.projectCount > 0}
27+
><a href="/dashboard/projects/create" class="underline">Create</a> your first project</ChecklistItem
28+
>
1629
<ChecklistItem completed={data.devlogCount > 0}>Make your first journal entry</ChecklistItem>
1730
<ChecklistItem completed={data.shipCount > 0}>Ship your project</ChecklistItem>
1831
</div>
1932
</div>
33+
<div class="themed-box mt-3 flex flex-col gap-0.5 p-3">
34+
<label class="flex flex-row items-center gap-1">
35+
<input type="checkbox" class="checkbox" bind:checked={enableModelRendering} />
36+
<span>Enable rendering 3D models</span>
37+
</label>
38+
</div>

src/routes/dashboard/projects/[id]/ship/+page.svelte

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@
6969
{#if form?.invalid_printables_url}
7070
<p class="text-sm">Invalid Printables URL</p>
7171
{:else if form?.invalid_license}
72-
<p class="text-sm">License not allowed, see below! You don't want Orpheus chasing you, do you?</p>
72+
<p class="text-sm">
73+
License not allowed, see below! You don't want Orpheus chasing you, do you?
74+
</p>
7375
{/if}
7476
</div>
7577
</div>
@@ -121,7 +123,8 @@
121123
</p>
122124
{:else}
123125
<p class="text-sm opacity-50">
124-
e.g. orpheus.f3d, monkey.blend (must be under {MAX_UPLOAD_SIZE / 1024 / 1024} MiB)
126+
e.g. orpheus.f3d, monkey.blend (must be under {MAX_UPLOAD_SIZE / 1024 / 1024} MiB). Make
127+
sure to use a format that preserves timeline if your editor supports that!
125128
</p>
126129
{/if}
127130
</div>
@@ -156,9 +159,7 @@
156159
<ChecklistItem completed={data.project.timeSpent >= 120}
157160
>At least 120 minutes spent</ChecklistItem
158161
>
159-
<ChecklistItem completed={data.project.devlogCount >= 2}
160-
>At least 2 journal logs</ChecklistItem
161-
>
162+
<ChecklistItem completed={data.project.devlogCount >= 2}>At least 2 journal logs</ChecklistItem>
162163
<ChecklistItem completed={data.project.description != ''}>
163164
Project has a description
164165
</ChecklistItem>

0 commit comments

Comments
 (0)