Skip to content

Commit

Permalink
feat: prepare for TS defs generation (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haprog authored May 29, 2020
1 parent 767bb51 commit 989d740
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
"polymer": "^2.0.0",
"iron-resizable-behavior": "^2.0.0",
"vaadin-license-checker": "vaadin/license-checker#^2.1.0",
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.0.0"
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.4.1"
},
"devDependencies": {
"app-layout": "PolymerElements/app-layout#v2.0.0",
"web-component-tester": "^6.1.5",
"webcomponentsjs": "^1.0.0",
"vaadin-demo-helpers": "vaadin/vaadin-demo-helpers#^3.0.0",
"vaadin-demo-helpers": "vaadin/vaadin-demo-helpers#^3.1.0",
"iron-icon": "^2.0.1",
"vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.1.0",
"vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.6.0",
"iron-component-page": "PolymerElements/iron-component-page#^3.0.1"
}
}
9 changes: 9 additions & 0 deletions gen-tsd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"excludeFiles": [
"wct.conf.js",
"index.html",
"demo/**/*",
"test/**/*",
"theme/**/*"
]
}
12 changes: 12 additions & 0 deletions magi-p3-post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
files: [
'vaadin-board-row.js',
'vaadin-board.js'
],
from: [
/import '\.\/theme\/lumo\/vaadin-(.+)\.js';/
],
to: [
`import './theme/lumo/vaadin-$1.js';\nexport * from './src/vaadin-$1.js';`
]
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"homepage": "https://vaadin.com/components",
"files": [
"vaadin-*.d.ts",
"vaadin-*.js",
"src",
"theme"
Expand Down
32 changes: 20 additions & 12 deletions src/vaadin-board-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
this._oldFlexBasis = [];
}

/** @protected */
ready() {
super.ready();
this.addEventListener('iron-resize', this._onIronResize, true);
Expand All @@ -95,13 +96,15 @@
});
}

/** @protected */
connectedCallback() {
super.connectedCallback();
Polymer.RenderStatus.afterNextRender(this, this._onIronResize);
}

/**
* Adds styles for board row based on width.
* @private
*/
_addStyleNames(width, breakpoints) {
if (width < breakpoints.smallSize) {
Expand All @@ -121,11 +124,12 @@

/**
* Calculates flex basis based on colSpan, width and breakpoints.
* @param {Number} colSpan colspan value of the row
* @param {Number} width width of the row in px
* @param {Number} colsInRow number of columns in the row
* @param {Object} breakpoints object with smallSize and mediumSize number properties, which tells
* @param {number} colSpan colspan value of the row
* @param {number} width width of the row in px
* @param {number} colsInRow number of columns in the row
* @param {object} breakpoints object with smallSize and mediumSize number properties, which tells
* where the row should switch rendering size in pixels.
* @private
*/
_calculateFlexBasis(colSpan, width, colsInRow, breakpoints) {
if (width < breakpoints.smallSize) {
Expand All @@ -138,6 +142,7 @@
return flexBasis + '%';
}

/** @private */
_reportError() {
const errorMessage = "The column configuration is not valid; column count should add up to 3 or 4.";
console.warn(errorMessage, "check: \r\n" + this.outerHTML);
Expand All @@ -146,9 +151,9 @@
/**
* Parses board-cols from DOM.
* If there is not enough space in the row drop board cols.
* @param {Array} array of nodes
*
* @return {Array} array of boardCols
* @param {!Array<!Node>} nodes array of nodes
* @return {!Array<number>} array of boardCols
* @private
*/
_parseBoardCols(nodes) {
const boardCols = nodes.map(node => {
Expand Down Expand Up @@ -180,10 +185,10 @@
/**
* If there is not enough space in the row.
* Extra items are dropped from DOM.
* @param {Array} array of board-cols for every node
* @param {Array} array of nodes
*
* @return {Array} filtered array of nodes
* @param {!Array<number>} boardCols array of board-cols for every node
* @param {!Array<!Node>} nodes array of nodes
* @return {!Array<!Node>} filtered array of nodes
* @private
*/
_removeExtraNodesFromDOM(boardCols, nodes) {
let isErrorReported = false;
Expand Down Expand Up @@ -214,10 +219,12 @@
this._recalculateFlexBasis(true);
}

/** @private */
_onIronResize() {
this._recalculateFlexBasis(false);
}

/** @private */
_recalculateFlexBasis(forceResize) {
const width = this.getBoundingClientRect().width;
const breakpoints = this._measureBreakpointsInPx();
Expand Down Expand Up @@ -252,8 +259,9 @@
* The breakpoints for `small` and `medium` can be given in any unit: `px`, `em`, `in` etc.
* We need to know them in `px` so that they are comparable with the actual size.
*
* @return {Object} object with smallSize and mediumSize number properties, which tells
* @return {object} object with smallSize and mediumSize number properties, which tells
* where the row should switch rendering size in pixels.
* @private
*/
_measureBreakpointsInPx() {
// Convert minWidth to px units for comparison
Expand Down

0 comments on commit 989d740

Please sign in to comment.