|
1 | 1 | <script lang="ts"> |
| 2 | + import Button from "$lib/components/ui/button/button.svelte"; |
| 3 | + import { ArrowDown, FileUp, AlertTriangle, MessageSquare } from "lucide-svelte"; |
2 | 4 | import type { VFSFile } from "../types"; |
| 5 | + import Separator from "$lib/components/ui/separator/separator.svelte"; |
| 6 | + import Textarea from "$lib/components/ui/textarea/textarea.svelte"; |
| 7 | + import Badge from "$lib/components/ui/badge/badge.svelte"; |
| 8 | + import { toast } from "svelte-sonner"; |
3 | 9 |
|
4 | 10 | interface Props { |
5 | 11 | file: VFSFile; |
6 | 12 | } |
7 | 13 |
|
8 | 14 | const { file }: Props = $props(); |
9 | 15 | let success = $state(true); |
| 16 | + let showRubricPanel = $state(false); |
| 17 | + let rubricFeedback = $state(""); |
| 18 | +
|
| 19 | + function handleUpload(e: Event) { |
| 20 | + const input = e.target as HTMLInputElement; |
| 21 | + const uploadedFile = input.files?.[0]; |
| 22 | +
|
| 23 | + if (uploadedFile) { |
| 24 | + // Here you would implement the actual upload logic |
| 25 | + toast.success(`${uploadedFile.name} has been uploaded for review`); |
| 26 | + input.value = ""; |
| 27 | + } |
| 28 | + } |
| 29 | +
|
| 30 | + function submitFeedback() { |
| 31 | + // Here you would implement the logic to submit the textual feedback |
| 32 | + toast.success(`Your correction notes have been saved`); |
| 33 | + showRubricPanel = false; |
| 34 | + } |
10 | 35 | </script> |
11 | 36 |
|
12 | | -<div class="relative h-full w-full"> |
13 | | - <iframe |
14 | | - title="Word Document" |
15 | | - src="https://view.officeapps.live.com/op/embed.aspx?src={file.content}" |
16 | | - width="100%" |
17 | | - height="100%" |
18 | | - frameborder="0" |
19 | | - onerror={() => (success = false)} |
20 | | - >This is an embedded <a target="_blank" href="http://office.com">Microsoft Office</a> |
21 | | - document, powered by |
22 | | - <a target="_blank" href="http://office.com/webapps">Office Online</a>.</iframe |
23 | | - > |
24 | | - |
25 | | - {#if !success} |
26 | | - <div |
27 | | - class="absolute inset-0 flex flex-col items-center justify-center bg-white/90 p-4" |
| 37 | +<div class="relative flex h-full w-full flex-col"> |
| 38 | + |
| 39 | + <!-- Controls Menu --> |
| 40 | + <menu class="bg-muted sticky top-0 z-50 flex items-center gap-3 p-3 shadow"> |
| 41 | + |
| 42 | + <!-- Download --> |
| 43 | + <Button |
| 44 | + variant="outline" |
| 45 | + title="Download document" |
| 46 | + onclick={() => { |
| 47 | + const link = document.createElement("a"); |
| 48 | + link.href = file.content; |
| 49 | + link.download = file.name || "document.docx"; |
| 50 | + link.click(); |
| 51 | + }} |
| 52 | + > |
| 53 | + Download |
| 54 | + <ArrowDown class="ml-2 h-4 w-4" /> |
| 55 | + </Button> |
| 56 | + |
| 57 | + <!-- Upload correction docx --> |
| 58 | + <Button variant="secondary" class="relative" title="Upload correction document"> |
| 59 | + <FileUp class="mr-2 h-4 w-4" /> |
| 60 | + Upload Corrections |
| 61 | + <input |
| 62 | + type="file" |
| 63 | + accept=".docx,.doc" |
| 64 | + class="absolute inset-0 cursor-pointer opacity-0" |
| 65 | + onchange={handleUpload} |
| 66 | + /> |
| 67 | + </Button> |
| 68 | + |
| 69 | + <!-- Rubric feedback toggle --> |
| 70 | + <Button |
| 71 | + variant={showRubricPanel ? "default" : "outline"} |
| 72 | + onclick={() => (showRubricPanel = !showRubricPanel)} |
28 | 73 | > |
29 | | - <div class="max-w-md rounded border border-red-400 bg-red-100 p-4 text-red-700"> |
30 | | - <p class="mb-2 text-lg font-bold">Error Loading Document</p> |
31 | | - <p> |
32 | | - The document could not be loaded. Please check the file format or try again |
33 | | - later. |
34 | | - </p> |
| 74 | + <MessageSquare class="mr-2 h-4 w-4" /> |
| 75 | + {showRubricPanel ? "Hide Feedback" : "Add Feedback"} |
| 76 | + </Button> |
| 77 | + </menu> |
| 78 | + |
| 79 | + <!-- Preview Banner --> |
| 80 | + <div class="border-b border-amber-200 bg-amber-50 p-2 text-center text-amber-800"> |
| 81 | + <AlertTriangle class="mr-1 inline-block h-4 w-4" /> |
| 82 | + <span class="font-medium">Preview Only</span> |
| 83 | + <span class="ml-1 text-sm">— Submit corrections using the options below</span> |
| 84 | + </div> |
| 85 | + |
| 86 | + <!-- Rubric Feedback Panel --> |
| 87 | + {#if showRubricPanel} |
| 88 | + <div class="border-b bg-white p-4 shadow-sm"> |
| 89 | + <h3 class="mb-2 font-medium">Correction Notes</h3> |
| 90 | + <Textarea |
| 91 | + placeholder="Enter your feedback and correction notes here..." |
| 92 | + class="mb-3 min-h-[100px]" |
| 93 | + bind:value={rubricFeedback} |
| 94 | + /> |
| 95 | + <div class="flex justify-end gap-2"> |
| 96 | + <Button variant="outline" onclick={() => (showRubricPanel = false)}> |
| 97 | + Cancel |
| 98 | + </Button> |
| 99 | + <Button onclick={submitFeedback}>Submit Feedback</Button> |
35 | 100 | </div> |
36 | 101 | </div> |
37 | 102 | {/if} |
| 103 | + |
| 104 | + <!-- Document Viewer --> |
| 105 | + <div class="relative flex-1"> |
| 106 | + <iframe |
| 107 | + title="Word Document" |
| 108 | + src="https://view.officeapps.live.com/op/embed.aspx?src={file.content}" |
| 109 | + width="100%" |
| 110 | + height="100%" |
| 111 | + frameborder="0" |
| 112 | + onerror={() => (success = false)} |
| 113 | + class="absolute inset-0 inset-shadow-xl" |
| 114 | + >This is an embedded <a target="_blank" href="http://office.com">Microsoft Office</a |
| 115 | + > |
| 116 | + document, powered by |
| 117 | + <a target="_blank" href="http://office.com/webapps">Office Online</a>. |
| 118 | + </iframe> |
| 119 | + |
| 120 | + <!-- Error State --> |
| 121 | + {#if !success} |
| 122 | + <div |
| 123 | + class="absolute inset-0 flex flex-col items-center justify-center bg-white/90 p-4" |
| 124 | + > |
| 125 | + <div class="max-w-md rounded border border-red-400 bg-red-100 p-4 text-red-700"> |
| 126 | + <p class="mb-2 text-lg font-bold">Error Loading Document</p> |
| 127 | + <p> |
| 128 | + The document could not be loaded. Please check the file format or try again |
| 129 | + later. |
| 130 | + </p> |
| 131 | + </div> |
| 132 | + </div> |
| 133 | + {/if} |
| 134 | + |
| 135 | + <!-- Watermark --> |
| 136 | + <div class="pointer-events-none absolute bottom-0 right-0 m-20"> |
| 137 | + <div class="rotate-[-30deg] scale-150 transform text-lg font-bold text-red-500/20"> |
| 138 | + PREVIEW ONLY |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + </div> |
38 | 142 | </div> |
0 commit comments