import classNames from "classnames"; import { faChevronDown, faChevronRight, faTrash, faCaretDown, faCaretUp, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { ListItem } from "components/editor-icons/comps/list/list-item"; import { Icons as ICONS, IconCustomIcon, IconCustomText, } from "components/svg/icons"; import { IconItem, IconType } from "@/types/editor"; import { ColorPicker } from "components/color-picker"; import { Range } from "components/range"; import { Input } from "components/input"; import { Switch } from "@/components/switch"; import { PremiumOverlay } from "@/components/premium/overlay"; import { FormattedMessage, useIntl } from "react-intl"; import { Label } from "@/components/label"; export const IconSelected = ({ index, totalIcons, icon, current, setCurrent, onDelete, onChange, onChangeOrder, }: { index: number; totalIcons: number; icon: IconType; current?: number | null; setCurrent: (index: number | null) => void; onDelete: (index: number) => void; onChange: (idnex: number, icon: IconType) => void; onChangeOrder: (index: number, value: number) => void; }) => { const findIcon: any = icon?.custom_text?.enabled ? IconCustomText : icon?.image ? IconCustomIcon : ICONS?.find((i: IconItem) => icon.component === i.name); const handleChange = (index: number, icon: any) => { onChange(index, icon); }; const intl = useIntl(); return (
setCurrent(current === index ? null : index)} >
{icon?.image ? (
) : ( {}} /> )}

{findIcon?.tags?.join(", ")}

{ e.preventDefault(); e.stopPropagation(); onDelete(index); }} >
{current === index && (

X

{ const newIcon = { ...icon, position: { ...icon.position, x: Number(value) }, }; handleChange(index, newIcon); }} />
{ let x: number = Number(newX); if (x > 100) x = 100; const newIcon = { ...icon, position: { ...icon.position, x: x }, }; handleChange(index, newIcon); }} />

Y

{ const newIcon = { ...icon, position: { ...icon.position, y: Number(value) }, }; handleChange(index, newIcon); }} />
{ let y = Number(newY); if (y > 100) y = 100; const newIcon = { ...icon, position: { ...icon.position, y: y }, }; handleChange(index, newIcon); }} />

Z

{ const newIcon = { ...icon, position: { ...icon.position, angle: Number(value) }, }; handleChange(index, newIcon); }} />
{ let angle = Number(newAngle); if (angle > 360) angle = 360; const newIcon = { ...icon, position: { ...icon.position, angle: angle }, }; handleChange(index, newIcon); }} />
{!icon?.custom_text?.enabled && (

{ const newIcon = { ...icon, position: { ...icon.position, scale: Number(value), }, }; handleChange(index, newIcon); }} />
{ let scale = Number(newScale); if (scale > 100) scale = 100; const newIcon = { ...icon, position: { ...icon.position, scale: Math.trunc(scale) / 100, }, }; handleChange(index, newIcon); }} />
)}
{!icon?.image && (
{ let newIcon = { ...icon, stringColor: c }; if (c.includes("gradient")) { const { colors, degrees } = datas; const gradientType = c?.startsWith("linear") ? "linearGradient" : "radialGradient"; const angle = c?.startsWith("linear") ? c?.replace("linear-gradient(", "")?.split("deg")?.[0] : 90; newIcon["gradient"] = { ...newIcon.gradient, enabled: true, colours: colors, angle, type: gradientType, }; } else { newIcon = { ...newIcon, colour: c, gradient: { ...icon?.gradient, enabled: false, }, }; } handleChange(index, newIcon); }} />
)} {icon?.custom_text?.enabled && ( <>

{ const newIcon = { ...icon, custom_text: { ...icon.custom_text, text: target.value, }, }; handleChange(index, newIcon); }} />

{ const newIcon = { ...icon, custom_text: { ...icon.custom_text, size: Number(target.value), }, }; handleChange(index, newIcon); }} />
)}
{!icon?.image && (

{ const newIcon = { ...icon, border: { ...icon.border, width: target?.value ? Number(target.value) : undefined, }, }; handleChange(index, newIcon); }} />

{ const newIcon = { ...icon, border: { ...icon.border, colour: c, }, }; handleChange(index, newIcon); }} />
)}
{ const newIcon = { ...icon, shadow: { ...icon.shadow, enabled, }, }; handleChange(index, newIcon); }} />
{icon?.shadow?.enabled && (

X

{ const newIcon = { ...icon, shadow: { ...icon.shadow, position: { ...icon?.shadow?.position, x: target?.value ? Number(target.value) : undefined, }, }, }; handleChange(index, newIcon); }} />

Y

{ const newIcon = { ...icon, shadow: { ...icon.shadow, position: { ...icon?.shadow?.position, y: target?.value ? Number(target.value) : undefined, }, }, }; handleChange(index, newIcon); }} />

{ const newIcon = { ...icon, shadow: { ...icon.shadow, position: { ...icon?.shadow?.position, blur: target?.value ? Number(target.value) : undefined, }, }, }; handleChange(index, newIcon); }} />

{ const newIcon = { ...icon, shadow: { ...icon.shadow, colour: c, }, }; handleChange(index, newIcon); }} />
)}
)}
{totalIcons > 1 && (
{index !== 0 && ( onChangeOrder(index, index - 1)} /> )} {index !== totalIcons - 1 && ( onChangeOrder(index, index + 1)} /> )}
)}
); };