diff --git a/src/Components/Modal.res b/src/Components/Modal.res index 885b13bcd..5c8a81c35 100644 --- a/src/Components/Modal.res +++ b/src/Components/Modal.res @@ -45,7 +45,7 @@ let make = (
Utils.rgbaTorgb }, (), )}> diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 1aeb30f94..95109af2c 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -726,6 +726,27 @@ let getDictIsSome = (dict, key) => { dict->Js.Dict.get(key)->Belt.Option.isSome } +let rgbaTorgb = bgColor => { + let cleanBgColor = bgColor->Js.String2.trim + if cleanBgColor->Js.String2.startsWith("rgba") || cleanBgColor->Js.String2.startsWith("rgb") { + let start = cleanBgColor->Js.String2.indexOf("(") + let end = cleanBgColor->Js.String2.indexOf(")") + + let colorArr = + cleanBgColor->Js.String2.substring(~from=start + 1, ~to_=end)->Js.String2.split(",") + if colorArr->Js.Array2.length === 3 { + cleanBgColor + } else { + let red = colorArr->Belt.Array.get(0)->Belt.Option.getWithDefault("0") + let green = colorArr->Belt.Array.get(1)->Belt.Option.getWithDefault("0") + let blue = colorArr->Belt.Array.get(2)->Belt.Option.getWithDefault("0") + `rgba(${red}, ${green}, ${blue})` + } + } else { + cleanBgColor + } +} + let delay = timeOut => { Promise.make((resolve, _reject) => { Js.Global.setTimeout(() => {