refactor(frontend): rename RSliderBtnGroup to RSegmentedControl (#5383)

This commit is contained in:
Sam Dornan
2026-10-29 07:39:22 -05:00
committed by GitHub
parent 83b0615424
commit be50c8bfd1
29 changed files with 152 additions and 142 deletions

View File

@@ -36,7 +36,9 @@ function scrollWindowTo(y: number) {
function mountNav() {
return mount(AppNav, {
global: { stubs: { RouterLink: true, RImg: true, RSliderBtnGroup: true } },
global: {
stubs: { RouterLink: true, RImg: true, RSegmentedControl: true },
},
});
}

View File

@@ -20,7 +20,7 @@ import NowPlayingPill from "@/components/Soundtrack/NowPlayingPill.vue";
import { useBreakpoint } from "@/composables/useBreakpoint";
import { useNavDestinations } from "@/composables/useNavDestinations";
import { useNavGlass } from "@/composables/useNavGlass";
import { RSliderBtnGroup, RImg } from "@/lib";
import { RSegmentedControl, RImg } from "@/lib";
defineOptions({ inheritAttrs: false });
@@ -71,7 +71,7 @@ const scrolled = computed(
</router-link>
<div class="r-nav__center">
<RSliderBtnGroup
<RSegmentedControl
:model-value="activeTab"
:items="tabs"
variant="tab"

View File

@@ -3,7 +3,7 @@
// on phones (xs) so the four destinations sit within thumb reach. AppNav
// drops its centre pill on xs in turn (see AppNav.vue).
//
// This is the SAME RSliderBtnGroup tab pill the top nav uses (same glass
// This is the SAME RSegmentedControl tab pill the top nav uses (same glass
// surface, same border, same sliding active indicator), just pinned to
// the bottom and stretched full-width. No bespoke nav surface and no
// alternate layout, so the brand look and feel stay identical top vs
@@ -17,7 +17,7 @@
import { useI18n } from "vue-i18n";
import { useBreakpoint } from "@/composables/useBreakpoint";
import { useNavDestinations } from "@/composables/useNavDestinations";
import { RSliderBtnGroup } from "@/lib";
import { RSegmentedControl } from "@/lib";
const { t } = useI18n();
const { smAndDown } = useBreakpoint();
@@ -29,7 +29,7 @@ const { destinations, activeId } = useNavDestinations();
<template>
<div v-if="smAndDown" class="r-bottom-nav-anchor">
<nav class="r-bottom-nav" :aria-label="t('common.primary-navigation')">
<RSliderBtnGroup
<RSegmentedControl
:model-value="activeId"
:items="destinations"
variant="tab"
@@ -84,16 +84,16 @@ const { destinations, activeId } = useNavDestinations();
instead of leaving the items bunched in the centre. The indicator sits
inside the pill's 4px padding, so even with sub-pixel cell rounding it
never grazes the border. */
.r-bottom-nav__group :deep(.r-slider-btn-group__btn) {
.r-bottom-nav__group :deep(.r-segmented-control__btn) {
flex: 1;
justify-content: center;
}
/* Icon-only on phones: four full-width inline labels won't fit, and the
icon-only treatment matches the top-nav-on-xs precedent. The
router-link `aria-label` (set by RSliderBtnGroup from each item's
router-link `aria-label` (set by RSegmentedControl from each item's
`ariaLabel`) stays the source of accessible naming. */
.r-bottom-nav__group :deep(.r-slider-btn-group__label) {
.r-bottom-nav__group :deep(.r-segmented-control__label) {
display: none;
}
</style>

View File

@@ -25,11 +25,11 @@ import {
RCollapsible,
REmptyState,
RIcon,
RSliderBtnGroup,
RSegmentedControl,
RTag,
RTextField,
} from "@/lib";
import type { SliderBtnGroupItem } from "@/lib";
import type { SegmentedControlItem } from "@/lib";
import type { Platform } from "@/stores/platforms";
import { platformMatchesSearch } from "@/utils/platformSearch";
@@ -129,7 +129,7 @@ const showDetectedFilter = computed(
identifiedDetectedCount.value > 0 && unidentifiedDetectedCount.value > 0,
);
const detectedFilterItems = computed<SliderBtnGroupItem<DetectedFilter>[]>(
const detectedFilterItems = computed<SegmentedControlItem<DetectedFilter>[]>(
() => [
{
id: "all",
@@ -365,7 +365,7 @@ const detectedPlatformCount = computed(
</RChip>
</h3>
<div v-if="showDetectedFilter" class="r-setup-platforms__toolbar">
<RSliderBtnGroup
<RSegmentedControl
v-model="detectedFilter"
:items="detectedFilterItems"
variant="segmented"

View File

@@ -88,7 +88,7 @@ describe("MatchRomDialog", () => {
MatchRomBodyGrid,
RTextField: true,
RSelect: true,
RSliderBtnGroup: true,
RSegmentedControl: true,
RIcon: true,
RSpinner: true,
RTooltip: true,

View File

@@ -22,7 +22,7 @@ import {
RDialog,
RIcon,
RSelect,
RSliderBtnGroup,
RSegmentedControl,
RSpinner,
RTextField,
} from "@/lib";
@@ -319,7 +319,7 @@ function closeDialog() {
<!-- Layout switcher: grid vs list, mirroring the gallery's own
toggle. It lives up here because the header is the one row that
never reflows as the filters or the search state change. -->
<RSliderBtnGroup
<RSegmentedControl
:model-value="variant"
:items="variantItems"
variant="segmented"

View File

@@ -32,7 +32,7 @@ import {
RDrawer,
RIcon,
RSelect,
RSliderBtnGroup,
RSegmentedControl,
RTag,
RTextField,
} from "@/lib";
@@ -133,7 +133,7 @@ const providerTitle = (slug: string): string =>
providerLabels.get(slug) ?? slug;
// ── Tri-state mapping helpers ──────────────────────────────────
// The RSliderBtnGroup speaks string ids; the store speaks `boolean | null`.
// The RSegmentedControl speaks string ids; the store speaks `boolean | null`.
// One helper makes the binding bidirectional in a few lines.
type TriValue = "all" | "yes" | "no";
function triFor(v: boolean | null): TriValue {
@@ -555,7 +555,7 @@ function saveAsSmartCollection() {
<RIcon :icon="cfg.icon" size="16" />
<span>{{ cfg.label }}</span>
</span>
<RSliderBtnGroup
<RSegmentedControl
:model-value="triFor(cfg.value.value)"
:items="triItems(cfg)"
size="small"
@@ -611,7 +611,7 @@ function saveAsSmartCollection() {
{{ s.label }}
</template>
</RSelect>
<RSliderBtnGroup
<RSegmentedControl
:model-value="s.logic.value"
:items="LOGIC_ITEMS"
size="small"

View File

@@ -35,7 +35,7 @@ function mountToolbar(
RBtn: true,
RIcon: true,
RMenu: menuStub,
RSliderBtnGroup: true,
RSegmentedControl: true,
},
},
});
@@ -158,7 +158,7 @@ describe("GalleryToolbar sort axis", () => {
it("hides the direction toggle while the unsorted order is active", () => {
const sorted = mountWithSortOptions({ unsortedLabel: "Relevance" });
const togglesWhenSorted = sorted.findAllComponents({
name: "RSliderBtnGroup",
name: "RSegmentedControl",
}).length;
sorted.unmount();
@@ -168,9 +168,9 @@ describe("GalleryToolbar sort axis", () => {
unsorted: true,
});
expect(wrapper.findAllComponents({ name: "RSliderBtnGroup" })).toHaveLength(
togglesWhenSorted - 1,
);
expect(
wrapper.findAllComponents({ name: "RSegmentedControl" }),
).toHaveLength(togglesWhenSorted - 1);
const relevance = wrapper
.findAllComponents({ name: "RMenuItem" })
.find((item) => item.props("label") === "Relevance");
@@ -184,7 +184,7 @@ describe("GalleryToolbar sort axis", () => {
it("ticks nothing and keeps the toggle for a sort it doesn't offer", () => {
const sorted = mountWithSortOptions({ unsortedLabel: "Relevance" });
const togglesWhenSorted = sorted.findAllComponents({
name: "RSliderBtnGroup",
name: "RSegmentedControl",
}).length;
sorted.unmount();
@@ -194,9 +194,9 @@ describe("GalleryToolbar sort axis", () => {
unsorted: false,
});
expect(wrapper.findAllComponents({ name: "RSliderBtnGroup" })).toHaveLength(
togglesWhenSorted,
);
expect(
wrapper.findAllComponents({ name: "RSegmentedControl" }),
).toHaveLength(togglesWhenSorted);
const ticked = wrapper
.findAllComponents({ name: "RMenuItem" })
.filter(

View File

@@ -25,7 +25,7 @@ import {
RIcon,
RMenu,
RMenuItem,
RSliderBtnGroup,
RSegmentedControl,
RTextField,
} from "@/lib";
import { shouldAutofocusSearch } from "@/utils/autofocus";
@@ -315,7 +315,7 @@ const { smAndUp } = useBreakpoint();
<slot name="actions" />
<template v-if="smAndUp">
<RSliderBtnGroup
<RSegmentedControl
v-for="sf in segmentFilters"
:key="sf.key"
:model-value="sf.value"
@@ -334,7 +334,7 @@ const { smAndUp } = useBreakpoint();
<div class="gallery-toolbar__controls">
<!-- Grouping and sort: list mode sorts from its column header instead. -->
<template v-if="smAndUp && !listMode">
<RSliderBtnGroup
<RSegmentedControl
v-if="showGroupBy"
:model-value="groupByValue"
:items="effectiveGroupByItems"
@@ -376,7 +376,7 @@ const { smAndUp } = useBreakpoint();
/>
</RMenu>
<RSliderBtnGroup
<RSegmentedControl
v-if="!unsorted"
:model-value="sortDirValue"
:items="sortDirItems"
@@ -386,7 +386,7 @@ const { smAndUp } = useBreakpoint();
/>
</template>
<RSliderBtnGroup
<RSegmentedControl
v-if="smAndUp"
:model-value="layoutValue"
:items="layoutItems"

View File

@@ -21,7 +21,7 @@ const RDialog = {
props: ["modelValue"],
template: `<div v-if="modelValue"><slot name="toolbar" /><slot name="content" /></div>`,
};
const RSliderBtnGroup = {
const RSegmentedControl = {
props: ["modelValue", "items"],
emits: ["update:modelValue"],
template: `<div><button v-for="i in items" :key="i.id" :class="'tab-' + i.id" @click="$emit('update:modelValue', i.id)" /></div>`,
@@ -64,7 +64,7 @@ function openDialog() {
const wrapper = mount(LoadSaveStateDialog, {
global: {
provide: { emitter },
stubs: { RDialog, RSliderBtnGroup, AssetList, AssetStrip, RBtn: true },
stubs: { RDialog, RSegmentedControl, AssetList, AssetStrip, RBtn: true },
},
});
const open = async () => {

View File

@@ -11,7 +11,7 @@ import { useBreakpoint } from "@/composables/useBreakpoint";
import { useConfirm } from "@/composables/useConfirm";
import { useEmitterEvent } from "@/composables/useEmitterEvent";
import { useSaveStateTabs } from "@/composables/useSaveStateTabs";
import { RDialog, RSliderBtnGroup } from "@/lib";
import { RDialog, RSegmentedControl } from "@/lib";
import type { DetailedRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import type { Asset, AssetType } from "@/utils/assets";
@@ -89,7 +89,7 @@ function closeDialog() {
</template>
<template #toolbar>
<div class="r-load-save-state__tabs">
<RSliderBtnGroup
<RSegmentedControl
v-model="tab"
variant="tab"
:items="tabs"

View File

@@ -3,8 +3,8 @@
import type { Meta, StoryObj } from "@storybook/vue3-vite";
import { computed, ref } from "vue";
import type { SaveSchema, StateSchema } from "@/__generated__";
import { RCard, RSliderBtnGroup } from "@/lib";
import type { SliderBtnGroupItem } from "@/lib/primitives/RSliderBtnGroup/types";
import { RCard, RSegmentedControl } from "@/lib";
import type { SegmentedControlItem } from "@/lib/primitives/RSegmentedControl/types";
import { makeSave, manyStates } from "@/utils/saveStates.fixtures";
import { CONTRAST_TODO_PARAMETERS } from "@/utils/storyA11y";
import AssetList from "../shared/AssetList.vue";
@@ -65,7 +65,13 @@ function renderPanel(
selectFirst = true,
) {
return {
components: { AssetList, AssetPreview, AssetStrip, RCard, RSliderBtnGroup },
components: {
AssetList,
AssetPreview,
AssetStrip,
RCard,
RSegmentedControl,
},
setup() {
const activeTab = ref<AssetTab>(tab);
const first = (list: { id: number }[]) =>
@@ -73,7 +79,7 @@ function renderPanel(
const selectedSaveId = ref<number | null>(first(saves));
const selectedStateId = ref<number | null>(first(states));
const tabs = computed<SliderBtnGroupItem<AssetTab>[]>(() => [
const tabs = computed<SegmentedControlItem<AssetTab>[]>(() => [
{
id: "save",
label: `Saves${saves.length ? ` · ${saves.length}` : ""}`,
@@ -147,7 +153,7 @@ function renderPanel(
"
>
<div style="padding:14px 14px 0;display:flex;justify-content:center">
<RSliderBtnGroup
<RSegmentedControl
variant="tab"
:model-value="activeTab"
:items="tabs"

View File

@@ -39,7 +39,7 @@ function mountSection(
RIcon: true,
PlatformIcon: true,
RProgressLinear: true,
RSliderBtnGroup: true,
RSegmentedControl: true,
RTextField: true,
},
},

View File

@@ -26,10 +26,10 @@ import {
REmptyState,
RIcon,
RProgressLinear,
RSliderBtnGroup,
RSegmentedControl,
RTextField,
} from "@/lib";
import type { SliderBtnGroupItem } from "@/lib";
import type { SegmentedControlItem } from "@/lib";
import storeConfig from "@/stores/config";
import storePlatforms from "@/stores/platforms";
import { formatBytes, regionToEmoji } from "@/utils";
@@ -56,7 +56,7 @@ type OrderBy = "name" | "size" | "count";
const orderBy = ref<OrderBy>("name");
const searchQuery = ref("");
const orderItems = computed<SliderBtnGroupItem<OrderBy>[]>(() => [
const orderItems = computed<SegmentedControlItem<OrderBy>[]>(() => [
{
id: "name",
icon: "mdi-sort-alphabetical-variant",
@@ -213,7 +213,7 @@ function onRowClick(e: MouseEvent, platformId: number): void {
<RIcon icon="mdi-magnify" size="16" />
</template>
</RTextField>
<RSliderBtnGroup
<RSegmentedControl
:model-value="orderBy"
:items="orderItems"
variant="segmented"

View File

@@ -61,7 +61,7 @@ function toggle() {
(e.g. a "Compact / Extended" segmented control for the
Library Snapshot widget toggle). Click events stop here so
nested interactive controls don't bubble up and flip the row
toggle; mousedown is stopped too so `<RSliderBtnGroup>`'s
toggle; mousedown is stopped too so `<RSegmentedControl>`'s
pointer-based active-pill animation doesn't trigger a row
click on release. */
-->

View File

@@ -1,7 +1,7 @@
import { computed, toValue, type MaybeRefOrGetter } from "vue";
import { useI18n } from "vue-i18n";
import type { SaveSchema, StateSchema } from "@/__generated__";
import type { SliderBtnGroupItem } from "@/lib/primitives/RSliderBtnGroup/types";
import type { SegmentedControlItem } from "@/lib/primitives/RSegmentedControl/types";
import { useStreamingStore } from "@/stores/streaming";
import { isCoreCompatible, type AssetType } from "@/utils/assets";
@@ -25,7 +25,7 @@ export function useSaveStateTabs(
() => compatibleStates.value.length === stateCount.value,
);
const tabs = computed<SliderBtnGroupItem<AssetType>[]>(() => [
const tabs = computed<SegmentedControlItem<AssetType>[]>(() => [
{
id: "save",
label: t("common.saves"),

View File

@@ -25,8 +25,8 @@ export * from "./primitives/RLetterHeading";
export * from "./primitives/RMarquee";
export * from "./primitives/RProgressCircular";
export * from "./primitives/RProgressLinear";
export * from "./primitives/RSegmentedControl";
export * from "./primitives/RSkeletonBlock";
export * from "./primitives/RSliderBtnGroup";
export * from "./primitives/RSpinner";
export * from "./primitives/RSteps";
export * from "./primitives/RTabNav";

View File

@@ -366,7 +366,7 @@ export const FormActions: Story = {
/**
* `surface` gives an outlined icon-only RBtn the same tinted chrome as the
* `RSliderBtnGroup` beside it.
* `RSegmentedControl` beside it.
*/
export const SurfaceWithSlider: Story = {
name: "Surface modifier (icon button next to slider)",

View File

@@ -86,7 +86,7 @@ interface Props {
/** Paints the lib's `--r-color-bg-elevated` token behind the button.
* Composes with any variant: use it when the button needs to read
* as "raised on a tinted pill" rather than "transparent on the page",
* so it visually aligns with adjacent segmented `RSliderBtnGroup`
* so it visually aligns with adjacent segmented `RSegmentedControl`
* surfaces (e.g., toolbar icon buttons next to sliders). */
surface?: boolean;
/** Toggle state. Defined → `aria-pressed`; true → translucent tint. */

View File

@@ -1,12 +1,12 @@
import type { Meta, StoryObj } from "@storybook/vue3";
import { ref } from "vue";
import RSliderBtnGroup from "./RSliderBtnGroup.vue";
import RSegmentedControl from "./RSegmentedControl.vue";
// Generic components can't fill Storybook's `component` slot, so it's cast;
// the instantiation types the stories' args.
const meta: Meta<typeof RSliderBtnGroup<string>> = {
title: "Primitives/RSliderBtnGroup",
component: RSliderBtnGroup as never,
const meta: Meta<typeof RSegmentedControl<string>> = {
title: "Primitives/RSegmentedControl",
component: RSegmentedControl as never,
argTypes: {
variant: {
control: "select",
@@ -33,13 +33,13 @@ type Story = StoryObj;
export const Segmented: Story = {
args: { variant: "segmented" },
render: (args) => ({
components: { RSliderBtnGroup },
components: { RSegmentedControl },
setup() {
const layout = ref<"grid" | "list">("grid");
return { args, layout };
},
template: `
<RSliderBtnGroup
<RSegmentedControl
v-bind="args"
:model-value="layout"
:items="[
@@ -55,13 +55,13 @@ export const Segmented: Story = {
export const Tab: Story = {
args: { variant: "tab" },
render: (args) => ({
components: { RSliderBtnGroup },
components: { RSegmentedControl },
setup() {
const active = ref<"home" | "favorites" | "platforms">("home");
return { args, active };
},
template: `
<RSliderBtnGroup
<RSegmentedControl
v-bind="args"
:model-value="active"
:items="[
@@ -82,14 +82,14 @@ export const Tab: Story = {
export const VerticalTab: Story = {
args: { variant: "tab", orientation: "vertical" },
render: (args) => ({
components: { RSliderBtnGroup },
components: { RSegmentedControl },
setup() {
const tool = ref<"scan" | "upload" | "patcher">("scan");
return { args, tool };
},
template: `
<div style="display: inline-block;">
<RSliderBtnGroup
<RSegmentedControl
v-bind="args"
:model-value="tool"
:items="[
@@ -120,13 +120,13 @@ export const VerticalTab: Story = {
export const VerticalSegmented: Story = {
args: { variant: "segmented", orientation: "vertical" },
render: (args) => ({
components: { RSliderBtnGroup },
components: { RSegmentedControl },
setup() {
const view = ref<"grid" | "list" | "compact">("grid");
return { args, view };
},
template: `
<RSliderBtnGroup
<RSegmentedControl
v-bind="args"
:model-value="view"
:items="[
@@ -143,13 +143,13 @@ export const VerticalSegmented: Story = {
export const Disabled: Story = {
args: { variant: "segmented" },
render: (args) => ({
components: { RSliderBtnGroup },
components: { RSegmentedControl },
setup() {
const group = ref<"none" | "letter">("none");
return { args, group };
},
template: `
<RSliderBtnGroup
<RSegmentedControl
v-bind="args"
:model-value="group"
:items="[

View File

@@ -2,9 +2,9 @@ import { mount } from "@vue/test-utils";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { nextTick } from "vue";
import { stubResizeObserver } from "@/test-utils/resizeObserver";
import RSliderBtnGroup from "./RSliderBtnGroup.vue";
import RSegmentedControl from "./RSegmentedControl.vue";
describe("RSliderBtnGroup resize", () => {
describe("RSegmentedControl resize", () => {
let frames: FrameRequestCallback[] = [];
let ro: ReturnType<typeof stubResizeObserver>;
@@ -24,7 +24,7 @@ describe("RSliderBtnGroup resize", () => {
});
async function render() {
const wrapper = mount(RSliderBtnGroup, {
const wrapper = mount(RSegmentedControl, {
props: {
modelValue: "a",
items: [
@@ -42,11 +42,11 @@ describe("RSliderBtnGroup resize", () => {
it("snaps into place without sliding when a hidden group is shown", async () => {
const wrapper = await render();
const group = wrapper.get(".r-slider-btn-group").element;
const group = wrapper.get(".r-segmented-control").element;
const animated = () =>
wrapper
.get(".r-slider-btn-group__indicator")
.classes("r-slider-btn-group__indicator--animate");
.get(".r-segmented-control__indicator")
.classes("r-segmented-control__indicator--animate");
expect(animated()).toBe(true);
vi.spyOn(group, "getBoundingClientRect").mockReturnValue(
@@ -63,7 +63,7 @@ describe("RSliderBtnGroup resize", () => {
it("stops observing on unmount", async () => {
const wrapper = await render();
const group = wrapper.get(".r-slider-btn-group").element;
const group = wrapper.get(".r-segmented-control").element;
expect(ro.isObserved(group)).toBe(true);
wrapper.unmount();

View File

@@ -1,5 +1,5 @@
<script setup lang="ts" generic="T extends string | number">
// RSliderBtnGroup: segmented/tab control with a sliding pill indicator.
// RSegmentedControl: segmented/tab control with a sliding pill indicator.
// One active id at a time; the indicator transitions from the previous button
// to the new one on modelValue change.
//
@@ -15,14 +15,14 @@ import { nextTick, onMounted, ref, watch } from "vue";
import RTooltip from "@/lib/structural/RTooltip/RTooltip.vue";
import RBtn from "../RBtn/RBtn.vue";
import RIcon from "../RIcon/RIcon.vue";
import type { SliderBtnGroupItem } from "./types";
import type { SegmentedControlItem } from "./types";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
modelValue: T | null;
items: SliderBtnGroupItem<T>[];
items: SegmentedControlItem<T>[];
variant?: "segmented" | "tab";
/** Stack direction. `vertical` swaps the indicator from translateX/width
* to translateY/height and changes the flex axis. Same aesthetic, same
@@ -165,7 +165,7 @@ onMounted(async () => {
// `badge` accepts `string | number | null`, so a plain truthiness check would
// still render a pill for the literal "0", and `badge !== 0` misses the string
// "0" / empty string. Centralise the visible-badge rule here.
function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
function showBadge(badge: SegmentedControlItem<T>["badge"]): boolean {
return badge != null && badge !== 0 && badge !== "" && badge !== "0";
}
</script>
@@ -178,20 +178,20 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
<div
ref="groupEl"
v-bind="$attrs"
class="r-slider-btn-group"
class="r-segmented-control"
:class="[
`r-slider-btn-group--${variant}`,
`r-slider-btn-group--${orientation}`,
`r-slider-btn-group--size-${size}`,
{ 'r-slider-btn-group--disabled': disabled },
`r-segmented-control--${variant}`,
`r-segmented-control--${orientation}`,
`r-segmented-control--size-${size}`,
{ 'r-segmented-control--disabled': disabled },
]"
:aria-label="ariaLabel"
:aria-disabled="disabled || undefined"
:role="ariaLabel ? 'group' : undefined"
>
<span
class="r-slider-btn-group__indicator"
:class="{ 'r-slider-btn-group__indicator--animate': animate }"
class="r-segmented-control__indicator"
:class="{ 'r-segmented-control__indicator--animate': animate }"
:style="
orientation === 'vertical'
? {
@@ -212,8 +212,8 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
v-if="item.to"
:ref="(el) => setBtnEl(item.id, el)"
:to="item.to"
class="r-slider-btn-group__btn"
:class="{ 'r-slider-btn-group__btn--active': item.id === modelValue }"
class="r-segmented-control__btn"
:class="{ 'r-segmented-control__btn--active': item.id === modelValue }"
:aria-label="item.ariaLabel"
>
<RTooltip
@@ -224,10 +224,10 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
/>
<slot name="item" :item="item" :active="item.id === modelValue">
<RIcon v-if="item.icon" :icon="item.icon" size="16" />
<span v-if="item.label" class="r-slider-btn-group__label">
<span v-if="item.label" class="r-segmented-control__label">
{{ item.label }}
</span>
<span v-if="showBadge(item.badge)" class="r-slider-btn-group__badge">
<span v-if="showBadge(item.badge)" class="r-segmented-control__badge">
{{ item.badge }}
</span>
</slot>
@@ -238,8 +238,8 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
variant="text"
density="compact"
size="x-small"
class="r-slider-btn-group__btn"
:class="{ 'r-slider-btn-group__btn--active': item.id === modelValue }"
class="r-segmented-control__btn"
:class="{ 'r-segmented-control__btn--active': item.id === modelValue }"
:aria-label="item.ariaLabel"
:aria-pressed="item.id === modelValue"
:disabled="disabled || item.disabled"
@@ -253,10 +253,10 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
/>
<slot name="item" :item="item" :active="item.id === modelValue">
<RIcon v-if="item.icon" :icon="item.icon" size="16" />
<span v-if="item.label" class="r-slider-btn-group__label">
<span v-if="item.label" class="r-segmented-control__label">
{{ item.label }}
</span>
<span v-if="showBadge(item.badge)" class="r-slider-btn-group__badge">
<span v-if="showBadge(item.badge)" class="r-segmented-control__badge">
{{ item.badge }}
</span>
</slot>
@@ -266,7 +266,7 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
</template>
<style scoped>
.r-slider-btn-group {
.r-segmented-control {
position: relative;
display: inline-flex;
align-items: center;
@@ -278,7 +278,7 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
work (just on the Y axis) thanks to the orientation-aware measure
in update(). Items stretch to the container's width so they align
in a clean column. */
.r-slider-btn-group--vertical {
.r-segmented-control--vertical {
flex-direction: column;
align-items: stretch;
border-radius: var(--r-radius-lg);
@@ -288,7 +288,7 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
28×28 inner buttons + 1px border puts the outer pill at 36px, which
matches an `RBtn size="default"` sitting next to it (e.g., the disc
filter / kebab buttons in `GalleryToolbar`). */
.r-slider-btn-group--segmented {
.r-segmented-control--segmented {
padding: 3px;
gap: 2px;
background: var(--r-color-bg-elevated);
@@ -296,7 +296,7 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
}
/* Tab: text-padded cluster (top-nav style). */
.r-slider-btn-group--tab {
.r-segmented-control--tab {
padding: 4px;
gap: 2px;
background: var(--r-color-surface);
@@ -304,7 +304,7 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
backdrop-filter: blur(20px);
}
.r-slider-btn-group__indicator {
.r-segmented-control__indicator {
position: absolute;
left: 0;
/* Always a white pill with dark ink on top (the emphasis-pill vocabulary),
@@ -318,13 +318,13 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
opacity: 0;
}
.r-slider-btn-group--segmented.r-slider-btn-group--horizontal
.r-slider-btn-group__indicator {
.r-segmented-control--segmented.r-segmented-control--horizontal
.r-segmented-control__indicator {
top: 3px;
bottom: 3px;
}
.r-slider-btn-group--tab.r-slider-btn-group--horizontal
.r-slider-btn-group__indicator {
.r-segmented-control--tab.r-segmented-control--horizontal
.r-segmented-control__indicator {
top: 4px;
bottom: 4px;
}
@@ -335,20 +335,20 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
the indicator's static position in a column-flex layout sits after
the flex items, and `translateY(<offset>)` then adds to that,
shifting the active background downward off the active item. */
.r-slider-btn-group--tab.r-slider-btn-group--vertical
.r-slider-btn-group__indicator {
.r-segmented-control--tab.r-segmented-control--vertical
.r-segmented-control__indicator {
top: 0;
left: 4px;
right: 4px;
}
.r-slider-btn-group--segmented.r-slider-btn-group--vertical
.r-slider-btn-group__indicator {
.r-segmented-control--segmented.r-segmented-control--vertical
.r-segmented-control__indicator {
top: 0;
left: 3px;
right: 3px;
}
.r-slider-btn-group__indicator--animate {
.r-segmented-control__indicator--animate {
transition:
transform var(--r-motion-med) var(--r-motion-ease-out),
width var(--r-motion-med) var(--r-motion-ease-out),
@@ -362,12 +362,12 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
opacity binding (see template); the active button must drop its
inverted text colour too so it reads like every other muted item
instead of leaving a low-contrast `--r-color-bg` ghost behind. */
.r-slider-btn-group--disabled {
.r-segmented-control--disabled {
opacity: 0.4;
pointer-events: none;
}
.r-slider-btn-group--disabled .r-slider-btn-group__btn--active,
.r-slider-btn-group--disabled .r-slider-btn-group__btn--active:hover {
.r-segmented-control--disabled .r-segmented-control__btn--active,
.r-segmented-control--disabled .r-segmented-control__btn--active:hover {
color: var(--r-color-fg-secondary) !important;
}
@@ -375,7 +375,7 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
transparent so the slide reads cleanly behind them. `transform` + extra
transitions give the hover/press animation parity with RBtn's
currentColor overlay + scale press cue. */
.r-slider-btn-group__btn {
.r-segmented-control__btn {
position: relative;
z-index: 1;
border-radius: var(--r-radius-pill) !important;
@@ -387,14 +387,14 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
}
/* Press feedback: subtle scale-down, skipping the active pill so its
content doesn't pulse during a drag/repeat. */
.r-slider-btn-group__btn:active:not(.r-slider-btn-group__btn--active) {
.r-segmented-control__btn:active:not(.r-segmented-control__btn--active) {
transform: scale(0.94);
}
/* Segmented sizing + colors. RBtn's variant styles apply a colour by
default; to get a neutral grey here we override with equal-or-greater
specificity + !important. */
.r-slider-btn-group--segmented .r-slider-btn-group__btn {
.r-segmented-control--segmented .r-segmented-control__btn {
min-width: 28px !important;
min-height: 28px !important;
width: 28px !important;
@@ -405,17 +405,19 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
display: inline-grid;
place-items: center;
}
.r-slider-btn-group--segmented .r-slider-btn-group__btn :deep(.r-btn__content) {
.r-segmented-control--segmented
.r-segmented-control__btn
:deep(.r-btn__content) {
min-width: 0;
}
.r-slider-btn-group--segmented
.r-slider-btn-group__btn:hover:not(.r-slider-btn-group__btn--active) {
.r-segmented-control--segmented
.r-segmented-control__btn:hover:not(.r-segmented-control__btn--active) {
color: var(--r-color-fg) !important;
background: var(--r-color-surface) !important;
transform: scale(1.08);
}
.r-slider-btn-group--segmented .r-slider-btn-group__btn--active,
.r-slider-btn-group--segmented .r-slider-btn-group__btn--active:hover {
.r-segmented-control--segmented .r-segmented-control__btn--active,
.r-segmented-control--segmented .r-segmented-control__btn--active:hover {
color: var(--r-color-overlay-emphasis-fg) !important;
}
@@ -423,22 +425,22 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
token so the segmented control reads as a peer to a 20px RSwitch
when sitting inline inside a SettingsToggleRow. Default `small`
(28×28) keeps every existing call site identical. */
.r-slider-btn-group--segmented.r-slider-btn-group--size-x-small
.r-slider-btn-group__btn {
.r-segmented-control--segmented.r-segmented-control--size-x-small
.r-segmented-control__btn {
min-width: 22px !important;
min-height: 22px !important;
width: 22px !important;
height: 22px !important;
}
.r-slider-btn-group--segmented.r-slider-btn-group--size-x-small
.r-slider-btn-group__btn
.r-segmented-control--segmented.r-segmented-control--size-x-small
.r-segmented-control__btn
:deep(.mdi) {
font-size: 12px !important;
}
/* Tab sizing + colors. Min-height is explicit (and !important) so RBtn items
(no `to`) match the height of router-link items. */
.r-slider-btn-group--tab .r-slider-btn-group__btn {
.r-segmented-control--tab .r-segmented-control__btn {
padding: 7px 22px !important;
min-height: 34px !important;
font-size: 13.5px;
@@ -448,13 +450,13 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
align-items: center;
gap: 6px;
}
.r-slider-btn-group--tab
.r-slider-btn-group__btn:hover:not(.r-slider-btn-group__btn--active) {
.r-segmented-control--tab
.r-segmented-control__btn:hover:not(.r-segmented-control__btn--active) {
color: var(--r-color-fg) !important;
background: var(--r-color-surface-hover);
}
.r-slider-btn-group--tab .r-slider-btn-group__btn--active,
.r-slider-btn-group--tab .r-slider-btn-group__btn--active:hover {
.r-segmented-control--tab .r-segmented-control__btn--active,
.r-segmented-control--tab .r-segmented-control__btn--active:hover {
color: var(--r-color-overlay-emphasis-fg) !important;
background: transparent !important;
font-weight: var(--r-font-weight-semibold);
@@ -463,7 +465,7 @@ function showBadge(badge: SliderBtnGroupItem<T>["badge"]): boolean {
/* Count pill after the label. Background is a translucent tint of the
current text colour, so it stays legible both on inactive items
(muted fg) and on the active item (inverted onto the indicator). */
.r-slider-btn-group__badge {
.r-segmented-control__badge {
display: inline-grid;
place-items: center;
min-width: 18px;

View File

@@ -0,0 +1,2 @@
export { default as RSegmentedControl } from "./RSegmentedControl.vue";
export type { SegmentedControlItem } from "./types";

View File

@@ -1,4 +1,4 @@
export interface SliderBtnGroupItem<T extends string | number> {
export interface SegmentedControlItem<T extends string | number> {
id: T;
label?: string;
icon?: string;

View File

@@ -1,2 +0,0 @@
export { default as RSliderBtnGroup } from "./RSliderBtnGroup.vue";
export type { SliderBtnGroupItem } from "./types";

View File

@@ -2,7 +2,7 @@
// RTabNav: single component, two visual presentations:
// * variant="underlined" (default): horizontal nav with a brand
// underline on active. Used for primary tabs and tight subtabs.
// The underline is a sliding indicator (parallels RSliderBtnGroup)
// The underline is a sliding indicator (parallels RSegmentedControl)
// that translates between buttons on `modelValue` change.
// * variant="pill": stacked menu-like items with a soft rounded
// fill on active. Pairs naturally with `orientation="vertical"`
@@ -477,7 +477,7 @@ html[data-input="pad"] .r-tab-nav__btn:focus-visible::before {
}
/* Sliding underline: sits on the bottom border line, slides between
buttons on modelValue change (parallels RSliderBtnGroup's indicator). */
buttons on modelValue change (parallels RSegmentedControl's indicator). */
.r-tab-nav__indicator {
position: absolute;
left: 0;

View File

@@ -64,7 +64,7 @@ import {
RCard,
RIcon,
RSelect,
RSliderBtnGroup,
RSegmentedControl,
RSpinner,
RSwitch,
RTextField,
@@ -862,7 +862,7 @@ const saveSlot = computed(() => chosenSlot(slotChoice.value, customSlot.value));
variant="flat"
>
<div class="r-ejs__panel-head">
<RSliderBtnGroup
<RSegmentedControl
variant="tab"
:model-value="activeAssetTab"
:items="assetTabs"

View File

@@ -64,12 +64,12 @@ import {
RIcon,
RSelect,
RSlider,
RSliderBtnGroup,
RSegmentedControl,
RSpinner,
RSwitch,
RTooltip,
} from "@/lib";
import type { SliderBtnGroupItem } from "@/lib/primitives/RSliderBtnGroup/types";
import type { SegmentedControlItem } from "@/lib/primitives/RSegmentedControl/types";
import romApi from "@/services/api/rom";
import streamingApi, {
type ContainerBusyDetail,
@@ -495,7 +495,7 @@ function setResumeTab(id: ResumeTab): void {
resumeTab.value = id;
}
const resumeTabs = computed<SliderBtnGroupItem<ResumeTab>[]>(() => [
const resumeTabs = computed<SegmentedControlItem<ResumeTab>[]>(() => [
{
id: "state",
label: t("common.states"),
@@ -1519,7 +1519,7 @@ onBeforeUnmount(() => {
class="r-stream__panel-head"
:class="{ 'r-stream__panel-head--label': !showResumeTabs }"
>
<RSliderBtnGroup
<RSegmentedControl
v-if="showResumeTabs"
variant="tab"
:model-value="activeResumeTab"

View File

@@ -25,7 +25,7 @@ import { useDebugMode } from "@/composables/useDebugMode";
import { useReducedMotion } from "@/composables/useReducedMotion";
import { useSnackbar } from "@/composables/useSnackbar";
import { useUISettings } from "@/composables/useUISettings";
import { RBtn, RIcon, RSelect, RSliderBtnGroup } from "@/lib";
import { RBtn, RIcon, RSelect, RSegmentedControl } from "@/lib";
import { canOpenNativeSettings, openNativeSettings } from "@/services/native";
import storeCollections from "@/stores/collections";
import { useNativeStore } from "@/stores/native";
@@ -321,7 +321,7 @@ function onVirtualCollectionTypeChange(value: unknown) {
are stopped by the slot wrapper in SettingsToggleRow
so toggling the segmented control doesn't also flip
the row's main switch. -->
<RSliderBtnGroup
<RSegmentedControl
v-model="libraryStatsMode"
:items="libraryStatsModeItems"
variant="segmented"