2017 / 2018
2017 / 2018
...many other smaller Projects
// index.html
<div class="js-react" data-appName="quickBuyWidget" data-productId="64031">
// bootstrap.js
const $apps = $("body").find(".js-react");
$apps.each(function(index, app) {
let htmlNode = app;
const $app = $(app);
const pageData = $app.data();
const appName = $app.data("appName");
const $mountNode = $app.find(".js-react-mount");
$script(`/${appName}.js`, function() {
$(document).trigger("bootstrap-react-app", {
htmlNode, appName, pageData, store, history
});
});
});
// quickbuyApp.js
$(document).on("bootstrap-react-app", function(event, data) {
if (data.appName !== "quickBuyWidget") return this;
ReactDOM.render(
<RootRedux store={data.store}>
<QuickBuyWidget
productId={data.pageData.productId}
/>
</RootRedux>,
data.htmlNode
);
});
// appConfig.js
window.ReactApp = window.ReactApp || {};
ReactApp.Env = ReactApp.Env || {};
ReactApp.Env.urlMagnolia = "https://pathe-ch.namics-test.com";
ReactApp.Env.urlSolr = "https://pathe-ch.namics-test.com/solr";
ReactApp.Sites = {
PLA: {
label: "Plaza",
wheelChairAreaCode: "0000000005",
preferredComplexID: "1011"
},
KUC: {
label: "Küchlin",
wheelChairAreaCode: "0000000006",
preferredComplexID: "1010"
}
}
// appConfig.js
window.ReactApp = window.ReactApp || {};
ReactApp.I18n = ReactApp.I18n || {};
ReactApp.I18n = {
'react.impulsCoach.molecules.Record.title': "Your new record is {recordValue}kg"
}
// Record.jsx
<Link
href={routes.dashboard.newMeasurement.href}
title={i18n('react.impulsCoach.molecules.Record.title', { recordValue, '60' })}
modifier="button"
/>
// Counter.jsx
import React from 'react';
import { onlyUpdateForKeys } from 'recompose';
export type CounterProps = {
count?: string | number,
modifier?: string,
};
const Counter = ({ count, modifier }: CounterProps): any => {
return (
<div className={`a-counter${modifier ? ' a-counter--' + modifier : ''}`}>
<span className="a-counter__number">{count}</span>
</div>
);
};
const shallowUpdate = onlyUpdateForKeys(['count']);
export { Counter };
export default shallowUpdate(Counter);