-
Notifications
You must be signed in to change notification settings - Fork 839
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
Allow passing a prop type or interface directly to the props
option in the docs
#3771
Allow passing a prop type or interface directly to the props
option in the docs
#3771
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Can you add examples to show this working? The |
Added a basic example. it could be found on the props table of basic table. |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3771/ |
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.
Nice, that didn't end up too bad :)
For the EuiPopoverPosition
& PaginationBarProps
examples, those should be applied to their respective pagees/sections instead of taking over the basic table's props rendering.
For the EuiPopoverPosition & PaginationBarProps examples, those should be applied to their respective pagees/sections instead of taking over the basic table's props rendering. I added those for demo 😄 . I guess there are so many possible places where props of types and interfaces must be shown. Should I do that ? |
Gotcha! Let's get at least a couple of those done as part of this PR. The other instances can follow later, especially if you find yourself waiting on us for something else. |
|
Nah; let's see, I think the data grid props would really benefit from this eui/src-docs/src/views/datagrid/datagrid_example.js Lines 352 to 366 in 8ff1efb
Another good place is the color picker. |
One thing to note here. If the types are exported using |
The props tab for Color palette picker errors with
|
Cache showed no error so I missed it 😞 . I will fix this. |
@chandlerprall Thanks for the review. Fixed it 😃 |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3771/ |
Thinking through this change and how it can impact things in the future: the syntax of passing a type/interface as a value in the Only thing I can think of is, instead of making this a babel plugin, do this same logic/conversion in a webpack loader. Then we can specify the loader in the examples when importing the type,
Webpack loader results can be defined in .d.ts files, like
|
Sure I will convert this into a webpack loader |
@ashikmeerankutty I'm looking into how to replace the type/interface with the object, instead of appending. I have that "working", but for some reason babel still sees/errors on a duplicate export name 😕 I'll let you know what I find |
…types & interfaces; use the loader specifically when needed
@ashikmeerankutty I sent a PR your way ashikmeerankutty#4 I don't like having to use a relative path to specify the prop-loader , would you mind investigating some to see if there's a way to specify a local webpack loader without the relative path? I have some ideas for "fixing" that, but I'd like to see if anyone has a better solution first :) note: I have not addressed the typescript module issue, as the current examples aren't TS files. Also think we need to address the loader-as-a-relative-path issue before the TS module. |
…ement Update prop-loader & usage
@chandlerprall Reading through the docs https://webpack.js.org/configuration/resolve/#resolvealias this seems to work. But I couldn't make it work on the project. 😞 |
Fixed it. Can you please review it |
Nice, good find with I'm looking into the typescript side of this; I can get a module declaration for the loader, but having some issues with getting the imports right, mostly around being able to define arbitrary named exports. @cchaos would you mind taking a look at the usage here? Primarily the |
I tried using the wildcard but still its showing cannot find module |
I think that's ok from a dev/syntax experience. So long as we have examples to copy/paste from and probably add a section to our Documentation guidelines wiki doc. Is this PR also supposed to show the examples currently working in the docs? I'm wondering how we will now "link" to the props table as references like how we would do |
I added a prop-loader.d.ts file into src/custom_typings with
which allows, e.g.
but not
|
The links continue working the same, just verified locally where EuiDataGridColumnVisibility references EuiDataGridColumn and that jump works. |
I couldn't find a better way to solve this issue till now. The only way I found was to define the module as any as
so that we can import in any way we want. This can avoid the use of |
Perfect! I confirmed that module declaration allows the import. Woo! Can you push that .d.ts file and update the PR description to reflect all the changes? I don't think this needs any work beyond that; I'll do a another review after this last addition is pushed. |
Should I add the declaration file to src/custom_typings directory or in the scripts directory ? |
Please add it to src/custom_typings, typescript is already configured to look there and will pick it up automatically. |
@chandlerprall Pushed the changes 😃 . Can you please review it |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3771/ |
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.
LGTM! Examples' props come through the same, new code looks good, nice isolated use with the custom loader.
Thanks again @ashikmeerankutty !
🎉 Great work! |
… in the docs (#3771) * Add docgen from ts props babel plugin * Add a basic example for demo * Removed example * Remove props.tsx and use props directly * Expand types * Passed interfaces directly to props in color picker example * Fixed type value in extended props * Added props-loader to convert interfaces to props * removed logger for result * Add comments * Update the prop-loader script to output only the processed, exported types & interfaces; use the loader specifically when needed * Fixed relative path for loader * Removed props.tsx files and uncomment playground files * removed docgen from ts props * Declare module as any * Add prop-loader declaration to custom typings Co-authored-by: Chandler Prall <[email protected]>
Summary
Fixes #1688
Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Checked in IE11 and Firefox- [ ] Props have proper autodocs- [ ] Added documentation- [ ] Checked Code Sandbox works for the any docs examples- [ ] Added or updated jest tests- [ ] Checked for accessibility including keyboard-only and screenreader modes- [ ] A changelog entry exists and is marked appropriately