Skip to content

Commit 0664917

Browse files
committed
fix: add rtl layout support to card form fields in dc
1 parent a1bb8f2 commit 0664917

5 files changed

Lines changed: 15 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "processout.js",
3-
"version": "1.9.7",
3+
"version": "1.9.8",
44
"description": "ProcessOut.js is a JavaScript library for ProcessOut's payment processing API.",
55
"scripts": {
66
"build:processout": "tsc -p src/processout && uglifyjs --compress --keep-fnames --ie8 dist/processout.js -o dist/processout.js",

src/dynamic-checkout/dynamic-checkout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ module ProcessOut {
162162
this.widgetWrapper = document.createElement("div")
163163
this.widgetWrapper.setAttribute("class", "dynamic-checkout-widget-wrapper")
164164

165-
if (this.paymentConfig.locale === "ar") {
165+
if (Translations.isRtlLocale(this.paymentConfig.locale)) {
166166
this.widgetWrapper.setAttribute("dir", "rtl")
167167
}
168168

src/dynamic-checkout/payment-methods/card.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ module ProcessOut {
250250
fontSize: "14px",
251251
}
252252

253+
if (Translations.isRtlLocale(this.paymentConfig.locale)) {
254+
// Hosted field iframes don't inherit the widget's dir="rtl",
255+
// so the direction has to be passed to them explicitly
256+
options.style.direction = "rtl"
257+
}
258+
253259
options.placeholder = ""
254260
options.expiryAutoNext = false
255261
options.cardNumberAutoNext = true

src/dynamic-checkout/styles/default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ const defaultStyles = `
937937
}
938938
939939
.dynamic-checkout-widget-wrapper[dir="rtl"] .dco-payment-method-card-form-input-cvc {
940-
padding-right: 0;
940+
padding-right: 8px;
941941
padding-left: 40px;
942942
}
943943

src/dynamic-checkout/utils/translations.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ module ProcessOut {
1919
vi: vi,
2020
}
2121

22+
static rtlLocales = ["ar"]
23+
2224
static getText(key: string, locale: string) {
2325
const keys =
2426
Translations.localeTranslationsMap[locale] || Translations.localeTranslationsMap.en
2527

2628
return keys[key] || ""
2729
}
30+
31+
static isRtlLocale(locale: string) {
32+
return Translations.rtlLocales.indexOf(locale) !== -1
33+
}
2834
}
2935
}

0 commit comments

Comments
 (0)