Skip to content

Commit a6bbdbc

Browse files
jonas-jonasory-bot
authored andcommitted
feat: hide Ory branding on qualifying plans
GitOrigin-RevId: bff5672da6df152437347b39a7202fcfbc193ef5
1 parent 9cf17ea commit a6bbdbc

7 files changed

Lines changed: 98 additions & 4 deletions

File tree

packages/elements-react/api-report/elements-react.api.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6021,6 +6021,33 @@
60216021
"endIndex": 2
60226022
}
60236023
},
6024+
{
6025+
"kind": "PropertySignature",
6026+
"canonicalReference": "@ory/elements-react!ProjectConfiguration#hide_ory_branding:member",
6027+
"docComment": "/**\n * Whether to hide the Ory branding badge on the account experience card.\n *\n * Defaults to `false`. Customers on qualifying plans can opt into hiding it.\n */\n",
6028+
"excerptTokens": [
6029+
{
6030+
"kind": "Content",
6031+
"text": "hide_ory_branding?: "
6032+
},
6033+
{
6034+
"kind": "Content",
6035+
"text": "boolean"
6036+
},
6037+
{
6038+
"kind": "Content",
6039+
"text": ";"
6040+
}
6041+
],
6042+
"isReadonly": false,
6043+
"isOptional": true,
6044+
"releaseTag": "Public",
6045+
"name": "hide_ory_branding",
6046+
"propertyTypeTokenRange": {
6047+
"startIndex": 1,
6048+
"endIndex": 2
6049+
}
6050+
},
60246051
{
60256052
"kind": "PropertySignature",
60266053
"canonicalReference": "@ory/elements-react!ProjectConfiguration#login_ui_url:member",

packages/elements-react/api-report/elements-react.api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ export type OryVerificationSuccessEvent = {
706706
export interface ProjectConfiguration {
707707
default_redirect_url: string;
708708
error_ui_url: string;
709+
hide_ory_branding?: boolean;
709710
login_ui_url: string;
710711
logo_dark_url?: string;
711712
logo_light_url?: string;
@@ -830,7 +831,7 @@ export type VerificationFlowContainer = {
830831
// dist/index.d.ts:737:5 - (ae-forgotten-export) The symbol "SelectRenderer" needs to be exported by the entry point index.d.ts
831832
// dist/index.d.ts:1077:5 - (ae-forgotten-export) The symbol "Locale" needs to be exported by the entry point index.d.ts
832833
// dist/index.d.ts:1081:5 - (ae-forgotten-export) The symbol "LocaleMap" needs to be exported by the entry point index.d.ts
833-
// dist/index.d.ts:1624:5 - (ae-forgotten-export) The symbol "OrySDK" needs to be exported by the entry point index.d.ts
834+
// dist/index.d.ts:1630:5 - (ae-forgotten-export) The symbol "OrySDK" needs to be exported by the entry point index.d.ts
834835

835836
// (No @packageDocumentation comment for this package)
836837

packages/elements-react/src/context/config.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const defaultProject: ProjectConfiguration = {
3737
settings_ui_url: "/ui/settings",
3838
default_redirect_url: "/ui/welcome",
3939
error_ui_url: "/ui/error",
40+
hide_ory_branding: false,
4041
}
4142

4243
/**

packages/elements-react/src/theme/default/components/card/badge.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import OryLogoVertical from "../../assets/ory-badge-vertical.svg"
66

77
export function Badge() {
88
return (
9-
<div className="absolute border border-ory-border-default bg-ory-background-default p-2 font-bold text-ory-foreground-default max-sm:bottom-0 max-sm:left-8 max-sm:translate-y-full max-sm:rounded-b-branding max-sm:py-[7px] sm:top-8 sm:right-0 sm:translate-x-full sm:rounded-r-branding sm:pl-[7px]">
9+
<div
10+
data-testid="ory/card/badge"
11+
className="absolute border border-ory-border-default bg-ory-background-default p-2 font-bold text-ory-foreground-default max-sm:bottom-0 max-sm:left-8 max-sm:translate-y-full max-sm:rounded-b-branding max-sm:py-[7px] sm:top-8 sm:right-0 sm:translate-x-full sm:rounded-r-branding sm:pl-[7px]"
12+
>
1013
<OryLogoHorizontal width={22} height={8} className="sm:hidden" />
1114
<OryLogoVertical width={8} height={22} className="max-sm:hidden" />
1215
</div>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright © 2025 Ory Corp
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { OryConfigurationProvider } from "@ory/elements-react"
5+
import { render } from "@testing-library/react"
6+
import { DefaultCard } from "./index"
7+
8+
// Replace the SVG modules used by <Badge />. The Jest `jest-transform-stub`
9+
// turns SVG imports into empty strings, which React then treats as the
10+
// element's tag name and JSDOM rejects with `InvalidCharacterError`. Mocking
11+
// them with simple React components avoids that and lets us assert on the
12+
// rendered DOM.
13+
jest.mock(
14+
"../../assets/ory-badge-horizontal.svg",
15+
() =>
16+
function OryBadgeHorizontal() {
17+
return <svg data-testid="ory/card/badge/horizontal" />
18+
},
19+
)
20+
jest.mock(
21+
"../../assets/ory-badge-vertical.svg",
22+
() =>
23+
function OryBadgeVertical() {
24+
return <svg data-testid="ory/card/badge/vertical" />
25+
},
26+
)
27+
28+
function renderCard(hideOryBranding: boolean | undefined) {
29+
return render(
30+
<OryConfigurationProvider
31+
sdk={{ url: "https://example.com" }}
32+
project={{ hide_ory_branding: hideOryBranding }}
33+
>
34+
<DefaultCard>content</DefaultCard>
35+
</OryConfigurationProvider>,
36+
)
37+
}
38+
39+
describe("DefaultCard branding badge", () => {
40+
test("should render the Ory badge by default", () => {
41+
const { container } = renderCard(undefined)
42+
expect(container.querySelector("svg")).toBeTruthy()
43+
})
44+
45+
test("should render the Ory badge when hide_ory_branding is false", () => {
46+
const { container } = renderCard(false)
47+
expect(container.querySelector("svg")).toBeTruthy()
48+
})
49+
50+
test("should omit the Ory badge when hide_ory_branding is true", () => {
51+
const { container } = renderCard(true)
52+
expect(container.querySelector("svg")).toBeFalsy()
53+
})
54+
})

packages/elements-react/src/theme/default/components/card/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright © 2024 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { OryCardProps } from "@ory/elements-react"
4+
import { OryCardProps, useOryConfiguration } from "@ory/elements-react"
55
import { Badge } from "./badge"
66
import { DefaultCardContent } from "./content"
77
import { DefaultCardFooter } from "./footer"
@@ -24,6 +24,8 @@ export function DefaultCard({
2424
className,
2525
...rest
2626
}: OryCardProps & ComponentPropsWithoutRef<"div">) {
27+
const { project } = useOryConfiguration()
28+
2729
return (
2830
<div className={cn("ory-elements", className)} {...rest}>
2931
<div className="flex w-full flex-1 items-start justify-center font-sans-default sm:w-[480px] sm:max-w-[480px] sm:items-center">
@@ -32,7 +34,7 @@ export function DefaultCard({
3234
data-testid="ory/card"
3335
>
3436
{children}
35-
<Badge />
37+
{!project.hide_ory_branding && <Badge />}
3638
</div>
3739
</div>
3840
</div>

packages/elements-react/src/util/clientConfiguration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ export interface ProjectConfiguration {
108108
* The URL for the recovery UI.
109109
*/
110110
recovery_ui_url: string
111+
/**
112+
* Whether to hide the Ory branding badge on the account experience card.
113+
*
114+
* Defaults to `false`. Customers on qualifying plans can opt into hiding it.
115+
*/
116+
hide_ory_branding?: boolean
111117
/**
112118
* Whether registration is enabled.
113119
*

0 commit comments

Comments
 (0)