From 015cf3b91c97d213160e9d96fb137e8c43f10ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marti=CC=81n?= Date: Mon, 16 Dec 2024 16:45:11 +0100 Subject: [PATCH] Allow deleting link variant options --- .../models/common/widgets/Link/components.tsx | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/components.tsx b/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/components.tsx index a2e03423a..cb697be2a 100644 --- a/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/components.tsx +++ b/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/components.tsx @@ -2,6 +2,7 @@ import { Box, Button, Icon, + IconButton, Switch, Text, TextInput, @@ -119,6 +120,8 @@ export function Variants({ const addButtonShown = (variants?.length ?? 0) < 5; + const deleteButtonShown = (variants?.length ?? 0) > 2; + return ( {variants?.map((variant, position) => ( - - - onVariantsChange( - variants?.map((variant, index) => - index === position ? newVariant : variant, - ), - ) - } - /> + + + + onVariantsChange( + variants?.map((variant, index) => + index === position ? newVariant : variant, + ), + ) + } + /> + + {deleteButtonShown && ( + + onVariantsChange( + variants?.filter((_, index) => index !== position), + ) + } + /> + )} ))} {addButtonShown && (