Skip to content

Commit 00fadef

Browse files
authored
simplify-branch-header-style-conditions (#10868)
* feat(ui): render draft placeholder simplify branch header styling * style: update bg to muted variant for contrast improvements
1 parent bf1eb24 commit 00fadef

File tree

5 files changed

+59
-50
lines changed

5 files changed

+59
-50
lines changed

apps/desktop/src/components/BranchCard.svelte

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
4747
interface DraftBranchProps extends BranchCardProps {
4848
type: 'draft-branch';
49-
branchContent: Snippet;
49+
branchContent?: Snippet;
5050
buttons?: Snippet;
5151
}
5252
@@ -118,6 +118,7 @@
118118
119119
const projectState = $derived(uiState.project(projectId));
120120
const exclusiveAction = $derived(projectState.exclusiveAction.current);
121+
121122
const showPrCreation = $derived(
122123
exclusiveAction?.type === 'create-pr' &&
123124
exclusiveAction.stackId === (args.type === 'stack-branch' ? args.stackId : undefined) &&
@@ -207,6 +208,7 @@
207208
onclick={args.onclick}
208209
menu={args.menu}
209210
conflicts={args.isConflicted}
211+
{showPrCreation}
210212
dragArgs={{
211213
disabled: args.isConflicted,
212214
label: branchName,
@@ -272,20 +274,21 @@
272274
</div>
273275
{/if}
274276
{/snippet}
277+
278+
{#snippet prCreation()}
279+
<div class="review-wrapper" class:no-padding={uiState.global.useFloatingBox.current}>
280+
<CreateReviewBox
281+
{projectId}
282+
{branchName}
283+
stackId={args.stackId}
284+
oncancel={() => {
285+
projectState.exclusiveAction.set(undefined);
286+
}}
287+
/>
288+
</div>
289+
{/snippet}
275290
</BranchHeader>
276291
</Dropzone>
277-
{#if showPrCreation}
278-
<div class="review-wrapper" class:no-padding={uiState.global.useFloatingBox.current}>
279-
<CreateReviewBox
280-
{projectId}
281-
{branchName}
282-
stackId={args.stackId}
283-
oncancel={() => {
284-
projectState.exclusiveAction.set(undefined);
285-
}}
286-
/>
287-
</div>
288-
{/if}
289292
{:else if args.type === 'normal-branch'}
290293
<BranchHeader
291294
{branchName}
@@ -366,7 +369,9 @@
366369
{/if}
367370

368371
{#if args.type === 'stack-branch' || args.type === 'normal-branch' || args.type === 'draft-branch'}
369-
{@render args.branchContent()}
372+
{#if args.branchContent}
373+
{@render args.branchContent()}
374+
{/if}
370375
{/if}
371376
</div>
372377

@@ -450,6 +455,7 @@
450455
451456
.review-wrapper {
452457
border-top: 1px solid var(--clr-border-2);
458+
background-color: var(--clr-bg-2);
453459
454460
&:not(.no-padding) {
455461
padding: 12px;

apps/desktop/src/components/BranchHeader.svelte

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
<script lang="ts">
1212
import BranchHeaderIcon from '$components/BranchHeaderIcon.svelte';
1313
import BranchLabel from '$components/BranchLabel.svelte';
14+
import CommitGoesHere from '$components/CommitGoesHere.svelte';
1415
import { BranchDropData } from '$lib/branches/dropHandler';
1516
import { draggableBranch, type DraggableConfig } from '$lib/dragging/draggable';
1617
import { DROPZONE_REGISTRY } from '$lib/dragging/registry';
18+
1719
import { inject } from '@gitbutler/core/context';
1820
import { Badge } from '@gitbutler/ui';
1921
import { TestId } from '@gitbutler/ui';
@@ -44,6 +46,8 @@
4446
content?: Snippet;
4547
menu?: Snippet<[{ rightClickTrigger: HTMLElement }]>;
4648
buttons?: Snippet;
49+
prCreation?: Snippet;
50+
showPrCreation?: boolean;
4751
dragArgs?: DragableBranchData;
4852
};
4953
@@ -67,6 +71,8 @@
6771
content,
6872
menu,
6973
buttons,
74+
prCreation,
75+
showPrCreation,
7076
dragArgs
7177
}: Props = $props();
7278
@@ -77,7 +83,6 @@
7783
let active = $state(false);
7884
7985
const actionsVisible = $derived(!draft && !isCommitting && (buttons || menu));
80-
const isCommittingEmpty = $derived(isCommitting && isEmpty);
8186
8287
const draggableBranchConfig = $derived.by<DraggableConfig>(() => {
8388
if (!dragArgs) {
@@ -97,6 +102,7 @@
97102

98103
<div
99104
class="header-wrapper"
105+
class:rounded={(actionsVisible && roundedBottom) || draft}
100106
use:focusable={{
101107
onAction: () => onclick?.(),
102108
onActive: (value) => (active = value),
@@ -112,7 +118,6 @@
112118
class:selected
113119
class:active
114120
class:draft
115-
class:rounded={!actionsVisible && roundedBottom && !isCommittingEmpty}
116121
class:commiting={isCommitting}
117122
{onclick}
118123
onkeypress={onclick}
@@ -161,29 +166,47 @@
161166
</div>
162167
</div>
163168

164-
{#if actionsVisible}
165-
<div
166-
class="branch-hedaer__actions-row"
167-
class:draft
168-
class:new-branch={isEmpty}
169-
data-no-drag
170-
class:rounded={roundedBottom}
171-
>
169+
{#if draft}
170+
<CommitGoesHere commitId={undefined} selected draft />
171+
{/if}
172+
173+
{#if actionsVisible && !showPrCreation}
174+
<div class="branch-hedaer__actions-row" class:draft class:new-branch={isEmpty} data-no-drag>
172175
{#if buttons}
173176
<div class="text-12 branch-header__actions">
174177
{@render buttons()}
175178
</div>
176179
{/if}
180+
177181
{#if menu}
178182
<div class="branch-header__menu">
179183
{@render menu({ rightClickTrigger })}
180184
</div>
181185
{/if}
182186
</div>
183187
{/if}
188+
189+
{#if prCreation && showPrCreation}
190+
{@render prCreation()}
191+
{/if}
184192
</div>
185193

186194
<style lang="postcss">
195+
.header-wrapper {
196+
display: flex;
197+
flex-direction: column;
198+
width: 100%;
199+
overflow: hidden;
200+
border: 1px solid var(--clr-border-2);
201+
border-bottom: none;
202+
border-radius: var(--radius-ml) var(--radius-ml) 0 0;
203+
204+
&.rounded {
205+
border-bottom: 1px solid var(--clr-border-2);
206+
border-radius: var(--radius-ml);
207+
}
208+
}
209+
187210
.branch-header {
188211
--branch-selected-bg: var(--clr-bg-1);
189212
--branch-selected-element-bg: var(--clr-selected-not-in-focus-element);
@@ -196,9 +219,7 @@
196219
padding-right: 12px;
197220
padding-left: 12px;
198221
overflow: hidden;
199-
border: 1px solid var(--clr-border-2);
200222
border-bottom: none;
201-
border-radius: var(--radius-ml) var(--radius-ml) 0 0;
202223
background-color: var(--branch-selected-bg);
203224
204225
/* Selected but NOT in focus */
@@ -216,11 +237,6 @@
216237
--branch-selected-bg: var(--clr-selected-in-focus-bg);
217238
--branch-selected-element-bg: var(--clr-selected-in-focus-element);
218239
}
219-
220-
&.rounded {
221-
border-bottom: 1px solid var(--clr-border-2);
222-
border-radius: var(--radius-ml);
223-
}
224240
}
225241
226242
.branch-header__details {
@@ -256,7 +272,6 @@
256272
align-items: center;
257273
justify-content: space-between;
258274
min-width: 0;
259-
/* overflow: hidden; */
260275
gap: 4px;
261276
}
262277
@@ -278,7 +293,6 @@
278293
flex: 1;
279294
flex-direction: column;
280295
width: 100%;
281-
/* margin-left: -2px; */
282296
padding: 14px 0;
283297
overflow: hidden;
284298
gap: 8px;
@@ -295,19 +309,12 @@
295309
padding: 10px;
296310
gap: 10px;
297311
border-top: 1px solid var(--clr-border-2);
298-
border-right: 1px solid var(--clr-border-2);
299-
border-left: 1px solid var(--clr-border-2);
300312
background-color: var(--clr-bg-2);
301313
302314
/* MODIFIERS */
303315
&.new-branch {
304316
border-bottom: none;
305317
}
306-
307-
&.rounded {
308-
border-bottom: 1px solid var(--clr-border-2);
309-
border-radius: 0 0 var(--radius-ml) var(--radius-ml);
310-
}
311318
}
312319
313320
.branch-header__actions {

apps/desktop/src/components/CommitGoesHere.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@
7070
}
7171
7272
&.draft {
73-
border: 1px solid var(--clr-border-2);
74-
border-radius: 0 0 var(--radius-ml) var(--radius-ml);
73+
border-top: 1px solid var(--clr-border-2);
74+
border-bottom: none;
7575
}
7676
}
77+
7778
.pin {
7879
display: flex;
7980
position: relative;

apps/desktop/src/components/FloatingCommitBox.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@
7070
background-color: var(--clr-bg-2);
7171
color: var(--clr-text-2);
7272
cursor: pointer;
73-
transition: background-color 0.2s ease-in-out;
73+
transition: background-color var(--transition-fast);
7474
7575
&:hover {
76-
background-color: var(--clr-bg-1);
76+
background-color: var(--clr-bg-1-muted);
7777
}
7878
}
7979

apps/desktop/src/components/StackDraft.svelte

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
22
import BranchCard from '$components/BranchCard.svelte';
3-
import CommitGoesHere from '$components/CommitGoesHere.svelte';
43
import ConfigurableScrollableContainer from '$components/ConfigurableScrollableContainer.svelte';
54
import NewCommitView from '$components/NewCommitView.svelte';
65
import ReduxResult from '$components/ReduxResult.svelte';
@@ -54,11 +53,7 @@
5453
{branchName}
5554
readonly={false}
5655
lineColor="var(--clr-commit-local)"
57-
>
58-
{#snippet branchContent()}
59-
<CommitGoesHere commitId={undefined} selected draft />
60-
{/snippet}
61-
</BranchCard>
56+
/>
6257
{/snippet}
6358
</ReduxResult>
6459
<Resizer

0 commit comments

Comments
 (0)