forked from laysense/laysense.cn
Merge pull request '分类优先的组件与元素库,优化网站后台' (#10) from ChatGPT/laysense.cn:categorized-admin-library into main
This commit is contained in:
+68
-21
@@ -167,19 +167,29 @@
|
||||
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-library-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .2rem; padding: .22rem; margin-bottom: .45rem; border-radius: .6rem; background: var(--paper); }
|
||||
.studio-library-tabs button, .studio-library-categories button, .studio-library-category-title button, .studio-element-items button {
|
||||
color: var(--ink); font-family: inherit; cursor: pointer;
|
||||
}
|
||||
.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-library-tabs button { min-height: 2.4rem; padding: .3rem .18rem; border: 1px solid transparent; border-radius: .42rem; background: transparent; font-size: .84rem; }
|
||||
.studio-library-tabs button[aria-selected="true"] { border-color: var(--line); background: var(--white); color: var(--accent-deep); font-weight: 650; box-shadow: 0 1px 2px #182e5110; }
|
||||
.studio-library-categories { list-style: none; padding: 0; margin: 0; }
|
||||
.studio-library-categories li + li { border-top: 1px solid var(--line); }
|
||||
.studio-library-categories button, .studio-element-items button {
|
||||
display: flex; gap: .35rem; align-items: center; width: 100%; min-height: 2.65rem; padding: .4rem .32rem;
|
||||
text-align: left; border: 1px solid transparent; border-radius: .35rem; background: transparent; font-size: .9rem;
|
||||
}
|
||||
.studio-library-categories button::after { content: ''; width: .38rem; height: .38rem; border: solid currentColor; border-width: 1px 1px 0 0; rotate: 45deg; margin-inline-end: .25rem; }
|
||||
.studio-library-categories small { margin-inline-start: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.studio-library-content { display: grid; gap: .55rem; min-width: 0; }
|
||||
.studio-library-category-title { display: grid; gap: .28rem; }
|
||||
.studio-library-category-title h3 { font-size: 1rem; margin: 0; }
|
||||
.studio-library-category-title button { justify-self: start; min-height: 2.25rem; padding: .25rem .45rem; background: var(--white); border: 1px solid var(--line); border-radius: .38rem; font-size: .8rem; }
|
||||
.studio-library-category-title button::before { content: '‹'; margin-inline-end: .3em; }
|
||||
.studio-element-items { display: grid; gap: .35rem; }
|
||||
.studio-element-items button { justify-content: space-between; padding-inline: .55rem; border-color: var(--line); background: var(--white); }
|
||||
.studio-element-items button::after { content: '+'; color: var(--accent-deep); }
|
||||
.studio-element-items button:disabled { opacity: .55; cursor: wait; }
|
||||
.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); }
|
||||
@@ -213,7 +223,7 @@
|
||||
.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-library-content { max-height: 55dvh; 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; }
|
||||
@@ -235,14 +245,51 @@
|
||||
.article-editor-heading > .button { min-height: 2.1rem; padding: .25rem .6rem; }
|
||||
.article-editor-help:empty { display: none; }
|
||||
|
||||
.studio-element-library { padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .5rem; }
|
||||
.studio-element-library summary { font-size: .9rem; font-weight: 650; cursor: pointer; }
|
||||
.studio-element-library [role="group"] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; margin-top: .55rem; }
|
||||
.studio-element-library button {
|
||||
min-height: 2.35rem; padding: .2rem; border: 1px solid var(--line);
|
||||
border-radius: .4rem; color: var(--ink); background: var(--white); font-size: .8rem; cursor: pointer;
|
||||
}
|
||||
.studio-element-library .field-note { margin: .45rem 0 0; font-size: .78rem; }
|
||||
.studio-element-align { display: flex; gap: .05rem; padding-inline-end: .2rem; border-inline-end: 1px solid #ffffff55; }
|
||||
.studio-element-align button { padding-inline: .38rem; }
|
||||
.studio-element-align button[aria-pressed="true"] { background: white; color: #244bc8; }
|
||||
|
||||
.admin-primary a { padding: .28rem .65rem; border-radius: .48rem; color: var(--muted); }
|
||||
.admin-primary a[aria-current="page"] { background: var(--accent-light); color: var(--accent-deep); }
|
||||
.admin-utility { display: flex; gap: .8rem; align-items: center; font-size: .88rem; }
|
||||
.admin-utility > a { padding-block: .55rem; white-space: nowrap; }
|
||||
.admin-account { position: relative; z-index: 5; }
|
||||
.admin-account summary {
|
||||
min-height: 2.45rem; padding: .43rem .6rem; border: 1px solid var(--line);
|
||||
border-radius: .45rem; color: var(--ink); cursor: pointer;
|
||||
}
|
||||
.admin-account-menu {
|
||||
position: absolute; inset: calc(100% + .4rem) 0 auto auto; min-width: 8rem; padding: .3rem;
|
||||
border: 1px solid var(--line); border-radius: .5rem; background: white; box-shadow: 0 .55rem 1.5rem #1d315026;
|
||||
}
|
||||
.admin-account-menu a, .admin-account-menu button {
|
||||
display: block; width: 100%; padding: .52rem .65rem; border: 0; border-radius: .3rem; background: white;
|
||||
color: var(--ink); text-align: left; text-decoration: none; font: inherit; cursor: pointer;
|
||||
}
|
||||
.admin-account-menu :is(a, button):hover { background: var(--paper); color: var(--accent-deep); }
|
||||
.dashboard-heading { margin-bottom: 1.55rem; }
|
||||
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; gap: 1.05rem; }
|
||||
.dashboard-grid .admin-panel { padding: clamp(.95rem, 2.3vw, 1.55rem); }
|
||||
.dashboard-filters { display: grid; grid-template-columns: 1fr minmax(6.8rem, 9rem); gap: .7rem; margin-bottom: .8rem; }
|
||||
.dashboard-filters label { display: grid; min-width: 0; gap: .25rem; font-size: .83rem; color: var(--muted); }
|
||||
.dashboard-filters :is(input, select) { width: 100%; min-height: 2.65rem; padding: .38rem .52rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--ink); background: var(--white); font: inherit; }
|
||||
.dashboard-page-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .55rem .85rem; }
|
||||
.dashboard-page-label { min-width: 0; overflow-wrap: anywhere; }
|
||||
.dashboard-page-state { padding: .15rem .48rem; border-radius: .35rem; background: var(--paper); color: var(--muted); font-size: .78rem; white-space: nowrap; }
|
||||
.dashboard-page-state[data-published="true"] { background: #e9f6ef; color: #1b6744; }
|
||||
.dashboard-page-actions { display: flex; align-items: center; gap: .55rem; white-space: nowrap; }
|
||||
.dashboard-page-actions > a { font-size: .84rem; }
|
||||
.dashboard-page-actions > .button { min-height: 2.25rem; padding: .28rem .55rem; }
|
||||
.dashboard-secondary .admin-list li { gap: .35rem .65rem; }
|
||||
.dashboard-secondary .admin-list .button { min-height: 2.15rem; padding: .25rem .5rem; font-size: .82rem; }
|
||||
.dashboard-settings h2 { margin-bottom: .55rem; }
|
||||
.dashboard-settings ul { display: flex; flex-wrap: wrap; gap: .45rem 1.15rem; list-style: none; padding: 0; margin: 0; }
|
||||
|
||||
@media (max-width: 51rem) {
|
||||
.dashboard-grid { grid-template-columns: 1fr; gap: 0; }
|
||||
.admin-bar .admin-primary { order: 3; width: 100%; gap: .15rem .35rem; }
|
||||
}
|
||||
@media (max-width: 28rem) {
|
||||
.dashboard-page-list li { grid-template-columns: minmax(0, 1fr) auto; }
|
||||
.dashboard-page-actions { grid-column: 1 / -1; }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
jQuery(function ($) {
|
||||
$('[data-page-list]').each(function () {
|
||||
const $panel = $(this);
|
||||
const $search = $panel.find('[data-page-search]');
|
||||
const $status = $panel.find('[data-page-status]');
|
||||
const $pages = $panel.find('[data-page-item]');
|
||||
$panel.find('[data-page-filters]').prop('hidden', false);
|
||||
$search.add($status).on('input change', function () {
|
||||
const query = $search.val().trim().toLowerCase();
|
||||
const status = $status.val();
|
||||
let count = 0;
|
||||
$pages.each(function () {
|
||||
const visible = (!status || this.dataset.pageItem === status) && this.dataset.pageLabel.toLowerCase().includes(query);
|
||||
$(this).prop('hidden', !visible);
|
||||
if (visible) count++;
|
||||
});
|
||||
$panel.find('[data-page-empty]').prop('hidden', count !== 0);
|
||||
});
|
||||
});
|
||||
|
||||
const formats = {
|
||||
markdown: {
|
||||
heading: ['## ', '', '小标题'],
|
||||
|
||||
@@ -704,3 +704,19 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
||||
.rich table[class*="studio-align-"] :is(th, td) { text-align: inherit; }
|
||||
.hero-visual[class*="studio-align-"] { justify-self: var(--studio-justify); }
|
||||
.hero-actions[class*="studio-align-"] { justify-content: var(--studio-justify); }
|
||||
|
||||
.studio-lead { font-size: 1.2rem; color: var(--ink); }
|
||||
.studio-definitions { margin: 0; }
|
||||
.studio-definitions dt { font-weight: 650; }
|
||||
.studio-definitions dd { margin: .2rem 0 .8rem; color: var(--muted); }
|
||||
.studio-definitions dd:last-child { margin-bottom: 0; }
|
||||
.studio-spacer { height: clamp(1.5rem, 4vw, 4rem); }
|
||||
[data-studio-editing] .studio-spacer { border: 1px dashed var(--line); }
|
||||
.studio-banner-two, .studio-contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem 2rem; }
|
||||
.studio-banner-two p, .studio-contact p { margin-bottom: 0; }
|
||||
.studio-banner-two .actions { margin: 0; }
|
||||
.studio-contact { border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 4vw, 2rem); }
|
||||
.studio-releases article { padding: 1.05rem 0; border-block-start: 1px solid var(--line); }
|
||||
.studio-releases article:last-child { border-block-end: 1px solid var(--line); }
|
||||
.studio-pricing { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
@media (max-width: 36rem) { .studio-pricing { grid-template-columns: 1fr; } }
|
||||
|
||||
+63
-25
@@ -182,44 +182,82 @@ jQuery(function ($) {
|
||||
|
||||
$('[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 $tabs = $gallery.find('[data-library-tab]');
|
||||
const $panels = $gallery.find('[data-library-panel]');
|
||||
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;
|
||||
function selectTab(kind, focus = false) {
|
||||
const $current = $tabs.filter((_, tab) => tab.dataset.libraryTab === kind);
|
||||
$tabs.attr({'aria-selected': 'false', tabindex: '-1'});
|
||||
$current.attr({'aria-selected': 'true', tabindex: '0'});
|
||||
$panels.each(function () {
|
||||
$(this).prop('hidden', this.dataset.libraryPanel !== kind);
|
||||
});
|
||||
$gallery.find('[data-template-empty]').prop('hidden', count !== 0);
|
||||
$gallery.closest('.studio-library').scrollTop(0);
|
||||
hidePeek();
|
||||
if (focus) $current.trigger('focus');
|
||||
}
|
||||
|
||||
function filterItems($panel) {
|
||||
const query = $panel.find('[data-template-search]').val().trim().toLowerCase();
|
||||
let matches = 0;
|
||||
$panel.find('[data-template-group]').filter((_, group) => !group.hidden).find('[data-library-item]').each(function () {
|
||||
const visible = this.dataset.templateSearchText.toLowerCase().includes(query);
|
||||
$(this).prop('hidden', !visible);
|
||||
if (visible) matches++;
|
||||
});
|
||||
$panel.find('[data-template-empty]').prop('hidden', matches !== 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.find('[data-library-tabs]').prop('hidden', false);
|
||||
function openLayersFromHash() {
|
||||
if (window.location.hash !== '#blocks') return false;
|
||||
selectTab('layers');
|
||||
$gallery.find('#blocks').prop('open', true);
|
||||
return true;
|
||||
}
|
||||
if (!openLayersFromHash()) selectTab('modules');
|
||||
$(window).on('hashchange', openLayersFromHash);
|
||||
$tabs.on('click', function () {
|
||||
selectTab(this.dataset.libraryTab);
|
||||
}).on('keydown', function (event) {
|
||||
const index = $tabs.index(this);
|
||||
const last = $tabs.length - 1;
|
||||
const next = {Home: 0, End: last, ArrowLeft: index === 0 ? last : index - 1, ArrowRight: index === last ? 0 : index + 1}[event.key];
|
||||
if (typeof next !== 'number') return;
|
||||
event.preventDefault();
|
||||
selectTab($tabs.get(next).dataset.libraryTab, true);
|
||||
});
|
||||
|
||||
$gallery.on('click', '[data-library-category]', function () {
|
||||
const $panel = $(this).closest('[data-library-panel]');
|
||||
$panel.data('categoryTrigger', this);
|
||||
$panel.find('[data-library-index]').prop('hidden', true);
|
||||
$panel.find('[data-library-content]').prop('hidden', false);
|
||||
$panel.find('[data-library-title]').text(this.dataset.libraryLabel);
|
||||
$panel.find('[data-template-search]').val('');
|
||||
const key = this.dataset.libraryCategory;
|
||||
$panel.find('[data-template-group]').each(function () {
|
||||
$(this).prop('hidden', this.dataset.templateGroup !== key);
|
||||
});
|
||||
filterItems($panel);
|
||||
$panel.find('[data-library-back]').trigger('focus');
|
||||
}).on('click', '[data-library-back]', function () {
|
||||
const $panel = $(this).closest('[data-library-panel]');
|
||||
$panel.find('[data-library-content]').prop('hidden', true);
|
||||
$panel.find('[data-library-index]').prop('hidden', false);
|
||||
hidePeek();
|
||||
$($panel.data('categoryTrigger')).trigger('focus');
|
||||
}).on('input', '[data-template-search]', function () {
|
||||
filterItems($(this).closest('[data-library-panel]'));
|
||||
});
|
||||
|
||||
$gallery.on('mouseenter focusin', '[data-template-preview]', function (event) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
Reference in New Issue
Block a user