Skip to content
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
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,59 @@ SolidusStripe.CartPageCheckout.prototype.onPrButtonMounted = function(id, result
}
```

Styling Stripe Elements
-----------------------

The Elements feature built in this gem come with some standard styles. If you want
to customize it, you can override the `SolidusStripe.Elements.prototype.baseStyle`
method and make it return a valid [Stripe Style](https://stripe.com/docs/js/appendix/style)
object:

```js
SolidusStripe.Elements.prototype.baseStyle = function () {
return {
base: {
iconColor: '#c4f0ff',
color: '#fff',
fontWeight: 500,
fontFamily: 'Roboto, Open Sans, Segoe UI, sans-serif',
fontSize: '16px',
fontSmoothing: 'antialiased',
':-webkit-autofill': {
color: '#fce883',
},
'::placeholder': {
color: '#87BBFD',
},
},
invalid: {
iconColor: '#FFC7EE',
color: '#FFC7EE',
}
}
};
```

You can also style your element containers directly by using CSS rules like this:

```css
.StripeElement {
border: 1px solid transparent;
}

.StripeElement--focus {
box-shadow: 0 1px 3px 0 #cfd7df;
}

.StripeElement--invalid {
border-color: #fa755a;
}

.StripeElement--webkit-autofill {
background-color: #fefde5 !important;
}
```

Migrating from solidus_gateway
------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,7 @@ SolidusStripe.Elements.prototype.init = function() {

SolidusStripe.Elements.prototype.initElements = function() {
var buildElements = function(elements) {
var style = {
base: {
color: 'black',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '14px',
'::placeholder': {
color: 'silver'
}
},
invalid: {
color: 'red',
iconColor: 'red'
}
};
var style = this.baseStyle();

elements.create('cardExpiry', {style: style}).mount('#card_expiry');
elements.create('cardCvc', {style: style}).mount('#card_cvc');
Expand All @@ -42,7 +28,7 @@ SolidusStripe.Elements.prototype.initElements = function() {
cardNumber.mount('#card_number');

return cardNumber;
};
}.bind(this);

this.cardNumber = buildElements(this.elements);

Expand All @@ -57,6 +43,24 @@ SolidusStripe.Elements.prototype.initElements = function() {
this.form.bind('submit', this.onFormSubmit.bind(this));
};

SolidusStripe.Elements.prototype.baseStyle = function () {
return {
base: {
color: 'black',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '14px',
'::placeholder': {
color: 'silver'
}
},
invalid: {
color: 'red',
iconColor: 'red'
}
};
};

SolidusStripe.Elements.prototype.showError = function(error) {
var message = error.message || error;

Expand Down