Skip to content

Commit

Permalink
feat: allow overriding of field messages (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Nov 25, 2024
1 parent a5fcd44 commit 2acabd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PropsWithChildren } from "react"
import { cn } from "../../utils/cn"
import { useIntl } from "react-intl"
import {
messageTestId,
OryFormRootProps,
uiTextToFormattedMessage,
useOryFlow,
Expand Down Expand Up @@ -52,11 +53,12 @@ export function DefaultMessage({ message }: OryMessageContentProps) {
const intl = useIntl()
return (
<span
className={cn("text-sm mt-1 leading-normal", {
className={cn("text-sm leading-normal", {
"text-forms-fg-error": message.type === "error",
"text-forms-fg-default": message.type === "info",
"text-forms-fg-success": message.type === "success",
})}
{...messageTestId(message)}
>
{uiTextToFormattedMessage(message, intl)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
OryNodeLabelProps,
messageTestId,
uiTextToFormattedMessage,
useComponents,
useOryFlow,
} from "@ory/elements-react"
import { useIntl } from "react-intl"
import { cn } from "../../utils/cn"

export function DefaultLabel({
node,
Expand All @@ -19,6 +19,7 @@ export function DefaultLabel({
}: OryNodeLabelProps) {
const intl = useIntl()
const label = getNodeLabel(node)
const { Message } = useComponents()
const { config, flowType, flow } = useOryFlow()

const isPassword = attributes.type === "password"
Expand Down Expand Up @@ -70,17 +71,7 @@ export function DefaultLabel({
)}
{children}
{node.messages.map((message) => (
<span
key={message.id}
className={cn("text-sm leading-normal", {
"text-forms-fg-error": message.type === "error",
"text-forms-fg-default": message.type === "info",
"text-forms-fg-success": message.type === "success",
})}
{...messageTestId(message)}
>
{uiTextToFormattedMessage(message, intl)}
</span>
<Message.Content key={message.id} message={message} />
))}
</div>
)
Expand Down

0 comments on commit 2acabd5

Please sign in to comment.