fix(app): align filetree change styling

This commit is contained in:
David Hill
2026-01-27 16:59:07 +00:00
parent d15201d11d
commit 18d6c2191c

View File

@@ -71,9 +71,11 @@ export default function FileTree(props: {
const marks = createMemo(() => { const marks = createMemo(() => {
if (props._marks) return props._marks if (props._marks) return props._marks
const modified = props.modified ?? (props.kinds ? Array.from(props.kinds.keys()) : undefined) const out = new Set<string>()
if (!modified || modified.length === 0) return for (const item of props.modified ?? []) out.add(item)
return new Set(modified) for (const item of props.kinds?.keys() ?? []) out.add(item)
if (out.size === 0) return
return out
}) })
const kinds = createMemo(() => { const kinds = createMemo(() => {
@@ -146,7 +148,7 @@ export default function FileTree(props: {
<Dynamic <Dynamic
component={local.as ?? "div"} component={local.as ?? "div"}
classList={{ classList={{
"w-full min-w-0 h-6 flex items-center justify-start gap-x-1.5 rounded-md px-2 py-0 text-left hover:bg-surface-raised-base-hover active:bg-surface-base-active transition-colors cursor-pointer": true, "w-full min-w-0 h-6 flex items-center justify-start gap-x-1.5 rounded-md px-[7px] py-0 text-left hover:bg-surface-raised-base-hover active:bg-surface-base-active transition-colors cursor-pointer": true,
...(local.classList ?? {}), ...(local.classList ?? {}),
[local.class ?? ""]: !!local.class, [local.class ?? ""]: !!local.class,
[props.nodeClass ?? ""]: !!props.nodeClass, [props.nodeClass ?? ""]: !!props.nodeClass,
@@ -180,35 +182,64 @@ export default function FileTree(props: {
{...rest} {...rest}
> >
{local.children} {local.children}
<span
classList={{
"flex-1 min-w-0 text-12-medium whitespace-nowrap truncate": true,
"text-text-weaker": local.node.ignored,
"text-text-weak": !local.node.ignored,
}}
>
{local.node.name}
</span>
{(() => { {(() => {
if (local.node.type !== "file") return null const kind = kinds()?.get(local.node.path)
const marked = marks()?.has(local.node.path) ?? false
const active = !!kind && marked && !local.node.ignored
const color =
kind === "add"
? "color: var(--icon-diff-add-base)"
: kind === "del"
? "color: var(--icon-diff-delete-base)"
: kind === "mix"
? "color: var(--icon-diff-modified-base)"
: undefined
return (
<span
classList={{
"flex-1 min-w-0 text-12-medium whitespace-nowrap truncate": true,
"text-text-weaker": local.node.ignored,
"text-text-weak": !local.node.ignored && !active,
}}
style={active ? color : undefined}
>
{local.node.name}
</span>
)
})()}
{(() => {
const kind = kinds()?.get(local.node.path)
if (!kind) return null
if (!marks()?.has(local.node.path)) return null if (!marks()?.has(local.node.path)) return null
const kind = kinds()?.get(local.node.path) if (local.node.type === "file") {
return ( const text = kind === "add" ? "A" : kind === "del" ? "D" : "M"
<div const color =
classList={{ kind === "add"
"shrink-0 size-1.5 rounded-full": true, ? "color: var(--icon-diff-add-base)"
"bg-surface-warning-strong": !kind || kind === "mix", : kind === "del"
}} ? "color: var(--icon-diff-delete-base)"
style={ : "color: var(--icon-diff-modified-base)"
kind === "add"
? "background-color: var(--icon-diff-add-base)" return (
: kind === "del" <span class="shrink-0 w-4 text-center text-12-medium" style={color}>
? "background-color: var(--icon-diff-delete-base)" {text}
: undefined </span>
} )
/> }
)
if (local.node.type === "directory") {
const color =
kind === "add"
? "background-color: var(--icon-diff-add-base)"
: kind === "del"
? "background-color: var(--icon-diff-delete-base)"
: "background-color: var(--icon-diff-modified-base)"
return <div class="shrink-0 size-1.5 mr-1.5 rounded-full" style={color} />
}
return null
})()} })()}
</Dynamic> </Dynamic>
) )
@@ -228,9 +259,8 @@ export default function FileTree(props: {
const head = parts.slice(0, -1).join("/") const head = parts.slice(0, -1).join("/")
const prefix = head ? `${head}/` : "" const prefix = head ? `${head}/` : ""
const kind = () => (node.type === "file" ? kinds()?.get(node.path) : undefined) const kind = () => kinds()?.get(node.path)
const label = () => { const label = () => {
if (!marks()?.has(node.path)) return
const k = kind() const k = kind()
if (!k) return if (!k) return
if (k === "add") return "Additions" if (k === "add") return "Additions"
@@ -238,6 +268,8 @@ export default function FileTree(props: {
return "Modifications" return "Modifications"
} }
const ignored = () => node.type === "directory" && node.ignored
return ( return (
<Tooltip <Tooltip
forceMount={false} forceMount={false}
@@ -262,6 +294,12 @@ export default function FileTree(props: {
</> </>
)} )}
</Show> </Show>
<Show when={ignored()}>
<>
<span class="mx-1 font-bold text-text-invert-strong"></span>
<span class="shrink-0 text-text-invert-weak">Ignored</span>
</>
</Show>
</div> </div>
} }
> >