mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
Move the diff settings into the settings modal
Grouped with the code font in a section of their own, replacing the per-view popover in the commit, changes and review views.
This commit is contained in:
@@ -1,184 +0,0 @@
|
||||
<script lang="ts" module>
|
||||
import type { ComponentProps } from "svelte";
|
||||
|
||||
import type { DiffOptions } from "@app/lib/diffOptions.svelte";
|
||||
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
|
||||
type DiffStyleOption = {
|
||||
value: DiffOptions["diffStyle"];
|
||||
icon: ComponentProps<typeof Icon>["name"];
|
||||
title: string;
|
||||
};
|
||||
|
||||
const diffStyleOptions: DiffStyleOption[] = [
|
||||
{ value: "unified", icon: "diff-unified", title: "Unified" },
|
||||
{ value: "split", icon: "diff-split", title: "Split" },
|
||||
];
|
||||
|
||||
type IndicatorOption = {
|
||||
value: DiffOptions["indicators"];
|
||||
icon: ComponentProps<typeof Icon>["name"];
|
||||
title: string;
|
||||
};
|
||||
|
||||
const indicatorOptions: IndicatorOption[] = [
|
||||
{ value: "classic", icon: "diff-classic", title: "Classic (+/−)" },
|
||||
{ value: "bars", icon: "diff-bars", title: "Bars" },
|
||||
{ value: "none", icon: "eye-slash", title: "None" },
|
||||
];
|
||||
|
||||
type WordDiffOption = {
|
||||
value: DiffOptions["lineDiffType"];
|
||||
label: string;
|
||||
title: string;
|
||||
};
|
||||
|
||||
const wordDiffOptions: WordDiffOption[] = [
|
||||
{
|
||||
value: "word-alt",
|
||||
label: "Word+",
|
||||
title: "Highlight entire words with enhanced algorithm",
|
||||
},
|
||||
{
|
||||
value: "word",
|
||||
label: "Word",
|
||||
title: "Highlight changed words within lines",
|
||||
},
|
||||
{ value: "char", label: "Char", title: "Highlight character changes" },
|
||||
{ value: "none", label: "None", title: "Show line-level changes only" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { diffOptions } from "@app/lib/diffOptions.svelte";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
|
||||
let expanded = $state(false);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
/* Wide enough to keep every label on one line next to its buttons; the
|
||||
widest pairing is "Word diff" against its four options. */
|
||||
width: 23rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid var(--color-border-subtle);
|
||||
border-radius: var(--border-radius-md);
|
||||
background-color: var(--color-surface-canvas);
|
||||
font: var(--txt-body-m-regular);
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
.switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
{#snippet boolSwitch(checked: boolean, onchange: (value: boolean) => void)}
|
||||
<div class="switch">
|
||||
<Button
|
||||
variant="ghost"
|
||||
flatRight
|
||||
active={checked}
|
||||
onclick={() => onchange(true)}>
|
||||
On
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
flatLeft
|
||||
active={!checked}
|
||||
onclick={() => onchange(false)}>
|
||||
Off
|
||||
</Button>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
<Popover placement="bottom-end" bind:expanded>
|
||||
{#snippet toggle(onclick)}
|
||||
<Button
|
||||
variant="naked"
|
||||
active={expanded}
|
||||
{onclick}
|
||||
title="Diff settings"
|
||||
styleHeight="2rem"
|
||||
styleWidth="2rem"
|
||||
stylePadding="0"
|
||||
styleJustifyContent="center">
|
||||
<Icon name="settings" />
|
||||
</Button>
|
||||
{/snippet}
|
||||
|
||||
{#snippet popover()}
|
||||
<div class="panel">
|
||||
<div class="row">
|
||||
Diff style
|
||||
<div class="switch">
|
||||
{#each diffStyleOptions as option, index}
|
||||
<Button
|
||||
variant="ghost"
|
||||
flatLeft={index > 0}
|
||||
flatRight={index < diffStyleOptions.length - 1}
|
||||
active={diffOptions.diffStyle === option.value}
|
||||
title={option.title}
|
||||
onclick={() => (diffOptions.diffStyle = option.value)}
|
||||
styleJustifyContent="center">
|
||||
<Icon name={option.icon} />
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
Word wrap
|
||||
{@render boolSwitch(
|
||||
diffOptions.wordWrap,
|
||||
value => (diffOptions.wordWrap = value),
|
||||
)}
|
||||
</div>
|
||||
<div class="row">
|
||||
Indicator style
|
||||
<div class="switch">
|
||||
{#each indicatorOptions as option, index}
|
||||
<Button
|
||||
variant="ghost"
|
||||
flatLeft={index > 0}
|
||||
flatRight={index < indicatorOptions.length - 1}
|
||||
active={diffOptions.indicators === option.value}
|
||||
title={option.title}
|
||||
onclick={() => (diffOptions.indicators = option.value)}
|
||||
styleJustifyContent="center">
|
||||
<Icon name={option.icon} />
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
Word diff
|
||||
<div class="switch">
|
||||
{#each wordDiffOptions as option, index}
|
||||
<Button
|
||||
variant="ghost"
|
||||
flatLeft={index > 0}
|
||||
flatRight={index < wordDiffOptions.length - 1}
|
||||
active={diffOptions.lineDiffType === option.value}
|
||||
title={option.title}
|
||||
onclick={() => (diffOptions.lineDiffType = option.value)}>
|
||||
{option.label}
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
</Popover>
|
||||
@@ -54,7 +54,6 @@
|
||||
|
||||
import { announce } from "@app/components/AnnounceSwitch.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import DiffOptionsButton from "@app/components/DiffOptionsButton.svelte";
|
||||
import Discussion from "@app/components/Discussion.svelte";
|
||||
import DropdownList from "@app/components/DropdownList.svelte";
|
||||
import DropdownListItem from "@app/components/DropdownListItem.svelte";
|
||||
@@ -1131,7 +1130,6 @@
|
||||
onclick={() => setAllFilesCollapsed(filesExpanded)}>
|
||||
<Icon name={filesExpanded ? "collapse-vertical" : "expand-vertical"} />
|
||||
</Button>
|
||||
<DiffOptionsButton />
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<script lang="ts" generics="T extends string">
|
||||
import type { ComponentProps } from "svelte";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
|
||||
interface Props {
|
||||
/// Two or more mutually exclusive choices, in the order they are shown. An
|
||||
/// option carries either a glyph or a word, not both.
|
||||
options: {
|
||||
value: T;
|
||||
label?: string;
|
||||
icon?: ComponentProps<typeof Icon>["name"];
|
||||
title?: string;
|
||||
}[];
|
||||
value: T;
|
||||
onchange: (value: T) => void;
|
||||
}
|
||||
|
||||
const { options, value, onchange }: Props = $props();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* The buttons square the edges they share (`flatLeft`/`flatRight`), so the row
|
||||
reads as one control with one of its segments on. */
|
||||
.switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="switch">
|
||||
{#each options as option, index (option.value)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
flatLeft={index > 0}
|
||||
flatRight={index < options.length - 1}
|
||||
active={value === option.value}
|
||||
title={option.title}
|
||||
onclick={() => onchange(option.value)}
|
||||
styleJustifyContent="center">
|
||||
{#if option.icon}
|
||||
<Icon name={option.icon} />
|
||||
{:else}
|
||||
{option.label}
|
||||
{/if}
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
+106
-8
@@ -1,4 +1,8 @@
|
||||
<script lang="ts">
|
||||
import type { ComponentProps } from "svelte";
|
||||
|
||||
import type { DiffOptions } from "@app/lib/diffOptions.svelte";
|
||||
import { diffOptions } from "@app/lib/diffOptions.svelte";
|
||||
import { hints } from "@app/lib/hints";
|
||||
import { hide } from "@app/lib/modal";
|
||||
import { updateChecker } from "@app/lib/updateChecker.svelte";
|
||||
@@ -11,8 +15,46 @@
|
||||
import ExternalLink from "@app/components/ExternalLink.svelte";
|
||||
import FontSizeSwitch from "@app/components/FontSizeSwitch.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import SegmentedSwitch from "@app/components/SegmentedSwitch.svelte";
|
||||
import ThemeSwitch from "@app/components/ThemeSwitch.svelte";
|
||||
import UpdateSwitch from "@app/components/UpdateSwitch.svelte";
|
||||
|
||||
// How a diff is drawn, wherever one is drawn: the commit view, a patch's
|
||||
// changes and a review all read the same preferences.
|
||||
type Option<T> = {
|
||||
value: T;
|
||||
label?: string;
|
||||
icon?: ComponentProps<typeof Icon>["name"];
|
||||
title?: string;
|
||||
};
|
||||
|
||||
const diffStyleOptions: Option<DiffOptions["diffStyle"]>[] = [
|
||||
{ value: "unified", icon: "diff-unified", title: "Unified" },
|
||||
{ value: "split", icon: "diff-split", title: "Split" },
|
||||
];
|
||||
const indicatorOptions: Option<DiffOptions["indicators"]>[] = [
|
||||
{ value: "classic", icon: "diff-classic", title: "Classic (+/−)" },
|
||||
{ value: "bars", icon: "diff-bars", title: "Bars" },
|
||||
{ value: "none", icon: "eye-slash", title: "None" },
|
||||
];
|
||||
const wordDiffOptions: Option<DiffOptions["lineDiffType"]>[] = [
|
||||
{
|
||||
value: "word-alt",
|
||||
label: "Word+",
|
||||
title: "Highlight entire words with enhanced algorithm",
|
||||
},
|
||||
{
|
||||
value: "word",
|
||||
label: "Word",
|
||||
title: "Highlight changed words within lines",
|
||||
},
|
||||
{ value: "char", label: "Char", title: "Highlight character changes" },
|
||||
{ value: "none", label: "None", title: "Show line-level changes only" },
|
||||
];
|
||||
const wordWrapOptions: Option<"on" | "off">[] = [
|
||||
{ value: "on", label: "On" },
|
||||
{ value: "off", label: "Off" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -64,8 +106,11 @@
|
||||
font: var(--txt-body-m-regular);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
.section {
|
||||
border-top: 1px solid var(--color-border-subtle);
|
||||
}
|
||||
.footer {
|
||||
padding: 7rem 1.5rem 1.5rem;
|
||||
padding: 4rem 1.5rem 1.5rem;
|
||||
font: var(--txt-body-m-regular);
|
||||
color: var(--color-text-tertiary);
|
||||
}
|
||||
@@ -113,13 +158,6 @@
|
||||
</div>
|
||||
<AnnounceSwitch />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-label">
|
||||
<span class="row-title">Code font</span>
|
||||
<span class="row-description">Use a monospace font in code views</span>
|
||||
</div>
|
||||
<CodeFontSwitch />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-label">
|
||||
<span class="row-title">Notify on new versions</span>
|
||||
@@ -149,6 +187,66 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- How every diff in the app is drawn — the commit view, a patch's changes
|
||||
and a review all read these. Kept apart from the rest because they are
|
||||
about one kind of screen rather than about the app. -->
|
||||
<div class="rows section">
|
||||
<div class="row">
|
||||
<div class="row-label">
|
||||
<span class="row-title">Code font</span>
|
||||
<span class="row-description">Use a monospace font in code views</span>
|
||||
</div>
|
||||
<CodeFontSwitch />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-label">
|
||||
<span class="row-title">Diff style</span>
|
||||
<span class="row-description">
|
||||
Show changes in one column or side by side
|
||||
</span>
|
||||
</div>
|
||||
<SegmentedSwitch
|
||||
options={diffStyleOptions}
|
||||
value={diffOptions.diffStyle}
|
||||
onchange={value => (diffOptions.diffStyle = value)} />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-label">
|
||||
<span class="row-title">Word wrap</span>
|
||||
<span class="row-description">
|
||||
Wrap long lines in a diff instead of scrolling sideways
|
||||
</span>
|
||||
</div>
|
||||
<SegmentedSwitch
|
||||
options={wordWrapOptions}
|
||||
value={diffOptions.wordWrap ? "on" : "off"}
|
||||
onchange={value => (diffOptions.wordWrap = value === "on")} />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-label">
|
||||
<span class="row-title">Change indicators</span>
|
||||
<span class="row-description">
|
||||
How added and removed lines are marked
|
||||
</span>
|
||||
</div>
|
||||
<SegmentedSwitch
|
||||
options={indicatorOptions}
|
||||
value={diffOptions.indicators}
|
||||
onchange={value => (diffOptions.indicators = value)} />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-label">
|
||||
<span class="row-title">Word diff</span>
|
||||
<span class="row-description">
|
||||
Highlight what changed within a line
|
||||
</span>
|
||||
</div>
|
||||
<SegmentedSwitch
|
||||
options={wordDiffOptions}
|
||||
value={diffOptions.lineDiffType}
|
||||
onchange={value => (diffOptions.lineDiffType = value)} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
{#if updateChecker.currentVersion}
|
||||
<span class="txt-selectable">
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
import { announce } from "@app/components/AnnounceSwitch.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import CheckoutPatchButton from "@app/components/CheckoutPatchButton.svelte";
|
||||
import DiffOptionsButton from "@app/components/DiffOptionsButton.svelte";
|
||||
import DraftReviewBar from "@app/components/DraftReviewBar.svelte";
|
||||
import DropdownList from "@app/components/DropdownList.svelte";
|
||||
import DropdownListItem from "@app/components/DropdownListItem.svelte";
|
||||
@@ -1201,9 +1200,9 @@
|
||||
? "All hidden"
|
||||
: "none"}
|
||||
{:else}
|
||||
{commentPosition.index >= 0
|
||||
? commentPosition.index + 1
|
||||
: "–"}
|
||||
<!-- Reads as 1 before the first step, which is where
|
||||
stepping down goes anyway. -->
|
||||
{Math.max(commentPosition.index + 1, 1)}
|
||||
of
|
||||
{commentPosition.total}
|
||||
{/if}
|
||||
@@ -1508,7 +1507,6 @@
|
||||
? "collapse-vertical"
|
||||
: "expand-vertical"} />
|
||||
</Button>
|
||||
<DiffOptionsButton />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import DiffActions from "@app/components/DiffActions.svelte";
|
||||
import DiffOptionsButton from "@app/components/DiffOptionsButton.svelte";
|
||||
import DiffStatBadge from "@app/components/DiffStatBadge.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import Id from "@app/components/Id.svelte";
|
||||
@@ -310,7 +309,6 @@
|
||||
title={allCollapsed ? "Expand all files" : "Collapse all files"}>
|
||||
<Icon name={allCollapsed ? "expand-vertical" : "collapse-vertical"} />
|
||||
</Button>
|
||||
<DiffOptionsButton />
|
||||
</div>
|
||||
</Topbar>
|
||||
<div class="body">
|
||||
|
||||
Reference in New Issue
Block a user