| 1 | <script lang="ts"> |
| 2 | import Menu from "./utility/Menu.svelte"; |
| 3 | import settings from "./Settings.svelte"; |
| 4 | import Welcome from "./Welcome.svelte"; |
| 5 | import { Settings } from "carbon-icons-svelte"; |
| 6 | import { addTab, tabs, closeActiveTab } from "../lib/EditorTabList.svelte"; |
| 7 | import { workspaceName } from "./File"; |
| 8 | import { commands } from "../config/commands"; |
| 9 | import { shell } from "@tauri-apps/api"; |
| 10 | import { openLogFiles } from "../config/config"; |
| 11 | |
| 12 | const items = [ |
| 13 | {menuname: "File", children: [ |
| 14 | {name: "New File", shortcut: commands.addEditorTab.keybind, action: commands.addEditorTab.command}, |
| 15 | {name: "Open File...", shortcut: commands.openFile.keybind, action: commands.openFile.command}, |
| 16 | {name: "Open Folder...", shortcut: commands.openFolder.keybind, action: commands.openFolder.command}, |
| 17 | {name: "Save File", shortcut: commands.saveFile.keybind, action: commands.saveFile.command}, |
| 18 | {name: "Save File As...", shortcut: commands.saveFileAs.keybind, action: commands.saveFileAs.command}, |
| 19 | {name: "Close Tab", disabled: $tabs.length === 0, shortcut: "", action: async () => {await closeActiveTab()}}, |
| 20 | ]}, |
| 21 | {menuname: "Edit", children: [ |
| 22 | {name: "Undo", disabled: commands.undo.disabled, shortcut: commands.undo.keybind, action: commands.undo.command}, |
| 23 | {name: "Redo", disabled: commands.redo.disabled, shortcut: commands.redo.keybind, action: commands.redo.command}, |
| 24 | {name: "Cut", disabled: commands.cut.disabled, shortcut: commands.cut.keybind, action: commands.cut.command}, |
| 25 | {name: "Copy", disabled: commands.copy.disabled, shortcut: commands.copy.keybind, action: commands.copy.command}, |
| 26 | {name: "Paste", disabled: commands.paste.disabled, shortcut: commands.paste.keybind, action: commands.paste.command}, |
| 27 | {name: "Paste From History...", disabled: true, shortcut: commands.pasteFromHistory.keybind, action: commands.pasteFromHistory.command}, |
| 28 | {name: "Delete", disabled: commands.delete.disabled, shortcut: commands.delete.keybind, action: commands.delete.command}, |
| 29 | {name: "Find", disabled: true, shortcut: commands.find.keybind, action: () => commands.find.command}, |
| 30 | {name: "Replace", disabled: true, shortcut: commands.replace.keybind, action: commands.replace.command}, |
| 31 | ]}, |
| 32 | {menuname: "View", children: [ |
| 33 | {name: "Command Pallete", disabled: true, shortcut: commands.openCommandPallete.keybind, action: commands.openCommandPallete.command}, |
| 34 | {name: "Zoom In", disabled: true, shortcut: commands.zoomIn.keybind, action: commands.zoomIn.command}, |
| 35 | {name: "Zoom Out", disabled: true, shortcut: commands.zoomOut.keybind, action: commands.zoomOut.command}, |
| 36 | {name: "Reset Zoom", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}, |
| 37 | {name: "Fullscreen", disabled: commands.fullscreen.disabled, shortcut: commands.fullscreen.keybind, action: commands.fullscreen.command}, |
| 38 | ]}, |
| 39 | {menuname: "Run", children: [ |
| 40 | {name: "Run File", disabled: true, shortcut: commands.runFile.keybind, action: commands.runFile.command}, |
| 41 | {name: "Debug File", disabled: true, shortcut: commands.debugFile.keybind, action: commands.debugFile.command}, |
| 42 | {name: "Stop File", disabled: true, shortcut: commands.stopFile.keybind, action: commands.stopFile.command}, |
| 43 | {name: "Open Configurations", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}, |
| 44 | ]}, |
| 45 | {menuname: "Help", children: [ |
| 46 | {name: "Welcome", shortcut: "", action: () => {addTab("Welcome", "Welcome", new Welcome({target: document.getElementById("tabview")}))}}, |
| 47 | {name: "Send Feedback", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}, |
| 48 | {name: "Contact Support", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}, |
| 49 | {name: "Report Issue", shortcut: "", action: () => {shell.open("https://github.com/setoelkahfi/svara/issues/new/choose")}}, |
| 50 | {name: "Documentation", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}, |
| 51 | {name: "Show Release Notes", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}, |
| 52 | {name: "Check for Updates", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}, |
| 53 | {name: "About", shortcut: "", action: () => {shell.open("https://github.com/setoelkahfi/svara")}}, |
| 54 | {name: "Open Logs", shortcut: "", action: async () => {await openLogFiles()}}, |
| 55 | ]}, |
| 56 | ]; |
| 57 | </script> |
| 58 | |
| 59 | <div id="header"> |
| 60 | <div id="logo"></div> |
| 61 | <div id="menubar"> |
| 62 | {#each items as item} |
| 63 | <Menu menu={item}></Menu> |
| 64 | {/each} |
| 65 | </div> |
| 66 | <div class="divider"></div> |
| 67 | <div id="workspace" title="" data-tauri-drag-region> |
| 68 | {$workspaceName} |
| 69 | </div> |
| 70 | <div id="handle" data-tauri-drag-region></div> |
| 71 | <div class="tools"> |
| 72 | |
| 73 | <div class="settings-button"> |
| 74 | <Menu right menu={{icon: Settings, children: [ |
| 75 | {name: "Settings", shortcut: "", action: () => {addTab("Settings", "Settings", new settings({target: document.getElementById("tabview")}))}}, |
| 76 | {name: "Keymap", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}} |
| 77 | ] |
| 78 | }} /> |
| 79 | </div> |
| 80 | </div> |
| 81 | <div id="window-controls"> |
| 82 | <!-- svelte-ignore a11y-click-events-have-key-events --> |
| 83 | <!-- svelte-ignore a11y-no-static-element-interactions --> |
| 84 | <div |
| 85 | class="window-button" |
| 86 | id="minimize" |
| 87 | on:click={commands.minimizeWindow.command} |
| 88 | /> |
| 89 | <!-- svelte-ignore a11y-click-events-have-key-events --> |
| 90 | <!-- svelte-ignore a11y-no-static-element-interactions --> |
| 91 | <div |
| 92 | class="window-button" |
| 93 | id="maximize" |
| 94 | on:click={commands.maximizeWindow.command} |
| 95 | /> |
| 96 | <!-- svelte-ignore a11y-click-events-have-key-events --> |
| 97 | <!-- svelte-ignore a11y-no-static-element-interactions --> |
| 98 | <div |
| 99 | class="window-button" |
| 100 | id="close" |
| 101 | on:click={commands.closeWindow.command} |
| 102 | /> |
| 103 | </div> |
| 104 | </div> |
| 105 | |
| 106 | <style lang="scss"> |
| 107 | #header { |
| 108 | width: 100%; |
| 109 | display: flex; |
| 110 | align-items: center; |
| 111 | position: relative; |
| 112 | z-index: 3; |
| 113 | } |
| 114 | #logo { |
| 115 | background-size: 20px; |
| 116 | background-repeat: no-repeat; |
| 117 | height: 100%; |
| 118 | min-width: 35px; |
| 119 | position: relative; |
| 120 | content: ''; |
| 121 | background-image: url("/assets/images/Icon.png"); |
| 122 | background-position: center; |
| 123 | z-index: 10; |
| 124 | } |
| 125 | #menubar { |
| 126 | height: 100%; |
| 127 | display: flex; |
| 128 | z-index: 10; |
| 129 | } |
| 130 | .divider { |
| 131 | width: 0.0625rem; |
| 132 | height: 1.2rem; |
| 133 | margin: 0 4px; |
| 134 | } |
| 135 | #workspace { |
| 136 | height: 100%; |
| 137 | padding: 0 0.5rem; |
| 138 | font-size: 0.813rem; |
| 139 | overflow: hidden; |
| 140 | text-overflow: ellipsis; |
| 141 | white-space: nowrap; |
| 142 | color: #8c8c8c; |
| 143 | z-index: 10; |
| 144 | } |
| 145 | |
| 146 | #handle { |
| 147 | position: absolute; |
| 148 | width: -webkit-fill-available; |
| 149 | z-index: 9; |
| 150 | } |
| 151 | |
| 152 | .settings-button { |
| 153 | height: 100%; |
| 154 | display: flex; |
| 155 | justify-content: center; |
| 156 | align-items: center; |
| 157 | z-index: 10; |
| 158 | } |
| 159 | .tools { |
| 160 | display: flex; |
| 161 | justify-content: end; |
| 162 | padding: 0 5px; |
| 163 | height: 100%; |
| 164 | margin-left: auto; |
| 165 | } |
| 166 | |
| 167 | #window-controls { |
| 168 | height: 100%; |
| 169 | display: flex; |
| 170 | z-index: 10; |
| 171 | .window-button { |
| 172 | min-width: 36px; |
| 173 | height: 100%; |
| 174 | line-height: 34px; |
| 175 | text-align: center; |
| 176 | padding: 0 5px; |
| 177 | font-size: 0.875rem; |
| 178 | cursor: pointer; |
| 179 | &#close:hover { |
| 180 | background-color: #ff3131; |
| 181 | } |
| 182 | &#minimize::before { |
| 183 | content: "\2014"; |
| 184 | font-size: 10px; |
| 185 | } |
| 186 | &#maximize::before { |
| 187 | content: "\2610"; |
| 188 | } |
| 189 | &#close::before { |
| 190 | content: "\2715"; |
| 191 | line-height: 30px; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | </style> |