-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tabs to the V3 workspace page
- Loading branch information
Showing
6 changed files
with
111 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script lang="ts"> | ||
import { DesktopRedux } from '$lib/redux/store.svelte'; | ||
import { StackService } from '$lib/stacks/stackService.svelte'; | ||
import { stacksToTabs } from '$lib/tabs/mapping'; | ||
import { getContext } from '@gitbutler/shared/context'; | ||
type Props = { | ||
projectId: string; | ||
selectedId: string | undefined; | ||
}; | ||
const { projectId, selectedId }: Props = $props(); | ||
const stackService = getContext(StackService); | ||
const redux = getContext(DesktopRedux); | ||
const { data: stacks } = $derived(stackService.select(projectId)(redux.rootState$)); | ||
const tabs = $derived(stacksToTabs(stacks)); | ||
stackService.poll(projectId); | ||
</script> | ||
|
||
<div class="tabs"> | ||
{#each tabs as tab, i (tab.name)} | ||
{@const first = i === 0} | ||
{@const last = i === tabs.length - 1} | ||
<div class="tab" class:first class:last class:selected={tab.id === selectedId}> | ||
{tab.name} | ||
</div> | ||
{/each} | ||
<button type="button" class="new-stack" onclick={() => stackService.new(projectId)}>+</button> | ||
</div> | ||
|
||
<style lang="postcss"> | ||
.tabs { | ||
display: flex; | ||
} | ||
.tab { | ||
padding: 12px 14px; | ||
background: var(--clr-stack-tab-inactive); | ||
border: 1px solid var(--clr-border-2); | ||
border-right: none; | ||
border-bottom: none; | ||
&.first { | ||
border-radius: 10px 0 0 0; | ||
} | ||
} | ||
.new-stack { | ||
border: 1px solid var(--clr-border-2); | ||
border-bottom: none; | ||
border-radius: 0 10px 0 0; | ||
padding: 14px 20px; | ||
} | ||
.selected { | ||
background-color: cadetblue; | ||
background: var(--clr-stack-tab-active); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { Stack } from '$lib/stacks/stack'; | ||
import type { Tab } from './tab'; | ||
|
||
export function stacksToTabs(stacks: Stack[] | undefined): Tab[] { | ||
if (!stacks) { | ||
return []; | ||
} | ||
return stacks.map((stack) => { | ||
return { | ||
id: stack.id, | ||
name: stack.branchNames[0] || 'new branch', | ||
anchors: stack.branchNames.slice(1) | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type Tab = { | ||
id: string; | ||
name: string; | ||
anchors: string[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters