feat(editor): add Run help hint and rename from project list
Show a help icon when Run is disabled, open the relevant instruction section on click, and position its tooltip below-left. Add Rename project to the home screen project card menu. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,8 @@ type ButtonProps = {
|
||||
ariaLabel?: string | undefined;
|
||||
/** Компактная кнопка под одну иконку. */
|
||||
iconOnly?: boolean;
|
||||
/** Позиция тултипа относительно кнопки. */
|
||||
tooltipPlacement?: 'top' | 'bottom-left';
|
||||
};
|
||||
|
||||
export function Button({
|
||||
@@ -23,6 +25,7 @@ export function Button({
|
||||
title,
|
||||
ariaLabel,
|
||||
iconOnly = false,
|
||||
tooltipPlacement = 'top',
|
||||
}: ButtonProps) {
|
||||
const btnRef = useRef<HTMLButtonElement | null>(null);
|
||||
const [tipPos, setTipPos] = useState<{ x: number; y: number } | null>(null);
|
||||
@@ -32,8 +35,12 @@ export function Button({
|
||||
const el = btnRef.current;
|
||||
if (!el) return;
|
||||
const r = el.getBoundingClientRect();
|
||||
if (tooltipPlacement === 'bottom-left') {
|
||||
setTipPos({ x: r.right, y: r.bottom });
|
||||
return;
|
||||
}
|
||||
setTipPos({ x: r.left + r.width / 2, y: r.top });
|
||||
}, [disabled, title]);
|
||||
}, [disabled, title, tooltipPlacement]);
|
||||
|
||||
const hideTip = useCallback(() => {
|
||||
setTipPos(null);
|
||||
@@ -47,10 +54,12 @@ export function Button({
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
|
||||
const tipClass = tooltipPlacement === 'bottom-left' ? styles.tooltipBottomLeft : styles.tooltipTop;
|
||||
|
||||
const tip =
|
||||
title && tipPos && typeof document !== 'undefined'
|
||||
? createPortal(
|
||||
<div role="tooltip" className={styles.tooltip} style={{ left: tipPos.x, top: tipPos.y }}>
|
||||
<div role="tooltip" className={tipClass} style={{ left: tipPos.x, top: tipPos.y }}>
|
||||
{title}
|
||||
</div>,
|
||||
document.body,
|
||||
|
||||
Reference in New Issue
Block a user