feat(ui): add Open Source URL action to recipe modal header, align header styles with model modal

This commit is contained in:
Will Miao
2026-05-16 16:11:14 +08:00
parent ff240db5b1
commit 612612f1c7
3 changed files with 101 additions and 11 deletions

View File

@@ -4,15 +4,20 @@
justify-content: flex-start; justify-content: flex-start;
align-items: flex-start; align-items: flex-start;
border-bottom: 1px solid var(--lora-border); border-bottom: 1px solid var(--lora-border);
padding-bottom: 10px; padding-bottom: var(--space-2);
margin-bottom: 10px; margin-bottom: var(--space-3);
position: relative;
} }
.recipe-modal-header h2 { .recipe-modal-header h2 {
font-size: 1.4em; /* Reduced from default h2 size */ margin: 0 0 var(--space-1);
line-height: 1.3; padding: var(--space-1);
margin: 0; border-radius: var(--border-radius-xs);
max-height: 2.6em; /* Limit to 2 lines */ font-size: 1.5em;
font-weight: 600;
line-height: 1.2;
color: var(--text-color);
max-height: 2.8em;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
@@ -127,7 +132,7 @@
/* Recipe Tags styles */ /* Recipe Tags styles */
.recipe-tags-container { .recipe-tags-container {
position: relative; position: relative;
margin-top: 6px; margin-top: 0;
margin-bottom: 10px; margin-bottom: 10px;
} }
@@ -225,6 +230,62 @@
overflow: hidden; overflow: hidden;
} }
/* Recipe Header Actions */
.recipe-header-actions {
display: flex;
align-items: center;
gap: var(--space-2);
flex-wrap: wrap;
width: 100%;
margin-bottom: var(--space-1);
flex-shrink: 0;
min-height: 0;
}
.recipe-header-actions:empty {
display: none;
}
.recipe-source-url-btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
background: rgba(0, 0, 0, 0.03);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: var(--border-radius-sm);
color: var(--text-color);
cursor: pointer;
font-weight: 500;
font-size: 0.9em;
transition: all 0.2s;
white-space: nowrap;
}
[data-theme="dark"] .recipe-source-url-btn {
background: rgba(255, 255, 255, 0.03);
border: 1px solid var(--lora-border);
}
.recipe-source-url-btn:hover {
background: oklch(var(--lora-accent-l) var(--lora-accent-c) var(--lora-accent-h) / 0.1);
border-color: var(--lora-accent);
transform: translateY(-1px);
}
.recipe-source-url-btn i {
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
}
@media (max-height: 860px) {
.recipe-header-actions {
padding-bottom: 4px;
}
}
/* Top Section: Preview and Gen Params */ /* Top Section: Preview and Gen Params */
.recipe-top-section { .recipe-top-section {
display: grid; display: grid;
@@ -1083,13 +1144,13 @@
} }
.recipe-modal-header { .recipe-modal-header {
padding-bottom: 6px; padding-bottom: var(--space-1);
margin-bottom: 8px; margin-bottom: var(--space-2);
} }
.recipe-modal-header h2 { .recipe-modal-header h2 {
font-size: 1.25em; font-size: 1.3em;
max-height: 2.5em; max-height: 2.4em;
} }
.recipe-tags-container { .recipe-tags-container {

View File

@@ -383,6 +383,7 @@ class RecipeModal {
this.syncGenerationParams(hydratedRecipe.gen_params); this.syncGenerationParams(hydratedRecipe.gen_params);
this.syncResourcesSection(hydratedRecipe); this.syncResourcesSection(hydratedRecipe);
this.syncSourceUrlAction();
// Show the modal // Show the modal
modalManager.showModal('recipeModal'); modalManager.showModal('recipeModal');
@@ -515,6 +516,7 @@ class RecipeModal {
} else { } else {
this.updateSourceUrlDisplay(this.currentRecipe.source_path || ''); this.updateSourceUrlDisplay(this.currentRecipe.source_path || '');
} }
this.syncSourceUrlAction();
} }
getPreviewMediaUrl(recipe = {}) { getPreviewMediaUrl(recipe = {}) {
@@ -582,6 +584,30 @@ class RecipeModal {
} }
} }
syncSourceUrlAction() {
const actionsContainer = document.getElementById('recipeHeaderActions');
if (!actionsContainer) {
return;
}
actionsContainer.innerHTML = '';
const sourcePath = this.currentRecipe?.source_path || '';
const isValidUrl = sourcePath.startsWith('http://') || sourcePath.startsWith('https://');
if (!isValidUrl) {
return;
}
const btn = document.createElement('button');
btn.className = 'recipe-source-url-btn';
btn.title = sourcePath;
btn.innerHTML = '<i class="fas fa-globe"></i> Open Source URL';
btn.addEventListener('click', () => {
window.open(sourcePath, '_blank');
});
actionsContainer.appendChild(btn);
}
syncTagsDisplay(tags) { syncTagsDisplay(tags) {
const tagsContainer = document.getElementById('recipeTagsCompact'); const tagsContainer = document.getElementById('recipeTagsCompact');
if (!tagsContainer) { if (!tagsContainer) {
@@ -1316,6 +1342,7 @@ class RecipeModal {
// Update source URL in the UI // Update source URL in the UI
this.commitField('source_path'); this.commitField('source_path');
this.updateSourceUrlDisplay(newSourceUrl, { forceInputSync: true }); this.updateSourceUrlDisplay(newSourceUrl, { forceInputSync: true });
this.syncSourceUrlAction();
// Update the current recipe object // Update the current recipe object
this.currentRecipe.source_path = newSourceUrl; this.currentRecipe.source_path = newSourceUrl;

View File

@@ -4,6 +4,8 @@
<header class="recipe-modal-header"> <header class="recipe-modal-header">
<h2 id="recipeModalTitle">Recipe Details</h2> <h2 id="recipeModalTitle">Recipe Details</h2>
<!-- Header Actions: populated dynamically in RecipeModal.js -->
<div class="recipe-header-actions" id="recipeHeaderActions"></div>
<!-- Recipe Tags Container --> <!-- Recipe Tags Container -->
<div class="recipe-tags-container"> <div class="recipe-tags-container">
<div class="recipe-tags-compact" id="recipeTagsCompact"></div> <div class="recipe-tags-compact" id="recipeTagsCompact"></div>