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

Feat/storybook integration #3623

Merged
merged 5 commits into from
Jul 31, 2023
Merged

Conversation

asvae
Copy link
Member

@asvae asvae commented Jul 19, 2023

What is done:

  • Converted all stories to storybook.
  • Removed vue-book completely.
  • Deployed experimental storybook to railway.
  • Link from docs contribution page to storybook.

There are still areas to improve for storybook, like attach figma or link stories to doc pages for particular components. But that would be part of a different effort depending on priority. Most of the value is here already.


I used a script to "convert" all vue-book demos to storybook stories. We may want to use it elsewhere.

import fs from 'fs'
import path from 'path'

const generateStorybook = (directory: string): void => {
  const files = fs.readdirSync(directory)

  for (const file of files) {
    const fullPath = path.join(directory, file)

    if (fs.statSync(fullPath).isDirectory()) {
      generateStorybook(fullPath)
      continue
    }

    if (!fullPath.endsWith('.demo.vue')) { continue }

    const componentName = path.basename(fullPath, '.demo.vue')
    const storyPath = path.join(directory, `${componentName}.stories.ts`)

    console.log(`Generating/Regenerating story for ${fullPath}...`)

    const storyContent = `
import { defineComponent } from 'vue'
import ${componentName} from './${componentName}.demo.vue'

export default {
  title: '${componentName}',
  component: ${componentName},
}

export const Default = defineComponent({
  components: { ${componentName} },
  template: '<${componentName}/>',
})
`

    fs.writeFileSync(storyPath, storyContent.trim() + '\n')
  }
}

const projectRoot = '.'
generateStorybook(projectRoot)
console.log('Storybook files generation/regeneration complete!')

@asvae asvae requested a review from m0ksem July 19, 2023 22:55
@asvae
Copy link
Member Author

asvae commented Jul 31, 2023

@m0ksem reviewed it and said it looks fine

@asvae asvae merged commit 634b228 into epicmaxco:develop Jul 31, 2023
1 check passed
@asvae asvae deleted the feat/storybook-integration branch July 31, 2023 19:23
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.

1 participant