Skip to content

Instantly share code, notes, and snippets.

@dannyhw
Last active July 5, 2022 16:19
Show Gist options
  • Select an option

  • Save dannyhw/8752965fed92217a316471e11b92bdf2 to your computer and use it in GitHub Desktop.

Select an option

Save dannyhw/8752965fed92217a316471e11b92bdf2 to your computer and use it in GitHub Desktop.

Revisions

  1. dannyhw revised this gist Nov 8, 2021. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -20,14 +20,15 @@ https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-b
    # The challenge of React Native

    React Native has its own Storybook implementation at @storybook/react-native however it has some limitations.
    The storybook UI is built for the web and so a lot of things need to be reimplmented for react native in order to support the full feature set.
    The storybook UI is built for the web and so a lot of things need to be re-implemented for react native in order to support the full feature set.

    The result of this is react native storybook supports only a very small portion of the addons that exist for Storybook on the web platform. This also means external tools like visual testing for Storybook need a custom implementation in order to support react native.
    The result of this is that react native storybook supports only a very small portion of the addons that exist for Storybook on the web platform. This also means external tools like visual testing for Storybook need a custom implementation in order to support react native.

    This has led to an incomplete experience for react native when compared with the web. Storybook for React Native has it's place for displaying components natively on the device, and I personally see a lot of potential with React Native Storybook beyong that. However in order to reach that potential a lot of work is needed, and it's mostly repeated work such as re-implementing features already existing on the web.
    This has led to an incomplete experience for react native when compared with the web. Storybook for React Native has its place for displaying components natively on the device, and I personally see a lot of potential with React Native Storybook beyond that. However in order to reach that potential a lot of work is needed, and it's mostly repeated work such as re-implementing features already existing on the web.

    The project that I want to show you now should help bridge the gap today for react native. Meaning you can have the full functionality that you know and love from Storybook on the web platform.


    Note: work on @storybook/react-native will continue and 6.0 will be coming out. I would love to talk more about my vision for react native storybook 6.x in a future post if there is interest.

    # Storybook + React Native Web
  2. dannyhw revised this gist Nov 8, 2021. 1 changed file with 3 additions and 7 deletions.
    10 changes: 3 additions & 7 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -20,15 +20,11 @@ https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-b
    # The challenge of React Native

    React Native has its own Storybook implementation at @storybook/react-native however it has some limitations.
    This stems from the fact that most things need to be reimplemented for the platform.
    The storybook UI is built for the web and so a lot of things need to be reimplmented for react native in order to support the full feature set.

    What it means in practice is that the storybook UI and almost all Addon UI has to be recreated for react native in order to support the full feature set.
    The result of this is react native storybook supports only a very small portion of the addons that exist for Storybook on the web platform. This also means external tools like visual testing for Storybook need a custom implementation in order to support react native.

    The result of this is that react native storybook supports only a very small portion of the addons that exist for Storybook on the web platform. This also means that external tools like visual testing for Storybook need a custom implementation in order to support react native.

    This has led to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with React Native Storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work such as re-implementing features already existing in the web.
    This has led to an incomplete experience for react native when compared with the web. Storybook for React Native has it's place for displaying components natively on the device, and I personally see a lot of potential with React Native Storybook beyong that. However in order to reach that potential a lot of work is needed, and it's mostly repeated work such as re-implementing features already existing on the web.

    The project that I want to show you now should help bridge the gap today for react native. Meaning you can have the full functionality that you know and love from Storybook on the web platform.

  3. dannyhw revised this gist Nov 8, 2021. No changes.
  4. dannyhw revised this gist Nov 8, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ That's why I'm excited to announce Storybook for React Native Web, a new complem

    # A different take on Storybook for React Native

    I've been working on a new approach of using a storybook with react-native that has all the functionality of storybook on the web. This is acheived by using the react-native-web library to make your components available in the browser.
    I've been working on a new approach of using a storybook with react-native that has all the functionality of storybook on the web. This is acheived by using the react-native-web library to make your components available in the browser. I've done the config for you in this addon and you just need to add it to your project.

    In the video below I am interacting with some react native components in the browser. The components displayed use features from popular React Native libraries such as: the animation library react-native-reanimated, and a common library for handling interactions react-native-gesture handler.

  5. dannyhw revised this gist Nov 8, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ That's why I'm excited to announce Storybook for React Native Web, a new complem

    # A different take on Storybook for React Native

    I've been working on a new approach of using a storybook with react-native that has all the functionality of storybook on the web.
    I've been working on a new approach of using a storybook with react-native that has all the functionality of storybook on the web. This is acheived by using the react-native-web library to make your components available in the browser.

    In the video below I am interacting with some react native components in the browser. The components displayed use features from popular React Native libraries such as: the animation library react-native-reanimated, and a common library for handling interactions react-native-gesture handler.

  6. dannyhw revised this gist Nov 8, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Storybook started off web focused and has expanded to many different platforms s

    Storybook for React Native is a catalog of all your components and states, that runs inside your iOS or Android app, on your mobile device. This is great for seeing your React Native components in their production setting, but also has some disadvantages when compared to Storybook's web UI.

    That's why I'm excited to announce Storybook for React Native Web, a new complementary approach to developing and and sharing React Native components in Storybook.
    That's why I'm excited to announce Storybook for React Native Web, a new complementary approach to developing and sharing React Native components in Storybook.

    # A different take on Storybook for React Native

  7. dannyhw revised this gist Nov 8, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ That's why I'm excited to announce Storybook for React Native Web, a new complem

    # A different take on Storybook for React Native

    I've been working on a new approach of using a storybook with react-native that is intended to be an alternative or complementary addition to the react native storybook space.
    I've been working on a new approach of using a storybook with react-native that has all the functionality of storybook on the web.

    In the video below I am interacting with some react native components in the browser. The components displayed use features from popular React Native libraries such as: the animation library react-native-reanimated, and a common library for handling interactions react-native-gesture handler.

  8. dannyhw revised this gist Nov 8, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,9 @@ Storybook is a UI development workshop for components and pages. It's used by ma

    Storybook started off web focused and has expanded to many different platforms since then. One of those platforms is React Native.

    React Native provides a way for javascript developers to develop for IOS and Android whilst using tools they are familiar with. In fact react native actually supports much more than just the mobile platform. There is also support for Web, Windows, MacOS and even VR.
    Storybook for React Native is a catalog of all your components and states, that runs inside your iOS or Android app, on your mobile device. This is great for seeing your React Native components in their production setting, but also has some disadvantages when compared to Storybook's web UI.

    That's why I'm excited to announce Storybook for React Native Web, a new complementary approach to developing and and sharing React Native components in Storybook.

    # A different take on Storybook for React Native

  9. dannyhw revised this gist Nov 7, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ React Native provides a way for javascript developers to develop for IOS and And

    I've been working on a new approach of using a storybook with react-native that is intended to be an alternative or complementary addition to the react native storybook space.

    In the video below I am interacting with some react native components in the browser. The components displayed use features from popular React Native libraries such as the animation library react-native-reanimated and a common library for handling interactions react-native-gesture-handler.
    In the video below I am interacting with some react native components in the browser. The components displayed use features from popular React Native libraries such as: the animation library react-native-reanimated, and a common library for handling interactions react-native-gesture handler.

    https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-babe-8c020935b11a.mp4

  10. dannyhw revised this gist Nov 7, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@ React Native provides a way for javascript developers to develop for IOS and And

    I've been working on a new approach of using a storybook with react-native that is intended to be an alternative or complementary addition to the react native storybook space.

    In the video below I am interacting with some react native components in the browser. The components displayed use features from popular React Native libraries such as the animation library react-native-reanimated and a common library for handling interactions react-native-gesture-handler.

    https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-babe-8c020935b11a.mp4


  11. dannyhw revised this gist Nov 6, 2021. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -59,8 +59,7 @@ this new addon and they all work very well on the web.

    # Introducing @storybook/addon-react-native-web

    This addon provides you with a simple setup for using the reactjs storybook in a react native project. You can run it
    locally or easily deploy as a website for others to see. The best part is that since it's running on the web with the ReactJS configuration most addons should work with no changes necessary.
    This addon provides you with a simple setup for using the reactjs storybook in a react native project. You can run it locally or easily deploy it as a website for others to see. The best part is that since it's running on the web with the ReactJS configuration most addons should work with no changes necessary.

    That means:

  12. dannyhw revised this gist Nov 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ This has led to an incomplete experience for react native when compared with the
    and I personally see a lot of potential with React Native Storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work such as re-implementing features already existing in the web.

    The project that I want to show you should help bridge the gap today. Meaning you can have the full functionality that you know and love from Storybook on the web platform.
    The project that I want to show you now should help bridge the gap today for react native. Meaning you can have the full functionality that you know and love from Storybook on the web platform.

    Note: work on @storybook/react-native will continue and 6.0 will be coming out. I would love to talk more about my vision for react native storybook 6.x in a future post if there is interest.

  13. dannyhw revised this gist Nov 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ What it means in practice is that the storybook UI and almost all Addon UI has t

    The result of this is that react native storybook supports only a very small portion of the addons that exist for Storybook on the web platform. This also means that external tools like visual testing for Storybook need a custom implementation in order to support react native.

    All this has led to an incomplete experience for react native when compared with the web. It still has it's uses,
    This has led to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with React Native Storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work such as re-implementing features already existing in the web.

  14. dannyhw revised this gist Nov 6, 2021. 1 changed file with 24 additions and 26 deletions.
    50 changes: 24 additions & 26 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -1,42 +1,42 @@
    # Intro

    Storybook is a UI development workshop for components and pages. It's used by many teams for all kinds of reasons. You can develop components in isolation, run visual tests and even validate the acessibility of your UI.
    Storybook is a UI development workshop for components and pages. It's used by many teams for all kinds of reasons. You can develop components in isolation, run visual tests and even validate the accessibility of your UI.

    Storybook started off web focused and has expanded to many different platforms since then. One of those platforms is React Native.

    React Native provides a way for javascript developers to develop for IOS and Android whilst using tools they are familar with. In fact react native actually supports much more than just the mobile platform. There is also support for Web, Windows, MacOS and even VR.
    React Native provides a way for javascript developers to develop for IOS and Android whilst using tools they are familiar with. In fact react native actually supports much more than just the mobile platform. There is also support for Web, Windows, MacOS and even VR.

    # A different take on Storybook for React Native

    I've been working on a new approach of using storybook with react-native that is intended to be an alternative or complementary addition to the react native storybook space.
    I've been working on a new approach of using a storybook with react-native that is intended to be an alternative or complementary addition to the react native storybook space.

    https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-babe-8c020935b11a.mp4


    # The challenge of React Native

    React native has it's own storybook implementation at @storybook/react-native however it has some limitations.
    React Native has its own Storybook implementation at @storybook/react-native however it has some limitations.
    This stems from the fact that most things need to be reimplemented for the platform.

    What is means in practice is that the storybook UI and almost all Addon UI has to be recreated for react native in order to support the full feature set.
    What it means in practice is that the storybook UI and almost all Addon UI has to be recreated for react native in order to support the full feature set.

    The result of this is that react native storybook supports only a very small portion of the addons that exist for storybook on web platform. This also means that external tools like visual testing for storybook need a custom implementation in order to support react native.
    The result of this is that react native storybook supports only a very small portion of the addons that exist for Storybook on the web platform. This also means that external tools like visual testing for Storybook need a custom implementation in order to support react native.

    All this has lead to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with react native storybook. The problem is that in order to reach that potential a
    All this has led to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with React Native Storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work such as re-implementing features already existing in the web.

    The project that I want to show you should help bridge the gap today. Meaning you can have the full functionality that you know and love from storybook in the web platform.
    The project that I want to show you should help bridge the gap today. Meaning you can have the full functionality that you know and love from Storybook on the web platform.

    Disclaimer: work on @storybook/react-native will continue and 6.0 will be coming out. I would love to talk more about my vision for react native storybook 6.x in a future post if there is interest.
    Note: work on @storybook/react-native will continue and 6.0 will be coming out. I would love to talk more about my vision for react native storybook 6.x in a future post if there is interest.

    # Storybook + React Native Web

    In an ideal situation we would have storybook for react native but with support for all popular addons
    and existing tools used on the web storybook. Is this possible?

    Well if you're here you probably guessed that the answer is yes. There are of course some limitations, however I think
    that for many usecases it will be worth it. The main thing that comes to mind is UI library maintainers that want to show off their react-native components in an interactive way.
    that for many use cases it will be worth it. The main thing that comes to mind is UI library maintainers that want to show off their react-native components in an interactive way.

    ## Is this realistic?

    @@ -56,18 +56,18 @@ if we look at some of the top downloaded libraries for react native based on npm
    All of these libraries have support for the web platform in some way. In fact I've tested many of the popular libraries with
    this new addon and they all work very well on the web.


    # Introducing @storybook/addon-react-native-web

    This addon provides you with a simple setup for using the reactjs storybook in a react native project. You can run it
    locally or easily deploy as a website for others to see. The best part is that since it's running in the web with the
    reactjs config most addons should work with no changes necessary.
    locally or easily deploy as a website for others to see. The best part is that since it's running on the web with the ReactJS configuration most addons should work with no changes necessary.

    That means:

    * Much better UI/UX
    * Popular addons such as Docs supported out of the box
    * Popular add-ons such as Docs supported out of the box
    * Chromatic and other visual testing tools supported
    * Easily share with stake holders such as designers and product owners (publish storybook as a webapp)
    * Easily share with stakeholders such as designers and product owners (publish storybook as a webapp)
    * Full support for the latest storybook features.

    The drawbacks are:
    @@ -76,22 +76,20 @@ The drawbacks are:
    * The components may not display exactly as they would on a native device
    * Some config needed for libraries that aren't transpiled

    Some libraries like reanimated require a bit of setup however I've made it really easy to configure by adding some extra options to the addon. Check out the [npm readme](https://www.npmjs.com/package/@storybook/addon-react-native-web) for more details.
    Some libraries like reanimated require a bit of setup, however I've made it really easy to configure by adding some extra options to the addon. Check out the [npm readme](https://www.npmjs.com/package/@storybook/addon-react-native-web) for more details.

    If those drawbacks aren't dealbreakers then I think you'll be happy with the results.

    ## The setup

    The setup is as follows.

    Setup your react native project if you haven't already
    Create your react native project if you haven't already

    ```sh
    npx react-native init AwesomeApp --template react-native-template-typescript
    cd AwesomeApp
    ```

    Initialize the react storybook.
    Initialize Storybook.

    ```sh
    npx sb init --type react
    @@ -103,14 +101,13 @@ You can delete the example stories if you like (not necessary).
    rm -rf stories/*
    ```


    Now add @storybook/addon-react-native-web and it's dependencies

    ```sh
    yarn add --dev react-dom react-native-web babel-plugin-react-native-web @storybook/addon-react-native-web
    ```

    Open up .storybook/main.js and add the addon to the addons list
    Open up .storybook/main.js and add the addon to the addons list.

    ```javascript
    module.exports = {
    @@ -119,9 +116,9 @@ module.exports = {
    };
    ```

    Now thats the setup done! Lets add a React native component and a story in the stories folder
    Now that's the setup done! Lets add a React native component and a story in the stories folder

    Heres an example of a button component:
    Here's an example of a button component:

    ```typescript
    // stories/MyButton.tsx
    @@ -194,14 +191,15 @@ Basic.args = {
    };
    ```

    Now run storybook with `yarn storybook` and it should open in your browser.
    Now run the Storybook with `yarn storybook` and it should open in your browser.

    You should see something like this:
    ![image](https://user-images.githubusercontent.com/3481514/140612591-554d0b2c-d15d-4e07-afa8-087400134d01.png)

    Running in the web without a single div or span in sight! 🎉
    Running on the web without a single div or span in sight! 🎉

    Thanks for reading this far! Please let me know what you think. You can contact me on twitter at @Danny_H_W or discord in the react-native channel of the [storybook discord server](https://discord.gg/sMFvFsG).

    If you want to see an example project with multiple react native libraries such as reanimated and gesture handler being utilized then checkout this [repository](https://github.com/dannyhw/addon_react_native_web_example).


  15. dannyhw revised this gist Nov 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Intro

    Storybook a UI development workshop for components and pages. It's used by many teams for all kinds of reasons. You can develop components in isolation, run visual tests and even validate the acessibility of your UI.
    Storybook is a UI development workshop for components and pages. It's used by many teams for all kinds of reasons. You can develop components in isolation, run visual tests and even validate the acessibility of your UI.

    Storybook started off web focused and has expanded to many different platforms since then. One of those platforms is React Native.

  16. dannyhw revised this gist Nov 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ This stems from the fact that most things need to be reimplemented for the platf

    What is means in practice is that the storybook UI and almost all Addon UI has to be recreated for react native in order to support the full feature set.

    The result of this is that react native storybook supports only a very small portion of the addons that exist for storybook on web platform. This also means that external tools like visual testing for storybook would need a custom implementation.
    The result of this is that react native storybook supports only a very small portion of the addons that exist for storybook on web platform. This also means that external tools like visual testing for storybook need a custom implementation in order to support react native.

    All this has lead to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with react native storybook. The problem is that in order to reach that potential a
  17. dannyhw revised this gist Nov 6, 2021. 1 changed file with 14 additions and 4 deletions.
    18 changes: 14 additions & 4 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    # Intro

    Storybook a UI development workshop for components and pages. It's used by many teams for all kinds of reasons. You can develop components in isolation, run visual tests and even validate the acessibility of your UI.

    Storybook started off web focused and has expanded to many different platforms since then. One of those platforms is React Native.

    React Native provides a way for javascript developers to develop for IOS and Android whilst using tools they are familar with. In fact react native actually supports much more than just the mobile platform. There is also support for Web, Windows, MacOS and even VR.

    # A different take on Storybook for React Native

    I've been working on a new approach of using storybook with react-native that is intended to be an alternative or complementary addition to the react native storybook space.
    @@ -8,15 +16,17 @@ https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-b
    # The challenge of React Native

    React native has it's own storybook implementation at @storybook/react-native however it has some limitations.
    This stems from the fact that most things need to be reimplemented for the platform particularly the UI and interactions with that UI.
    This stems from the fact that most things need to be reimplemented for the platform.

    What is means in practice is that the storybook UI and almost all Addon UI has to be recreated for react native in order to support the full feature set.

    Storybook has a wide range of addons and tooling and this is very difficult to utilize for react native since it's outside of the react native ecosystem due to it being based on web apis and the dom.
    The result of this is that react native storybook supports only a very small portion of the addons that exist for storybook on web platform. This also means that external tools like visual testing for storybook would need a custom implementation.

    All this has lead to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with react native storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work i.e re-implementing features already existing in the web.
    lot of work is needed, and it's mostly repeated work such as re-implementing features already existing in the web.

    This project should help bridge the gap today for users that want the full functionality that they know and love from storybook in the web platform.
    The project that I want to show you should help bridge the gap today. Meaning you can have the full functionality that you know and love from storybook in the web platform.

    Disclaimer: work on @storybook/react-native will continue and 6.0 will be coming out. I would love to talk more about my vision for react native storybook 6.x in a future post if there is interest.

  18. dannyhw revised this gist Nov 6, 2021. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -8,26 +8,25 @@ https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-b
    # The challenge of React Native

    React native has it's own storybook implementation at @storybook/react-native however it has some limitations.
    This stems from the fact that most things need to be reimplemented for the platform particualary the UI and interactions with that UI.
    This stems from the fact that most things need to be reimplemented for the platform particularly the UI and interactions with that UI.

    Storybook has a wide range of addons and tooling and this is very difficult to utilize for react native since it's essentially
    outside of the react native ecosystem due to it being based on web apis and the dom.
    Storybook has a wide range of addons and tooling and this is very difficult to utilize for react native since it's outside of the react native ecosystem due to it being based on web apis and the dom.

    All this has lead to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with react native storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work i.e re-implementing features already existing in the web.

    This project should help bridge the gap for users that want the full functionality that they know and love from storybook in the web platform.
    This project should help bridge the gap today for users that want the full functionality that they know and love from storybook in the web platform.

    Disclaimer: work on @storybook/react-native will continue and 6.0 will be coming out.
    Disclaimer: work on @storybook/react-native will continue and 6.0 will be coming out. I would love to talk more about my vision for react native storybook 6.x in a future post if there is interest.

    # Storybook + React Native Web

    In an ideal situation we have storybook for react native but with support for all popular addons
    In an ideal situation we would have storybook for react native but with support for all popular addons
    and existing tools used on the web storybook. Is this possible?

    Well if you're here you probably guessed that the answer is yes. There are of course some limitations, however I think
    that for many usecases it will be worth the cost of some unsupported native components. The main thing that comes to mind is UI library maintainers that want to show off their react-native components in an interactive way.
    that for many usecases it will be worth it. The main thing that comes to mind is UI library maintainers that want to show off their react-native components in an interactive way.

    ## Is this realistic?

    @@ -83,6 +82,7 @@ cd AwesomeApp
    ```

    Initialize the react storybook.

    ```sh
    npx sb init --type react
    ```
  19. dannyhw revised this gist Nov 6, 2021. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    # A different take on Storybook for React Native

    I've been working on a new approach of using storybook with react-native that is intended to be an alternative or complementary
    addition to the space.
    I've been working on a new approach of using storybook with react-native that is intended to be an alternative or complementary addition to the react native storybook space.

    https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-babe-8c020935b11a.mp4

  20. dannyhw revised this gist Nov 6, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -161,7 +161,7 @@ export const MyButton = ({text, onPress, color, textColor}: ButtonProps) => (

    ```

    And a story for that component
    And a story for that component:

    ```typescript
    // stories/MyButton.stories.tsx
    @@ -192,7 +192,7 @@ You should see something like this:

    Running in the web without a single div or span in sight! 🎉

    Thanks for reading this far, please let me know what you think. You can contact me via twitter @Danny_H_W or discord in the react-native channel of the [storybook discord server](https://discord.gg/sMFvFsG).
    Thanks for reading this far! Please let me know what you think. You can contact me on twitter at @Danny_H_W or discord in the react-native channel of the [storybook discord server](https://discord.gg/sMFvFsG).

    If you want to see an example project with multiple react native libraries such as reanimated and gesture handler being utilized then checkout this [repository](https://github.com/dannyhw/addon_react_native_web_example).

  21. dannyhw revised this gist Nov 6, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -164,6 +164,7 @@ export const MyButton = ({text, onPress, color, textColor}: ButtonProps) => (
    And a story for that component

    ```typescript
    // stories/MyButton.stories.tsx
    import React from 'react';
    import {ComponentMeta, ComponentStory} from '@storybook/react';

    @@ -189,7 +190,7 @@ Now run storybook with `yarn storybook` and it should open in your browser.
    You should see something like this:
    ![image](https://user-images.githubusercontent.com/3481514/140612591-554d0b2c-d15d-4e07-afa8-087400134d01.png)
    Running in the web without a single div or span in sight!
    Running in the web without a single div or span in sight! 🎉
    Thanks for reading this far, please let me know what you think. You can contact me via twitter @Danny_H_W or discord in the react-native channel of the [storybook discord server](https://discord.gg/sMFvFsG).
  22. dannyhw revised this gist Nov 6, 2021. 1 changed file with 10 additions and 7 deletions.
    17 changes: 10 additions & 7 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,9 @@ All this has lead to an incomplete experience for react native when compared wit
    and I personally see a lot of potential with react native storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work i.e re-implementing features already existing in the web.

    This project should help bridge the gap for users that really want the full functionality that they know and love from storybook in the web platform. To be clear work on @storybook/react-native will continue and 6.0 will be coming out, it's just going to take a bit of time due to those limitations I've mentioned here.
    This project should help bridge the gap for users that want the full functionality that they know and love from storybook in the web platform.

    Disclaimer: work on @storybook/react-native will continue and 6.0 will be coming out.

    # Storybook + React Native Web

    @@ -30,7 +32,7 @@ that for many usecases it will be worth the cost of some unsupported native comp

    ## Is this realistic?

    You'd might be surprised at the number of react native libraries that already fully support the web platform. Also
    You might be surprised at the number of react native libraries that already fully support the web platform. Also
    if you've been following the react native scene you'll know that facebook is putting a strong emphasis on the
    [many platform vision](https://reactnative.dev/blog/2021/08/26/many-platform-vision).

    @@ -48,8 +50,8 @@ this new addon and they all work very well on the web.

    # Introducing @storybook/addon-react-native-web

    This addon provides you with a simple setup for using the reactjs storybook in a react native project that you can run
    locally and easily deploy as a website for others to work on. The best part is that since it's running in the web with the
    This addon provides you with a simple setup for using the reactjs storybook in a react native project. You can run it
    locally or easily deploy as a website for others to see. The best part is that since it's running in the web with the
    reactjs config most addons should work with no changes necessary.

    That means:
    @@ -81,8 +83,7 @@ npx react-native init AwesomeApp --template react-native-template-typescript
    cd AwesomeApp
    ```

    Initialize the react storybook, I'm using sb@next but you can use the stable version.

    Initialize the react storybook.
    ```sh
    npx sb init --type react
    ```
    @@ -94,7 +95,7 @@ rm -rf stories/*
    ```


    Now add addon-react-native-web and it's dependencies
    Now add @storybook/addon-react-native-web and it's dependencies

    ```sh
    yarn add --dev react-dom react-native-web babel-plugin-react-native-web @storybook/addon-react-native-web
    @@ -192,3 +193,5 @@ Running in the web without a single div or span in sight!
    Thanks for reading this far, please let me know what you think. You can contact me via twitter @Danny_H_W or discord in the react-native channel of the [storybook discord server](https://discord.gg/sMFvFsG).
    If you want to see an example project with multiple react native libraries such as reanimated and gesture handler being utilized then checkout this [repository](https://github.com/dannyhw/addon_react_native_web_example).
  23. dannyhw revised this gist Nov 6, 2021. 1 changed file with 25 additions and 8 deletions.
    33 changes: 25 additions & 8 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -14,22 +14,24 @@ This stems from the fact that most things need to be reimplemented for the platf
    Storybook has a wide range of addons and tooling and this is very difficult to utilize for react native since it's essentially
    outside of the react native ecosystem due to it being based on web apis and the dom.

    All this has basically lead to an incomplete experience for react native when compared with the web. It still has it's uses,
    All this has lead to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with react native storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work i.e re-implementing features already existing in the web.

    This project should help bridge the gap for users that really want the full functionality that they know and love from storybook in the web platform. To be clear work on @storybook/react-native will continue and 6.0 will be coming out, it's just going to take a bit of time due to those limitations I've mentioned here.

    # Storybook + React Native Web

    In an ideal situation we have storybook for react native but with support for all popular addons
    and existing tools used on the web storybook. Is this possible?

    Well if you're here you probably guessed that the answer is yes. There are of course some limitations, however I think
    that for some usecases it will be a no brainer. The main thing that comes to mind is UI libraries that support react-native-web.
    that for many usecases it will be worth the cost of some unsupported native components. The main thing that comes to mind is UI library maintainers that want to show off their react-native components in an interactive way.

    ## Is this realistic?

    You'd actually be surprised at the number of react native libraries that already fully support the web platform.
    If you've been following the react native scene you'll know that facebook is putting a strong emphasis on the
    You'd might be surprised at the number of react native libraries that already fully support the web platform. Also
    if you've been following the react native scene you'll know that facebook is putting a strong emphasis on the
    [many platform vision](https://reactnative.dev/blog/2021/08/26/many-platform-vision).

    if we look at some of the top downloaded libraries for react native based on npm numbers:
    @@ -55,12 +57,22 @@ That means:
    * Much better UI/UX
    * Popular addons such as Docs supported out of the box
    * Chromatic and other visual testing tools supported
    * Easily share with stake holders such as designers and product owners
    * Easily share with stake holders such as designers and product owners (publish storybook as a webapp)
    * Full support for the latest storybook features.

    The drawbacks are:

    * Some libraries won't have web support
    * The components may not display exactly as they would on a native device
    * Some config needed for libraries that aren't transpiled

    Some libraries like reanimated require a bit of setup however I've made it really easy to configure by adding some extra options to the addon. Check out the [npm readme](https://www.npmjs.com/package/@storybook/addon-react-native-web) for more details.

    If those drawbacks aren't dealbreakers then I think you'll be happy with the results.

    ## The setup

    The setup is super simple.
    The setup is as follows.

    Setup your react native project if you haven't already

    @@ -72,7 +84,7 @@ cd AwesomeApp
    Initialize the react storybook, I'm using sb@next but you can use the stable version.

    ```sh
    npx sb@next init --type react
    npx sb init --type react
    ```

    You can delete the example stories if you like (not necessary).
    @@ -81,13 +93,14 @@ You can delete the example stories if you like (not necessary).
    rm -rf stories/*
    ```


    Now add addon-react-native-web and it's dependencies

    ```sh
    yarn add --dev react-dom react-native-web babel-plugin-react-native-web @storybook/addon-react-native-web
    ```

    Open up .storybook/main.js and add the addon to the config
    Open up .storybook/main.js and add the addon to the addons list

    ```javascript
    module.exports = {
    @@ -175,3 +188,7 @@ Now run storybook with `yarn storybook` and it should open in your browser.
    You should see something like this:
    ![image](https://user-images.githubusercontent.com/3481514/140612591-554d0b2c-d15d-4e07-afa8-087400134d01.png)
    Running in the web without a single div or span in sight!
    Thanks for reading this far, please let me know what you think. You can contact me via twitter @Danny_H_W or discord in the react-native channel of the [storybook discord server](https://discord.gg/sMFvFsG).
  24. dannyhw created this gist Nov 6, 2021.
    177 changes: 177 additions & 0 deletions addon_react_native_web.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,177 @@
    # A different take on Storybook for React Native

    I've been working on a new approach of using storybook with react-native that is intended to be an alternative or complementary
    addition to the space.

    https://user-images.githubusercontent.com/3481514/140611482-95241a87-45e2-45ee-babe-8c020935b11a.mp4


    # The challenge of React Native

    React native has it's own storybook implementation at @storybook/react-native however it has some limitations.
    This stems from the fact that most things need to be reimplemented for the platform particualary the UI and interactions with that UI.

    Storybook has a wide range of addons and tooling and this is very difficult to utilize for react native since it's essentially
    outside of the react native ecosystem due to it being based on web apis and the dom.

    All this has basically lead to an incomplete experience for react native when compared with the web. It still has it's uses,
    and I personally see a lot of potential with react native storybook. The problem is that in order to reach that potential a
    lot of work is needed, and it's mostly repeated work i.e re-implementing features already existing in the web.

    # Storybook + React Native Web

    In an ideal situation we have storybook for react native but with support for all popular addons
    and existing tools used on the web storybook. Is this possible?

    Well if you're here you probably guessed that the answer is yes. There are of course some limitations, however I think
    that for some usecases it will be a no brainer. The main thing that comes to mind is UI libraries that support react-native-web.

    ## Is this realistic?

    You'd actually be surprised at the number of react native libraries that already fully support the web platform.
    If you've been following the react native scene you'll know that facebook is putting a strong emphasis on the
    [many platform vision](https://reactnative.dev/blog/2021/08/26/many-platform-vision).

    if we look at some of the top downloaded libraries for react native based on npm numbers:

    * react-navigation
    * react-native-screens
    * react-native-gesture-handler
    * react-native-svg
    * react-native-reanimated
    * react-native-vector-icons

    All of these libraries have support for the web platform in some way. In fact I've tested many of the popular libraries with
    this new addon and they all work very well on the web.

    # Introducing @storybook/addon-react-native-web

    This addon provides you with a simple setup for using the reactjs storybook in a react native project that you can run
    locally and easily deploy as a website for others to work on. The best part is that since it's running in the web with the
    reactjs config most addons should work with no changes necessary.

    That means:

    * Much better UI/UX
    * Popular addons such as Docs supported out of the box
    * Chromatic and other visual testing tools supported
    * Easily share with stake holders such as designers and product owners
    * Full support for the latest storybook features.

    ## The setup

    The setup is super simple.

    Setup your react native project if you haven't already

    ```sh
    npx react-native init AwesomeApp --template react-native-template-typescript
    cd AwesomeApp
    ```

    Initialize the react storybook, I'm using sb@next but you can use the stable version.

    ```sh
    npx sb@next init --type react
    ```

    You can delete the example stories if you like (not necessary).

    ```sh
    rm -rf stories/*
    ```

    Now add addon-react-native-web and it's dependencies

    ```sh
    yarn add --dev react-dom react-native-web babel-plugin-react-native-web @storybook/addon-react-native-web
    ```

    Open up .storybook/main.js and add the addon to the config

    ```javascript
    module.exports = {
    /* existing config */
    addons: [/*existing addons,*/ '@storybook/addon-react-native-web'],
    };
    ```

    Now thats the setup done! Lets add a React native component and a story in the stories folder

    Heres an example of a button component:

    ```typescript
    // stories/MyButton.tsx
    import React from 'react';
    import {StyleSheet, Text, TouchableOpacity, View} from 'react-native';

    export type ButtonProps = {
    onPress: () => void;
    text: string;
    color?: string;
    textColor?: string;
    };

    const styles = StyleSheet.create({
    button: {
    paddingVertical: 8,
    paddingHorizontal: 16,
    borderRadius: 4,
    alignSelf: 'flex-start',
    flexGrow: 0,
    backgroundColor: 'purple',
    },
    buttonText: {
    color: 'white',
    fontSize: 16,
    fontWeight: 'bold',
    },
    buttonContainer: {
    alignItems: 'flex-start',
    flex: 1,
    },
    });

    export const MyButton = ({text, onPress, color, textColor}: ButtonProps) => (
    <View style={styles.buttonContainer}>
    <TouchableOpacity
    style={[styles.button, !!color && {backgroundColor: color}]}
    onPress={onPress}
    activeOpacity={0.8}>
    <Text style={[styles.buttonText, !!textColor && {color: textColor}]}>
    {text}
    </Text>
    </TouchableOpacity>
    </View>
    );

    ```

    And a story for that component

    ```typescript
    import React from 'react';
    import {ComponentMeta, ComponentStory} from '@storybook/react';

    import {MyButton} from './MyButton';

    export default {
    title: 'components/MyButton',
    component: MyButton,
    } as ComponentMeta<typeof MyButton>;

    export const Basic: ComponentStory<typeof MyButton> = args => (
    <MyButton {...args} />
    );

    Basic.args = {
    text: 'Hello World',
    color: 'purple',
    };
    ```
    Now run storybook with `yarn storybook` and it should open in your browser.
    You should see something like this:
    ![image](https://user-images.githubusercontent.com/3481514/140612591-554d0b2c-d15d-4e07-afa8-087400134d01.png)