mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-05 17:30:48 +08:00
Rename to LabelRadio
This commit is contained in:
+7
-7
@@ -2,19 +2,19 @@ import { Box, Button, Flex, useColorMode } from "@chakra-ui/react";
|
||||
import { useId, useState } from "react";
|
||||
import { colors } from "src/styles/Theme/colors";
|
||||
|
||||
interface LabelSimpleGroupProps {
|
||||
interface LabelRadioGroupProps {
|
||||
labelIDs: Array<string>;
|
||||
onChange: (sliderValues: number[]) => unknown;
|
||||
isDisabled?: boolean;
|
||||
}
|
||||
|
||||
export const LabelSimpleGroup = (props: LabelSimpleGroupProps) => {
|
||||
export const LabelRadioGroup = (props: LabelRadioGroupProps) => {
|
||||
const [labelValues, setLabelValues] = useState<number[]>(Array.from({ length: props.labelIDs.length }).map(() => 0));
|
||||
|
||||
return (
|
||||
<Flex direction="column" justify="center">
|
||||
{props.labelIDs.map((labelId, idx) => (
|
||||
<LabelSimpleItem
|
||||
<LabelRadioItem
|
||||
key={idx}
|
||||
labelId={labelId}
|
||||
labelValue={labelValues[idx]}
|
||||
@@ -25,8 +25,8 @@ export const LabelSimpleGroup = (props: LabelSimpleGroupProps) => {
|
||||
setLabelValues(newState);
|
||||
}}
|
||||
states={[
|
||||
{ text: "No", value: 0, colorScheme: "green" },
|
||||
{ text: "Yes", value: 1, colorScheme: "red" },
|
||||
{ text: "No", value: 0, colorScheme: "blue" },
|
||||
{ text: "Yes", value: 1, colorScheme: "blue" },
|
||||
]}
|
||||
isDisabled={props.isDisabled}
|
||||
/>
|
||||
@@ -41,7 +41,7 @@ interface ButtonState {
|
||||
colorScheme: string;
|
||||
}
|
||||
|
||||
interface LabelSimpleItemProps {
|
||||
interface LabelRadioItemProps {
|
||||
labelId: string;
|
||||
labelValue: number;
|
||||
clickHandler: (newVal: number) => unknown;
|
||||
@@ -49,7 +49,7 @@ interface LabelSimpleItemProps {
|
||||
isDisabled: boolean;
|
||||
}
|
||||
|
||||
const LabelSimpleItem = (props: LabelSimpleItemProps) => {
|
||||
const LabelRadioItem = (props: LabelRadioItemProps) => {
|
||||
const id = useId();
|
||||
const { colorMode } = useColorMode();
|
||||
|
||||
@@ -7,7 +7,7 @@ import { TwoColumnsWithCards } from "src/components/Survey/TwoColumnsWithCards";
|
||||
import { TaskSurveyProps } from "src/components/Tasks/Task";
|
||||
import { TaskType } from "src/types/Task";
|
||||
import { LabelSliderGroup } from "src/components/Survey/LabelSliderGroup";
|
||||
import { LabelSimpleGroup } from "src/components/Survey/LabelSimpleGroup";
|
||||
import { LabelRadioGroup } from "src/components/Survey/LabelRadioGroup";
|
||||
|
||||
export const LabelTask = ({
|
||||
task,
|
||||
@@ -67,7 +67,7 @@ export const LabelTask = ({
|
||||
)}
|
||||
</>
|
||||
{valid_labels.length === 1 ? (
|
||||
<LabelSimpleGroup labelIDs={task.valid_labels} isDisabled={isDisabled} onChange={onSliderChange} />
|
||||
<LabelRadioGroup labelIDs={task.valid_labels} isDisabled={isDisabled} onChange={onSliderChange} />
|
||||
) : (
|
||||
<LabelSliderGroup labelIDs={task.valid_labels} isDisabled={isDisabled} onChange={onSliderChange} />
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user