mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-17 19:24:30 +01:00
* Loop Lock/Unlock * fixed condition. 4 line points are required for the action to be available * extracted updateLoopLock to improve readability. Removed unnecessary SVG attributes * lint + added loopLock to restore.ts * added loopLock to newElement, updated test snapshots * lint * dislocate enpoint when breaking the loop. * change icon & turn into a state style button * POC: auto-transform to polygon on bg set * keep polygon icon constant * do not split points on de-polygonizing & highlight overlapping points * rewrite color picker to support no (mixed) colors & fix focus handling * refactor * tweak point rendering inside line editor * do not disable polygon when creating new points via alt * auto-enable polygon when aligning start/end points * TBD: remove bg color when disabling polygon * TBD: only show polygon button for enabled polygons * fix polygon behavior when adding/removing/moving points within line editor * convert to polygon when creating line * labels tweak * add to command palette * loopLock -> polygon * restore `polygon` state on type conversions * update snapshots * naming * break polygon on restore/finalize if invalid & prevent creation * snapshots * fix: merge issue and forgotten debug * snaps * do not merge points for 3-point lines --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
41 lines
1007 B
TypeScript
41 lines
1007 B
TypeScript
import clsx from "clsx";
|
|
import { forwardRef } from "react";
|
|
|
|
import "./ButtonIcon.scss";
|
|
|
|
import type { JSX } from "react";
|
|
|
|
interface ButtonIconProps {
|
|
icon: JSX.Element;
|
|
title: string;
|
|
className?: string;
|
|
testId?: string;
|
|
/** if not supplied, defaults to value identity check */
|
|
active?: boolean;
|
|
/** include standalone style (could interfere with parent styles) */
|
|
standalone?: boolean;
|
|
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
export const ButtonIcon = forwardRef<HTMLButtonElement, ButtonIconProps>(
|
|
(props, ref) => {
|
|
const { title, className, testId, active, standalone, icon, onClick } =
|
|
props;
|
|
return (
|
|
<button
|
|
type="button"
|
|
ref={ref}
|
|
key={title}
|
|
title={title}
|
|
data-testid={testId}
|
|
className={clsx(className, { standalone, active })}
|
|
onClick={onClick}
|
|
style={props.style}
|
|
>
|
|
{icon}
|
|
</button>
|
|
);
|
|
},
|
|
);
|