diff --git a/packages/core/lib/components/Breadcrumb.tsx b/packages/core/lib/components/Breadcrumb.tsx new file mode 100644 index 0000000..44d042d --- /dev/null +++ b/packages/core/lib/components/Breadcrumb.tsx @@ -0,0 +1,97 @@ +import React from 'react'; +import { Label } from './Label'; + +interface BreadcrumbItem { + label: string; + onClick: () => void; +} + +interface BreadcrumbProps { + items: BreadcrumbItem[]; + maxLength?: number; +} + +const ChevronIcon: React.FC = () => ( + +); + +const EllipsisIcon: React.FC = () => ( + +); + +export const Breadcrumb: React.FC = ({ + items, + maxLength = 3, +}) => { + const maxItems = Math.max(2, maxLength); + const renderItems = () => { + if (items.length <= maxItems) { + return items; + } + + const visibleItems = []; + visibleItems.push(items[0]); + + if (maxItems > 2) { + for (let i = 1; i < maxItems - 1; i++) { + visibleItems.push(items[items.length - maxItems + i]); + } + } + + visibleItems.push(items[items.length - 1]); + + return visibleItems; + }; + + return ( + + ); +}; diff --git a/packages/core/lib/components/TextArea.tsx b/packages/core/lib/components/TextArea.tsx new file mode 100644 index 0000000..ce149be --- /dev/null +++ b/packages/core/lib/components/TextArea.tsx @@ -0,0 +1,79 @@ +import React, { forwardRef, useState } from 'react'; +import { Label } from './Label'; + +type TextAreaProps = { + id: string; + title?: string; + description?: string; + size?: 'small' | 'medium' | 'large'; + maxLength?: number; +} & React.TextareaHTMLAttributes; + +export const TextArea = forwardRef( + ( + { + title, + description, + id, + placeholder, + size = 'medium', + maxLength, + onChange, + ...props + }, + ref + ) => { + const [charCount, setCharCount] = useState(0); + + const sizeClasses = { + small: 'h-24', + medium: 'h-32', + large: 'h-40', + }[size]; + + const handleChange = (e: React.ChangeEvent) => { + setCharCount(e.target.value.length); + if (onChange) { + onChange(e); + } + }; + + return ( +
+ {title && ( + + )} + {description && ( + + )} +
+