Skip to content

Commit

Permalink
Merge pull request #7 from apparena/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vklein committed Aug 3, 2017
2 parents 277a26f + 3c3bc4e commit 305f88d
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 176 deletions.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### Prerequisites

* Checked that your issue isn't already filed: [https://github.com/apparena/patterns/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20is%3Anew](https://github.com/apparena/patterns/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20is%3Anew)

### Description

[Description of the issue]


### Steps to Reproduce

1. [First Step]
2. [Second Step]
3. [and so on...]

**Expected behavior:** [What you expect to happen]

**Actual behavior:** [What actually happens]

**Reproduces how often:** [What percentage of the time does it reproduce?]

### Name and version of Component(s)

You can get this information by running `yarn list | grep 'apparena-patterns-react'` or `npm list | grep 'apparena-patterns-react'` from the command line.

###Did this work in previous versions of the AppArena-Patterns component?

Yes / No / Don't know

### Browser and OS information

Please include the browser version, OS and OS version you're running. You could go to http://www.whatsmybrowser.org/ and copy the link.

### Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- Thanks so much for your PR, your contribution is appreciated! -->

- [ ] PR has tests / docs demo, and is linted.
- [ ] Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
- [ ] Description explains the issue / use-case resolved, and auto-closes the related issue(s)
(https://help.github.com/articles/closing-issues-using-keywords/).

245 changes: 130 additions & 115 deletions .idea/workspace.xml

Large diffs are not rendered by default.

86 changes: 53 additions & 33 deletions build/generator/frontend/src/include/props-container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,28 @@ export default class Example extends ReactComponent {
};
}

renderProps(infos) {
return (
<div>
{Object.keys(infos.props).map((key, i) => {
const prop = infos.props[key];
let type = prop.type;
if (!type) {
return null;
}
if (type.type) {
type = type.type;
}
return (
<div key={i} className={styles.prop}>
<h3 className={styles.header}>
<code>
<span className={styles.type}>{type.name}</span>
{key}
{prop.defaultValue &&
<span className={styles.defaultValue}> = {prop.defaultValue.value}</span>
}
</code>
</h3>
<div className={styles.description}>{prop.description}</div>
{type.value &&
<code className={styles.enum}>
generatePropType(type) {
switch (type.name) {
case 'union':
case 'enum':
let values = [];
if (type.raw) {
// flow union
values = type.raw.split('|').map((v) => v.trim());
} else {
values = type.value.map((v) => v.value || v.name);
}
return (
<code className={styles.enum}>
<span>
<span className={styles.header}>One of
<span className={styles.brac}>(</span>
</span>
<div style={{paddingLeft: '10px'}}>
{Object.keys(type.value).map((vKey, index) => {
{values.map((value, index) => {
return (
<span key={index} className={styles.item}>
<span className={styles.title}>{typeof type.value[vKey].value === 'string' && type.value[vKey].value}</span>
<span className={styles.title}>{typeof value === 'string' && value}</span>
</span>
);
})}
Expand All @@ -57,11 +44,44 @@ export default class Example extends ReactComponent {
<span className={styles.brac}>)</span>
</span>
</span>
</code>
}
</div>
);
})}
</code>
);
default:
return null;
}
}

renderProp(key, i) {
const {infos} = this.props;
const prop = infos.props[key];
let type = prop.type;
if (!type) {
return null;
}
if (type.type) {
type = type.type;
}
return (
<div key={i} className={styles.prop}>
<h3 className={styles.header}>
<code>
<span className={styles.type}>{type.name}</span>
{key}
{prop.defaultValue &&
<span className={styles.defaultValue}> = {prop.defaultValue.value}</span>
}
</code>
</h3>
<div className={styles.description}>{prop.description}</div>
{this.generatePropType(type)}
</div>
);
}

renderProps(infos) {
return (
<div>
{Object.keys(infos.props).map(::this.renderProp)}
</div>
);
}
Expand Down
45 changes: 19 additions & 26 deletions build/scripts/copy-files.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
/* eslint-disable no-console */
import path from "path";
import fse from "fs-extra";
import Minimist from "minimist";
import path from 'path';
import fse from 'fs-extra';
import Minimist from 'minimist';

const argv = Minimist(process.argv.slice(2));

const files = [
'./source/css',
'./source/fonts',
'README.md',
'CHANGELOG.md',
'LICENSE',
];

Promise.all(
files.map((file) => copyFile(file))
)
.then(() => createPackageFile());

function copyFile(file) {
const buildPath = resolveBuildPath(file);
const buildPath = path.resolve(__dirname, '../apparena-patterns-react/', path.basename(file));
return new Promise((resolve) => {
fse.copy(
file,
Expand All @@ -33,10 +20,6 @@ function copyFile(file) {
.then(() => console.log(`Copied ${file} to ${buildPath}`));
}

function resolveBuildPath(file) {
return path.resolve(__dirname, '../apparena-patterns-react/', path.basename(file));
}

function createPackageFile() {
return new Promise((resolve) => {
fse.readFile(path.resolve(__dirname, '../../package.json'), 'utf8', (err, data) => {
Expand All @@ -58,16 +41,16 @@ function createPackageFile() {
bugs,
homepage,
peerDependencies,
dependencies,
dependencies
} = packageData;

var {version} = packageData;
var {version} = packageData;
if (argv._.length) {
version = argv._[0];
}

const minimalPackage = {
name: "apparena-patterns-react",
name: 'apparena-patterns-react',
author,
version,
description,
Expand All @@ -78,7 +61,7 @@ function createPackageFile() {
bugs,
homepage,
peerDependencies,
dependencies,
dependencies
};

return new Promise((resolve) => {
Expand All @@ -91,4 +74,14 @@ function createPackageFile() {
});
});
});
}
}

const files = [
'./source/css',
'./source/fonts',
'README.md',
'CHANGELOG.md',
'LICENSE'
];

Promise.all(files.map((file) => copyFile(file))).then(() => createPackageFile());
4 changes: 3 additions & 1 deletion build/scripts/run-travis-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
set -ev
npm run test
npm run test:coverage
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
bash <(curl -s https://codecov.io/bash) -f ./coverage/coverage-final.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"publish": "cd build/apparena-patterns-react && npm publish",
"start": "node build/webpack/server.js",
"test": "cross-env NODE_ENV=test nyc ava",
"test:coverage": "nyc report --reporter=lcov",
"test:coverage": "nyc report --reporter=lcov --reporter=json --reporter=text-lcov",
"test:coverage:html": "nyc report --reporter=html"
},
"repository": {
Expand Down

0 comments on commit 305f88d

Please sign in to comment.