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

[WIP] Feat: add Vue integration #95

Closed
wants to merge 2 commits into from
Closed

[WIP] Feat: add Vue integration #95

wants to merge 2 commits into from

Conversation

pedronauck
Copy link
Member

@pedronauck pedronauck commented Jun 27, 2018

Description

This pull request support Vue integration

Review

  • Add example with vue
  • Add docz-plugin-vue
  • Translate VueWrapper to component name in output

Pre-merge checklist

  • Test <PropsTable> integration
  • Test <Playground> integration

import { createPlugin } from 'docz-core'
import { VueLoaderPlugin } from 'vue-loader'

interface BabelRC {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marceloavf you can remove this interface here, typescript already infer this type!


export const doczPluginVue = () =>
createPlugin({
modifyBabelRc: (babelrc: BabelRC): BabelRC => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, I don't get it here too!

})

config.module.rules.push({
test: /\.css$/,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that and how it can integrate with docz-plugin-css 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be a good thing too, we could specify it in Playground tag or also in configuration file, in vue we can just set a tag lang="scss" to change the processor of template, style and script. Might be a way to get it. https://vue-loader.vuejs.org/guide/pre-processors.html#sass


<script>
export default {
name: 'Alert',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this Alert in the same pattern of others that has in the examples? Changing the background based on the kind property...

babelrc?: boolean
}

export const doczPluginVue = () =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the simplicity pattern here, instead of export doczPluginVue, use just vue

@pedronauck pedronauck changed the title Feat: add Vue integration [WIP] Feat: add Vue integration Jun 28, 2018
@pedronauck
Copy link
Member Author

Closed until we figure out the best strategy for that 👍

@artalar
Copy link

artalar commented Aug 9, 2018

Hi! Any news?
@pedronauck

@marceloavf
Copy link
Contributor

Still no solution for the parse of proptables, component name conversion and full compatibility tested with render and single file components @artalar.

@artalar
Copy link

artalar commented Aug 9, 2018

What about https://github.com/akxcv/vuera ?

@marceloavf
Copy link
Contributor

We are using vuera @artalar, you can see more in this branch https://github.com/pedronauck/docz/tree/feat/vue

We also have some problems with babel, as you can see here too akxcv/vuera#46

If you figure out something, feel free to discuss or help us with that integration!

@Aaron-Pool
Copy link

So, would these problems also exist for plain old .js Vue components? My company uses Vue, but our design system code is purely .js, we don't use .vue single file components. We just write Vue components with a render function and JSX. Its very react-y, actually.

@marceloavf
Copy link
Contributor

We need also to make pure render components to work @Aaron-Pool, they both render normally, but we still have an issue with PropsTable and make vuera more interactive to render our code.

@Aaron-Pool
Copy link

Ok! I'll look through the vue branch you have set up and see if there's anything I can think of worth suggesting. Thanks for the quick response!

@Aaron-Pool
Copy link

Aaron-Pool commented Aug 17, 2018

Ok, so, just a thought after poking around for a bit, instead of using VueWrapper, have you considered creating a simple webpack loader to chain after the .vue file loader that does two things:

  1. Runs the component through vue-docgen-api (https://github.com/vue-styleguidist/vue-docgen-api)
  2. Wraps the vue component in the vuera VueInReact HOC
  3. Assign the output of vue-docgen-api to __docgenInfo, just like react-docgen does

Then you could conditionally skip adding react-docgen loader to jsx if any non-compatible plugins have been required (such as a vue plugin), so that the __docgenInfo isn't overwritten?

Or, if you didn't want to worry about conditionally skipping the react-docgen loader based on current plugins, you could just assign the output of vue-docgen-api to __altDocgenInfo and use __altDocgenInfo if it's defined when you parse the props/component name. That could be a pattern for future "nonReact" jsx plugins as well.

I've never done a webpack loader before, but if the theory sounds alright I would consider putting some time into a PR. But I wouldn't want to commit any time to it if that sounds like too messy of an approach to you.

@marceloavf
Copy link
Contributor

Great ideas @Aaron-Pool, I was thinking about a while ago about abandon VueWrapper to make it more interactive and show real component name inside playground, but I can't make it work with webpack.

Also saw vue-docgen-api and tried something, but no success either. Some of this points can also be discussed with @pedronauck, since him understand more of the docz-core

I'll try to rebase the feat/vue branch to get it working with latest release of docz, I would be very grateful if you could help me implement these solutions to see what we can get.

Thank you again!

@Aaron-Pool
Copy link

Got my contributor environment set up last night and started messing with creating a webpack loader. Totally haven't forgotten about this! 👍

@marceloavf marceloavf mentioned this pull request Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants