Skip to content

Commit c3e5258

Browse files
committed
feat(app): changes view
1 parent 2badfcd commit c3e5258

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

packages/app/src/components/file-tree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function FileTree(props: {
1818
<Dynamic
1919
component={p.as ?? "div"}
2020
classList={{
21-
"p-0.5 w-full flex items-center gap-x-2 hover:bg-background-panel cursor-pointer": true,
21+
"p-0.5 w-full flex items-center gap-x-2 hover:bg-background-element cursor-pointer": true,
2222
"bg-background-element": local.file.active()?.path === p.node.path,
2323
[props.nodeClass ?? ""]: !!props.nodeClass,
2424
}}

packages/app/src/context/local.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function init() {
163163
})
164164
}
165165

166-
const open = async (path: string, options?: { pin?: boolean }) => {
166+
const open = async (path: string, options?: { pinned?: boolean; view?: LocalFile["view"] }) => {
167167
const relative = path.replace(sync.data.path.directory + "/", "")
168168
if (!store.node[relative]) {
169169
const parent = relative.split("/").slice(0, -1).join("/")
@@ -181,7 +181,8 @@ function init() {
181181
]
182182
})
183183
setStore("active", relative)
184-
if (options?.pin) setStore("node", path, "pinned", true)
184+
if (options?.pinned) setStore("node", path, "pinned", true)
185+
if (options?.view && store.node[relative].view === undefined) setStore("node", path, "view", options.view)
185186
if (store.node[relative].loaded) return
186187
return load(relative)
187188
}
@@ -297,6 +298,7 @@ function init() {
297298
setStore("node", path, "selectedChange", index)
298299
},
299300
changed,
301+
changes,
300302
status,
301303
children(path: string) {
302304
return Object.values(store.node).filter(

packages/app/src/pages/index.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,26 @@ export default function Page() {
259259
<FileTree path="" onFileClick={handleFileClick} />
260260
</Tabs.Content>
261261
<Tabs.Content value="changes" class="grow min-h-0 py-2 bg-background">
262-
<div class="px-2 text-xs text-text-muted">No changes yet</div>
262+
<div class="text-xs text-text-muted">
263+
<ul class="">
264+
<For each={[...local.file.changes()]}>
265+
{(path) => (
266+
<li>
267+
<button
268+
onClick={() => local.file.open(path, { view: "diff-unified", pinned: true })}
269+
class="w-full flex items-center px-2 py-0.5 gap-x-2 text-text-muted grow min-w-0 cursor-pointer hover:bg-background-element"
270+
>
271+
<FileIcon node={{ path, type: "file" }} class="shrink-0 size-3" />
272+
<span class="text-xs text-text whitespace-nowrap">{getFilename(path)}</span>
273+
<span class="text-xs text-text-muted/60 whitespace-nowrap truncate min-w-0">
274+
{getDirectory(path)}
275+
</span>
276+
</button>
277+
</li>
278+
)}
279+
</For>
280+
</ul>
281+
</div>
263282
</Tabs.Content>
264283
</Tabs>
265284
</div>
@@ -579,7 +598,7 @@ export default function Page() {
579598
</div>
580599
)}
581600
onClose={() => setStore("fileSelectOpen", false)}
582-
onSelect={(x) => (x ? local.file.open(x, { pin: true }) : undefined)}
601+
onSelect={(x) => (x ? local.file.open(x, { pinned: true }) : undefined)}
583602
/>
584603
</Show>
585604
</div>

0 commit comments

Comments
 (0)