Add categorized template previews and fix canvas event delegation
@@ -100,7 +100,7 @@
|
||||
grid-template-areas: "library workspace" "library settings";
|
||||
gap: .9rem;
|
||||
}
|
||||
.studio-library { grid-area: library; position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow: auto; }
|
||||
.studio-library { grid-area: library; position: sticky; z-index: 3; top: .75rem; max-height: calc(100vh - 1.5rem); overflow: auto; }
|
||||
.studio-library h2 { font-size: 1.05rem; margin-bottom: .7rem; }
|
||||
.studio-workspace { grid-area: workspace; min-width: 0; }
|
||||
.studio-inspector { grid-area: settings; }
|
||||
@@ -108,7 +108,7 @@
|
||||
.studio-workspace .studio-frame-window { height: max(34rem, calc(100dvh - 16rem)); }
|
||||
.studio-workspace .studio-preview h2 { font-size: 1.2rem; }
|
||||
.studio-presets { display: grid; gap: .4rem; }
|
||||
.studio-library :is(.studio-presets, .studio-layers) button:not(.button) {
|
||||
.studio-library .studio-layers button:not(.button), .studio-pending button {
|
||||
width: 100%;
|
||||
min-height: 2.75rem;
|
||||
padding: .55rem .75rem;
|
||||
@@ -136,7 +136,70 @@
|
||||
@media (max-width: 54rem) {
|
||||
.studio-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "library" "workspace" "settings"; }
|
||||
.studio-library { position: static; max-height: none; }
|
||||
.studio-presets { grid-template-columns: repeat(auto-fit, minmax(5.35rem, 1fr)); }
|
||||
.studio-insert-mode, .studio-presets [role="status"], .studio-pending { grid-column: 1 / -1; }
|
||||
.studio-workspace .studio-frame-window { height: max(25rem, 64dvh); }
|
||||
}
|
||||
|
||||
.studio-template-search { display: grid; gap: .3rem; font-size: .9rem; font-weight: 600; }
|
||||
.studio-template-search input {
|
||||
width: 100%;
|
||||
min-height: 42px;
|
||||
padding: .45rem .6rem;
|
||||
color: var(--ink);
|
||||
background: var(--white);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: .5rem;
|
||||
}
|
||||
.studio-template-filters { display: flex; gap: .3rem; flex-wrap: wrap; margin-block: .25rem; }
|
||||
.studio-template-filters button {
|
||||
min-height: 36px;
|
||||
padding: .2rem .5rem;
|
||||
color: var(--muted);
|
||||
font-size: .825rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: .35rem;
|
||||
background: var(--white);
|
||||
}
|
||||
.studio-template-filters button[aria-pressed="true"] { border-color: #9bb5fa; color: var(--accent-deep); background: var(--accent-light); }
|
||||
.studio-template-group + .studio-template-group { margin-top: .9rem; }
|
||||
.studio-template-group h3 { margin: 0 0 .4rem; font-size: .9rem; font-weight: 650; }
|
||||
.studio-template-cards { display: grid; gap: .48rem; }
|
||||
.studio-template-card { min-width: 0; border: 1px solid var(--line); border-radius: .55rem; background: var(--white); }
|
||||
.studio-template-card:focus-within { border-color: var(--accent); }
|
||||
.studio-template-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border: 0;
|
||||
border-radius: .5rem .5rem 0 0;
|
||||
background: var(--paper);
|
||||
}
|
||||
.studio-template-image img { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; transition: transform .16s ease; }
|
||||
.studio-template-image:hover img, .studio-template-image:focus-visible img { transform: scale(1.07); }
|
||||
.studio-template-meta { display: flex; align-items: center; justify-content: space-between; gap: .3rem; padding: .3rem .38rem .3rem .55rem; font-size: .875rem; }
|
||||
.studio-template-meta .button { min-height: 33px; font-size: .8rem; flex: 0 0 auto; padding: .2rem .45rem; }
|
||||
.studio-template-peek {
|
||||
position: fixed;
|
||||
z-index: 2;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
background: var(--white);
|
||||
border: 1px solid #adbfdf;
|
||||
border-radius: .65rem;
|
||||
box-shadow: 0 14px 35px #142e5626;
|
||||
}
|
||||
.studio-template-peek img, .studio-template-dialog img { width: 100%; height: auto; aspect-ratio: 8 / 5; display: block; }
|
||||
.studio-template-peek p { padding: .5rem .8rem; margin: 0; font-size: .9rem; color: var(--ink); }
|
||||
.studio-template-dialog { width: min(90vw, 49rem); }
|
||||
.studio-template-dialog > img { border: 1px solid var(--line); border-radius: .55rem; }
|
||||
.studio-template-dialog > .actions { justify-content: flex-end; margin-top: .75rem; }
|
||||
|
||||
@media (max-width: 54rem) {
|
||||
.studio-template-groups { max-height: 44dvh; overflow-y: auto; padding: .2rem; }
|
||||
.studio-template-cards { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
|
||||
.studio-template-meta { flex-wrap: wrap; }
|
||||
.studio-template-peek { display: none; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.studio-template-image img { transition: none; }
|
||||
}
|
||||
|
||||
@@ -554,3 +554,15 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
||||
.rich :is(img, video)[class*="studio-media-"] { height: auto; max-width: 100%; }
|
||||
.hero-visual[class*="studio-media-"] { justify-self: center; }
|
||||
[data-studio-editing] [data-studio-selected] { outline: 2px solid #4477f9; outline-offset: 3px; }
|
||||
|
||||
.rich .studio-intro { max-width: 47rem; }
|
||||
.rich .studio-intro h3, .rich .studio-cover h3 { font-size: clamp(1.75rem, 4vw, 2.8rem); }
|
||||
.rich .studio-cover { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: center; gap: clamp(1rem, 4vw, 3rem); background: var(--paper); padding: clamp(.8rem, 3vw, 2rem); border-radius: var(--radius); }
|
||||
.rich .studio-cover img { width: 100%; }
|
||||
.rich .studio-cover p { margin-bottom: .85rem; }
|
||||
.rich .studio-two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
|
||||
.rich .studio-quick-nav { display: flex; flex-wrap: wrap; gap: .55rem 1rem; list-style: none; padding: .75rem; border: 1px solid var(--line); border-radius: .6rem; }
|
||||
.rich .studio-quick-nav a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: .4rem; font-weight: 600; }
|
||||
@media (max-width: 44rem) {
|
||||
.rich .studio-cover, .rich .studio-two-column { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
||||
@@ -179,6 +179,83 @@ jQuery(function ($) {
|
||||
return edits;
|
||||
}
|
||||
|
||||
$('[data-canvas-presets]').each(function () {
|
||||
const $gallery = $(this);
|
||||
const $search = $gallery.find('[data-template-search]');
|
||||
const $groups = $gallery.find('[data-template-group]');
|
||||
const $filters = $gallery.find('[data-template-filter]');
|
||||
const $peek = $gallery.find('[data-template-peek]');
|
||||
const $dialog = $gallery.find('[data-template-dialog]');
|
||||
const $use = $dialog.find('[data-template-use]');
|
||||
let category = '';
|
||||
let $selection;
|
||||
|
||||
function hidePeek() {
|
||||
$peek.prop('hidden', true);
|
||||
}
|
||||
|
||||
function filter() {
|
||||
const query = String($search.val()).trim().toLowerCase();
|
||||
let count = 0;
|
||||
$groups.each(function () {
|
||||
const $group = $(this);
|
||||
const allowed = !category || this.dataset.templateGroup === category;
|
||||
let groupCount = 0;
|
||||
$group.find('[data-template-card]').each(function () {
|
||||
const visible = allowed && this.dataset.templateSearchText.toLowerCase().includes(query);
|
||||
$(this).prop('hidden', !visible);
|
||||
if (visible) groupCount++;
|
||||
});
|
||||
$group.prop('hidden', groupCount === 0);
|
||||
count += groupCount;
|
||||
});
|
||||
$gallery.find('[data-template-empty]').prop('hidden', count !== 0);
|
||||
hidePeek();
|
||||
}
|
||||
|
||||
$search.on('input', filter);
|
||||
$filters.on('click', function () {
|
||||
category = this.dataset.templateFilter;
|
||||
$filters.attr('aria-pressed', 'false');
|
||||
$(this).attr('aria-pressed', 'true');
|
||||
filter();
|
||||
});
|
||||
|
||||
$gallery.on('mouseenter focusin', '[data-template-preview]', function (event) {
|
||||
if (event.type === 'mouseenter' && !matchMedia('(hover: hover)').matches) return;
|
||||
const bounds = this.getBoundingClientRect();
|
||||
const width = Math.min(430, window.innerWidth - bounds.right - 24);
|
||||
if (width < 240) return;
|
||||
const top = Math.max(12, Math.min(bounds.top, window.innerHeight - width * 0.625 - 56));
|
||||
$peek.find('img').attr('src', $(this).find('img').attr('src'));
|
||||
$peek.find('p').text(this.dataset.templateTitle);
|
||||
$peek.css({width, top, left: bounds.right + 12}).prop('hidden', false);
|
||||
});
|
||||
$gallery.on('mouseleave focusout', '[data-template-preview]', hidePeek);
|
||||
$gallery.closest('.studio-library').on('scroll', hidePeek);
|
||||
$(window).on('scroll resize', hidePeek);
|
||||
|
||||
$gallery.on('click', '[data-template-preview]', function () {
|
||||
hidePeek();
|
||||
const $card = $(this).closest('[data-template-card]');
|
||||
$selection = $card.find('[data-canvas-template]');
|
||||
$dialog.find('h2').text(this.dataset.templateTitle);
|
||||
$dialog.find('img').attr('src', $(this).find('img').attr('src'));
|
||||
$use.prop('disabled', $selection.prop('disabled'));
|
||||
$dialog.get(0).showModal();
|
||||
});
|
||||
$dialog.on('click', '[data-template-close]', () => $dialog.get(0).close());
|
||||
$use.on('click', () => {
|
||||
if (!$selection || $selection.prop('disabled')) return;
|
||||
$dialog.get(0).close();
|
||||
hidePeek();
|
||||
$selection.trigger('click');
|
||||
});
|
||||
$gallery.on('studio:canvas-ready', () => {
|
||||
if ($selection) $use.prop('disabled', $selection.prop('disabled'));
|
||||
});
|
||||
});
|
||||
|
||||
$('[data-preview-studio]').each(function () {
|
||||
const $studio = $(this);
|
||||
const $frame = $studio.find('iframe');
|
||||
@@ -578,7 +655,7 @@ jQuery(function ($) {
|
||||
section.id = id;
|
||||
const title = section.querySelector('[data-studio-part="title"]');
|
||||
title.id = 'heading-' + id;
|
||||
title.textContent = this.textContent.trim();
|
||||
title.textContent = this.dataset.templateTitle;
|
||||
section.setAttribute('aria-labelledby', title.id);
|
||||
section.querySelector('[data-studio-part="body"]').innerHTML = markup;
|
||||
end.before(section);
|
||||
@@ -621,7 +698,7 @@ jQuery(function ($) {
|
||||
if (!event.target.closest?.('[data-studio-selected]')) selectMedia(null);
|
||||
});
|
||||
$doc.on('click.canvas auxclick.canvas', 'a', (event) => event.preventDefault());
|
||||
const mediaTargets = '[data-studio-hero-image], [data-studio-part="body"] :is(img, audio, video)';
|
||||
const mediaTargets = '[data-studio-hero-image], [data-studio-part="body"] img, [data-studio-part="body"] audio, [data-studio-part="body"] video';
|
||||
$doc.on('click.canvas dblclick.canvas', mediaTargets, function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -656,6 +733,7 @@ jQuery(function ($) {
|
||||
$toolbar.prop('hidden', false);
|
||||
$layout.find('[data-canvas-jump]').prop('hidden', false);
|
||||
$layout.find('[data-canvas-template], [data-hero-control]').prop('disabled', false);
|
||||
$presets.triggerHandler('studio:canvas-ready');
|
||||
}
|
||||
|
||||
$frame.on('load', attachCanvas);
|
||||
|
||||
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 2.9 KiB |