import { useState } from "react"; import { FormattedMessage, useIntl } from "react-intl"; import { FontFamilySelector } from "@/components/font-family"; import { FontWeight } from "@/components/font-weight"; import { Switch } from "@/components/switch"; import { BadgeType } from "@/types/badge"; import { ColorPicker } from "components/color-picker"; import { Label } from "@/components/label"; import { Input } from "@/components/input"; import classNames from "classnames"; import { SelectShapes } from "../../select-shapes"; import { IconPicker } from "@/components/icon-picker"; export const MainForm = ({ badge, setBadge, }: { badge: BadgeType; setBadge: (b: BadgeType) => void; }) => { const intl = useIntl(); return (
{ setBadge({ ...badge, text: { ...badge.text, value: value as string }, }); }} />

{ let newBadge = { ...badge, stringColor: c }; if (c.includes("gradient")) { const { colors, degrees } = datas; const gradientType = c?.startsWith("linear") ? "linearGradient" : "radialGradient"; const anglePI = Number(degrees ? degrees?.replace("deg", "") : 90) * (Math.PI / 180); const angleCoords = { x1: Math.round(50 + Math.sin(anglePI) * 50) + "%", y1: Math.round(50 + Math.cos(anglePI) * 50) + "%", x2: Math.round(50 + Math.sin(anglePI + Math.PI) * 50) + "%", y2: Math.round(50 + Math.cos(anglePI + Math.PI) * 50) + "%", }; newBadge["gradient"] = { ...newBadge.gradient, enabled: true, colours: colors, angle: angleCoords, type: gradientType, }; } else { newBadge = { ...newBadge, colour: c, gradient: { ...newBadge?.gradient, enabled: false, }, }; } setBadge(newBadge); }} />

{ let newBadge = { ...badge, text: { ...badge.text, stringColor: c }, }; if (c.includes("gradient")) { const { colors, degrees } = datas; const gradientType = c?.startsWith("linear") ? "linearGradient" : "radialGradient"; const anglePI = Number(degrees ? degrees?.replace("deg", "") : 90) * (Math.PI / 180); const angleCoords = { x1: Math.round(50 + Math.sin(anglePI) * 50) + "%", y1: Math.round(50 + Math.cos(anglePI) * 50) + "%", x2: Math.round(50 + Math.sin(anglePI + Math.PI) * 50) + "%", y2: Math.round(50 + Math.cos(anglePI + Math.PI) * 50) + "%", }; newBadge["text"]["gradient"] = { ...newBadge?.text?.gradient, enabled: true, colours: colors, angle: angleCoords, type: gradientType, }; } else { newBadge = { ...newBadge, text: { ...newBadge?.text, colour: c, gradient: { ...newBadge?.text?.gradient, enabled: false, }, }, }; } setBadge(newBadge); }} />
setBadge({ ...badge, icon: { ...badge.icon, position: badge?.icon?.position ?? "left", enabled, }, }) } />

{ setBadge({ ...badge, icon: { ...badge?.icon, position: badge?.icon?.position ?? "left", colour: c, stringColor: c, }, }); }} />

{ setBadge({ ...badge, icon: { ...badge?.icon, position: badge?.icon?.position ?? "left", enabled: true, component, }, }); }} />

setBadge({ ...badge, icon: { ...badge?.icon, position: "left" }, }) } > Left
setBadge({ ...badge, icon: { ...badge?.icon, position: "right" }, }) } > Right
setBadge({ ...badge, icon: { ...badge?.icon, position: "left-right" }, }) } > Left & Right
); };