import React, { CSSProperties } from 'react'; import { SpacingInput, SpacingValue, parseSpacingShorthand, spacingToShorthand } from './SpacingInput'; interface AdvancedTabProps { style: CSSProperties; onStyleChange: (updates: CSSProperties) => void; /** Optional: current CSS ID value */ cssId?: string; onCssIdChange?: (id: string) => void; /** Optional: current CSS class value */ cssClass?: string; onCssClassChange?: (cls: string) => void; /** Optional: show HTML tag selector (for containers) */ showTagSelector?: boolean; tag?: string; onTagChange?: (tag: string) => void; /** Responsive visibility */ hideOnDesktop?: boolean; onHideOnDesktopChange?: (hide: boolean) => void; hideOnTablet?: boolean; onHideOnTabletChange?: (hide: boolean) => void; hideOnMobile?: boolean; onHideOnMobileChange?: (hide: boolean) => void; /** Entrance animation */ animation?: string; onAnimationChange?: (anim: string) => void; animationDelay?: string; onAnimationDelayChange?: (delay: string) => void; } const labelStyle: React.CSSProperties = { fontSize: 11, fontWeight: 600, color: '#a1a1aa', display: 'block', marginBottom: 6, textTransform: 'uppercase', letterSpacing: '0.3px', }; const inputStyle: React.CSSProperties = { width: '100%', padding: '5px 8px', background: '#27272a', color: '#e4e4e7', border: '1px solid #3f3f46', borderRadius: 4, fontSize: 11, }; const selectStyle: React.CSSProperties = { width: '100%', padding: '5px 8px', background: '#27272a', color: '#e4e4e7', border: '1px solid #3f3f46', borderRadius: 4, fontSize: 11, }; const TAG_OPTIONS = ['div', 'section', 'article', 'header', 'footer', 'main', 'aside', 'nav']; export const AdvancedTab: React.FC = ({ style, onStyleChange, cssId = '', onCssIdChange, cssClass = '', onCssClassChange, showTagSelector = false, tag, onTagChange, hideOnDesktop = false, onHideOnDesktopChange, hideOnTablet = false, onHideOnTabletChange, hideOnMobile = false, onHideOnMobileChange, animation = 'none', onAnimationChange, animationDelay = '0', onAnimationDelayChange, }) => { // Parse margin and padding from style const margin: SpacingValue = { top: (style.marginTop as string) || '0', right: (style.marginRight as string) || '0', bottom: (style.marginBottom as string) || '0', left: (style.marginLeft as string) || '0', }; // If there's a shorthand margin, parse it const marginShorthand = style.margin as string | undefined; const resolvedMargin = marginShorthand ? parseSpacingShorthand(marginShorthand) : margin; const padding: SpacingValue = { top: (style.paddingTop as string) || '0', right: (style.paddingRight as string) || '0', bottom: (style.paddingBottom as string) || '0', left: (style.paddingLeft as string) || '0', }; const paddingShorthand = style.padding as string | undefined; const resolvedPadding = paddingShorthand ? parseSpacingShorthand(paddingShorthand) : padding; const handleMarginChange = (val: SpacingValue) => { onStyleChange({ margin: spacingToShorthand(val), marginTop: undefined, marginRight: undefined, marginBottom: undefined, marginLeft: undefined, } as CSSProperties); }; const handlePaddingChange = (val: SpacingValue) => { onStyleChange({ padding: spacingToShorthand(val), paddingTop: undefined, paddingRight: undefined, paddingBottom: undefined, paddingLeft: undefined, } as CSSProperties); }; return (
{/* Margin */} {/* Padding */} {/* HTML Tag (for containers) */} {showTagSelector && onTagChange && (
)} {/* CSS ID */} {onCssIdChange && (
onCssIdChange(e.target.value.replace(/\s/g, '-'))} placeholder="my-element" style={inputStyle} />
)} {/* CSS Class */} {onCssClassChange && (
onCssClassChange(e.target.value)} placeholder="class-one class-two" style={inputStyle} />
)} {/* Responsive Visibility */} {(onHideOnDesktopChange || onHideOnTabletChange || onHideOnMobileChange) && (
{([ { key: 'hideOnDesktop' as const, label: 'Desktop', icon: 'fa-desktop', value: hideOnDesktop, onChange: onHideOnDesktopChange }, { key: 'hideOnTablet' as const, label: 'Tablet', icon: 'fa-tablet', value: hideOnTablet, onChange: onHideOnTabletChange }, { key: 'hideOnMobile' as const, label: 'Mobile', icon: 'fa-mobile', value: hideOnMobile, onChange: onHideOnMobileChange }, ] as const).map(({ key, label, icon, value, onChange }) => ( ))}
)} {/* Entrance Animation */} {onAnimationChange && (
{animation && animation !== 'none' && onAnimationDelayChange && (
)}
)}
); };