fix(frontend): align page-set hint bar and FA5 icons with the reference
- 齿轮提示横条改为参考主题的 .abs-right 垂直居中几何(top:50% + right:.7em + translateY(-50%)),本站 legacy .abs-right 是 top:0/right:0 导致横条贴到按钮顶角 - 新增 front-page-admin-set.js:横条 2 秒后淡出 1 秒消失(对齐参考 主题 js/page-edit.js),开关关闭时不出队脚本 - 齿轮与弹窗内图标统一为 FA5 惯例 fa fas fa-*,并采用 FA5 的 glyph 重命名(sliders→sliders-h、pie-chart→chart-pie)
This commit is contained in:
@@ -218,6 +218,54 @@ test('frontend page edit ships gate, footer modal, and legacy ajax-save contract
|
||||
assert.equal(fs.existsSync(path.join(root, 'assets/js/page-admin-set.js')), false);
|
||||
});
|
||||
|
||||
test('frontend page edit icons follow the FA5 convention and the hint bar fades like the reference', () => {
|
||||
const pageAdminSet = read('src/Frontend/PageAdminSet.php');
|
||||
const hintJs = read('assets/js/front-page-admin-set.js');
|
||||
const floatingCss = read('assets/css/frontend/floating-buttons.css');
|
||||
const publicCss = read('assets/css/build/public.css');
|
||||
const publicMinCss = read('assets/css/build/public.min.css');
|
||||
|
||||
// Site-wide icon convention is aksrt_icon_markup()'s normalized `fa fas fa-*`:
|
||||
// the gear, the modal header, both footer links and the submit button.
|
||||
// FA5 renames the reference's FA4 glyphs (sliders→sliders-h, pie-chart→chart-pie).
|
||||
assert.match(pageAdminSet, /<i class="fa fas fa-cog fa-spin" aria-hidden="true"><\/i>/);
|
||||
assert.match(pageAdminSet, /<i class="fa fas fa-sliders-h mr10" aria-hidden="true"><\/i>/);
|
||||
assert.match(pageAdminSet, /<i class="fa fas fa-chart-pie" aria-hidden="true"><\/i>/);
|
||||
assert.match(pageAdminSet, /<i class="fa fas fa-wordpress" aria-hidden="true"><\/i>/);
|
||||
assert.match(pageAdminSet, /<i class="fa fas fa-check" aria-hidden="true"><\/i>/);
|
||||
assert.match(pageAdminSet, /<i class="fa fas fa-times" aria-hidden="true"><\/i>/);
|
||||
// No bare FA4 prefixes survive inside the feature markup.
|
||||
assert.doesNotMatch(pageAdminSet, /class="fa fa-(cog|sliders|sliders-h|chart-pie|pie-chart|wordpress|check|times)\b/);
|
||||
// Every glyph must exist in the shipped FA5 build (fa-spin is a utility, not a glyph).
|
||||
const fa5 = read('assets/fontawesome5/css/all.min.css');
|
||||
for (const token of ['fa-cog', 'fa-sliders-h', 'fa-chart-pie', 'fa-wordpress', 'fa-check', 'fa-times']) {
|
||||
assert.ok(fa5.includes(`.${token}:before`), `${token} is missing from Font Awesome 5.15.4`);
|
||||
}
|
||||
|
||||
// The transient label fades 2s after load over 1s (reference js/page-edit.js).
|
||||
assert.match(pageAdminSet, /add_action\('wp_footer', \[self::class, 'enqueue_hint_script'\], 9\)/);
|
||||
assert.match(pageAdminSet, /wp_enqueue_script\(\s*'aksrt-front-page-admin-set',\s*get_template_directory_uri\(\) \. '\/assets\/js\/front-page-admin-set\.js',\s*\['jquery'\],\s*\(string\) filemtime\(\$path\),\s*true\s*\)/s);
|
||||
assert.match(hintJs, /setTimeout\(function \(\) \{/, 'the fade is delayed like the reference');
|
||||
assert.match(hintJs, /hint\.style\.transition = 'opacity 1s'/);
|
||||
assert.match(hintJs, /hint\.style\.opacity = '0'/);
|
||||
assert.match(hintJs, /querySelector\('\.admin-set-page \.admin-set-info'\)/);
|
||||
|
||||
// Label geometry: reference .abs-right is top:50% + right:.7em + translateY(-50%).
|
||||
// AKSRT's legacy .abs-right is top:0/right:0, so the float bar restores it.
|
||||
// The minified bundle has no space before the brace, so keep it optional.
|
||||
const labelRule = /\.float-right \.admin-set-page \.admin-set-info\s*\{[^}]*\}/s;
|
||||
assert.match(floatingCss, labelRule);
|
||||
assert.match(publicCss, labelRule);
|
||||
assert.match(publicMinCss, labelRule);
|
||||
for (const css of [floatingCss, publicCss, publicMinCss]) {
|
||||
const rule = css.match(labelRule)[0];
|
||||
assert.match(rule, /position:\s*absolute/);
|
||||
assert.match(rule, /top:\s*50%/);
|
||||
assert.match(rule, /right:\s*0?\.7em/);
|
||||
assert.match(rule, /transform:\s*translateY\(-50%\)/);
|
||||
}
|
||||
});
|
||||
|
||||
test('float toolbar config reaches the tinymce plugin with reference-context buttons', () => {
|
||||
const editorJs = read('assets/js/front-submit-editor.js');
|
||||
const submitPage = read('templates/pages/page-submit.php');
|
||||
|
||||
Reference in New Issue
Block a user