Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Fix some css issues, styles & responsive design

Smaug6739b91481f0d2c8
diff --git a/frontend/app/pages/dashboard/settings/_views/snippets.vue b/frontend/app/pages/dashboard/settings/_views/snippets.vue
index 6cda2413..fc992c6d 100644
--- a/frontend/app/pages/dashboard/settings/_views/snippets.vue
+++ b/frontend/app/pages/dashboard/settings/_views/snippets.vue
@@ -2,117 +2,66 @@
<div>
<div class="header">
<h2 class="ctitle">Snippets</h2>
- <p class="csubtitle">
- Manage your markdown snippets for quick insertion. Use shortcuts like !blue to quickly insert pre-defined content.
- </p>
+ <p class="csubtitle">Manage your markdown snippets for quick insertion. Use shortcuts like !blue to quickly insert pre-defined content.</p>
</div>
<!-- Search and Actions -->
<div class="toolbar">
<div class="search-section">
<div class="search-wrapper">
- <Icon name="search" class="search-icon" />
- <input
- v-model="searchQuery"
- type="text"
- placeholder="Search snippets..."
- class="search-input"
- />
+ <Icon fill="var(--font-color)" name="search" class="search-icon" />
+ <input v-model="searchQuery" type="text" placeholder="Search snippets..." class="search-input" />
</div>
<div class="filter-section">
- <AppSelect
- v-model="sortBy"
- :items="sortOptions"
- placeholder="Sort by..."
- size="150px"
- :searchable="false"
- />
+ <AppSelect v-model="sortBy" :items="sortOptions" placeholder="Sort by..." size="200px" :searchable="false" />
</div>
</div>
-
+
<div class="actions">
- <AppButton
- v-if="selectedSnippets.length > 0"
- type="danger"
- @click="deleteSelected"
- >
- Delete Selected ({{ selectedSnippets.length }})
- </AppButton>
- <AppButton type="secondary" @click="exportSnippets">
- <Icon name="download" /> Export
- </AppButton>
- <AppButton type="secondary" @click="importSnippets">
- <Icon name="upload" /> Import
- </AppButton>
- <AppButton type="primary" @click="addSnippet">
- + Add Snippet
- </AppButton>
- <AppButton type="secondary" @click="restoreDefaults">
- ↺ Restore Defaults
- </AppButton>
+ <AppButton v-if="selectedSnippets.length > 0" type="danger" @click="deleteSelected"> Delete Selected ({{ selectedSnippets.length }}) </AppButton>
+ <AppButton type="secondary" class="flex-btn" @click="exportSnippets"><Icon fill="var(--font-color)" name="backup" /> Export </AppButton>
+ <AppButton type="secondary" class="flex-btn" @click="importSnippets"><Icon fill="var(--font-color)" name="import" /> Import </AppButton>
+ <AppButton type="secondary" @click="restoreDefaults"> ↺ Restore defaults</AppButton>
+ <AppButton type="primary" @click="addSnippet"> + Add Snippet </AppButton>
</div>
</div>
<!-- Snippets Grid -->
<div class="snippets-container">
<div v-if="filteredSnippets.length === 0" class="no-snippets">
- <Icon name="search" class="no-snippets-icon" />
+ <Icon fill="var(--font-color)" name="search" class="no-snippets-icon" />
<p v-if="searchQuery">No snippets found matching "{{ searchQuery }}"</p>
<p v-else>No snippets available. Create your first snippet!</p>
</div>
-
+
<TransitionGroup name="snippet" tag="div" class="snippets-grid">
- <div
- v-for="(snippet, index) in filteredSnippets"
+ <div
+ v-for="(snippet, index) in filteredSnippets"
:key="snippet.id || index"
class="snippet-card"
- :class="{ 'selected': selectedSnippets.includes(index), 'editing': editingIndex === index }"
+ :class="{ selected: selectedSnippets.includes(index), editing: editingIndex === index }"
>
<!-- Card Header -->
<div class="snippet-header">
<div class="snippet-header-left">
- <input
- type="checkbox"
- :checked="selectedSnippets.includes(index)"
- @change="toggleSelection(index)"
- class="snippet-checkbox"
- />
- <div class="snippet-shortcut-display" v-if="editingIndex !== index">
+ <input type="checkbox" :checked="selectedSnippets.includes(index)" @change="toggleSelection(index)" class="snippet-checkbox" />
+ <div v-if="editingIndex !== index" class="snippet-shortcut-display">
<code class="shortcut-code">{{ snippet.id || '!untitled' }}</code>
</div>
</div>
-
+
<div class="snippet-actions">
- <button
- v-if="editingIndex !== index"
- class="action-btn edit-btn"
- title="Edit snippet"
- @click="startEdit(index)"
- >
- <Icon name="edit" />
+ <button v-if="editingIndex !== index" class="action-btn edit-btn" title="Edit snippet" @click="startEdit(index)">
+ <Icon fill="var(--font-color)" name="edit" />
</button>
- <button
- v-if="editingIndex === index"
- class="action-btn save-btn"
- title="Save snippet"
- @click="saveEdit()"
- >
- <Icon name="check" />
+ <button v-if="editingIndex === index" class="action-btn save-btn" title="Save snippet" @click="saveEdit()">
+ <Icon fill="var(--font-color)" name="check" />
</button>
- <button
- v-if="editingIndex === index"
- class="action-btn cancel-btn"
- title="Cancel edit"
- @click="cancelEdit()"
- >
- <Icon name="close" />
+ <button v-if="editingIndex === index" class="action-btn cancel-btn" title="Cancel edit" @click="cancelEdit()">
+ <Icon fill="var(--font-color)" name="close" />
</button>
- <button
- class="action-btn delete-btn"
- title="Delete snippet"
- @click="removeSnippet(index)"
- >
- <Icon name="delete" />
+ <button class="action-btn delete-btn" title="Delete snippet" @click="removeSnippet(index)">
+ <Icon fill="var(--font-color)" name="delete" />
</button>
</div>
</div>
@@ -121,25 +70,13 @@
<div v-if="editingIndex === index" class="snippet-edit-form">
<div class="form-group">
<label>Shortcut:</label>
- <input
- v-model="editingSnippet.id"
- class="snippet-key-input"
- placeholder="!shortcut"
- :class="{ 'error': hasError(editingSnippet.id) }"
- />
- <div v-if="hasError(editingSnippet.id)" class="error-message">
- {{ getErrorMessage(editingSnippet.id) }}
- </div>
+ <input v-model="editingSnippet.id" class="snippet-key-input" placeholder="!shortcut" :class="{ error: error(editingSnippet.id) }" />
+ <div v-if="error(editingSnippet.id)" class="error-message">{{ error(editingSnippet.id) }}</div>
</div>
-
+
<div class="form-group">
<label>Content:</label>
- <textarea
- v-model="editingSnippet.label"
- class="snippet-content-input"
- placeholder="Snippet content..."
- rows="4"
- />
+ <textarea v-model="editingSnippet.label" class="snippet-content-input" placeholder="Snippet content..." rows="4" />
</div>
</div>
@@ -149,7 +86,7 @@
<div class="preview-label">Preview:</div>
<div class="preview-content" v-html="getPreviewHtml(snippet.label)" />
</div>
-
+
<div class="snippet-raw">
<div class="raw-label">Raw content:</div>
<pre class="raw-content">{{ snippet.label }}</pre>
@@ -160,14 +97,7 @@
</div>
<!-- Import file input (hidden) -->
- <input
- ref="fileInput"
- type="file"
- accept=".json"
- style="display: none"
- @change="handleFileImport"
- />
-
+ <input ref="fileInput" type="file" accept=".json" style="display: none" @change="handleFileImport" />
</div>
</template>
@@ -181,7 +111,7 @@ const snippets = usePreferences().get('snippets');
const sortOptions = [
{ id: 'shortcut', label: 'Sort by Shortcut' },
{ id: 'content', label: 'Sort by Content' },
- { id: 'usage', label: 'Sort by Usage' }
+ { id: 'usage', label: 'Sort by Usage' },
];
// Reactive state
@@ -195,12 +125,9 @@ const fileInput = ref<HTMLInputElement | null>(null);
// Computed properties
const filteredSnippets = computed(() => {
- let filtered = snippets.value.filter(snippet => {
+ const filtered = snippets.value.filter(snippet => {
const searchLower = searchQuery.value.toLowerCase();
- return (
- snippet.id.toLowerCase().includes(searchLower) ||
- snippet.label.toLowerCase().includes(searchLower)
- );
+ return snippet.id.toLowerCase().includes(searchLower) || snippet.label.toLowerCase().includes(searchLower);
});
// Sort snippets
@@ -223,7 +150,7 @@ const filteredSnippets = computed(() => {
function addSnippet() {
const newSnippet = { id: '', label: '' };
snippets.value = [newSnippet, ...snippets.value];
-
+
// Start editing the new snippet immediately
nextTick(() => {
startEdit(0);
@@ -234,10 +161,10 @@ function removeSnippet(index: number) {
const actualIndex = findActualIndex(index);
if (actualIndex !== -1) {
snippets.value.splice(actualIndex, 1);
-
+
// Clear selection if deleted snippet was selected
selectedSnippets.value = selectedSnippets.value.filter(i => i !== index);
-
+
// Cancel editing if we're editing this snippet
if (editingIndex.value === index) {
cancelEdit();
@@ -247,9 +174,7 @@ function removeSnippet(index: number) {
function findActualIndex(filteredIndex: number): number {
const targetSnippet = filteredSnippets.value[filteredIndex];
- return snippets.value.findIndex(snippet =>
- snippet.id === targetSnippet.id && snippet.label === targetSnippet.label
- );
+ return snippets.value.findIndex(snippet => snippet.id === targetSnippet?.id && snippet.label === targetSnippet.label);
}
function toggleSelection(index: number) {
@@ -279,13 +204,13 @@ function startEdit(index: number) {
const actualIndex = findActualIndex(index);
if (actualIndex !== -1) {
editingIndex.value = index;
- editingSnippet.value = { ...snippets.value[actualIndex] };
- originalSnippet.value = { ...snippets.value[actualIndex] };
+ editingSnippet.value = snippets.value[actualIndex]!;
+ originalSnippet.value = snippets.value[actualIndex]!;
}
}
function saveEdit() {
- if (editingIndex.value !== null && !hasError(editingSnippet.value.id)) {
+ if (editingIndex.value !== null && !error(editingSnippet.value.id)) {
const actualIndex = findActualIndex(editingIndex.value);
if (actualIndex !== -1) {
snippets.value[actualIndex] = { ...editingSnippet.value };
@@ -300,31 +225,14 @@ function cancelEdit() {
originalSnippet.value = { id: '', label: '' };
}
-function hasError(shortcut: string): boolean {
- if (!shortcut.trim()) return true;
- if (!shortcut.startsWith('!')) return true;
-
- // Check for duplicates (excluding current editing snippet)
- const otherSnippets = snippets.value.filter((_, index) =>
- index !== (editingIndex.value !== null ? findActualIndex(editingIndex.value) : -1)
- );
-
- return otherSnippets.some(snippet => snippet.id === shortcut);
-}
-
-function getErrorMessage(shortcut: string): string {
+function error(shortcut: string): string | false {
if (!shortcut.trim()) return 'Shortcut is required';
- if (!shortcut.startsWith('!')) return 'Shortcut must start with !';
-
- const otherSnippets = snippets.value.filter((_, index) =>
- index !== (editingIndex.value !== null ? findActualIndex(editingIndex.value) : -1)
- );
-
+ const otherSnippets = snippets.value.filter((_, index) => index !== (editingIndex.value !== null ? findActualIndex(editingIndex.value) : -1));
if (otherSnippets.some(snippet => snippet.id === shortcut)) {
return 'This shortcut already exists';
}
-
- return '';
+
+ return false;
}
function getPreviewHtml(content: string): string {
@@ -335,14 +243,14 @@ function exportSnippets() {
const dataStr = JSON.stringify(snippets.value, null, 2);
const dataBlob = new Blob([dataStr], { type: 'application/json' });
const url = URL.createObjectURL(dataBlob);
-
+
const link = document.createElement('a');
link.href = url;
link.download = 'alexandrie-snippets.json';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
-
+
URL.revokeObjectURL(url);
}
@@ -355,16 +263,14 @@ function handleFileImport(event: Event) {
if (!file) return;
const reader = new FileReader();
- reader.onload = (e) => {
+ reader.onload = e => {
try {
const importedSnippets = JSON.parse(e.target?.result as string);
if (Array.isArray(importedSnippets)) {
// Merge with existing snippets, avoiding duplicates
const existingIds = new Set(snippets.value.map(s => s.id));
- const newSnippets = importedSnippets.filter(snippet =>
- snippet.id && snippet.label && !existingIds.has(snippet.id)
- );
-
+ const newSnippets = importedSnippets.filter(snippet => snippet.id && snippet.label && !existingIds.has(snippet.id));
+
snippets.value = [...snippets.value, ...newSnippets];
}
} catch (error) {
@@ -372,9 +278,9 @@ function handleFileImport(event: Event) {
alert('Failed to import snippets. Please check the file format.');
}
};
-
+
reader.readAsText(file);
-
+
// Reset input
if (fileInput.value) {
fileInput.value.value = '';
@@ -382,11 +288,9 @@ function handleFileImport(event: Event) {
}
function restoreDefaults() {
- if (confirm('Are you sure you want to restore default snippets? This will replace all current snippets.')) {
- snippets.value = [...DEFAULT_PREFERENCES.snippets];
- selectedSnippets.value = [];
- cancelEdit();
- }
+ snippets.value = [...DEFAULT_PREFERENCES.snippets];
+ selectedSnippets.value = [];
+ cancelEdit();
}
// Watch for search query changes to clear selection
@@ -403,17 +307,8 @@ watch(searchQuery, () => {
// Toolbar styles
.toolbar {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
gap: 1rem;
margin-bottom: 2rem;
- flex-wrap: wrap;
-
- @media (max-width: 768px) {
- flex-direction: column;
- align-items: stretch;
- }
}
.search-section {
@@ -443,29 +338,14 @@ watch(searchQuery, () => {
left: 0.75rem;
top: 50%;
transform: translateY(-50%);
- color: var(--font-color-sub);
font-size: 1rem;
}
.search-input {
width: 100%;
- padding: 0.75rem 0.75rem 0.75rem 2.5rem;
- border: 1px solid var(--border-color);
- border-radius: 8px;
+ padding-left: 2.5rem;
background: var(--bg-color);
color: var(--font-color);
- font-size: 0.9rem;
- transition: border-color 0.2s ease;
-
- &:focus {
- outline: none;
- border-color: var(--primary);
- box-shadow: 0 0 0 2px var(--primary-border);
- }
-
- &::placeholder {
- color: var(--font-color-sub);
- }
}
.filter-section {
@@ -473,35 +353,18 @@ watch(searchQuery, () => {
gap: 0.5rem;
}
-.sort-select {
- padding: 0.5rem 0.75rem;
- border: 1px solid var(--border-color);
- border-radius: 6px;
- background: var(--bg-color);
- color: var(--font-color);
- font-size: 0.9rem;
- cursor: pointer;
-
- &:focus {
- outline: none;
- border-color: var(--primary);
- }
+.flex-btn {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
}
.actions {
display: flex;
align-items: center;
gap: 0.5rem;
+ padding: 0.5rem 0;
flex-wrap: wrap;
-
- @media (max-width: 768px) {
- justify-content: stretch;
-
- :deep(.app-button) {
- flex: 1;
- justify-content: center;
- }
- }
}
// Snippets container
@@ -511,16 +374,12 @@ watch(searchQuery, () => {
.no-snippets {
display: flex;
- flex-direction: column;
align-items: center;
justify-content: center;
padding: 4rem 2rem;
- color: var(--font-color-sub);
- text-align: center;
.no-snippets-icon {
font-size: 3rem;
- margin-bottom: 1rem;
opacity: 0.5;
}
@@ -534,7 +393,7 @@ watch(searchQuery, () => {
.snippets-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
- gap: 1.5rem;
+ gap: 0.5rem;
@media (max-width: 768px) {
grid-template-columns: 1fr;
@@ -575,7 +434,6 @@ watch(searchQuery, () => {
align-items: center;
margin-bottom: 0.75rem;
padding-bottom: 0.5rem;
- border-bottom: 1px solid var(--border-color-light);
}
.snippet-header-left {
@@ -593,9 +451,7 @@ watch(searchQuery, () => {
.snippet-shortcut-display {
.shortcut-code {
background: var(--code-bg);
- color: var(--primary);
- padding: 0.25rem 0.5rem;
- border-radius: 4px;
+ color: var(--font-color-dark);
font-family: $monospace-font;
font-size: 0.9rem;
font-weight: 600;
@@ -621,20 +477,8 @@ watch(searchQuery, () => {
min-width: 32px;
height: 32px;
- &.edit-btn:hover {
- background: var(--primary-bg-light);
- }
-
- &.save-btn:hover {
- background: var(--green-bg-light);
- }
-
- &.cancel-btn:hover {
- background: var(--orange-bg-light);
- }
-
- &.delete-btn:hover {
- background: var(--red-bg-light);
+ &:hover {
+ background: var(--bg-ui);
}
}
@@ -643,26 +487,17 @@ watch(searchQuery, () => {
.form-group {
margin-bottom: 1rem;
- label {
- display: block;
- margin-bottom: 0.5rem;
- font-weight: 600;
- font-size: 0.9rem;
- color: var(--font-color);
- }
-
.snippet-key-input,
.snippet-content-input {
width: 100%;
padding: 0.75rem;
border: 1px solid var(--border-color);
border-radius: 6px;
- background: var(--bg-color);
- color: var(--font-color);
font-family: $monospace-font;
font-size: 0.9rem;
transition: border-color 0.2s ease;
resize: vertical;
+ text-align: left;
&:focus {
outline: none;
@@ -676,14 +511,6 @@ watch(searchQuery, () => {
}
}
- .snippet-key-input {
- font-weight: 600;
- }
-
- .snippet-content-input {
- min-height: 100px;
- }
-
.error-message {
margin-top: 0.5rem;
color: var(--red);
@@ -694,69 +521,26 @@ watch(searchQuery, () => {
// View mode content
.snippet-content {
- .snippet-preview,
- .snippet-raw {
- margin-bottom: 1rem;
-
- &:last-child {
- margin-bottom: 0;
- }
- }
-
.preview-label,
.raw-label {
font-size: 0.85rem;
font-weight: 600;
- color: var(--font-color-sub);
- margin-bottom: 0.5rem;
}
.preview-content {
background: var(--bg-color-secondary);
- border: 1px solid var(--border-color-light);
border-radius: 6px;
- padding: 0.75rem;
- min-height: 2.5rem;
+ padding: 0.35rem 0;
font-size: 0.9rem;
- line-height: 1.5;
-
- :deep(strong) {
- font-weight: 600;
- }
-
- :deep(em) {
- font-style: italic;
- }
-
- :deep(code) {
- background: var(--code-bg);
- padding: 0.2rem 0.4rem;
- border-radius: 3px;
- font-family: $monospace-font;
- font-size: 0.85rem;
- }
-
- :deep(.container) {
- padding: 0.5rem;
- border-radius: 4px;
- margin: 0.5rem 0;
-
- &.blue { background: var(--primary-bg-light); border-left: 4px solid var(--blue); }
- &.green { background: var(--green-bg-light); border-left: 4px solid var(--green); }
- &.yellow { background: var(--orange-bg-light); border-left: 4px solid var(--orange); }
- &.grey { background: var(--bg-color-secondary); border-left: 4px solid var(--border-color); }
- }
}
.raw-content {
background: var(--code-bg);
- border: 1px solid var(--border-color-light);
border-radius: 6px;
- padding: 0.75rem;
+ padding: 0.35rem 0;
font-family: $monospace-font;
font-size: 0.85rem;
line-height: 1.4;
- color: var(--font-color-sub);
white-space: pre-wrap;
word-break: break-word;
margin: 0;