Skip to content

Commit

Permalink
chore: oppdater bruken av radioknapper
Browse files Browse the repository at this point in the history
affects: @fremtind/jkl-feedback-react

BREAKING CHANGE:
Avhenger av jkl-radio-button med breaking change
  • Loading branch information
wkillerud committed Nov 5, 2021
1 parent 992bb4a commit b0ce108
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/feedback-react/src/questions/RadioQuestion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ChangeEventHandler, useEffect, useMemo, useRef } from "react";
import { RadioButtons } from "@fremtind/jkl-radio-button-react";
import { RadioButton, RadioButtonGroup } from "@fremtind/jkl-radio-button-react";
import { QuestionProps } from "../types";
import { useFollowUpContext } from "../followup/followupContext";
import { useMainQuestionContext } from "../main-question/mainQuestionContext";
Expand Down Expand Up @@ -37,16 +37,23 @@ export const RadioQuestion: React.VFC<QuestionProps> = ({ label, name, options,
}

return (
<RadioButtons
ref={ref}
variant="large"
inline={numOptions < 3}
<RadioButtonGroup
legend={label}
labelProps={{ variant: "large" }}
name={name || label}
choices={options?.map(({ label, value }) => ({ label, value: value.toString() })) || []}
selectedValue={selectedValue}
inline={numOptions < 3}
value={selectedValue || ""}
onChange={handleChange}
helpLabel={helpLabel}
/>
>
{options?.map((option, i) => (
<RadioButton
ref={i === 0 ? ref : undefined}
key={`${name || label}${option.value}`}
label={option.label}
value={String(option.value)}
/>
))}
</RadioButtonGroup>
);
};

0 comments on commit b0ce108

Please sign in to comment.