BinCode/public/index.html

139 lines
4.4 KiB
HTML
Raw Normal View History

2025-01-17 20:05:21 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>JS Playground</title>
<link rel="stylesheet" href="/style.css" />
<!-- Prismjs css -->
<link rel="stylesheet" href="./libraries/prism/theme/prism.min.css" />
</head>
<body>
<div id="app">
<nav>
<div class="brand">BinCode</div>
<div class="title-input" v-if="token">
<input type="text" v-model="title" placeholder="Snippet title" />
</div>
<div>
<button class="toggle-icon" @click="toggleEditor">
{{ showEditor ? '🙈 editor': '👀 editor'}}
</button>
<button class="toggle-icon" @click="togglePreview">
{{ showPreview ? '🙈 preview' : '👀 preview' }}
</button>
</div>
<div class="nav-actions">
<div class="auth-buttons" v-if="!token">
<button @click="showLogin = true">Login</button>
</div>
<div class="user-menu" v-else>
<button @click="saveSnippet" class="primary">Save</button>
<button @click="logout">Logout</button>
</div>
</div>
</nav>
<div class="editor-container">
<div
class="editor-group"
v-show="showEditor"
:style="{ width: editorWidth }"
>
<!-- Tab bar -->
<div class="tab-bar">
<button
v-for="tab in tabs"
:key="tab.id"
class="tab"
:class="{ active: activeTab === tab.id }"
@click="switchTab(tab.id)"
>
<span class="tab-icon">{{ tab.icon }}</span>
{{ tab.label }}
<kbd v-if="tab.id === 'html'">⌘1</kbd>
<kbd v-if="tab.id === 'css'">⌘2</kbd>
<kbd v-if="tab.id === 'js'">⌘3</kbd>
</button>
</div>
<!-- Editor content -->
<div class="editor-content">
<textarea
:value="currentCode"
@input="handleInput"
@keydown="handleKeydown"
:class="{ 'active-editor': true }"
spellcheck="false"
autocomplete="off"
:placeholder="'Enter your ' + activeTab.toUpperCase() + ' code here...'"
></textarea>
<pre
class="editor-highlight"
aria-hidden="true"
><code v-html="highlightedCode[activeTab]"></code></pre>
</div>
</div>
<div
class="preview"
:style="{ width: previewWidth }"
v-show="showPreview"
>
<iframe id="preview-frame"></iframe>
</div>
</div>
<!-- Share Modal -->
<div
class="modal"
v-if="showShareModal"
@click.self="showShareModal = false"
>
<div class="modal-content">
<h2>Share Snippet</h2>
<div class="share-url">
<input type="text" :value="shareUrl" readonly ref="shareUrlInput" />
<button @click="copyShareUrl" class="primary">Copy</button>
</div>
<button class="close" @click="showShareModal = false">&times;</button>
</div>
</div>
<!-- Login Modal -->
<div class="modal" v-if="showLogin" @click.self="showLogin = false">
<div class="modal-content">
<h2>Login</h2>
<form @submit.prevent="login">
<input
type="email"
v-model="loginEmail"
placeholder="Email"
required
/>
<input
type="password"
v-model="loginPassword"
placeholder="Password"
required
/>
<button type="submit" class="primary">Login</button>
</form>
<button class="close" @click="showLogin = false">&times;</button>
</div>
</div>
</div>
<!-- use`_dev` or `_prod` lib for vuejs based on env -->
<script src="./libraries/vue/vuejs_3.5.13_prod.js"></script>
<!-- Prismjs -->
<script src="./libraries/prism/prism.min.js"></script>
<script src="./libraries/prism/prism-markup.min.js"></script>
<script src="./libraries/prism/prism-css.min.js"></script>
<script src="./libraries/prism/prism-javascript.min.js"></script>
<script src="/app.js"></script>
</body>
</html>