[UI Framework] [K7] Improve generator snippets (#13598) (#13599) (#13600)

* Remove extraneous path info from SCSS import snippet.
* Add GuideCode to demo page. Put stateless function params on multiple lines.
* Log an error if you try to create a component with a blank name.
This commit is contained in:
CJ Cenizal 2017-08-18 16:14:54 -07:00 committed by GitHub
parent 66bb17e913
commit 25900adc51
3 changed files with 13 additions and 3 deletions

View file

@ -27,6 +27,11 @@ module.exports = class extends Generator {
default: true,
}]).then(answers => {
this.config = answers;
if (!answers.name || !answers.name.trim()) {
this.log.error('Sorry, please run this generator again and provide a component name.');
process.exit(1);
}
});
}
@ -121,7 +126,7 @@ module.exports = class extends Generator {
this.log(chalk.white('\n// Import component styles into the root index.scss.'));
this.log(
`${chalk.magenta('@import')} ${chalk.cyan(`'./${this.config.name}/index'`)};`
`${chalk.magenta('@import')} ${chalk.cyan(`'${this.config.name}/index'`)};`
);
};

View file

@ -2,7 +2,11 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
export const <%= componentName %> = ({ children, className, ...rest }) => {
export const <%= componentName %> = ({
children,
className,
...rest,
}) => {
const classes = classNames('<%= cssClassName %>', className);
return (

View file

@ -3,6 +3,7 @@ import React from 'react';
import { renderToHtml } from '../../services';
import {
GuideCode,
GuideDemo,
GuidePage,
GuideSection,
@ -27,7 +28,7 @@ export default props => (
}]}
>
<GuideText>
Description needed: how to use the <%= componentExampleName %> component.
Description needed: how to use the <GuideCode><%= componentExampleName %></GuideCode> component.
</GuideText>
<GuideDemo>