Compare commits

...

5 Commits

Author SHA1 Message Date
tcardoza f4ad67e097 sidebar improvements 2026-03-13 19:01:56 -05:00
tcardoza 6a1af4b723 Layout fixed 2026-03-13 18:53:59 -05:00
tcardoza b52564d44d mid layout change 2026-03-13 18:41:44 -05:00
tcardoza c72da2fad5 mostly fixed layouts 2026-03-13 18:31:21 -05:00
tcardoza dfc4cccb56 Layout Fixes 2026-03-13 16:49:17 -05:00
10 changed files with 737 additions and 493 deletions
+11 -2
View File
@@ -208,9 +208,18 @@ const EstimateBuilder: Component<EstimateBuilderProps> = (props) => {
onSaveChanges={() => appStore.isLatestVersion() ? saveChangesToCloud() : saveAsNewestToCloud()}
/>
<div class="flex flex-1 relative items-start">
<div
style={{
display: 'grid',
'grid-template-columns': isSidebarCollapsed() ? '0px 1fr' : '18rem 1fr',
transition: 'grid-template-columns 500ms ease',
'align-items': 'start',
flex: '1',
}}
>
<BuilderSidebar
isCollapsed={isSidebarCollapsed()}
onToggleSidebar={() => setIsSidebarCollapsed(!isSidebarCollapsed())}
unassignedItems={unassignedItems()}
grandTotals={grandTotals()}
hoveredScopeId={hoveredScopeId()}
@@ -219,7 +228,7 @@ const EstimateBuilder: Component<EstimateBuilderProps> = (props) => {
onAddScope={addScope}
/>
<main onClick={clearSelection} class="flex-1 min-w-0 p-4 md:p-8 bg-zinc-50/50 space-y-8 min-h-screen">
<main onClick={clearSelection} class="min-w-0 p-4 md:p-8 bg-zinc-50/50 space-y-8 min-h-screen">
<ProjectDetailsForm />
<div class="bg-muted/30 border border-border rounded-3xl p-6 mb-8">
+130 -72
View File
@@ -54,16 +54,27 @@ const ItemRow: Component<ItemRowProps> = (props) => {
return num.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
};
/* ─────────────────────────────────────────────
MOBILE layout (<md): stacked card
DESKTOP layout (≥md): flat flex row, columns
match header widths exactly:
w-4 | flex-1 min-w-[200px] | w-20 | w-24 |
w-24 | w-32 | w-32 | w-28 | w-16
──────────────────────────────────────────── */
return (
<div
class={`group flex items-start gap-4 p-3 border transition-all animate-in fade-in slide-in-from-left-2
class={`group transition-all animate-in fade-in slide-in-from-left-2 w-full border
${props.isSelected
? 'bg-primary/5 border-primary shadow-premium z-10'
: 'bg-card border-border hover:shadow-premium-hover hover:border-border/80'
}
${isEditing() ? 'ring-1 ring-primary/20 shadow-premium border-primary/30' : 'rounded-2xl'}
${isEditing() ? 'ring-1 ring-primary/20 shadow-premium border-primary/30 rounded-2xl' : 'rounded-2xl'}
`}
>
{/* ── DESKTOP ROW ── */}
<div class="hidden md:flex items-center gap-4 px-3 py-2">
{/* Grip / Select — w-4 */}
<div
draggable={!isEditing() || props.anySelected}
onDragStart={(e) => props.onDragStart(e, props.item.id)}
@@ -71,25 +82,21 @@ const ItemRow: Component<ItemRowProps> = (props) => {
e.stopPropagation();
props.onToggleSelection(props.item.id, e.metaKey || e.ctrlKey, e.shiftKey);
}}
class={`cursor-grab transition-colors shrink-0 w-4 mt-2 p-1 rounded hover:bg-muted ${props.isSelected ? 'text-primary' : 'text-muted-foreground/30 hover:text-muted-foreground/60'}`}
class={`cursor-grab shrink-0 w-4 p-1 rounded hover:bg-muted transition-colors ${props.isSelected ? 'text-primary' : 'text-muted-foreground/30 hover:text-muted-foreground/60'}`}
title="Drag to move or click to select"
>
<GripVertical class="w-4 h-4" />
</div>
<div class="flex-1 relative min-w-[200px]">
{/* Description — flex-1 min-w-[200px] */}
<div class="flex-1 min-w-[200px] relative">
<textarea
ref={descriptionRef}
value={localDescription()}
onFocus={() => {
if (!props.anySelected) setIsEditing(true);
}}
onFocus={() => { if (!props.anySelected) setIsEditing(true); }}
onBlur={handleBlur}
onInput={(e) => {
setLocalDescription(e.currentTarget.value);
// Fallback auto-resize for browsers without field-sizing support
if (!('fieldSizing' in document.documentElement.style)) {
e.currentTarget.style.height = 'auto';
e.currentTarget.style.height = e.currentTarget.scrollHeight + 'px';
@@ -97,31 +104,23 @@ const ItemRow: Component<ItemRowProps> = (props) => {
}}
disabled={props.anySelected}
rows="1"
class={`w-full bg-transparent border-b border-transparent hover:border-border/40 focus:border-primary outline-none py-1 transition-all resize-none block overflow-hidden align-top leading-normal text-base font-medium text-foreground/90
class={`w-full bg-transparent border-b border-transparent hover:border-border/40 focus:border-primary outline-none py-1 transition-all resize-none block overflow-hidden align-top leading-normal text-sm font-medium text-foreground/90
${props.anySelected ? 'cursor-default pointer-events-none' : ''}
`}
style={{
"field-sizing": "content",
"min-height": "1.5em"
}}
style={{ "field-sizing": "content", "min-height": "1.5em" }}
placeholder="Item description..."
/>
</div>
<div class="w-20 shrink-0 mt-1">
{/* Qty — w-20 */}
<div class="w-20 shrink-0">
<NumericInput
dataFieldName="qty"
value={props.item.quantity}
onUpdate={(val) => props.onUpdate(props.item.id, { quantity: val })}
onDragStart={(e) => {
const val = props.item.quantity;
const data = {
type: 'item-field',
itemId: props.item.id,
fieldName: 'qty',
value: val,
label: `${props.item.description || 'Unnamed Item'}: Qty`
};
const data = { type: 'item-field', itemId: props.item.id, fieldName: 'qty', value: val, label: `${props.item.description || 'Unnamed Item'}: Qty` };
e.dataTransfer!.setData('application/json', JSON.stringify(data));
e.dataTransfer!.setData('text/plain', String(val));
e.dataTransfer!.effectAllowed = 'copy';
@@ -134,9 +133,9 @@ const ItemRow: Component<ItemRowProps> = (props) => {
/>
</div>
<div class="w-24 shrink-0 mt-1">
<div class="relative">
<span class="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground/50 text-[10px]">$</span>
{/* Price — w-24 */}
<div class="w-24 shrink-0 relative">
<span class="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground/50 text-[10px] pointer-events-none">$</span>
<NumericInput
dataFieldName="price"
step="0.1"
@@ -144,13 +143,7 @@ const ItemRow: Component<ItemRowProps> = (props) => {
onUpdate={(val) => props.onUpdate(props.item.id, { unitPrice: val })}
onDragStart={(e) => {
const val = props.item.unitPrice;
const data = {
type: 'item-field',
itemId: props.item.id,
fieldName: 'price',
value: val,
label: `${props.item.description || 'Unnamed Item'}: Price`
};
const data = { type: 'item-field', itemId: props.item.id, fieldName: 'price', value: val, label: `${props.item.description || 'Unnamed Item'}: Price` };
e.dataTransfer!.setData('application/json', JSON.stringify(data));
e.dataTransfer!.setData('text/plain', String(val));
e.dataTransfer!.effectAllowed = 'copy';
@@ -162,100 +155,87 @@ const ItemRow: Component<ItemRowProps> = (props) => {
placeholder="Price"
/>
</div>
</div>
{/* Subtotal — w-24 */}
<div
draggable="true"
onDragStart={(e) => {
const val = baseTotal();
const data = {
type: 'item-field',
itemId: props.item.id,
fieldName: 'subtotal',
value: val,
label: `${props.item.description || 'Unnamed Item'}: Subtotal`
};
const data = { type: 'item-field', itemId: props.item.id, fieldName: 'subtotal', value: val, label: `${props.item.description || 'Unnamed Item'}: Subtotal` };
e.dataTransfer!.setData('application/json', JSON.stringify(data));
e.dataTransfer!.setData('text/plain', String(val));
e.dataTransfer!.effectAllowed = 'copy';
e.stopPropagation();
}}
class={`w-24 shrink-0 text-right text-muted-foreground/60 text-[11px] mt-2 font-bold uppercase tracking-tighter cursor-grab hover:text-primary transition-colors`}
class="w-24 shrink-0 text-right text-muted-foreground/60 text-[11px] font-bold uppercase tracking-tighter cursor-grab hover:text-primary transition-colors"
>
${formatNumber(baseTotal())}
</div>
{/* Markup — w-32 (conditional) */}
<Show when={props.isSidebarCollapsed() || !props.hideColumns}>
<div class="w-32 shrink-0 flex items-center gap-1.5 mt-1">
<div class="w-32 shrink-0">
<div class="flex items-center gap-1.5">
<NumericInput
dataFieldName="markup"
value={props.item.markup}
onUpdate={(val) => props.onUpdate(props.item.id, { markup: val })}
disabled={props.anySelected}
class="w-full bg-muted/30 border border-border/60 rounded-xl px-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-primary transition-all"
class="flex-1 min-w-0 bg-muted/30 border border-border/60 rounded-xl px-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-primary transition-all"
placeholder="Markup"
/>
<button
onClick={(e) => {
e.stopPropagation();
props.onUpdate(props.item.id, { markupType: props.item.markupType === 'percent' ? 'amount' : 'percent' });
}}
onClick={(e) => { e.stopPropagation(); props.onUpdate(props.item.id, { markupType: props.item.markupType === 'percent' ? 'amount' : 'percent' }); }}
disabled={props.anySelected}
class="text-[9px] font-black px-1.5 py-1.5 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary min-w-[24px] disabled:opacity-50 transition-colors border border-border/40"
>
{props.item.markupType === 'percent' ? '%' : '$'}
</button>
</div>
</div>
<div class="w-32 shrink-0 flex items-center gap-1.5 mt-1">
{/* Contingency — w-32 */}
<div class="w-32 shrink-0">
<div class="flex items-center gap-1.5">
<NumericInput
dataFieldName="contingency"
value={props.item.contingency}
onUpdate={(val) => props.onUpdate(props.item.id, { contingency: val })}
disabled={props.anySelected}
class="w-full bg-muted/30 border border-border/60 rounded-xl px-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-foreground/80 transition-all"
class="flex-1 min-w-0 bg-muted/30 border border-border/60 rounded-xl px-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-foreground/80 transition-all"
placeholder="Contingency"
/>
<button
onClick={(e) => {
e.stopPropagation();
props.onUpdate(props.item.id, { contingencyType: props.item.contingencyType === 'percent' ? 'amount' : 'percent' });
}}
onClick={(e) => { e.stopPropagation(); props.onUpdate(props.item.id, { contingencyType: props.item.contingencyType === 'percent' ? 'amount' : 'percent' }); }}
disabled={props.anySelected}
class="text-[9px] font-black px-1.5 py-1.5 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary min-w-[24px] disabled:opacity-50 transition-colors border border-border/40"
>
{props.item.contingencyType === 'percent' ? '%' : '$'}
</button>
</div>
</div>
</Show>
{/* Total — w-28 */}
<div
draggable="true"
onDragStart={(e) => {
const val = total();
const data = {
type: 'item-field',
itemId: props.item.id,
fieldName: 'total',
value: val,
label: `${props.item.description || 'Unnamed Item'}: Total`
};
const data = { type: 'item-field', itemId: props.item.id, fieldName: 'total', value: val, label: `${props.item.description || 'Unnamed Item'}: Total` };
e.dataTransfer!.setData('application/json', JSON.stringify(data));
e.dataTransfer!.setData('text/plain', String(val));
e.dataTransfer!.effectAllowed = 'copy';
e.stopPropagation();
}}
class={`w-28 shrink-0 text-right font-black text-sm mt-2 cursor-grab hover:text-primary transition-colors ${props.isSelected ? 'text-primary' : 'text-foreground'}`}
class={`w-28 shrink-0 text-right font-black text-sm cursor-grab hover:text-primary transition-colors ${props.isSelected ? 'text-primary' : 'text-foreground'}`}
>
${formatNumber(total())}
</div>
<div class="w-16 shrink-0 flex items-center justify-end gap-1.5 mt-1.5 opacity-0 group-hover:opacity-100 transition-opacity">
{/* Actions — w-16 */}
<div class="w-16 shrink-0 flex items-center justify-end gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity">
<button
onClick={(e) => {
e.stopPropagation();
props.onDuplicateItem(props.item.id);
}}
onClick={(e) => { e.stopPropagation(); props.onDuplicateItem(props.item.id); }}
class="text-muted-foreground/40 hover:text-primary transition-colors"
title="Duplicate Item"
>
@@ -263,12 +243,8 @@ const ItemRow: Component<ItemRowProps> = (props) => {
<Copy class="w-3 h-3" />
</div>
</button>
<button
onClick={(e) => {
e.stopPropagation();
props.onDelete(props.item.id);
}}
onClick={(e) => { e.stopPropagation(); props.onDelete(props.item.id); }}
class="text-muted-foreground/40 hover:text-destructive transition-colors"
title="Delete Item"
>
@@ -278,6 +254,88 @@ const ItemRow: Component<ItemRowProps> = (props) => {
</button>
</div>
</div>
{/* ── MOBILE LAYOUT ── (stacked card, shown below md) */}
<div class="md:hidden flex flex-col gap-3 p-3">
<div class="flex items-start gap-3">
{/* Grip */}
<div
draggable={!isEditing() || props.anySelected}
onDragStart={(e) => props.onDragStart(e, props.item.id)}
onClick={(e) => {
e.stopPropagation();
props.onToggleSelection(props.item.id, e.metaKey || e.ctrlKey, e.shiftKey);
}}
class={`cursor-grab shrink-0 w-4 mt-2 p-1 rounded hover:bg-muted transition-colors ${props.isSelected ? 'text-primary' : 'text-muted-foreground/30 hover:text-muted-foreground/60'}`}
>
<GripVertical class="w-4 h-4" />
</div>
{/* Description */}
<div class="flex-1 relative">
<textarea
value={localDescription()}
onFocus={() => { if (!props.anySelected) setIsEditing(true); }}
onBlur={handleBlur}
onInput={(e) => {
setLocalDescription(e.currentTarget.value);
if (!('fieldSizing' in document.documentElement.style)) {
e.currentTarget.style.height = 'auto';
e.currentTarget.style.height = e.currentTarget.scrollHeight + 'px';
}
}}
disabled={props.anySelected}
rows="1"
class="w-full bg-transparent border-b border-transparent hover:border-border/40 focus:border-primary outline-none py-1 transition-all resize-none block overflow-hidden align-top leading-normal text-base font-medium text-foreground/90"
style={{ "field-sizing": "content", "min-height": "1.5em" }}
placeholder="Item description..."
/>
</div>
{/* Mobile actions */}
<div class="flex items-center gap-1.5 mt-1">
<button onClick={(e) => { e.stopPropagation(); props.onDuplicateItem(props.item.id); }} class="text-muted-foreground/40 hover:text-primary transition-colors">
<div class="p-1 px-1.5 bg-muted rounded-lg border border-border/40 hover:bg-primary/10"><Copy class="w-3 h-3" /></div>
</button>
<button onClick={(e) => { e.stopPropagation(); props.onDelete(props.item.id); }} class="text-muted-foreground/40 hover:text-destructive transition-colors">
<div class="p-1 px-1.5 bg-muted rounded-lg border border-border/40 hover:bg-destructive/10"><Trash2 class="w-3 h-3" /></div>
</button>
</div>
</div>
{/* Numeric fields — wrapping grid on mobile */}
<div class="flex flex-wrap gap-3 pl-7">
<div class="w-20">
<div class="text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Qty</div>
<NumericInput value={props.item.quantity} onUpdate={(val) => props.onUpdate(props.item.id, { quantity: val })} disabled={props.anySelected} class="w-full bg-muted/30 border border-border/60 rounded-xl px-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-foreground/80 transition-all" placeholder="Qty" />
</div>
<div class="w-24">
<div class="text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Price</div>
<div class="relative">
<span class="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground/50 text-[10px]">$</span>
<NumericInput step="0.1" value={props.item.unitPrice} onUpdate={(val) => props.onUpdate(props.item.id, { unitPrice: val })} disabled={props.anySelected} class="w-full bg-muted/30 border border-border/60 rounded-xl pl-5 pr-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-foreground/80 transition-all" placeholder="Price" />
</div>
</div>
<Show when={props.isSidebarCollapsed() || !props.hideColumns}>
<div class="w-32">
<div class="text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Markup</div>
<div class="flex items-center gap-1.5">
<NumericInput value={props.item.markup} onUpdate={(val) => props.onUpdate(props.item.id, { markup: val })} disabled={props.anySelected} class="flex-1 min-w-0 bg-muted/30 border border-border/60 rounded-xl px-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-primary transition-all" placeholder="Markup" />
<button onClick={(e) => { e.stopPropagation(); props.onUpdate(props.item.id, { markupType: props.item.markupType === 'percent' ? 'amount' : 'percent' }); }} disabled={props.anySelected} class="text-[9px] font-black px-1.5 py-1.5 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary min-w-[24px] disabled:opacity-50 transition-colors border border-border/40">{props.item.markupType === 'percent' ? '%' : '$'}</button>
</div>
</div>
<div class="w-32">
<div class="text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Contingency</div>
<div class="flex items-center gap-1.5">
<NumericInput value={props.item.contingency} onUpdate={(val) => props.onUpdate(props.item.id, { contingency: val })} disabled={props.anySelected} class="flex-1 min-w-0 bg-muted/30 border border-border/60 rounded-xl px-2 py-1.5 text-xs text-right focus:bg-background focus:ring-2 focus:ring-primary/20 focus:border-primary outline-none disabled:opacity-50 font-bold text-foreground/80 transition-all" placeholder="Contingency" />
<button onClick={(e) => { e.stopPropagation(); props.onUpdate(props.item.id, { contingencyType: props.item.contingencyType === 'percent' ? 'amount' : 'percent' }); }} disabled={props.anySelected} class="text-[9px] font-black px-1.5 py-1.5 rounded-lg bg-muted text-muted-foreground hover:bg-primary/10 hover:text-primary min-w-[24px] disabled:opacity-50 transition-colors border border-border/40">{props.item.contingencyType === 'percent' ? '%' : '$'}</button>
</div>
</div>
</Show>
<div class="w-28">
<div class="text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Total</div>
<div class={`font-black text-sm text-right ${props.isSelected ? 'text-primary' : 'text-foreground'}`}>${formatNumber(total())}</div>
</div>
</div>
</div>
</div>
);
};
+16 -13
View File
@@ -7,6 +7,7 @@ import ItemRow from './ItemRow';
import SubScopeCard from './SubScopeCard';
import NoteEditor from './NoteEditor';
import LazyItem from './LazyItem';
import ScopeScaleWrapper from './ui/ScopeScaleWrapper';
interface ScopeCardProps {
scope: Scope;
@@ -200,14 +201,9 @@ const ScopeCard: Component<ScopeCardProps> = (props) => {
</div>
</Show>
<div
onClick={(e) => { if (e.target === e.currentTarget) props.onClearSelection(); }}
class="p-6 space-y-4 relative"
>
<Show when={scopeItems().length > 0}>
<div class="relative pb-4">
{/* Column Headers - Sticky, Square Top */}
<div class="sticky top-header z-20 bg-background/95 backdrop-blur-sm border-b border-border py-2 mb-2 hidden md:flex items-center gap-4 text-[10px] font-bold text-muted-foreground uppercase tracking-wider px-3 rounded-none">
<ScopeScaleWrapper>
{/* Sticky Column Headers */}
<div class="scope-sticky-header py-2 mb-2 hidden md:flex items-center gap-4 text-[10px] font-bold text-muted-foreground uppercase tracking-wider px-3">
<div class="w-4 shrink-0"></div> {/* Grip space */}
<div class="flex-1 min-w-[200px]">Description</div>
<div class="w-20 shrink-0 text-right">Qty</div>
@@ -221,8 +217,13 @@ const ScopeCard: Component<ScopeCardProps> = (props) => {
<div class="w-16 shrink-0"></div> {/* Action space */}
</div>
{/* Scope-level items */}
<div
onClick={(e) => { if (e.target === e.currentTarget) props.onClearSelection(); }}
class="px-3 pb-3 space-y-2"
>
<Show when={scopeItems().length > 0}>
<div class="grid gap-2">
{/* Scope Level Items */}
<For each={props.items.filter(i => !i.subScopeId)}>
{(item) => (
<LazyItem estimatedHeight={60}>
@@ -242,7 +243,6 @@ const ScopeCard: Component<ScopeCardProps> = (props) => {
)}
</For>
</div>
</div>
</Show>
<Show when={scopeItems().length === 0 && props.subScopes.length === 0}>
@@ -250,9 +250,10 @@ const ScopeCard: Component<ScopeCardProps> = (props) => {
Empty scope. Drag items here or add sub-scopes.
</div>
</Show>
</div>
{/* Sub-scopes */}
<div class="space-y-6 pt-4">
{/* Sub-scopes — rendered inside the same scale wrapper so they zoom together */}
<div class="px-3 pb-3 space-y-4">
<For each={props.subScopes}>
{(subScope) => (
<SubScopeCard
@@ -277,9 +278,11 @@ const ScopeCard: Component<ScopeCardProps> = (props) => {
)}
</For>
</div>
</ScopeScaleWrapper>
<div class="p-6 pt-4 space-y-4">
{/* Scope Extras & Totals */}
<div class="mt-8 pt-6 border-t border-border space-y-3">
<div class="mt-4 pt-6 border-t border-border space-y-3">
{/* Management Line */}
<div class="flex items-center justify-between group">
<div class="flex items-center gap-3">
+4 -2
View File
@@ -166,11 +166,11 @@ const SubScopeCard: Component<SubScopeCardProps> = (props) => {
<Show when={!isCollapsed()}>
<div
onClick={(e) => { if (e.target === e.currentTarget) props.onClearSelection(); }}
class="p-2 space-y-1.5 relative"
class="relative"
>
{/* SubScope Column Headers */}
<Show when={props.items.length > 0}>
<div class="sticky top-header z-20 bg-background/95 backdrop-blur-sm hidden md:flex items-center gap-4 text-[9px] font-bold text-muted-foreground/60 uppercase tracking-wider px-3 pb-2 pt-1 mb-2 border-b border-border/40">
<div class="scope-sticky-header py-2 mb-2 hidden md:flex items-center gap-4 text-[9px] font-bold text-muted-foreground/60 uppercase tracking-wider px-3">
<div class="w-4 shrink-0"></div>
<div class="flex-1 min-w-[200px]">Description</div>
<div class="w-20 shrink-0 text-right">Qty</div>
@@ -185,6 +185,7 @@ const SubScopeCard: Component<SubScopeCardProps> = (props) => {
</div>
</Show>
<div class="px-3 pb-3 space-y-1.5">
<For each={props.items}>
{(item) => (
<LazyItem estimatedHeight={60}>
@@ -209,6 +210,7 @@ const SubScopeCard: Component<SubScopeCardProps> = (props) => {
</div>
</Show>
</div>
</div>
</Show>
</div>
);
@@ -1,6 +1,6 @@
import { createSignal, onCleanup, Show } from 'solid-js';
import type { Component } from 'solid-js';
import { PanelLeftOpen, PanelLeftClose, Calculator, Plus, Upload, Table, Download, History, Save, ChevronDown, MoreHorizontal } from 'lucide-solid';
import { Calculator, Plus, Upload, Table, Download, History, Save, ChevronDown, MoreHorizontal } from 'lucide-solid';
import { appStore } from '../../store/appStore';
interface BuilderHeaderProps {
@@ -34,13 +34,6 @@ export const BuilderHeader: Component<BuilderHeaderProps> = (props) => {
return (
<div class="min-h-[4rem] py-3 px-6 border-b border-border bg-background/50 flex flex-wrap gap-y-4 items-center justify-between sticky top-0 z-50 backdrop-blur-md">
<div class="flex items-center gap-4">
<button
onClick={props.onToggleSidebar}
class="p-2 hover:bg-accent rounded-xl transition-colors text-muted-foreground shrink-0"
title={props.isSidebarCollapsed ? "Expand Sidebar" : "Collapse Sidebar"}
>
{props.isSidebarCollapsed ? <PanelLeftOpen class="w-5 h-5" /> : <PanelLeftClose class="w-5 h-5" />}
</button>
<div class="flex items-center gap-3">
<div class="p-2 bg-primary rounded-xl text-primary-foreground shadow-md shadow-primary/20 shrink-0">
<Calculator class="w-5 h-5" />
@@ -1,11 +1,12 @@
import type { Component } from 'solid-js';
import { For } from 'solid-js';
import { Plus, ListTree, ChevronRight } from 'lucide-solid';
import { Plus, ListTree, ChevronRight, PanelLeftOpen, PanelLeftClose } from 'lucide-solid';
import { appStore } from '../../store/appStore';
import type { EstimateItem } from '../../types';
interface BuilderSidebarProps {
isCollapsed: boolean;
onToggleSidebar: () => void;
unassignedItems: EstimateItem[];
grandTotals: { grandTotal: number };
hoveredScopeId: string | null;
@@ -22,14 +23,45 @@ export const BuilderSidebar: Component<BuilderSidebarProps> = (props) => {
};
return (
/*
* The sidebar sits inside a CSS grid column (in EstimateBuilder.tsx).
* We use overflow-visible on the aside so the toggle button can remain
* visible and clickable even when the grid column width is 0px.
*/
<aside
class={`h-[calc(100vh-var(--spacing-header))] sticky top-header bg-background border-r border-border flex flex-col transition-all duration-500 ease-in-out relative group/sidebar
${props.isCollapsed ? 'w-0 opacity-0 -translate-x-full overflow-hidden' : 'w-72 opacity-100'}`}
class="h-[calc(100vh-var(--spacing-header))] sticky top-[var(--spacing-header)] bg-background border-r border-border flex flex-col overflow-visible z-40 transition-colors"
style={{ "min-width": 0 }}
>
<div class="flex-1 overflow-y-auto px-4 py-8">
{/*
* Sticky Toggle Button
* Anchored to the right edge (100% width) of the sidebar column.
* As the column width animates, the button follows perfectly.
* We use translateX to adjust horizontal offset from the edge.
*/}
<button
onClick={props.onToggleSidebar}
class="absolute top-4 z-50 w-10 h-10 bg-background hover:bg-accent rounded-xl transition-all duration-500 ease-in-out shadow-premium border border-border text-muted-foreground hover:text-primary active:scale-95 flex items-center justify-center cursor-pointer"
style={{
left: '100%',
transform: props.isCollapsed
? 'translateX(1.25rem)' // When closed (0px width), sit 20px off the left edge
: 'translateX(-0.5rem)' // When open, hang 80% out to the right (overlap only 8px)
}}
title={props.isCollapsed ? "Expand Sidebar" : "Collapse Sidebar"}
>
{props.isCollapsed ? <PanelLeftOpen class="w-5 h-5" /> : <PanelLeftClose class="w-5 h-5" />}
</button>
{/*
* Sidebar Content Wrapper
* We apply the overflow-hidden here so the content doesn't leak out
* when the grid column is 0px.
*/}
<div class={`flex-1 overflow-y-auto overflow-x-hidden transition-all duration-500 flex flex-col ${props.isCollapsed ? 'w-0 opacity-0 pointer-events-none' : 'w-72 opacity-100'}`}>
<div class="flex-1 px-4 py-8">
<div class="mb-4">
<div class="flex items-center justify-between mb-4 px-2">
<span class="text-[10px] font-black text-muted-foreground uppercase tracking-[0.2em]">Estimate Navigator</span>
<span class="text-[10px] font-black text-muted-foreground uppercase tracking-[0.2em] whitespace-nowrap">Estimate Navigator</span>
<button
onClick={props.onAddScope}
class="p-1.5 bg-muted hover:bg-primary/10 text-muted-foreground hover:text-primary rounded-lg transition-all"
@@ -53,18 +85,15 @@ export const BuilderSidebar: Component<BuilderSidebarProps> = (props) => {
const headerOffset = 180;
const elementPosition = el.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
window.scrollTo({ top: offsetPosition, behavior: 'smooth' });
}
}}
class={`group flex items-center justify-between px-3 py-3 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer border-2 ${props.hoveredScopeId === 'unassigned' ? 'bg-primary/10 border-primary scale-[1.02] shadow-premium-lg shadow-primary/10 text-primary' : (props.unassignedItems.length > 0 ? 'bg-muted/30 text-foreground border-border/50 hover:bg-muted/50' : 'text-muted-foreground border-transparent hover:bg-accent')}`}
class={`group flex items-center justify-between px-3 py-3 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer border-2 ${props.hoveredScopeId === 'unassigned' ? 'bg-primary/10 border-primary scale-[1.02] shadow-premium text-primary' : (props.unassignedItems.length > 0 ? 'bg-muted/30 text-foreground border-border/50 hover:bg-muted/50' : 'text-muted-foreground border-transparent hover:bg-accent')}`}
>
<span class="flex items-center gap-2">
<ListTree class="w-4 h-4" /> Unassigned
<span class="flex items-center gap-2 whitespace-nowrap">
<ListTree class="w-4 h-4 shrink-0" /> Unassigned
</span>
<span class={`px-2 py-0.5 rounded-lg text-[10px] font-black border transition-colors ${props.hoveredScopeId === 'unassigned' ? 'bg-primary text-primary-foreground border-primary' : 'bg-background text-primary border-border'}`}>
<span class={`px-2 py-0.5 rounded-lg text-[10px] font-black border transition-colors shrink-0 ${props.hoveredScopeId === 'unassigned' ? 'bg-primary text-primary-foreground border-primary' : 'bg-background text-primary border-border'}`}>
{props.unassignedItems.length}
</span>
</div>
@@ -76,28 +105,22 @@ export const BuilderSidebar: Component<BuilderSidebarProps> = (props) => {
{(scope) => (
<div class="space-y-1">
<div
onDragOver={(e) => {
e.preventDefault();
props.setHoveredScopeId(scope.id);
}}
onDragOver={(e) => { e.preventDefault(); props.setHoveredScopeId(scope.id); }}
onDragLeave={() => props.setHoveredScopeId(null)}
onDrop={(e) => props.onDrop(e, scope.id)}
class={`group flex items-center justify-between px-4 py-3 rounded-xl text-sm font-bold transition-all cursor-pointer border-2 ${props.hoveredScopeId === scope.id ? 'bg-primary/10 border-primary scale-[1.02] shadow-premium-lg shadow-primary/10 text-primary-foreground' : 'text-muted-foreground border-transparent hover:bg-card hover:shadow-premium hover:border-border'}`}
class={`group flex items-center justify-between px-4 py-3 rounded-xl text-sm font-bold transition-all cursor-pointer border-2 ${props.hoveredScopeId === scope.id ? 'bg-primary/10 border-primary scale-[1.02] shadow-premium text-primary' : 'text-muted-foreground border-transparent hover:bg-card hover:shadow-premium hover:border-border'}`}
onClick={() => {
const el = document.getElementById(`scope-${scope.id}`);
if (el) {
const headerOffset = 180;
const elementPosition = el.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
window.scrollTo({ top: offsetPosition, behavior: 'smooth' });
}
}}
>
<span class="truncate pr-2">{scope.name}</span>
<div class="flex items-center gap-2">
<div class="flex items-center gap-2 shrink-0">
<span class={`px-2 py-0.5 rounded-lg text-[10px] font-black border transition-colors ${props.hoveredScopeId === scope.id ? 'bg-primary text-primary-foreground border-primary' : 'bg-muted text-muted-foreground border-border'}`}>
{items.filter(i => i.scopeId === scope.id).length}
</span>
@@ -110,16 +133,9 @@ export const BuilderSidebar: Component<BuilderSidebarProps> = (props) => {
<For each={subScopes.filter(ss => ss.scopeId === scope.id)}>
{(subScope) => (
<div
onDragOver={(e) => {
e.preventDefault();
e.stopPropagation();
props.setHoveredScopeId(subScope.id);
}}
onDragOver={(e) => { e.preventDefault(); e.stopPropagation(); props.setHoveredScopeId(subScope.id); }}
onDragLeave={() => props.setHoveredScopeId(null)}
onDrop={(e) => {
e.stopPropagation();
props.onDrop(e, scope.id, subScope.id);
}}
onDrop={(e) => { e.stopPropagation(); props.onDrop(e, scope.id, subScope.id); }}
onClick={(e) => {
e.stopPropagation();
const el = document.getElementById(`subscope-${subScope.id}`);
@@ -127,16 +143,13 @@ export const BuilderSidebar: Component<BuilderSidebarProps> = (props) => {
const headerOffset = 180;
const elementPosition = el.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
window.scrollTo({ top: offsetPosition, behavior: 'smooth' });
}
}}
class={`flex items-center justify-between px-3 py-1.5 rounded-lg text-[11px] font-black uppercase tracking-wider transition-all cursor-pointer border ${props.hoveredScopeId === subScope.id ? 'bg-primary/5 border-primary/30 text-primary scale-[1.02]' : 'text-muted-foreground/60 border-transparent hover:bg-muted hover:text-foreground'}`}
>
<span class="truncate">{subScope.name}</span>
<span class="text-[10px] opacity-60 font-medium">
<span class="text-[10px] opacity-60 font-medium shrink-0">
{items.filter(i => i.subScopeId === subScope.id).length}
</span>
</div>
@@ -150,13 +163,14 @@ export const BuilderSidebar: Component<BuilderSidebarProps> = (props) => {
</div>
{/* Sidebar Footer */}
<div class="p-4 border-t border-border bg-muted/30">
<div class="p-4 border-t border-border bg-muted/30 rounded-2xl mt-4">
<div class="bg-card rounded-2xl p-4 border border-border shadow-sm">
<div class="text-[10px] font-black text-muted-foreground uppercase tracking-widest mb-1">Current Total</div>
<div class="text-[10px] font-black text-muted-foreground uppercase tracking-widest mb-1 whitespace-nowrap">Current Total</div>
<div class="text-xl font-black text-foreground">${formatNumber(props.grandTotals.grandTotal)}</div>
</div>
</div>
</div>
</div>
</aside>
);
};
@@ -43,9 +43,13 @@ export const UnassignedItemsSection: Component<UnassignedItemsSectionProps> = (p
{props.unassignedItems.length} Items Pending
</span>
</div>
<div class="relative pb-4">
<div
onClick={(e) => { if (e.target === e.currentTarget) props.clearSelection(e); }}
class="relative overflow-x-auto min-w-0 px-6"
>
<div class="min-w-full md:min-w-max flex flex-col items-stretch pb-4">
{/* Sticky Column Headers for Unassigned */}
<div class="sticky top-header z-10 bg-background/95 backdrop-blur-sm border-b border-border py-3 mb-4 hidden md:flex items-center gap-4 text-[10px] font-black text-muted-foreground/60 uppercase tracking-[0.2em] px-3">
<div class="sticky top-0 z-10 bg-background/95 backdrop-blur-sm border-b border-border py-3 mb-4 hidden md:flex items-center gap-4 text-[10px] font-black text-muted-foreground/60 uppercase tracking-[0.2em] px-3">
<div class="w-4 shrink-0"></div>
<div class="flex-1 min-w-[200px]">Description</div>
<div class="w-20 shrink-0 text-right">Qty</div>
@@ -81,6 +85,7 @@ export const UnassignedItemsSection: Component<UnassignedItemsSectionProps> = (p
</div>
</div>
</div>
</div>
</Show>
);
};
+38 -8
View File
@@ -30,13 +30,14 @@ const TemplateItemRow: Component<TemplateItemRowProps> = (props) => {
};
return (
<div class={`group flex items-start gap-4 p-3 border transition-all animate-in fade-in slide-in-from-left-2 rounded-2xl bg-card border-border hover:shadow-premium-hover hover:border-border/80 ${isEditing() ? 'ring-1 ring-primary/20 shadow-premium border-primary/30' : ''}`}>
<div class={`group flex flex-col md:flex-row items-stretch md:items-start gap-3 md:gap-4 p-3 border transition-all animate-in fade-in slide-in-from-left-2 rounded-2xl bg-card border-border hover:shadow-premium-hover hover:border-border/80 ${isEditing() ? 'ring-1 ring-primary/20 shadow-premium border-primary/30' : ''}`}>
<div class="cursor-grab transition-colors shrink-0 w-4 mt-2 p-1 -m-1 rounded hover:bg-muted text-muted-foreground/30 hover:text-muted-foreground/60" title="Drag to reorder (Coming soon)">
<div class="flex items-start gap-3">
<div class="cursor-grab transition-colors shrink-0 w-4 mt-2 p-1 rounded hover:bg-muted text-muted-foreground/30 hover:text-muted-foreground/60" title="Drag to reorder (Coming soon)">
<GripVertical class="w-4 h-4" />
</div>
<div class="flex-1 relative">
<div class="flex-1 relative min-w-[200px]">
<textarea
ref={descriptionRef}
value={localDescription()}
@@ -56,7 +57,25 @@ const TemplateItemRow: Component<TemplateItemRowProps> = (props) => {
/>
</div>
<div class="w-24 shrink-0 mt-1">
{/* Mobile Actions Container */}
<div class="flex md:hidden items-center gap-1.5 mt-1.5 px-1">
<button
onClick={() => props.onDelete(props.item.id)}
class="text-muted-foreground/40 hover:text-destructive transition-colors"
title="Delete Item"
>
<div class="p-1 px-1.5 bg-muted rounded-lg border border-border/40 hover:bg-destructive/10">
<Trash2 class="w-3 h-3" />
</div>
</button>
</div>
</div>
{/* Numeric Fields Group */}
<div class="flex flex-wrap md:flex-nowrap items-center gap-3 md:gap-4 pl-7 md:pl-0">
<div class="flex items-center gap-2">
<div class="w-24 shrink-0">
<div class="md:hidden text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Qty</div>
<NumericInput
value={props.item.quantity}
onUpdate={(val) => props.onUpdate(props.item.id, { quantity: val })}
@@ -65,7 +84,8 @@ const TemplateItemRow: Component<TemplateItemRowProps> = (props) => {
/>
</div>
<div class="w-32 shrink-0 mt-1">
<div class="w-32 shrink-0">
<div class="md:hidden text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Price</div>
<div class="relative">
<span class="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground/50 text-[10px]">$</span>
<NumericInput
@@ -77,8 +97,12 @@ const TemplateItemRow: Component<TemplateItemRowProps> = (props) => {
/>
</div>
</div>
</div>
<div class="w-28 shrink-0 flex items-center gap-1.5 mt-1">
<div class="flex items-center gap-2">
<div class="w-28 shrink-0">
<div class="md:hidden text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Markup</div>
<div class="flex items-center gap-1.5">
<NumericInput
value={props.item.markup}
onUpdate={(val) => props.onUpdate(props.item.id, { markup: val })}
@@ -92,8 +116,11 @@ const TemplateItemRow: Component<TemplateItemRowProps> = (props) => {
{props.item.markupType === 'percent' ? '%' : '$'}
</button>
</div>
</div>
<div class="w-28 shrink-0 flex items-center gap-1.5 mt-1">
<div class="w-28 shrink-0">
<div class="md:hidden text-[9px] font-bold text-muted-foreground/60 uppercase mb-1 ml-1">Cont</div>
<div class="flex items-center gap-1.5">
<NumericInput
value={props.item.contingency}
onUpdate={(val) => props.onUpdate(props.item.id, { contingency: val })}
@@ -107,8 +134,10 @@ const TemplateItemRow: Component<TemplateItemRowProps> = (props) => {
{props.item.contingencyType === 'percent' ? '%' : '$'}
</button>
</div>
</div>
</div>
<div class="w-10 shrink-0 flex items-center justify-end gap-1.5 mt-1.5 opacity-0 group-hover:opacity-100 transition-opacity">
<div class="hidden md:flex w-10 shrink-0 items-center justify-end gap-1.5 mt-1.5 opacity-0 group-hover:opacity-100 transition-opacity">
<button
onClick={() => props.onDelete(props.item.id)}
class="text-muted-foreground/40 hover:text-destructive transition-colors"
@@ -120,6 +149,7 @@ const TemplateItemRow: Component<TemplateItemRowProps> = (props) => {
</button>
</div>
</div>
</div>
);
};
+104
View File
@@ -0,0 +1,104 @@
/**
* ScopeScaleWrapper
*
* Wraps a scope's items/header block so that on narrow screens the
* whole thing scales down as a unit rather than overflowing.
*
* Critical CSS behaviour used here:
*
* overflow: clip
* Clips the inner element at the outer's edges identical to
* `overflow: hidden` visually, BUT does NOT create a scroll
* container. This matters because `position: sticky` elements
* inside reference the nearest scroll container ancestor. With
* `overflow: hidden` that would be this element (which doesn't
* scroll sticky breaks). With `overflow: clip` there is no
* new scroll container sticky still references the page.
*
* transform: scale() + transform-origin: top left
* Visually shrinks the inner block. Layout size is unaffected
* (transform never changes layout). We compensate by setting
* the outer div's explicit height = naturalHeight × scale, and
* clipping with overflow: clip.
*/
import type { Component, JSX } from 'solid-js';
import { onMount, onCleanup } from 'solid-js';
interface ScopeScaleWrapperProps {
children: JSX.Element;
class?: string;
/** Minimum scale factor — won't zoom below this. Default: 0.65 */
minScale?: number;
}
const ScopeScaleWrapper: Component<ScopeScaleWrapperProps> = (props) => {
let outerEl: HTMLDivElement | undefined;
let innerEl: HTMLDivElement | undefined;
const recalculate = () => {
if (!outerEl || !innerEl) return;
const minScale = props.minScale ?? 0.65;
// ── Step 1: measure the inner's TRUE natural width ───────────────
// Must set max-content BEFORE measuring — if width is unset the
// element stretches to fill the parent, making scrollWidth == outerWidth
// and we'd never think scaling is needed.
innerEl.style.width = 'max-content';
innerEl.style.transform = 'none';
outerEl.style.height = '';
outerEl.style.overflow = '';
void outerEl.offsetWidth; // force reflow
const naturalWidth = innerEl.scrollWidth;
const naturalHeight = innerEl.scrollHeight;
const outerWidth = outerEl.clientWidth;
if (naturalWidth <= outerWidth) {
// ── Fits naturally — fill available width, no clip/scale ──────
innerEl.style.width = '100%';
innerEl.style.transform = '';
outerEl.style.height = '';
outerEl.style.overflow = '';
} else {
// ── Too wide — scale down ─────────────────────────────────────
const rawScale = outerWidth / naturalWidth;
const newScale = Math.max(minScale, rawScale);
// Fix inner to its natural pixel width so transform-origin math
// is reliable, then scale from the top-left corner
innerEl.style.width = `${naturalWidth}px`;
innerEl.style.transformOrigin = 'top left';
innerEl.style.transform = `scale(${newScale})`;
// Set outer height to visual (post-scale) height so no dead space
// appears below the scaled block
outerEl.style.height = `${naturalHeight * newScale}px`;
// overflow: clip — clips layout overflow WITHOUT creating a scroll
// container, so position:sticky inside still works against the page
outerEl.style.overflow = 'clip';
}
};
let ro: ResizeObserver;
onMount(() => {
ro = new ResizeObserver(recalculate);
if (outerEl) ro.observe(outerEl);
if (innerEl) ro.observe(innerEl);
recalculate();
});
onCleanup(() => ro?.disconnect());
return (
<div ref={outerEl} class={`relative ${props.class ?? ''}`}>
<div ref={innerEl}>
{props.children}
</div>
</div>
);
};
export default ScopeScaleWrapper;
+26
View File
@@ -105,3 +105,29 @@
@apply hidden;
}
}
/* =========================================================
Scope Sticky Header
A shared class for scope and sub-scope column headers.
position:sticky works inside the ScopeScaleWrapper because
the outer container has overflow-y:visible.
========================================================= */
.scope-sticky-header {
position: sticky;
top: 0;
z-index: 20;
background: hsl(0 0% 100% / 0.97);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
border-bottom: 1px solid hsl(240 5.9% 90%);
}
/* shadow-premium custom utility */
.shadow-premium {
box-shadow: var(--shadow-premium);
}
.shadow-premium-hover:hover {
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.07), 0 8px 10px -6px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
}