mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-12-05 21:00:15 +08:00
补充官网多语言静态页面、管理端词条和动态提示,统一相关资源用量展示,保留表格导出等现有修改。 修正 RTL 布局与字体回退,并加入翻译契约、文案宽度、逻辑样式及浏览器回归检查。
43 lines
2.0 KiB
JavaScript
43 lines
2.0 KiB
JavaScript
// Chrome 86 supports logical spacing, but not logical insets or corner radii.
|
|
// Only legacy browsers use these root-direction fallbacks. Modern browsers keep
|
|
// native logical properties, including nested direction overrides.
|
|
const mappings = {
|
|
"inset-inline-start": ["left", "right"],
|
|
"inset-inline-end": ["right", "left"],
|
|
"border-start-start-radius": ["border-top-left-radius", "border-top-right-radius"],
|
|
"border-start-end-radius": ["border-top-right-radius", "border-top-left-radius"],
|
|
"border-end-start-radius": ["border-bottom-left-radius", "border-bottom-right-radius"],
|
|
"border-end-end-radius": ["border-bottom-right-radius", "border-bottom-left-radius"],
|
|
}
|
|
|
|
module.exports = {
|
|
postcssPlugin: "admin-chrome86-logical-fallbacks",
|
|
OnceExit(root, { postcss }) {
|
|
root.walkDecls("inset", (decl) => {
|
|
const values = postcss.list.space(decl.value)
|
|
const [top, right = top, bottom = top, left = right] = values
|
|
for (const [prop, value] of Object.entries({ top, right, bottom, left })) {
|
|
decl.cloneBefore({ prop, value })
|
|
}
|
|
})
|
|
|
|
root.walkRules((rule) => {
|
|
const declarations = rule.nodes.filter((node) => node.type === "decl" && mappings[node.prop])
|
|
if (!declarations.length) return
|
|
for (const feature of ["inset-inline-start", "border-start-start-radius"]) {
|
|
const group = declarations.filter((decl) => decl.prop.startsWith(feature.startsWith("inset") ? "inset" : "border"))
|
|
if (!group.length) continue
|
|
const fallback = postcss.atRule({ name: "supports", params: `not (${feature}: 0)` })
|
|
for (const [index, direction] of ["ltr", "rtl"].entries()) {
|
|
const prefix = direction === "rtl" ? 'html[dir="rtl"]' : 'html:not([dir="rtl"])'
|
|
const copy = rule.clone({ nodes: [] })
|
|
copy.selectors = rule.selectors.map((selector) => `${prefix} ${selector}`)
|
|
for (const decl of group) copy.append(decl.clone({ prop: mappings[decl.prop][index] }))
|
|
fallback.append(copy)
|
|
}
|
|
rule.after(fallback)
|
|
}
|
|
})
|
|
},
|
|
}
|