mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-25 13:00:24 +08:00
* website: Support new widget types for labelling Adds proper support for yes/no spam style questions as well as a simple interface for flag style labels. Also cleaned up the Task component to fix some rerender issues. * website: Fix some UI text, adjust yes/no button alignment * website: Remove left over console.log Co-authored-by: notmd <33456881+notmd@users.noreply.github.com> --------- Co-authored-by: notmd <33456881+notmd@users.noreply.github.com>
33 lines
932 B
TypeScript
33 lines
932 B
TypeScript
import { Button, Flex } from "@chakra-ui/react";
|
|
import { useTranslation } from "next-i18next";
|
|
import { getTypeSafei18nKey } from "src/lib/i18n";
|
|
|
|
interface LabelFlagGroupProps {
|
|
values: number[];
|
|
labelNames: string[];
|
|
isEditable?: boolean;
|
|
onChange: (values: number[]) => void;
|
|
}
|
|
|
|
export const LabelFlagGroup = ({ values, labelNames, isEditable = true, onChange }: LabelFlagGroupProps) => {
|
|
const { t } = useTranslation("labelling");
|
|
return (
|
|
<Flex wrap="wrap" gap="4">
|
|
{labelNames.map((name, idx) => (
|
|
<Button
|
|
key={name}
|
|
onClick={() => {
|
|
const newValues = values.slice();
|
|
newValues[idx] = newValues[idx] ? 0 : 1;
|
|
onChange(newValues);
|
|
}}
|
|
isDisabled={!isEditable}
|
|
colorScheme={values[idx] === 1 ? "blue" : undefined}
|
|
>
|
|
{t(getTypeSafei18nKey(name))}
|
|
</Button>
|
|
))}
|
|
</Flex>
|
|
);
|
|
};
|