From e3882eb308ef03035a31c8f364daa33e58f7794a Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Fri, 24 Nov 2023 15:50:10 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F(react)=20support=20ReactN?= =?UTF-8?q?ode=20as=20input=20label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are use cases that required to put links inside Checkboxes or Radio inputs. --- .changeset/eighty-elephants-call.md | 5 +++++ packages/react/src/components/Forms/Checkbox/index.tsx | 3 ++- packages/react/src/components/Forms/Radio/index.tsx | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/eighty-elephants-call.md diff --git a/.changeset/eighty-elephants-call.md b/.changeset/eighty-elephants-call.md new file mode 100644 index 0000000..c0a88f5 --- /dev/null +++ b/.changeset/eighty-elephants-call.md @@ -0,0 +1,5 @@ +--- +"@openfun/cunningham-react": patch +--- + +support ReactNode as input label diff --git a/packages/react/src/components/Forms/Checkbox/index.tsx b/packages/react/src/components/Forms/Checkbox/index.tsx index 5393052..dff2f3a 100644 --- a/packages/react/src/components/Forms/Checkbox/index.tsx +++ b/packages/react/src/components/Forms/Checkbox/index.tsx @@ -5,13 +5,14 @@ import React, { useEffect, useRef, useState, + ReactNode, } from "react"; import classNames from "classnames"; import { Field, FieldProps } from ":/components/Forms/Field"; export type CheckboxOnlyProps = { indeterminate?: boolean; - label?: string; + label?: ReactNode; }; export type CheckboxProps = InputHTMLAttributes & diff --git a/packages/react/src/components/Forms/Radio/index.tsx b/packages/react/src/components/Forms/Radio/index.tsx index 42ec8e3..e93805d 100644 --- a/packages/react/src/components/Forms/Radio/index.tsx +++ b/packages/react/src/components/Forms/Radio/index.tsx @@ -2,12 +2,13 @@ import React, { InputHTMLAttributes, PropsWithChildren, forwardRef, + ReactNode, } from "react"; import classNames from "classnames"; import { Field, FieldProps } from ":/components/Forms/Field"; export type RadioOnlyProps = { - label?: string; + label?: ReactNode; }; export type RadioProps = InputHTMLAttributes &