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

fix: loader changes #442

Merged
merged 2 commits into from
Jun 13, 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
40 changes: 26 additions & 14 deletions src/Components/Loader.res
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
@react.component
let make = (~showText=true) => {
let make = (~branding="auto", ~showText=true) => {
let arr = ["hyperswitch-triangle", "hyperswitch-square", "hyperswitch-circle"]

<div className="flex flex-col gap-10 justify-center items-center">
<div className="flex flex-row gap-10">
{arr
->Array.mapWithIndex((item, i) => {
<Icon
size=52
style={
animation: "slowShow 1.5s ease-in-out infinite",
animationDelay: {((i + 1) * 180)->Int.toString ++ "ms"},
}
name=item
key={i->Int.toString}
/>
})
->React.array}
<RenderIf condition={branding === "auto"}>
{arr
->Array.mapWithIndex((item, i) => {
<Icon
size=52
style={
animation: "slowShow 1.5s ease-in-out infinite",
animationDelay: {((i + 1) * 180)->Int.toString ++ "ms"},
}
name=item
key={i->Int.toString}
/>
})
->React.array}
</RenderIf>
<RenderIf condition={branding === "never"}>
<div
className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-[#0069FD] border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"
role="status">
<span
className="!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]">
{"Loading..."->React.string}
</span>
</div>
</RenderIf>
</div>
<RenderIf condition={showText}>
<div className="flex flex-col gap-5">
Expand Down
24 changes: 20 additions & 4 deletions src/Components/PaymentLoader.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
@react.component
let make = () => {
let loaderUI =
let (branding, setBranding) = React.useState(_ => "auto")

React.useEffect0(() => {
Utils.handlePostMessage([("iframeMountedCallback", true->JSON.Encode.bool)])
let handle = (ev: Window.event) => {
let json = ev.data->JSON.parseExn
let dict = json->Utils.getDictFromJson
setBranding(_ => dict->Utils.getDictFromDict("options")->Utils.getString("branding", "auto"))
}
Window.addEventListener("message", handle)
Some(() => {Window.removeEventListener("message", handle)})
})

let styles =
branding === "auto"
? "backdrop-blur-md bg-black/80"
: "backdrop-contrast-125 backdrop-blur-2xl opacity-70 bg-black/80"

<div className={`h-screen w-screen flex m-auto items-center ${styles}`}>
<div className={`flex flex-col justify-center m-auto visible`}>
<Loader />
<Loader branding />
</div>
<div className="h-screen w-screen bg-black/80 flex m-auto items-center backdrop-blur-md">
{loaderUI}
</div>
}
1 change: 1 addition & 0 deletions src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ let itemToObjMapper = (dict, logger) => {
"paymentMethodsHeaderText",
"savedPaymentMethodsHeaderText",
"hideExpiredPaymentMethods",
"branding",
"displayDefaultSavedPaymentIcon",
],
dict,
Expand Down
10 changes: 8 additions & 2 deletions src/orca-loader/LoaderPaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) =
`#orca-payment-element-iframeRef-${localSelectorString}`,
)
switch elem->Nullable.toOption {
| Some(ele) => ele
| Some(ele) =>
ele
->Window.style
->Window.setHeight(`${iframeHeightRef.contents->Float.toString}px`)
| None => ()
Expand Down Expand Up @@ -246,6 +247,7 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) =
[
("fullScreenIframeMounted", true->JSON.Encode.bool),
("metadata", fullscreenMetadata.contents),
("options", options),
]->Dict.fromArray,
)
}
Expand All @@ -254,6 +256,7 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) =
[
("fullScreenIframeMounted", true->JSON.Encode.bool),
("metadata", fullscreenMetadata.contents),
("options", options),
]->Dict.fromArray,
)
}
Expand All @@ -269,7 +272,10 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) =
: {
ele->Window.innerHTML("")
mainElement->Window.iframePostMessage(
[("fullScreenIframeMounted", false->JSON.Encode.bool)]->Dict.fromArray,
[
("fullScreenIframeMounted", false->JSON.Encode.bool),
("options", options),
]->Dict.fromArray,
)
}
| None => ()
Expand Down
Loading