question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Packaging an addon

See original GitHub issue

I made a nice addon that shows you the QR code of the current story you are on (for mobile web testing) and I can’t figure out how to package it.

This works fine when I import it in my project, in addons.js:

import React from 'react'
import addons from '@storybook/addons'

const externalUrl = process.env.STORYBOOK_URL || window.location.origin

addons.register('local_qr', api => {
  class QRPanel extends React.Component {
    constructor (props) {
      super(props)
      this.state = {url: ''}
      this.handleUrl = this.handleUrl.bind(this)
    }

    componentDidMount () {
      api.onStory(this.handleUrl)
    }

    handleUrl (kind, story) {
      const url = `${externalUr}/iframe.html?selectedKind=${encodeURIComponent(kind)}&selectedStory=${encodeURIComponent(story)}`
      this.setState({url})
    }

    render () {
      return (
        <div>
          <img
            height={200}
            width={200}
            src={'https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=' + encodeURIComponent(this.state.url)}
          />
          <div>{this.state.url}</div>
        </div>
      )
    }
  }

  addons.addPanel('local_qr/panel', {
    title: 'QR Code',
    render: () => <QRPanel />
  })
})

But when I put it in it’s own project and link to it via file:/// url in package.json in another project, it doesn’t seem to be registering (the QR panel isn’t created, and things inside addons.register aren’t called. A console.log in the top of my register file is called, however, so I know it’s loading.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:24 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
usulprocommented, Sep 23, 2017

@konsumer I tried your addon on my machine locally and everything worked fine (except the gitignore issue)

Maybe it will be useful to left the steps I did to run it (and maybe you can follow them from scratch as well):

git clone https://github.com/konsumer/storybook-qr.git
cd storybook-qr
npm i
cd ..
create-react-app test
cd test
getstorybook
npm i ../storybook-qr --save-dev
# add to addons.js line: import 'storybook-qr/register'; 
npm run storybook
1reaction
konsumercommented, Sep 23, 2017

I just published it on npm, and it works fine, so my point is the instructions for local development need a change, as they don’t work as-is.

screen shot 2017-09-23 at 10 16 54 am
Read more comments on GitHub >

github_iconTop Results From Across the Web

Most Common Addons Used By Packaging Companies | ECB
Various types of these add-ons are used for multiple types of custom packaging. Attachments are added attributes or one-of-a-kind aspects that ...
Read more >
AddOn Packaging — Koverse 2.9 documentation
AddOn Packaging ¶. Custom sources, sinks, authentication mechanisms, and analytics are plugged into Koverse via simple packages called AddOns.
Read more >
Addon Packages: Purchase Access to a Page, Post or “Thing”
Admin designates a post as an “addon package” by setting a price for access and selecting which membership levels can purchase the package....
Read more >
Packing AddOn for SAP - SAP Community
Hi everybody, I'm new in SBO Development, and i have one question about packaging an add'on. I'm developing an addOn using Visual Basic...
Read more >
How to package a Django application as an Aldryn addon
Select Package Information from your addon's menu. Download the packaging files, and add them to the addon. It should look something like this:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found