Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow overriding of field messages #293

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
}: OryNodeLabelProps) {
const intl = useIntl()
const label = getNodeLabel(node)
const { Message } = useComponents()

Check warning on line 22 in packages/elements-react/src/theme/default/components/form/label.tsx

View check run for this annotation

Codecov / codecov/patch

packages/elements-react/src/theme/default/components/form/label.tsx#L22

Added line #L22 was not covered by tests
const { config, flowType, flow } = useOryFlow()

const isPassword = attributes.type === "password"
Expand Down Expand Up @@ -70,17 +71,7 @@
)}
{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} />

Check warning on line 74 in packages/elements-react/src/theme/default/components/form/label.tsx

View check run for this annotation

Codecov / codecov/patch

packages/elements-react/src/theme/default/components/form/label.tsx#L74

Added line #L74 was not covered by tests
))}
</div>
)
Expand Down
Loading