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

Marino/fix button to browser general error #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 10 additions & 9 deletions example-1/script.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* Initialize Mollie Components instance
*/
var mollie = Mollie(
var mollie = Mollie(
"pfl_HgMrHhRAFm", // You can find your Profile ID in the Dashboard (https://www.mollie.com/dashboard/developers/api-keys)
{
locale: "en_US", // Optional. If not provided, we will determine the users' language by looking at the document and/or userAgent.
testmode: false // Set to true to enable test mode.
testmode: false, // Set to true to enable test mode.
}
);

var options = {
styles: {
base: {
color: 'rgba(0, 0, 0, 0.8)',
}
}
}
color: "rgba(0, 0, 0, 0.8)",
},
},
};

/**
* Get elements
Expand Down Expand Up @@ -78,9 +78,7 @@ expiryDate.addEventListener("change", function (event) {
var verificationCode = mollie.createComponent("verificationCode", options);
verificationCode.mount("#verification-code");

var verificationCodeError = document.getElementById(
"verification-code-error"
);
var verificationCodeError = document.getElementById("verification-code-error");

verificationCode.addEventListener("change", function (event) {
if (event.error && event.touched) {
Expand Down Expand Up @@ -120,9 +118,12 @@ form.addEventListener("submit", function (event) {
var token = result.token;
var error = result.error;

formError.classList.remove("has-error");
el-angel marked this conversation as resolved.
Show resolved Hide resolved

if (error) {
enableForm();
formError.textContent = error.message;
formError.classList.add("has-error");
return;
}

Expand Down
29 changes: 19 additions & 10 deletions example-1/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
font-size: 16px;
background: #e6f1ff;
background: #eef;
}

.wrapper {
Expand All @@ -24,15 +24,15 @@ label {
opacity: 0.6;
font-size: 18px;
padding-bottom: 7px;
padding-top: 13px;
padding-top: 5px;
font-weight: 500;
display: block;
}

.mollie-component {
background: #fff;
box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.1), 0px 2px 4px rgba(0, 0, 0, 0.1),
0px 4px 8px rgba(0, 0, 0, 0.05);
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.1),
0 4px 8px rgba(0, 0, 0, 0.05);
border-radius: 4px;
padding: 13px;
border: 1px solid transparent;
Expand All @@ -41,7 +41,7 @@ label {
}

.mollie-component.has-focus {
border-color: #0077ff;
border-color: #07f;
transition: 0.3s border-color cubic-bezier(0.4, 0, 0.2, 1);
}

Expand All @@ -50,22 +50,30 @@ label {
transition: 0.3s border-color cubic-bezier(0.4, 0, 0.2, 1);
}

#form-error.has-error {
background-color: rgba(206, 0, 0, 0.1);
padding: 5px;
border: 1px solid #f11;
margin-top: 10px;
border-radius: 4px;
}

.field-error {
font-size: 12px;
margin-top: 2px;
color: #ff1717;
color: #f11;
font-weight: 400;
}

button.submit-button {
width: 100%;
border: 0;
background: #0077ff;
box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.1), 0px 2px 4px rgba(0, 0, 0, 0.1),
0px 4px 8px rgba(0, 0, 0, 0.05);
background: #07f;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.1),
0 4px 8px rgba(0, 0, 0, 0.05);
border-radius: 4px;
padding: 14px;
color: #ffffff;
color: #fff;
font-weight: 600;
font-size: 18px;
opacity: 0.9;
Expand All @@ -85,6 +93,7 @@ button.submit-button:hover {

.form-group {
width: 100%;
min-height: 100px;
}

.form-group--expiry-date {
Expand Down
19 changes: 10 additions & 9 deletions example-2/script.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* Initialize Mollie Components instance
*/
var mollie = Mollie(
var mollie = Mollie(
"pfl_HgMrHhRAFm", // You can find your Profile ID in the Dashboard (https://www.mollie.com/dashboard/developers/api-keys)
{
locale: "en_US", // Optional. If not provided, we will determine the users' language by looking at the document and/or userAgent.
testmode: false // Set to true to enable test mode.
testmode: false, // Set to true to enable test mode.
}
);

var options = {
styles: {
base: {
color: 'rgba(0, 0, 0, 0.8)',
}
}
}
color: "rgba(0, 0, 0, 0.8)",
},
},
};

/**
* Get elements
Expand Down Expand Up @@ -78,9 +78,7 @@ expiryDate.addEventListener("change", function (event) {
var verificationCode = mollie.createComponent("verificationCode", options);
verificationCode.mount("#verification-code");

var verificationCodeError = document.getElementById(
"verification-code-error"
);
var verificationCodeError = document.getElementById("verification-code-error");

verificationCode.addEventListener("change", function (event) {
if (event.error && event.touched) {
Expand Down Expand Up @@ -120,9 +118,12 @@ form.addEventListener("submit", function (event) {
var token = result.token;
var error = result.error;

formError.classList.remove("has-error");

if (error) {
enableForm();
formError.textContent = error.message;
formError.classList.add("has-error");
return;
}

Expand Down
27 changes: 15 additions & 12 deletions example-2/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
font-size: 16px;
background: #000000;
background: #000;
color: #fff;
}

Expand All @@ -13,10 +13,6 @@ body {
max-width: 718px;
}

input {
color: #fff;
}

.wrapper form {
width: 100%;
}
Expand All @@ -25,7 +21,7 @@ label {
opacity: 0.6;
font-size: 16px;
font-weight: 400;
color: #ffffff;
color: #fff;
padding-bottom: 7px;
display: block;
}
Expand All @@ -39,7 +35,7 @@ label {
}

.mollie-component.has-focus {
border-color: rgba(255,255,255,0.5);
border-color: rgba(255, 255, 255, 0.5);
}

.mollie-component.is-invalid {
Expand All @@ -50,26 +46,32 @@ label {
border-color: rgba(140, 252, 136, 0.5);
}

#form-error.has-error {
background-color: rgba(206, 0, 0, 0.1);
padding: 5px;
border: 1px solid #ff5555;
margin-top: 10px;
}

.field-error {
font-size: 12px;
margin-top: 2px;
color: #ff5555;
color: #f55;
font-weight: 500;
}

button.submit-button {
width: 100%;
border: 0;
border-radius: 0;
background: #fedd00;
background: #fd0;
padding: 14px;
color: #000;
font-weight: 600;
font-size: 18px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
outline: 0;
cursor: pointer;
transition: 0.3s opacity cubic-bezier(0.4, 0, 0.2, 1);
}

Expand All @@ -84,11 +86,11 @@ button.submit-button:hover {
.row {
display: flex;
width: 100%;
margin-bottom: 20px;
margin-bottom: 10px;
}

.row:last-child {
margin-bottom: 0px;
margin-bottom: 0;
}

.form-group:first-child {
Expand All @@ -103,6 +105,7 @@ button.submit-button:hover {
width: 100%;
margin: 0 8px;
flex: 1 1 20%;
min-height: 85px;
}

.form-group--card-holder {
Expand Down
20 changes: 11 additions & 9 deletions example-3/script.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* Initialize Mollie Components instance
*/
var mollie = Mollie(
var mollie = Mollie(
"pfl_HgMrHhRAFm", // You can find your Profile ID in the Dashboard (https://www.mollie.com/dashboard/developers/api-keys)
{
locale: "en_US", // Optional. If not provided, we will determine the users' language by looking at the document and/or userAgent.
testmode: false // Set to true to enable test mode.
testmode: false, // Set to true to enable test mode.
}
);

var options = {
styles: {
base: {
color: 'rgba(0, 0, 0, 0.8)',
}
}
}
color: "rgba(0, 0, 0, 0.8)",
},
},
};

/**
* Get elements
Expand Down Expand Up @@ -78,9 +78,7 @@ expiryDate.addEventListener("change", function (event) {
var verificationCode = mollie.createComponent("verificationCode", options);
verificationCode.mount("#verification-code");

var verificationCodeError = document.getElementById(
"verification-code-error"
);
var verificationCodeError = document.getElementById("verification-code-error");

verificationCode.addEventListener("change", function (event) {
if (event.error && event.touched) {
Expand Down Expand Up @@ -120,9 +118,13 @@ form.addEventListener("submit", function (event) {
var token = result.token;
var error = result.error;

formError.classList.remove("has-error");

if (error) {
enableForm();
formError.textContent = error.message;
formError.classList.add("has-error");

return;
}

Expand Down
Loading