Skip to content

Commit 9dfe4ee

Browse files
refactor(switch): rename Radio to SwitchSingle
1 parent 26c70b7 commit 9dfe4ee

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import type { MayHaveClass } from "~ui/utils/MayHaveClass"
88
/**
99
* https://github.com/radix-ui/primitives/blob/main/packages/react/radio-group/src/Radio.tsx
1010
*/
11-
export interface RadioSwitchProps extends MayHaveClass {
11+
export interface SwitchSingleProps extends MayHaveClass {
1212
id?: string
1313
valueSignal: SignalObject<string>
1414
getOptions: () => string[]
1515
valueText?: (value: string) => string
1616
disabled?: boolean
1717
}
1818

19-
export function RadioSwitch(p: RadioSwitchProps) {
19+
export function SwitchSingle(p: SwitchSingleProps) {
2020
const filled = true
2121
return (
2222
<div

src/demos/demoList.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@ const DemoTablePagination = lazy(async () => {
2121
return { default: c.DemoTablePagination }
2222
})
2323

24-
const DemoRadioSwitch = lazy(async () => {
25-
const c = await import("@/demos/input/DemoRadioSwitch")
26-
return { default: c.DemoRadioSwitch }
27-
})
28-
29-
const DemoMultiSelect = lazy(async () => {
30-
const c = await import("@/demos/input/DemoMultiSelect")
31-
return { default: c.DemoMultiSelect }
24+
const DemoSwitchSingle = lazy(async () => {
25+
const c = await import("@/demos/input/DemoSwitchSingle")
26+
return { default: c.DemoSwitchSingle }
3227
})
3328

3429
const DemoInputS = lazy(async () => {
@@ -41,9 +36,24 @@ const DemoNumberInput = lazy(async () => {
4136
return { default: c.DemoNumberInput }
4237
})
4338

44-
const DemoNativeSingleSelect = lazy(async () => {
45-
const c = await import("@/demos/input/DemoNativeSingleSelect")
46-
return { default: c.DemoNativeSingleSelect }
39+
const DemoSelectSingleNative = lazy(async () => {
40+
const c = await import("@/demos/input/DemoSelectSingleNative")
41+
return { default: c.DemoSelectSingleNative }
42+
})
43+
44+
const DemoCheckMultiple = lazy(async () => {
45+
const c = await import("@/demos/input/DemoCheckMultiple")
46+
return { default: c.DemoCheckMultiple }
47+
})
48+
49+
const DemoCheckbox = lazy(async () => {
50+
const c = await import("@/demos/input/DemoCheckbox")
51+
return { default: c.DemoCheckbox }
52+
})
53+
54+
const DemoSelectMultiple = lazy(async () => {
55+
const c = await import("@/demos/input/DemoSelectMultiple")
56+
return { default: c.DemoSelectMultiple }
4757
})
4858

4959
const DemoIcons = lazy(async () => {
@@ -146,11 +156,6 @@ const DemoDetails = lazy(async () => {
146156
return { default: c.DemoDetails }
147157
})
148158

149-
const DemoCheckbox = lazy(async () => {
150-
const c = await import("@/demos/interactive/DemoCheckbox")
151-
return { default: c.DemoCheckbox }
152-
})
153-
154159
const DemoDialog = lazy(async () => {
155160
const c = await import("@/demos/interactive/DemoDialog")
156161
return { default: c.DemoDialog }
@@ -173,11 +178,13 @@ const DemoLists = lazy(async () => {
173178

174179
export const demoList = {
175180
input: {
176-
DemoRadioSwitch: DemoRadioSwitch,
177-
DemoMultiSelect: DemoMultiSelect,
181+
DemoSwitchSingle: DemoSwitchSingle,
178182
DemoInputS: DemoInputS,
179183
DemoNumberInput: DemoNumberInput,
180-
DemoNativeSingleSelect: DemoNativeSingleSelect,
184+
DemoSelectSingleNative: DemoSelectSingleNative,
185+
DemoCheckMultiple: DemoCheckMultiple,
186+
DemoCheckbox: DemoCheckbox,
187+
DemoSelectMultiple: DemoSelectMultiple,
181188
},
182189
interactive: {
183190
DemoToaster: DemoToaster,
@@ -186,7 +193,6 @@ export const demoList = {
186193
DemoToggle: DemoToggle,
187194
DemoTheme: DemoTheme,
188195
DemoDetails: DemoDetails,
189-
DemoCheckbox: DemoCheckbox,
190196
DemoDialog: DemoDialog,
191197
DemoButtons: DemoButtons,
192198
DemoPopover: DemoPopover,
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import { RadioSwitch } from "~ui/input/radio/RadioSwitch"
1+
import { demoGetTextValue } from "@/demos/input/demoGetTextValue"
2+
import { SwitchSingle } from "~ui/input/switch/SwitchSingle"
23
import { PageWrapper } from "~ui/static/page/PageWrapper"
34
import { createSignalObject } from "~ui/utils/createSignalObject"
45
import { arrCreate } from "~utils/arr/arrCreate"
56

67
const options100 = arrCreate<string>(100, (i) => "" + i)
78
const singleValueSignal = createSignalObject<string>("")
89

9-
export function DemoRadioSwitch() {
10+
export function DemoSwitchSingle() {
1011
return (
1112
<PageWrapper>
12-
<RadioSwitch
13-
valueSignal={singleValueSignal}
14-
getOptions={() => options100}
15-
valueText={(value) => `Option ${value}`}
16-
/>
13+
<SwitchSingle valueSignal={singleValueSignal} getOptions={() => options100} valueText={demoGetTextValue} />
1714
</PageWrapper>
1815
)
1916
}

0 commit comments

Comments
 (0)