Skip to content
This repository has been archived by the owner on Feb 2, 2020. It is now read-only.

Commit

Permalink
make layout creating using default templateLayoutFactory templates
Browse files Browse the repository at this point in the history
* add dist folder to .gitignore
* fix error at build:umd script
  • Loading branch information
Mike_Device committed Feb 27, 2017
1 parent ff66db3 commit 332487c
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
dist
.DS_Store
.DS_Store?
.idea/
Expand Down
2 changes: 0 additions & 2 deletions lib/MapMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ var MapMarker = function (_Component) {
key: '_setupMarkerLayout',
value: function _setupMarkerLayout(component) {
this._markerElement = document.createElement('div');
this._markerElement.className = 'icon-content';
this._markerElement.style.display = 'inline-block';

_reactDom2.default.render(component, this._markerElement);
this._controller.setLayout('iconLayout', this._markerElement);
Expand Down
6 changes: 1 addition & 5 deletions lib/MarkerLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ var MarkerLayout = function (_Component) {
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
'div',
null,
this.props.children
);
return this.props.children;
}
}]);

Expand Down
11 changes: 3 additions & 8 deletions lib/controllers/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ function createLayout(_ref) {
_ref$extendMethods = _ref.extendMethods,
extendMethods = _ref$extendMethods === undefined ? {} : _ref$extendMethods;

var LayoutClass = _api2.default.getAPI().templateLayoutFactory.createClass('<i></i>', Object.assign({
var LayoutClass = _api2.default.getAPI().templateLayoutFactory.createClass(domElement.innerHTML, Object.assign({
build: function build() {
LayoutClass.superclass.build.call(this);

this.options = this.getData().options;

this._setupContent(domElement);
this._updateSize();

detectImagesLoaded(this.getElement()).then(this._updateMarkerShape.bind(this));
Expand All @@ -54,17 +53,13 @@ function createLayout(_ref) {
this.events.fire('shapechange');
},

_setupContent: function _setupContent(domElement) {
var element = this.getElement();
element.appendChild(domElement);
},

_updateSize: function _updateSize() {
this._size = this._getSize();
},

_getSize: function _getSize() {
var element = this.getElement().querySelector('.icon-content');
var element = this.getElement().firstChild;

return [element.offsetWidth, element.offsetHeight];
}
}, extendMethods));
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build:lib": "babel ./src -d lib",
"build:umd": "webpack src/index.js dist/YandexMapReact.js --config webpack.config.dev.js",
"watch": "babel --watch ./src -d lib",
"watch:umd": "webpack src/index.js dist/YandexMapReact.js --watch --config webpack.config.dev.js",
"lint": "eslint src/",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
2 changes: 0 additions & 2 deletions src/MapMarker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ class MapMarker extends Component {

_setupMarkerLayout (component) {
this._markerElement = document.createElement('div');
this._markerElement.className = 'icon-content';
this._markerElement.style.display = 'inline-block';

ReactDOM.render(component, this._markerElement);
this._controller.setLayout('iconLayout', this._markerElement);
Expand Down
2 changes: 1 addition & 1 deletion src/MarkerLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MarkerLayout extends Component {
}

render () {
return <div>{this.props.children}</div>;
return this.props.children;
}
}

Expand Down
11 changes: 3 additions & 8 deletions src/controllers/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ function detectImagesLoaded (element) {
}

function createLayout ({domElement, extendMethods = {}}) {
const LayoutClass = (api.getAPI()).templateLayoutFactory.createClass('<i></i>', Object.assign({
const LayoutClass = (api.getAPI()).templateLayoutFactory.createClass(domElement.innerHTML, Object.assign({
build: function () {
LayoutClass.superclass.build.call(this);

this.options = this.getData().options;

this._setupContent(domElement);
this._updateSize();

detectImagesLoaded(this.getElement()).then(this._updateMarkerShape.bind(this));
Expand All @@ -47,17 +46,13 @@ function createLayout ({domElement, extendMethods = {}}) {
this.events.fire('shapechange');
},

_setupContent: function (domElement) {
const element = this.getElement();
element.appendChild(domElement);
},

_updateSize: function () {
this._size = this._getSize();
},

_getSize: function () {
const element = this.getElement().querySelector('.icon-content');
const element = this.getElement().firstChild;

return [element.offsetWidth, element.offsetHeight];
}
}, extendMethods));
Expand Down
3 changes: 3 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ module.exports = {
loaders: [
{test: /\.jsx?/i, exclude: /node_modules/, loader: 'babel'}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
}
};

0 comments on commit 332487c

Please sign in to comment.