Skip to content

Commit

Permalink
fix: cardtheme props
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Mar 5, 2024
1 parent c0a0760 commit f73c060
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 31 deletions.
8 changes: 6 additions & 2 deletions src/BrutalTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ let brutal = {
colorIconCardError: "#ff1a1a",
spacingGridColumn: "20px",
spacingGridRow: "20px",
buttonBackgroundColor: "#f5fb1f",
buttonTextColor: "#000000",
}
let brutalRules = (theme: CardThemeType.themeClass) =>
{
Expand Down Expand Up @@ -171,3 +169,9 @@ let brutalRules = (theme: CardThemeType.themeClass) =>

let default = brutal
let defaultRules = brutalRules

let defaultPayNowProps = {
...PaymentType.defaultValueSdkHandleConfirmPaymentProps,
buttonBackgroundColor: "#f5fb1f",
textColor: "#000000",
}
22 changes: 15 additions & 7 deletions src/CardTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open CardThemeType
open Utils
open ErrorUtils

external toJson: 'a => Js.Json.t = "%identity"

let getTheme = (val, logger) => {
switch val {
| "default" => Default
Expand Down Expand Up @@ -244,13 +246,13 @@ let getVariables = (str, dict, default, logger) => {
~logger,
),
spacingGridRow: getWarningString(json, "spacingGridRow", default.spacingGridRow, ~logger),
buttonBackgroundColor: getWarningString(
json,
"buttonBackgroundColor",
default.buttonBackgroundColor,
~logger,
),
buttonTextColor: getWarningString(json, "buttonTextColor", default.buttonTextColor, ~logger),
// buttonBackgroundColor: getWarningString(
// json,
// "buttonBackgroundColor",
// default.buttonBackgroundColor,
// ~logger,
// ),
// buttonTextColor: getWarningString(json, "buttonTextColor", default.buttonTextColor, ~logger),
}
})
->Belt.Option.getWithDefault(default)
Expand Down Expand Up @@ -325,3 +327,9 @@ let itemToObjMapper = (
loader: getWarningString(dict, "loader", "auto", ~logger)->getShowLoader(logger),
}
}

let getSdkHandleConfirmPaymentProps = (str, dict, default) => {
let val = dict->Js.Dict.get(str)->Belt.Option.getWithDefault(Js.Json.null)
Js.log2("Champ val", val)
mergeJsons(val->toJson, default->toJson)
}
4 changes: 2 additions & 2 deletions src/CharcoalTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ let charcoal = {
colorIconCardError: "#fd1717",
spacingGridColumn: "20px",
spacingGridRow: "20px",
buttonBackgroundColor: "#000000",
buttonTextColor: "#ffffff",
// buttonBackgroundColor: "#000000",
// buttonTextColor: "#ffffff",
}

let charcoalRules = theme =>
Expand Down
12 changes: 2 additions & 10 deletions src/Components/PayNowButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ let make = () => {
onClick=handleOnClick
className={`w-full flex flex-row justify-center items-center rounded-md`}
style={ReactDOMStyle.make(
~backgroundColor={
sdkHandleConfirmPaymentProps.buttonBackgroundColor->Js.String2.length > 0
? sdkHandleConfirmPaymentProps.buttonBackgroundColor
: themeObj.buttonBackgroundColor
},
~backgroundColor=sdkHandleConfirmPaymentProps.buttonBackgroundColor,
~height={
sdkHandleConfirmPaymentProps.buttonHeight->Js.String2.length > 0
? sdkHandleConfirmPaymentProps.buttonHeight
Expand All @@ -79,11 +75,7 @@ let make = () => {
<span
id="button-text"
style={ReactDOMStyle.make(
~color={
sdkHandleConfirmPaymentProps.textColor->Js.String2.length > 0
? sdkHandleConfirmPaymentProps.textColor
: themeObj.buttonTextColor
},
~color=sdkHandleConfirmPaymentProps.textColor,
~fontSize={
sdkHandleConfirmPaymentProps.textFontSize->Js.String2.length > 0
? sdkHandleConfirmPaymentProps.textFontSize
Expand Down
4 changes: 2 additions & 2 deletions src/DefaultTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ let default = {
colorIconCardError: "#fd1717",
spacingGridColumn: "20px",
spacingGridRow: "20px",
buttonBackgroundColor: "#006df9",
buttonTextColor: "#ffffff",
// buttonBackgroundColor: "#006df9",
// buttonTextColor: "#ffffff",
}
let defaultRules = theme =>
{
Expand Down
19 changes: 19 additions & 0 deletions src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger) => {
let appearance =
optionsAppearance == CardTheme.defaultAppearance ? config.appearance : optionsAppearance

Js.log2("Champ optionsDict", optionsDict)

let sdkHandleConfirmPaymentProps = CardTheme.getSdkHandleConfirmPaymentProps(
"sdkHandleConfirmPaymentProps",
optionsDict,
PaymentType.defaultValueSdkHandleConfirmPaymentProps,
)

Js.log2("Champ sdkHandleConfirmPaymentProps", sdkHandleConfirmPaymentProps)

setConfig(._ => {
config: {
appearance,
Expand All @@ -119,6 +129,15 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger) => {
: CardTheme.getLocaleObject(localeString),
showLoader: config.loader == Auto || config.loader == Always,
})

setOptionsPayment(.prev => {
...prev,
sdkHandleConfirmPaymentProps: {
...prev.sdkHandleConfirmPaymentProps,
buttonBackgroundColor: "red",
textColor: "white",
},
})
}

React.useEffect0(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/MidnightTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ let midnight = {
colorIconCardError: "#fd1717",
spacingGridColumn: "20px",
spacingGridRow: "20px",
buttonBackgroundColor: "#85d996",
buttonTextColor: "#000000",
// buttonBackgroundColor: "#85d996",
// buttonTextColor: "#000000",
}

let midnightRules = theme =>
Expand Down
4 changes: 2 additions & 2 deletions src/NoTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ let nakedValues = {
colorIconCardError: "#fd1717",
spacingGridColumn: "20px",
spacingGridRow: "20px",
buttonBackgroundColor: "",
buttonTextColor: "",
// buttonBackgroundColor: "",
// buttonTextColor: "",
}

let nakedValuesRules = _ => Js.Dict.empty()->Js.Json.object_
Expand Down
4 changes: 2 additions & 2 deletions src/SoftTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ let soft = {
colorIconCardError: "#fe87a1",
spacingGridColumn: "20px",
spacingGridRow: "20px",
buttonBackgroundColor: "transparent",
buttonTextColor: "#7d8fff",
// buttonBackgroundColor: "transparent",
// buttonTextColor: "#7d8fff",
}

let softRules = theme =>
Expand Down
2 changes: 0 additions & 2 deletions src/Types/CardThemeType.res
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ type themeClass = {
colorIconCardError: string,
spacingGridColumn: string,
spacingGridRow: string,
buttonBackgroundColor: string,
buttonTextColor: string,
}
type appearance = {
theme: theme,
Expand Down

0 comments on commit f73c060

Please sign in to comment.