-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Reorganize UI Framework and add Yeoman generator #13172
[UI Framework] Reorganize UI Framework and add Yeoman generator #13172
Conversation
328f389
to
2bc7291
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot comment on the efficacy of the scss reorganization, but the rest looks quite well-organized to me. I left a few small inline comments.
The generators are very handy! They could be made even more efficient for regular use by also adding the prompt choices as command-line arguments. I would be happy to create a PR for that.
package.json
Outdated
"uiFramework:build": "grunt uiFramework:build" | ||
"uiFramework:build": "grunt uiFramework:build", | ||
"uiFramework:create": "yo ./ui_framework/generator-kui/app/component.js", | ||
"uiFramework:document": "yo ./ui_framework/generator-kui/app/documentation.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ui_framework/README.md
Outdated
@@ -54,15 +93,25 @@ you created. | |||
|
|||
This makes your styles available to Kibana and the UI Framework documentation. | |||
|
|||
### Create the React component | |||
#### Create the React component | |||
|
|||
1. Create the React component(s) in the same directory as the related SCSS file(s). | |||
2. Export these components from an `index.js` file. | |||
3. Re-export these components from `ui_framework/components/index.js`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this path has changed to ui_framework/src/components/index.js
.
ui_framework/README.md
Outdated
KuiButtonIcon, | ||
} from '../path/to/ui_framework/components'; | ||
``` | ||
|
||
## Creating components | ||
|
||
There are four steps to creating a new component: | ||
|
||
1. Create the SCSS for the component in `ui_framework/components`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this path has changed to ui_framework/src/components
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a src/components.js
file and a src/services.js
file which re-export the relevant components and services, so I think we can leave these docs as-is. I created this file to avoid having to make any changes in the way the UI Framework is consumed by Kibana.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ignore that comment! I wasn't paying close enough attention. You're right, I'll fix this.
ui_framework/README.md
Outdated
|
||
### Manually | ||
|
||
#### Create component SCSS | ||
|
||
1. Create a directory for your component in `ui_framework/components`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this path has changed to ui_framework/src/components
.
src/jest/config.json
Outdated
"!ui_framework/src/services/**/*/index.js", | ||
"ui_framework/src/components/**/*.js", | ||
"!ui_framework/src/components/index.js", | ||
"!ui_framework/src/components/**/*/index.js" | ||
], | ||
"moduleNameMapper": { | ||
"^ui_framework/components": "<rootDir>/ui_framework/components", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this path has changed to ui_framework/src/components
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think this one is OK, because there's a ui_framework/components/index.js
file which re-exports everything from src
.
@@ -0,0 +1,33 @@ | |||
import React, { | |||
Component, | |||
PropTypes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the interest of forward-compatibility we might want to take PropTypes
from the prop-types
package:
import PropTypes from 'prop-types';
@@ -0,0 +1,20 @@ | |||
import React, { | |||
PropTypes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment about prop-types
above.
}; | ||
|
||
<%= componentName %>.propTypes = { | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding className
and children
by default here as well?
name: 'folderName', | ||
type: 'input', | ||
store: true, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this default to the component name?
prompts.push({
// ...
default: (answers) => answers.name,
// ...
});
this.log(chalk.white('\n// Import route definition into routes.js.')); | ||
this.log( | ||
`{\n` + | ||
` name: ${chalk.cyan(`'${componentExampleName}'`)},\n` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed route name collides with that of the component docs. If the user just copy+pastes this the sandbox menu entry will link to the component doc page. Maybe we could propose something with a prefix or suffix to avoid that?
The test failure looks genuine. The yo templates need to be excluded from the test runner patterns. |
My dislike of yoeman aside, is there a benefit to having the generator in the ui-framework, and not just as another tool in |
f6a7e34
to
72e8e10
Compare
package.json
Outdated
"uiFramework:build": "grunt uiFramework:build" | ||
"uiFramework:build": "grunt uiFramework:build", | ||
"uiFramework:create": "./node_modules/_bin/yo ./ui_framework/generator-kui/app/component.js", | ||
"uiFramework:document": "./node_modules/_bin/yo ./ui_framework/generator-kui/app/documentation.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbudz Will these paths be a problem on Windows machines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because of the slashes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You for sure do not need the whole node_modules
part, you can just use yo
. The beauty of npm scripts is that all the modules are injected into the $PATH.
I can't speak to the path following the command though.
@w33ble I set up the generator and the tasks which run it so that you don't need to install anything except the regular NPM dependencies via |
ui_framework/README.md
Outdated
#### Install Yeoman | ||
|
||
```bash | ||
npm install -g yo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If all of this runs from npm scripts, is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@w33ble @weltenwort Thanks for the feedback! Ready for another review. |
@weltenwort That would be great, thank you. |
df69cbf
to
b0600ea
Compare
jenkins, test this |
…ts directory. (elastic#12809) - Remove global styles, e.g. body and html element selectors.
…c directory. (elastic#12880) - Add components/index.js and services/index.js files to continue to export JS modules from the root.
* Support creation of components. * Add documentation generator for main page, demo, and sandbox. Add additional documentation snippets to KUI generator. (elastic#13076) Fix incorrect use of double quotes in KUI generator snippet. (elastic#13086) Remove infrequently used imports from the KUI generator test template. (elastic#13110)
- Add dashboard back to Jest config. - Add missing form and tool_bar variables.
b0600ea
to
8f2b43a
Compare
…tic#13172) * Reorganize documentation styles so they all live in doc_site/components directory. (elastic#12809) - Remove global styles, e.g. body and html element selectors. * Create global_styles dir with sub-directories. (elastic#12833) * Add SCSS style guide. (elastic#12850) * Refactor UI Framework directory structure to house everything in a src directory. (elastic#12880) - Add components/index.js and services/index.js files to continue to export JS modules from the root. * Add KUI Yeoman generator. * Support creation of components. * Add documentation generator for main page, demo, and sandbox. - Add additional documentation snippets to KUI generator. (elastic#13076) - Fix incorrect use of double quotes in KUI generator snippet. (elastic#13086) - Remove infrequently used imports from the KUI generator test template. (elastic#13110) * Mock assets files for Jest. (elastic#13060) * Fix broken coverage report paths in Jest config. (elastic#13082) * Update eslint config to lint the new UI Framework directory structure. (elastic#13102) * Fix positioning of doc site pagination buttons. (elastic#13203) * Support hasReact prop for sandboxes. (elastic#13270) * Remove deprecated used of component mixin from KUI generator's SCSS template. (elastic#13377) * Fix rebasing errors. - Add dashboard back to Jest config. - Add missing form and tool_bar variables. * Rename tasks to createComponent and documentComponent. * Reference correct src paths in README. * Add children and className to templates' propTypes. * Add default folder name for page demo. * Add suffix to sandbox routes. * Specify testPathIgnorePatterns more clearly. * Rename component.test.js to test.js so that Jenkins won't try to run it. * Update npm scripts to depend on local yo dependency, not global. * Add ui_framework/src to copy task. * Simplify npm scripts and remove requirement for installing Yeoman from README. * Add services to moduleNameMapper in jest config. * Clean up Button and Gallery examples.
…) (#13477) * Reorganize documentation styles so they all live in doc_site/components directory. (#12809) - Remove global styles, e.g. body and html element selectors. * Create global_styles dir with sub-directories. (#12833) * Add SCSS style guide. (#12850) * Refactor UI Framework directory structure to house everything in a src directory. (#12880) - Add components/index.js and services/index.js files to continue to export JS modules from the root. * Add KUI Yeoman generator. * Support creation of components. * Add documentation generator for main page, demo, and sandbox. - Add additional documentation snippets to KUI generator. (#13076) - Fix incorrect use of double quotes in KUI generator snippet. (#13086) - Remove infrequently used imports from the KUI generator test template. (#13110) * Mock assets files for Jest. (#13060) * Fix broken coverage report paths in Jest config. (#13082) * Update eslint config to lint the new UI Framework directory structure. (#13102) * Fix positioning of doc site pagination buttons. (#13203) * Support hasReact prop for sandboxes. (#13270) * Remove deprecated used of component mixin from KUI generator's SCSS template. (#13377) * Fix rebasing errors. - Add dashboard back to Jest config. - Add missing form and tool_bar variables. * Rename tasks to createComponent and documentComponent. * Reference correct src paths in README. * Add children and className to templates' propTypes. * Add default folder name for page demo. * Add suffix to sandbox routes. * Specify testPathIgnorePatterns more clearly. * Rename component.test.js to test.js so that Jenkins won't try to run it. * Update npm scripts to depend on local yo dependency, not global. * Add ui_framework/src to copy task. * Simplify npm scripts and remove requirement for installing Yeoman from README. * Add services to moduleNameMapper in jest config. * Clean up Button and Gallery examples.
This cherry-picks multiple commits from the
k7-ui-framework
branch, squashing similar ones together: