Skip to content

Commit

Permalink
[UI Framework] [K7] Improve generator snippets (#13598) (#13599)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
cjcenizal authored Aug 18, 2017
1 parent 8aaa900 commit cb5f508
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ui_framework/generator-kui/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}

Expand Down Expand Up @@ -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'`)};`
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { renderToHtml } from '../../services';

import {
GuideCode,
GuideDemo,
GuidePage,
GuideSection,
Expand All @@ -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>
Expand Down

0 comments on commit cb5f508

Please sign in to comment.