Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions apps/desktop/src/components/ReduxResult.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
result: Result<A> | undefined;
projectId: string;
children: Snippet<[A, Env<B>]>;
loading?: Snippet<[]>;
error?: Snippet<[unknown]>;
onerror?: (err: unknown) => void;
} & (B extends undefined ? { stackId?: B } : { stackId: B });
Expand Down Expand Up @@ -77,19 +78,26 @@
{#if props.error}
{@render props.error(display.result.error)}
{/if}
{:else if display.result?.status === 'pending' || display.result?.status === 'uninitialized'}
{#if props.loading}
{@render props.loading()}
{:else}
<div class="text-12 loading-spinner">
<Icon name="spinner" />
<span>{display.result?.status}</span>
</div>
{/if}
{:else if display.result?.data !== undefined}
{@render props.children(display.result.data, display.env)}
{:else if display.result?.status === 'pending'}
<div class="loading-spinner">
<Icon name="spinner" />
</div>
{:else if display.result?.status === 'uninitialized'}
Uninitialized...
{/if}

<style>
.loading-spinner {
display: flex;
align-items: center;
gap: 8px;
z-index: var(--z-lifted);
position: relative;
color: var(--clr-text-2);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { StackService } from '$lib/stacks/stackService.svelte';
import { UiState } from '$lib/state/uiState.svelte';
import { inject } from '@gitbutler/shared/context';
import { preventTransitionOnMount } from '@gitbutler/ui/utils/preventTransitionOnMount';

interface Props {
projectId: string;
Expand All @@ -20,14 +21,13 @@
{#snippet overlay({ hovered, activated })}
<div class="hidden-dropzone__lane" class:activated class:hovered>
<div class="hidden-dropzone__content">
<div>
<div use:preventTransitionOnMount class="hidden-dropzone__svg">
<svg
xmlns="http://www.w3.org/2000/svg"
width="72"
height="97"
viewBox="0 0 72 97"
fill="none"
class="hidden-dropzone__svg"
>
<g class="hidden-dropzone__svg__plus-list">
<path
Expand Down Expand Up @@ -75,7 +75,7 @@
</svg>
</div>

<p class="hidden-dropzone__label text-13 text-body">
<p use:preventTransitionOnMount class="hidden-dropzone__label text-13 text-body">
Drag and drop files<br />to create a new branch.
</p>
</div>
Expand Down
49 changes: 30 additions & 19 deletions apps/desktop/src/components/v3/WorkspaceView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,34 @@
{/if}
</div>

<ReduxResult {projectId} result={stacksResult?.current}>
{#snippet children(stacks)}
<div
class="stacks-view-wrap"
bind:this={stacksViewEl}
style:width={stacksViewWidth.current + 'rem'}
use:focusable={{ id: Focusable.WorkspaceRight, parentId: Focusable.Workspace }}
>
<div
class="stacks-view-wrap"
bind:this={stacksViewEl}
style:width={stacksViewWidth.current + 'rem'}
use:focusable={{ id: Focusable.WorkspaceRight, parentId: Focusable.Workspace }}
>
<ReduxResult {projectId} result={stacksResult?.current}>
{#snippet loading()}
<div class="stacks-view-skeleton"></div>
{/snippet}

{#snippet children(stacks)}
<MultiStackView
{projectId}
{stacks}
selectedId={stackId}
active={focusGroup.current !== Focusable.UncommittedChanges}
/>

<Resizer
viewport={stacksViewEl}
direction="left"
minWidth={16}
borderRadius="ml"
onWidth={(value) => uiState.global.stacksViewWidth.set(value)}
/>
</div>
{/snippet}
</ReduxResult>
{/snippet}
</ReduxResult>
<Resizer
viewport={stacksViewEl}
direction="left"
minWidth={16}
borderRadius="ml"
onWidth={(value) => uiState.global.stacksViewWidth.set(value)}
/>
</div>
</div>

<style>
Expand Down Expand Up @@ -202,4 +205,12 @@
gap: 8px;
min-width: 320px;
}

/* SKELETON LOADING */
.stacks-view-skeleton {
width: 100%;
height: 100%;
border-radius: var(--radius-ml);
border: 1px solid var(--clr-border-2);
}
</style>
45 changes: 23 additions & 22 deletions apps/desktop/src/components/v3/WorktreeChanges.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,24 @@
let listFooterHeight = $state(0);
</script>

<ReduxResult {stackId} {projectId} result={changesResult.current}>
{#snippet children(changes, { stackId, projectId })}
<Dropzone handlers={[uncommitDzHandler]} maxHeight>
{#snippet overlay({ hovered, activated })}
<CardOverlay {hovered} {activated} label="Uncommit changes" />
{/snippet}
<div
class="uncommitted-changes-wrap"
use:focusable={{ id: Focusable.UncommittedChanges, parentId: Focusable.WorkspaceLeft }}
>
<ScrollableContainer
autoScroll={false}
padding={{
top: listHeaderHeight,
bottom: listFooterHeight
}}
>
<Dropzone handlers={[uncommitDzHandler]} maxHeight>
{#snippet overlay({ hovered, activated })}
<CardOverlay {hovered} {activated} label="Uncommit changes" />
{/snippet}

<div
class="uncommitted-changes-wrap"
use:focusable={{ id: Focusable.UncommittedChanges, parentId: Focusable.WorkspaceLeft }}
>
<ScrollableContainer
autoScroll={false}
padding={{
top: listHeaderHeight,
bottom: listFooterHeight
}}
>
<ReduxResult {stackId} {projectId} result={changesResult.current}>
{#snippet children(changes, { stackId, projectId })}
<div
data-testid={TestId.UncommittedChanges_Header}
use:stickyHeader
Expand Down Expand Up @@ -202,11 +203,11 @@
<WorktreeTipsFooter />
</div>
{/if}
</ScrollableContainer>
</div>
</Dropzone>
{/snippet}
</ReduxResult>
{/snippet}
</ReduxResult>
</ScrollableContainer>
</div>
</Dropzone>

<style>
.uncommitted-changes-wrap {
Expand Down
10 changes: 7 additions & 3 deletions packages/ui/src/lib/scroll/Scrollbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
}
</script>

<!-- {#if mounted} -->
<div
bind:this={track}
data-remove-from-draggable
Expand Down Expand Up @@ -308,6 +309,8 @@
></div>
</div>

<!-- {/if} -->

<style>
.scrollbar-track {
position: absolute;
Expand All @@ -331,9 +334,6 @@
background-color: var(--clr-scale-ntrl-0);
opacity: 0;
will-change: transform, opacity;
transition:
opacity 0.2s,
transform 0.15s;
}

/* modify vertical scrollbar */
Expand All @@ -353,9 +353,13 @@
}

/* MODIFIERS */

.show-scrollbar {
& .scrollbar-thumb {
opacity: 0.15;
transition:
opacity 0.2s,
transform 0.15s;
}
}

Expand Down
19 changes: 19 additions & 0 deletions packages/ui/src/lib/utils/preventTransitionOnMount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function preventTransitionOnMount(node: HTMLElement) {
// cunstruct class styles

// run timer to prevent transition on mount
function runTimer() {
node.classList.add('h-no-transition');
setTimeout(() => {
node.classList.remove('h-no-transition');
}, 100);
}

runTimer();

return {
destroy() {
node.classList.remove('h-no-transition');
}
};
}
6 changes: 5 additions & 1 deletion packages/ui/src/styles/utility/helpers.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ pre {
}

/* STICKY HEADER */

.h-sticky-header {
position: sticky;
z-index: var(--z-lifted);
Expand All @@ -113,3 +112,8 @@ pre {
.h-sticky-header_sticked-bottom {
border-top: 1px solid var(--clr-border-2);
}

/* NO TRANSITION ON MOUNT */
.h-no-transition {
transition: none !important;
}
Loading