diff --git a/web/src/lib/components/notifications/NotificationToolbar.svelte b/web/src/lib/components/notifications/NotificationToolbar.svelte index 56f6b92bb..5c02414df 100644 --- a/web/src/lib/components/notifications/NotificationToolbar.svelte +++ b/web/src/lib/components/notifications/NotificationToolbar.svelte @@ -1,13 +1,12 @@ -{#snippet readSegment( - filter: ReadFilter, - label: string, - icon: Component -)} - -{/snippet} -
- - {@render readSegment("inbox", "Inbox", Inbox)} - {@render readSegment("unread", "Unread", Glasses)} - + pageHref(filter, categoryFilter)} + label="Read state" + > + onReadFilter?.("inbox")} + >Inbox + onReadFilter?.("unread")} + >Unread + {#if hasNotifications} + {/each} - + {/if} {#if preferences} diff --git a/web/src/lib/components/repo/BlobHeader.svelte b/web/src/lib/components/repo/BlobHeader.svelte index c04980691..480aa1f39 100644 --- a/web/src/lib/components/repo/BlobHeader.svelte +++ b/web/src/lib/components/repo/BlobHeader.svelte @@ -7,7 +7,9 @@ import type { ResolvedPathname } from "$app/types"; import { hasRenderedView, hasTextView, type BlobKind, type BlobViewMode } from "$lib/api/blob"; import Button from "$lib/components/ui/Button.svelte"; - import ButtonGroup, { segmentProps } from "$lib/components/ui/ButtonGroup.svelte"; + import ButtonGroup from "$lib/components/ui/ButtonGroup.svelte"; + import Segment from "$lib/components/ui/Segment.svelte"; + import SegmentedControl from "$lib/components/ui/SegmentedControl.svelte"; import Checkbox from "$lib/components/ui/Checkbox.svelte"; import ColorBall from "$lib/components/ui/ColorBall.svelte"; import CopyButton from "$lib/components/ui/CopyButton.svelte"; @@ -156,24 +158,20 @@ {/if} {#if hasRenderedView(kind)} - -
{/if} diff --git a/web/src/lib/components/repo/DiffView.svelte b/web/src/lib/components/repo/DiffView.svelte index 2f65fc0ff..5e8754b61 100644 --- a/web/src/lib/components/repo/DiffView.svelte +++ b/web/src/lib/components/repo/DiffView.svelte @@ -13,7 +13,8 @@ import UnfoldVertical from "$icon/unfold-vertical"; import Button, { buttonIcon } from "$lib/components/ui/Button.svelte"; import EmptyState from "$lib/components/ui/EmptyState.svelte"; - import ButtonGroup, { segmentProps } from "$lib/components/ui/ButtonGroup.svelte"; + import Segment from "$lib/components/ui/Segment.svelte"; + import SegmentedControl from "$lib/components/ui/SegmentedControl.svelte"; import Card from "$lib/components/ui/Card.svelte"; import Modal from "$lib/components/ui/Modal.svelte"; import Toggle from "$lib/components/ui/Toggle.svelte"; @@ -151,26 +152,28 @@ {/snippet} {#snippet styleSwitch(size: "small" | "regular", narrow: string)} - + styleHref(style) as "/" : undefined} + label="Diff style" + > {#each ["unified", "split"] as const as style (style)} - {@const segment = segmentProps(diffStyle === style)} - + {/each} - + {/snippet} {#if loading && !diff} diff --git a/web/src/lib/components/repo/pipelines/PipelineToolbar.svelte b/web/src/lib/components/repo/pipelines/PipelineToolbar.svelte index 524249d7c..97d01dfec 100644 --- a/web/src/lib/components/repo/pipelines/PipelineToolbar.svelte +++ b/web/src/lib/components/repo/pipelines/PipelineToolbar.svelte @@ -5,8 +5,8 @@ import GitPullRequest from "$icon/git-pull-request"; import Play from "$icon/play"; import Layers2 from "$icon/layers-2"; - import Button from "$lib/components/ui/Button.svelte"; - import ButtonGroup, { segmentLabel, segmentProps } from "$lib/components/ui/ButtonGroup.svelte"; + import Segment from "$lib/components/ui/Segment.svelte"; + import SegmentedControl from "$lib/components/ui/SegmentedControl.svelte"; import ListToolbar from "$lib/components/ui/ListToolbar.svelte"; import Pending from "$lib/components/ui/Pending.svelte"; import Bones from "$lib/components/ui/Bones.svelte"; @@ -42,32 +42,14 @@ {/snippet} {#snippet filters()} - - - - - + Pull + + {/snippet} {#snippet trailing()} diff --git a/web/src/lib/components/repo/tickets/TicketToolbar.svelte b/web/src/lib/components/repo/tickets/TicketToolbar.svelte index ccf76dc7f..6f4917903 100644 --- a/web/src/lib/components/repo/tickets/TicketToolbar.svelte +++ b/web/src/lib/components/repo/tickets/TicketToolbar.svelte @@ -7,7 +7,8 @@ import GitPullRequestClosed from "$icon/git-pull-request-closed"; import Plus from "$icon/plus"; import Button from "$lib/components/ui/Button.svelte"; - import ButtonGroup, { segmentLabel, segmentProps } from "$lib/components/ui/ButtonGroup.svelte"; + import Segment from "$lib/components/ui/Segment.svelte"; + import SegmentedControl from "$lib/components/ui/SegmentedControl.svelte"; import ListToolbar from "$lib/components/ui/ListToolbar.svelte"; import TicketSearch from "$lib/components/repo/tickets/TicketSearch.svelte"; import Pending from "$lib/components/ui/Pending.svelte"; @@ -44,42 +45,27 @@ {/snippet} {#snippet filters()} - - + resolve(`${base}?state=${value}` as "/")} + label="State" + > + + + Open + {#if isPull} - + + + Merged + {/if} - - + + + Closed + + {/snippet} {#snippet trailing()} diff --git a/web/src/lib/components/ui/ButtonGroup.stories.svelte b/web/src/lib/components/ui/ButtonGroup.stories.svelte index bf055fe13..a0b44d635 100644 --- a/web/src/lib/components/ui/ButtonGroup.stories.svelte +++ b/web/src/lib/components/ui/ButtonGroup.stories.svelte @@ -1,7 +1,7 @@
diff --git a/web/src/lib/components/ui/Segment.svelte b/web/src/lib/components/ui/Segment.svelte new file mode 100644 index 000000000..c649bd82f --- /dev/null +++ b/web/src/lib/components/ui/Segment.svelte @@ -0,0 +1,80 @@ + + + + + diff --git a/web/src/lib/components/ui/SegmentedControl.stories.svelte b/web/src/lib/components/ui/SegmentedControl.stories.svelte new file mode 100644 index 000000000..dea471e53 --- /dev/null +++ b/web/src/lib/components/ui/SegmentedControl.stories.svelte @@ -0,0 +1,59 @@ + + + + + + + All + Push + Pull request + + + + + + Open + Closed + + + + + + Open + Closed + + + + + + + + + + + + + Small + Regular + Large + + diff --git a/web/src/lib/components/ui/SegmentedControl.svelte b/web/src/lib/components/ui/SegmentedControl.svelte new file mode 100644 index 000000000..8f66ee8a1 --- /dev/null +++ b/web/src/lib/components/ui/SegmentedControl.svelte @@ -0,0 +1,163 @@ + + + + +
+ + {@render children()} +
diff --git a/web/src/routes/[handle]/[repo]/pulls/[rkey]/[version]/[[range]]/PullViewPage.svelte b/web/src/routes/[handle]/[repo]/pulls/[rkey]/[version]/[[range]]/PullViewPage.svelte index 8cbf9fe3a..20256c40f 100644 --- a/web/src/routes/[handle]/[repo]/pulls/[rkey]/[version]/[[range]]/PullViewPage.svelte +++ b/web/src/routes/[handle]/[repo]/pulls/[rkey]/[version]/[[range]]/PullViewPage.svelte @@ -55,7 +55,8 @@ import { atUriOf, didOf, gitOidOf } from "$lib/api/syntax"; import type { CommentView } from "$lib/components/comment/comments"; import Button from "$lib/components/ui/Button.svelte"; - import ButtonGroup, { segmentProps } from "$lib/components/ui/ButtonGroup.svelte"; + import Segment from "$lib/components/ui/Segment.svelte"; + import SegmentedControl from "$lib/components/ui/SegmentedControl.svelte"; import Separator from "$lib/components/ui/Separator.svelte"; import Tag from "$lib/components/ui/Tag.svelte"; import Spinner from "$lib/components/ui/Spinner.svelte"; @@ -757,20 +758,13 @@
- + {#each tabs as { id, label, icon } (id)} - {@const segment = segmentProps(tab === id)} - + {/each} - + {#if pull.versions.length} diff --git a/web/src/routes/dev/components/+page.svelte b/web/src/routes/dev/components/+page.svelte index a906cd64d..d29088c51 100644 --- a/web/src/routes/dev/components/+page.svelte +++ b/web/src/routes/dev/components/+page.svelte @@ -25,7 +25,9 @@ import Bones from "$lib/components/ui/Bones.svelte"; import Button from "$lib/components/ui/Button.svelte"; import ButtonCard from "$lib/components/ui/ButtonCard.svelte"; - import ButtonGroup, { segmentProps } from "$lib/components/ui/ButtonGroup.svelte"; + import ButtonGroup from "$lib/components/ui/ButtonGroup.svelte"; + import Segment from "$lib/components/ui/Segment.svelte"; + import SegmentedControl from "$lib/components/ui/SegmentedControl.svelte"; import Card from "$lib/components/ui/Card.svelte"; import Checkbox from "$lib/components/ui/Checkbox.svelte"; import ColorBall from "$lib/components/ui/ColorBall.svelte"; @@ -139,6 +141,7 @@ let radio = $state("spindle.tangled.sh"); let select = $state(""); let combobox = $state("main"); + let segmented = $state("push"); let pageNumber = $state(3); let tags = $state([{ value: "oppi.li" }]); let modalOpen = $state(false); @@ -159,6 +162,7 @@ { name: "Input", demo: input }, { name: "Select", demo: selectDemo }, { name: "ButtonGroup", demo: buttonGroup }, + { name: "SegmentedControl", demo: segmentedControlDemo }, { name: "Combobox", demo: comboboxDemo }, { name: "Toggle", demo: toggle }, { name: "Field", demo: field }, @@ -240,13 +244,21 @@ {/snippet} {#snippet buttonGroup()} - - - - + + + + {/snippet} +{#snippet segmentedControlDemo()} + + All + Push + Pull request + +{/snippet} + {#snippet comboboxDemo()}