Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI Framework] [K7] Improve generator snippets #13598

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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