From fbb3b7f05737f9571b04b0a8f4f15c0928de8545 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 7 Jul 2025 01:43:36 +0000 Subject: (대표님) 변경사항 20250707 10시 43분 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ui/text-utils.tsx | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 components/ui/text-utils.tsx (limited to 'components/ui/text-utils.tsx') diff --git a/components/ui/text-utils.tsx b/components/ui/text-utils.tsx new file mode 100644 index 00000000..a3507dd0 --- /dev/null +++ b/components/ui/text-utils.tsx @@ -0,0 +1,131 @@ +"use client" + +import { useState } from "react" +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible" +import { ChevronDown, ChevronUp } from "lucide-react" + +export function TruncatedText({ + text, + maxLength = 50, + showTooltip = true +}: { + text: string | null + maxLength?: number + showTooltip?: boolean +}) { + if (!text) return - + + if (text.length <= maxLength) { + return {text} + } + + const truncated = text.slice(0, maxLength) + "..." + + if (!showTooltip) { + return {truncated} + } + + return ( + + + + + {truncated} + + + +

{text}

+
+
+
+ ) +} + +export function ExpandableText({ + text, + maxLength = 100, + className = "" +}: { + text: string | null + maxLength?: number + className?: string +}) { + const [isExpanded, setIsExpanded] = useState(false) + + if (!text) return - + + if (text.length <= maxLength) { + return {text} + } + + return ( + +
+ + + +
+
+ ) +} + +export function AddressDisplay({ + address, + addressEng, + postalCode, + addressDetail +}: { + address: string | null + addressEng: string | null + postalCode: string | null + addressDetail: string | null +}) { + const hasAnyAddress = address || addressEng || postalCode || addressDetail + + if (!hasAnyAddress) { + return - + } + + return ( +
+ {postalCode && ( +
+ 우편번호: {postalCode} +
+ )} + {address && ( +
+ {address} +
+ )} + {addressDetail && ( +
+ {addressDetail} +
+ )} + {addressEng && ( +
+ {addressEng} +
+ )} +
+ ) +} \ No newline at end of file -- cgit v1.2.3