Skip to content

Commit 181edee

Browse files
committed
update segment control styles
to match button styles for small sizes.
1 parent c384421 commit 181edee

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/ui/src/lib/components/segmentControl/Segment.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
const context = getContext<SegmentContext>("SegmentControl");
2222
const selectedSegmentId = context.selectedSegmentId;
23+
const iconSize = $derived(context.size === "small" ? 14 : 16);
2324
2425
let elRef = $state<HTMLButtonElement>();
2526
let isFocused = $state(false);
@@ -67,7 +68,7 @@
6768
{/if}
6869
{#if icon}
6970
<span class="segment-control-item__icon" aria-hidden="true">
70-
<Icon name={icon} />
71+
<Icon name={icon} size={iconSize} />
7172
</span>
7273
{/if}
7374
</button>

packages/ui/src/lib/components/segmentControl/SegmentControl.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
3535
const context: SegmentContext = {
3636
selectedSegmentId,
37+
get size() {
38+
return size;
39+
},
3740
registerSegment: (id: string) => {
3841
if (!registeredSegments.includes(id)) {
3942
registeredSegments.push(id);

packages/ui/src/lib/components/segmentControl/segmentTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Writable } from "svelte/store";
22

33
export interface SegmentContext {
44
selectedSegmentId: Writable<string | undefined>;
5+
size: "default" | "small";
56
registerSegment(id: string): void;
67
selectSegment(id: string): void;
78
}

packages/ui/src/stories/components/SegmentControl.stories.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
fullWidth: false,
1010
size: "default",
1111
segments: [
12-
{ id: "1", icon: "horz-columns" },
13-
{ id: "2", icon: "single-view" },
14-
{ id: "3", icon: "vert-columns" },
12+
{ id: "1", icon: "folder-tree" },
13+
{ id: "2", icon: "list" },
1514
],
1615
},
1716
argTypes: {

0 commit comments

Comments
 (0)