Skip to content

Commit

Permalink
Add option "skinClasses" to uiOptions, fixes #32
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjalava committed Jun 26, 2017
1 parent 19fc9e3 commit 8e9bd84
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Application expects to find an object named `sizeme_options` (TODO: rename to `S
- [addToCartElement] (_String_): DOM-element to listen to for add-to-cart events
- [addToCartEvent] (_String_): DOM-event for add-to-cart
- [maxRecommendationDistance] (_Integer_): maximum difference between optimal fit and total fit for SizeMe to consider the size for pre-selection. Default not set, meaning all sizes that are not too small are considered.
- [skinClasses] (_String_): contents will be appended to the class-attribute of SizeMe container element. Empty by default.

* [additionalTranslations] (_Object_): Optionally override translations defined under ['i18n'](src/i18n). Example of how to
override the Swedish translation for chest:
Expand Down
4 changes: 3 additions & 1 deletion src/SizeMeApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SizeMeApp extends React.Component {
this.state = {
loginModalOpen: false
};
this.shopType = Optional.ofNullable(uiOptions.shopType).map((s) => `sizeme-${s}`).orElse("");
this.skinClasses = uiOptions.skinClasses || "";
}

componentDidMount () {
Expand Down Expand Up @@ -76,7 +78,7 @@ class SizeMeApp extends React.Component {

if (resolved) {
return (
<div className={`${matchState} sizeme-content`}>
<div className={`sizeme-content ${this.shopType} ${this.skinClasses} ${matchState}`}>
<div className="sizeme-slider-row">
<SizeSlider match={currentMatch} fitRecommendation={product.item.fitRecommendation || 0}
selectedSize={selectedSize} matchState={matchState}/>
Expand Down
3 changes: 1 addition & 2 deletions src/api/uiOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const shops = {
addToCartElement: "button.btn-cart",
addToCartEvent: "click",
firstRecommendation: true,
sizeSelectorType: "default",
maxRecommendationDistance: null
sizeSelectorType: "default"
}
};

Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import "./scss/index.scss";
console.log("Initializing SizeMe, version " + VERSION + ", built on " + BUILD_DATE);

const section = document.createElement("div");
section.setAttribute("class", `sizeme-content-${uiOptions.shopType}`);
document.querySelector(uiOptions.appendContentTo).appendChild(section);

const { addToCartElement, addToCartEvent } = uiOptions;
Expand Down

0 comments on commit 8e9bd84

Please sign in to comment.