Skip to content

Commit

Permalink
merging to version 1.0.1
Browse files Browse the repository at this point in the history
Minor bug fixes and removing old files:
* Fixing bug with components displayName in side bar
* Adding baseRoute to readme example.
* Removing old vendor file.
  • Loading branch information
NoamELB authored Aug 17, 2017
2 parents 46ab16d + 7081a0f commit 4418dea
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4,047 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ UiZoo.init(documentation, components, rootElement);

### init
```
UiZoo.init(documentation, components, rootElement):
UiZoo.init(documentation: Object, components: Object, rootElement: HTMLElement?, baseRoute: String?)
```

**documentation** - Object, mapping of component name to its documentation. See [example](https://github.com/myheritage/uizoo.js/blob/master/client/documentation.js).
Expand Down
31 changes: 7 additions & 24 deletions client/Components/ComponentsSideBar/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component } from 'react';
import TextField from '../UI/TextField';
import Collapsible from "../UI/Collapsible";
import _ from "underscore";
import { NON_MODULE_NAME } from "../../constants/modules";
import Collapsible from '../UI/Collapsible';
import _ from 'underscore';
import { NON_MODULE_NAME } from '../../constants/modules';

import './index.scss';

Expand Down Expand Up @@ -75,31 +75,14 @@ export default class ComponentsSideBar extends Component {
return componentsLinks;
}

/**
* Get the component name, compatible with ie11 that doesn't support Function.prototype.name ...
* @param {function} comp
* @return {string}
*/
getComponentName(comp) {
let componentName = '';
if (comp) {
if (comp.name) {
componentName = comp.name
} else if (typeof comp === 'function') { // ie11 stuff make sure it's function
componentName = comp.toString().match(/^function\s*([^\s(]+)/)[1];
}
}
return componentName;
}

/**
* @param {Array} moduleComponents
*/
renderModuleLinks(moduleComponents) {
return moduleComponents &&
moduleComponents
.filter(currModuleComponent => this.getComponentName(currModuleComponent).toLowerCase().indexOf(this.state.searchValue.toLowerCase()) !== -1)
.map(currComponent => this.renderComponentLink(this.getComponentName(currComponent)));
return moduleComponents &&
_.keys(moduleComponents)
.filter(componentName => componentName.toLowerCase().indexOf(this.state.searchValue.toLowerCase()) !== -1)
.map(componentName => this.renderComponentLink(componentName));
}

/**
Expand Down
7 changes: 4 additions & 3 deletions client/services/componentByModuleMapper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { NON_MODULE_NAME } from "../constants/modules";
import { NON_MODULE_NAME } from '../constants/modules';
import _ from 'underscore';

/**
* Creates a map object mapping module names to arrays holding their components' constructors
* Creates a map object mapping module names to named objects holding their components' constructors
*
* @param {*} components
* @param {*} documentations
Expand All @@ -12,7 +13,7 @@ export default function mapComponentsByModule(components, documentations) {
_.each(components, (componentData, componentName) => {
if (documentations[componentName]) {
let moduleName = (documentations[componentName].module && documentations[componentName].module[0].name) || NON_MODULE_NAME;
componentsByModule[moduleName] = [].concat(componentsByModule[moduleName] || [], componentData);
componentsByModule[moduleName] = _.extend({[componentName]: componentData}, componentsByModule[moduleName]);
}
});

Expand Down
26 changes: 20 additions & 6 deletions documentationMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,30 @@ glob(inputGlob, {}, (error, componentsPaths) => {
componentsDone++;
if (componentsDone === componentsPaths.length) {
let results =
`export default ${JSON.stringify(nameToDoc)};`;
fs.writeFile(outputPath, results, (error, data) => {
if (error) {
console.error("Had an error writing the results file: " + error);
howToUse();
`export default ${transformToJSON(nameToDoc)};`;
fs.readFile(outputPath, "utf8", (error, data) => {
if(1, data !== results) {
fs.writeFile(outputPath, results, (error, data) => {
if (error) {
console.error("Had an error writing the results file: " + error);
howToUse();
}
console.log("Wrote documentation map successfully.");
});
}
console.log("Wrote documentation map successfully.");
});
}
}

function transformToJSON(obj) {
let keys = Object.keys(obj),
jsonReadyObj = {};
keys.sort();
for (let i = 0, l = keys.length; i < l; i++) {
jsonReadyObj[keys[i]] = obj[keys[i]];
}
return JSON.stringify(jsonReadyObj);
}
});

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uizoo",
"version": "1.0.0",
"version": "1.0.1",
"description": "Dynamic React Component Library",
"scripts": {
"start": "npm run gulp:w",
Expand Down
Loading

0 comments on commit 4418dea

Please sign in to comment.