mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
bfe1f33ea0
* improve(ui): make Control UI feel native on mobile * fix(ui): keep coarse-pointer input floor text-scale aware * fix(ui): let self-sized controls opt out of the touch input floor * fix(ui): fold per-control coarse-pointer font floors into the shared touch floor
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import type { AnyNode, Plugin, Rule } from "postcss";
|
|
|
|
function isHoverGuarded(rule: Rule): boolean {
|
|
let ancestor: AnyNode | undefined = rule.parent;
|
|
while (ancestor) {
|
|
if (ancestor.type === "atrule" && ancestor.params.includes("hover:")) {
|
|
return true;
|
|
}
|
|
ancestor = ancestor.parent;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
export function controlUiHoverGuardPlugin(): Plugin {
|
|
return {
|
|
postcssPlugin: "control-ui-hover-guard",
|
|
Rule(rule, { AtRule }) {
|
|
if (!rule.selector.includes(":hover") || isHoverGuarded(rule)) {
|
|
return;
|
|
}
|
|
|
|
const hoverSelectors = rule.selectors.filter((selector) => selector.includes(":hover"));
|
|
const otherSelectors = rule.selectors.filter((selector) => !selector.includes(":hover"));
|
|
const hoverRule = rule.clone();
|
|
hoverRule.selectors = hoverSelectors;
|
|
const guard = new AtRule({ name: "media", params: "(hover: hover)" });
|
|
guard.append(hoverRule);
|
|
|
|
if (otherSelectors.length === 0) {
|
|
rule.replaceWith(guard);
|
|
return;
|
|
}
|
|
|
|
rule.selectors = otherSelectors;
|
|
rule.after(guard);
|
|
},
|
|
};
|
|
}
|