Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

feat: enhance UI components with new styling and multi-select functionality in canvas elements

CristianOlivera1761fc6412ca6
diff --git a/app/components/ui/ExportImageDropdown.tsx b/app/components/ui/ExportImageDropdown.tsx
index 45c706f..5ee4c8d 100644
--- a/app/components/ui/ExportImageDropdown.tsx
+++ b/app/components/ui/ExportImageDropdown.tsx
@@ -220,7 +220,7 @@ export function ExportImageDropdown({
}`}
>
<div
- className={`relative size-12 rounded-2xl flex items-center justify-center transition-all duration-300 border ${isSelected
+ className={`relative size-12 squircle-element flex items-center justify-center transition-all duration-300 border ${isSelected
? "border-white/30 scale-105"
: "border-white/10 hover:border-white/20"
}`}
@@ -255,7 +255,7 @@ export function ExportImageDropdown({
</div>
<div className="px-2 pb-2">
- <div className="bg-white/3 rounded-2xl border border-white/10 overflow-hidden max-h-64 overflow-y-auto custom-scrollbar">
+ <div className="bg-white/3 squircle-element border border-white/10 overflow-hidden max-h-64 overflow-y-auto custom-scrollbar">
{qualityPresets.map((preset, i) => (
<button
key={i}
diff --git a/app/components/ui/editor/CanvasElementsLayer.tsx b/app/components/ui/editor/CanvasElementsLayer.tsx
index 67c3996..80ff39d 100644
--- a/app/components/ui/editor/CanvasElementsLayer.tsx
+++ b/app/components/ui/editor/CanvasElementsLayer.tsx
@@ -8,10 +8,12 @@ export function CanvasElementsLayer({
canvasContainerRef,
canvasElements,
selectedElementId,
+ selectedElementIds,
hoveredElementId,
isDraggingElement,
behindVideo,
onElementSelect,
+ onMultiSelect,
onElementUpdate,
setHoveredElementId,
setIsDraggingElement,
@@ -25,10 +27,12 @@ export function CanvasElementsLayer({
canvasContainerRef?: React.RefObject<HTMLDivElement | null>;
canvasElements: CanvasElement[];
selectedElementId: string | null;
+ selectedElementIds?: string[];
hoveredElementId: string | null;
isDraggingElement: boolean;
behindVideo: boolean;
onElementSelect?: (id: string | null) => void;
+ onMultiSelect?: (ids: string[]) => void;
onElementUpdate?: (id: string, updates: Partial<CanvasElement>) => void;
setHoveredElementId: (id: string | null) => void;
setIsDraggingElement: (dragging: boolean) => void;
@@ -42,7 +46,6 @@ export function CanvasElementsLayer({
const layerRef = useRef<HTMLDivElement>(null);
const [refSize, setRefSize] = useState(0);
- // Estado local como fallback si no se pasan las props (capas que no son hit)
const [localElementCorners, setLocalElementCorners] = useState<Record<string, Corner | null>>({});
const elementCorners = elementCornersProp ?? localElementCorners;
const setElementCorners = setElementCornersProp ?? setLocalElementCorners;
@@ -104,7 +107,7 @@ export function CanvasElementsLayer({
}
return a.zIndex - b.zIndex;
}).map((element) => {
- const isSelected = selectedElementId === element.id;
+ const isSelected = selectedElementId === element.id || (selectedElementIds?.includes(element.id) ?? false);
const isHovered = hoveredElementId === element.id;
const activeCorner: Corner | null = elementCorners[element.id] ?? null;
@@ -133,13 +136,26 @@ export function CanvasElementsLayer({
};
const handleMouseDown = (e: React.MouseEvent<HTMLElement>) => {
if (!onElementSelect) return;
+ if (element.locked) return;
+ if (e.button === 2) return;
if ((e.target as HTMLElement).closest('[data-element-rotation]')) {
e.stopPropagation();
return;
}
e.preventDefault();
e.stopPropagation();
- onElementSelect(element.id);
+ const current = selectedElementIds ?? (selectedElementId ? [selectedElementId] : []);
+ if (e.shiftKey && onMultiSelect) {
+ const next = current.includes(element.id)
+ ? current.filter(id => id !== element.id)
+ : [...current, element.id];
+ onMultiSelect(next);
+ } else if (current.includes(element.id) && current.length > 1) {
+ onElementSelect(element.id);
+ } else {
+ onElementSelect(element.id);
+ if (onMultiSelect) onMultiSelect([element.id]);
+ }
setIsDraggingElement(true);
elementDragStart.current = {
x: e.clientX,
@@ -180,6 +196,8 @@ export function CanvasElementsLayer({
) : null;
if (hitTestOnly) {
+ if (element.visible === false) return null;
+
const TOP_Z_INDEX = 2147483647;
const expandedHitArea = isSelected ? (
@@ -197,7 +215,7 @@ export function CanvasElementsLayer({
<div
key={element.id}
data-canvas-element
- className="absolute pointer-events-auto cursor-move select-none"
+ className={`absolute pointer-events-auto select-none ${element.locked ? "cursor-not-allowed" : "cursor-move"}`}
style={{
left: `${element.x}%`,
top: `${element.y}%`,
@@ -233,7 +251,7 @@ export function CanvasElementsLayer({
<div
key={element.id}
data-canvas-element
- className="absolute pointer-events-auto cursor-move"
+ className={`absolute pointer-events-auto ${element.locked ? "cursor-not-allowed" : "cursor-move"}`}
style={{
...commonStyle,
zIndex: isSelected ? TOP_Z_INDEX : element.zIndex,
@@ -251,6 +269,8 @@ export function CanvasElementsLayer({
</div>
);
}
+ if (element.visible === false) return null;
+
if (element.type === "svg") {
const SvgComponent = SVG_COMPONENTS[(element as SvgElement).svgId];
return (
diff --git a/app/components/ui/editor/ElementsMenu.tsx b/app/components/ui/editor/ElementsMenu.tsx
index fe65b17..e35eddd 100644
--- a/app/components/ui/editor/ElementsMenu.tsx
+++ b/app/components/ui/editor/ElementsMenu.tsx
@@ -18,8 +18,6 @@ export function ElementsMenu({
selectedElement,
onUpdateElement,
onDeleteElement,
- onBringToFront,
- onSendToBack
}: ElementsMenuProps) {
const t = useTranslations("elementsMenu");
@@ -59,12 +57,12 @@ export function ElementsMenu({
startTransition(() => {
if (selectedElement) {
if (selectedElement.type === "svg") {
- setShapeSize(selectedElement.width);
+ setShapeSize(Math.round(selectedElement.width));
setShapeColor(selectedElement.color || "#FFFFFF");
setShapeOpacity(Math.round(selectedElement.opacity * 100));
setMode("elements");
} else if (selectedElement.type === "image") {
- setImageSize(selectedElement.width);
+ setImageSize(Math.round(selectedElement.width));
setImageOpacity(Math.round(selectedElement.opacity * 100));
setMode("elements");
} else if (selectedElement.type === "text") {
@@ -367,11 +365,16 @@ export function ElementsMenu({
<div className="p-3 grid grid-cols-8 gap-2 overflow-y-auto custom-scrollbar">
{filteredImageItems.map((item) => (
<div key={`${item.category}-${item.id}`} className="w-full" style={{ paddingBottom: "100%", position: "relative" }}>
- <TooltipAction label={item.name}>
- <button title={item.name} onClick={() => handleAddImage(item, item.category)} className="absolute inset-0 bg-white/3 hover:bg-white/8 border border-white/[0.07] hover:border-white/20 squircle-element transition-all active:scale-90 overflow-hidden group">
- <ProgressiveImg src={getImagePreviewPath(item)} alt={item.name} className="w-full h-full object-contain group-hover:scale-110" />
- </button>
- </TooltipAction>
+ <button
+ onClick={() => handleAddImage(item, item.category)}
+ className="absolute inset-0 bg-white/3 hover:bg-white/8 border border-white/[0.07] hover:border-white/20 squircle-element transition-all active:scale-90 overflow-hidden group"
+ >
+ <ProgressiveImg
+ src={getImagePreviewPath(item)}
+ alt={item.name}
+ className="w-full h-full object-contain group-hover:scale-110"
+ />
+ </button>
</div>
))}
</div>
@@ -408,27 +411,6 @@ export function ElementsMenu({
<SliderControl icon="mdi:resize" label={t("properties.size")} value={selectedElement.type === "svg" ? shapeSize : imageSize} onChange={selectedElement.type === "svg" ? setShapeSize : setImageSize} min={5} max={200} />
<SliderControl icon="mdi:opacity" label={t("properties.opacity")} value={selectedElement.type === "svg" ? shapeOpacity : imageOpacity} onChange={selectedElement.type === "svg" ? setShapeOpacity : setImageOpacity} />
</div>
-
- <div className="space-y-2">
- <div className="flex items-center justify-between">
- <div className="text-[10px] uppercase tracking-widest text-white/40 font-semibold">{t("sections.hierarchy")}</div>
- <TooltipAction label={t("actions.delete")}>
- <button onClick={() => onDeleteElement?.(selectedElement.id)} className="p-1.5 bg-red-500/10 hover:bg-red-500/20 border border-red-500/30 rounded-md text-red-400 hover:text-red-300 transition-all active:scale-95">
- <Icon icon="ph:trash-bold" width="14" />
- </button>
- </TooltipAction>
- </div>
- <div className="grid grid-cols-2 gap-2">
- <button onClick={() => onBringToFront?.(selectedElement.id)} className="flex items-center justify-center gap-2 px-3 py-2 bg-white/5 hover:bg-white/10 border border-white/10 rounded-lg text-xs text-white/70 hover:text-white transition-all">
- <Icon icon="ph:bring-to-front-bold" width="16" />
- {t("actions.bringToFront")}
- </button>
- <button onClick={() => onSendToBack?.(selectedElement.id)} className="flex items-center justify-center gap-2 px-3 py-2 bg-white/5 hover:bg-white/10 border border-white/10 rounded-lg text-xs text-white/70 hover:text-white transition-all">
- <Icon icon="ph:send-to-back-bold" width="16" />
- {t("actions.sendToBack")}
- </button>
- </div>
- </div>
</>
)}
</div>
@@ -525,29 +507,6 @@ export function ElementsMenu({
<Icon icon="ph:plus-bold" width="16" />
{t("text.addButton")}
</Button>
-
- {selectedElement && selectedElement.type === "text" && (
- <div className="space-y-2">
- <div className="flex items-center justify-between">
- <div className="text-[10px] uppercase tracking-widest text-white/40 font-semibold">{t("sections.hierarchy")}</div>
- <TooltipAction label={t("actions.delete")}>
- <button onClick={() => onDeleteElement?.(selectedElement.id)} className="p-1.5 bg-red-500/10 hover:bg-red-500/20 border border-red-500/30 rounded-md text-red-400 hover:text-red-300 transition-all active:scale-95">
- <Icon icon="ph:trash-bold" width="14" />
- </button>
- </TooltipAction>
- </div>
- <div className="grid grid-cols-2 gap-2">
- <Button variant="outline" className="text-xs" onClick={() => onBringToFront?.(selectedElement.id)}>
- <Icon icon="ph:bring-to-front-bold" width="16" />
- {t("actions.bringToFront")}
- </Button>
- <Button variant="outline" className="text-xs" onClick={() => onSendToBack?.(selectedElement.id)}>
- <Icon icon="ph:send-to-back-bold" width="16" />
- {t("actions.sendToBack")}
- </Button>
- </div>
- </div>
- )}
</div>
)}
diff --git a/app/components/ui/editor/PhotoEditorPlaceholder.tsx b/app/components/ui/editor/PhotoEditorPlaceholder.tsx
index f94563c..d632743 100644
--- a/app/components/ui/editor/PhotoEditorPlaceholder.tsx
+++ b/app/components/ui/editor/PhotoEditorPlaceholder.tsx
@@ -319,7 +319,7 @@ export function PhotoEditorPlaceholder({
return (
<div className={`flex flex-col bg-black border-t border-white/10 ${className}`}>
- <div className="flex flex-wrap items-center justify-between gap-3 px-5 py-3 border-b border-white/5">
+ <div className="h-13 shrink-0 border-t border-white/10 flex items-center justify-between px-5 bg-[#0D0D11]">
<div className="flex items-center gap-2 text-white/60 whitespace-nowrap">
<Icon icon="mdi:tune-vertical" width={16} />
<span className="text-xs font-semibold tracking-wide uppercase">
@@ -406,7 +406,7 @@ export function PhotoEditorPlaceholder({
</div>
</div>
- <div className="flex gap-3 px-5 py-4 overflow-x-auto custom-scrollbar mask-r-from-90% ">
+ <div className="flex gap-3 px-5 overflow-x-auto custom-scrollbar mask-r-from-90% ">
{allPreviews.map(renderPreviewCard)}
</div>
</div>