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/v8 #538

Merged
merged 149 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
c7c8d88
v7 init
dannyhw Jul 30, 2023
bd8d3da
fix
dannyhw Jul 30, 2023
d0476ea
remove unused
dannyhw Jul 30, 2023
e9804f7
fix: story render
dannyhw Jul 30, 2023
07cd886
controls
dannyhw Jul 30, 2023
36893ef
actions
dannyhw Jul 30, 2023
f6c9d0d
fix: argenchancer import
dannyhw Jul 30, 2023
ce6759e
backgrounds
dannyhw Jul 30, 2023
3995ed0
fix remaining addons
dannyhw Jul 30, 2023
dabdf49
fix: tests
dannyhw Jul 30, 2023
3a51176
remove client-api
dannyhw Aug 2, 2023
8496cdb
remove yarn cache
dannyhw Aug 2, 2023
5663e06
hot/dispose
dannyhw Aug 4, 2023
583d2b8
Merge remote-tracking branch 'origin/next' into feat/v7
dannyhw Aug 4, 2023
9cbebc2
Merge remote-tracking branch 'origin/next' into feat/v7
dannyhw Aug 4, 2023
a16d060
v7.0.0-alpha.0
dannyhw Aug 4, 2023
3db81f0
stories of hack
dannyhw Aug 6, 2023
c4d6504
remove console.log fix
dannyhw Aug 6, 2023
bb9ed13
fix: stories of with loadAddedExports in start
dannyhw Aug 7, 2023
6e25726
v7.0.0-alpha.1
dannyhw Aug 7, 2023
39f5653
fix: update snapshots
dannyhw Aug 7, 2023
cb47081
use addons.add
dannyhw Aug 7, 2023
3b0607a
fix: comsthing
dannyhw Aug 9, 2023
284fd8a
v7.0.0-alpha.2
dannyhw Aug 9, 2023
caa9868
use manager api
dannyhw Aug 9, 2023
965a875
v7.0.0-alpha.3
dannyhw Aug 9, 2023
3d34bdb
setstory fix/hack
dannyhw Aug 13, 2023
5ddd20b
remove log
dannyhw Aug 13, 2023
eb7e4f2
v7.0.0-alpha.4
dannyhw Aug 13, 2023
3e4e301
try again
dannyhw Aug 13, 2023
7e6db94
v7.0.0-alpha.5
dannyhw Aug 13, 2023
e3c9288
feat/v7 store7 (#509)
dannyhw Oct 15, 2023
13c1081
fix: user channel wasnt working
dannyhw Oct 15, 2023
b17a6c6
fix: deprecation warning
dannyhw Oct 15, 2023
7f5728a
note
dannyhw Oct 15, 2023
297efe8
fix: notes markdown and add error boundaries
dannyhw Oct 16, 2023
6472ca1
fix: set channel on both preview and manager and revert store.channel
dannyhw Oct 22, 2023
002ec8d
fix: actions dont clear
dannyhw Oct 22, 2023
962fd39
Merge remote-tracking branch 'origin/next' into feat/v7
dannyhw Oct 22, 2023
52baead
fix: broken empty config test
dannyhw Oct 22, 2023
b934d12
test: initial generation tests
dannyhw Oct 22, 2023
5b63fc5
fix: only require preview if it exists
dannyhw Oct 22, 2023
98ada29
tests: comment out absolute test
dannyhw Oct 22, 2023
5fc1996
fix: peer
dannyhw Oct 22, 2023
07aa303
fix: peer
dannyhw Oct 22, 2023
e3e0ae9
lock
dannyhw Oct 28, 2023
d0d09fc
v7.0.0-alpha.6
dannyhw Oct 28, 2023
e4d59eb
fix: make actions and controls regular deps for the addons
dannyhw Oct 28, 2023
1e3f579
v7.0.0-alpha.7
dannyhw Oct 28, 2023
a3038aa
fix: missing story error
dannyhw Oct 29, 2023
c383729
v7.0.0-alpha.8
dannyhw Oct 29, 2023
0f83a20
update to alpha 6
dannyhw Dec 17, 2023
e143b04
feat: initial adjustments to server
dannyhw Dec 20, 2023
77ceb0d
chore: update to 7.6.7
dannyhw Jan 2, 2024
da1c920
v7.6.7-alpha.0
dannyhw Jan 2, 2024
679f4b8
requires
dannyhw Jan 2, 2024
c3d9608
v7.6.7-alpha.1
dannyhw Jan 2, 2024
365651b
Merge remote-tracking branch 'origin/next' into feat/v7
dannyhw Jan 2, 2024
dc7661c
start new server implementation
dannyhw Jan 7, 2024
15c4e56
fix: 7.6.8 resolves globals resolution
dannyhw Jan 14, 2024
4968705
fix: resend channel events (controls working, actions not)
dannyhw Jan 15, 2024
3ebf30c
fix: more server progress
dannyhw Jan 15, 2024
c89d260
using addon react native server
dannyhw Jan 15, 2024
9d4a0f4
remove server in favour of addon server
dannyhw Jan 15, 2024
113d7fc
lock
dannyhw Jan 15, 2024
17607f9
fix: tests
dannyhw Jan 15, 2024
1fd96da
v7.6.8-alpha.0
dannyhw Jan 15, 2024
181b1aa
fix: knobs fix and get latest server version
dannyhw Jan 15, 2024
4f4da4f
fix: version
dannyhw Jan 16, 2024
a1b8c3b
fix: patch annoying warning
dannyhw Jan 16, 2024
b0c0513
fix: patch annoying warning
dannyhw Jan 16, 2024
921116d
test out example of not bundling sb code
dannyhw Jan 16, 2024
6c7852f
remove log
dannyhw Jan 16, 2024
55f4892
fix: animation style type
dannyhw Jan 16, 2024
06c547f
docs: update things
dannyhw Jan 17, 2024
b067bf0
fix: types
dannyhw Jan 17, 2024
ea5f98c
fix: another type
dannyhw Jan 17, 2024
99b82f1
fix: update version
dannyhw Jan 17, 2024
d458704
v7.6.9-alpha.0
dannyhw Jan 17, 2024
301aa6e
refactor: use storybook/react types
dannyhw Jan 18, 2024
ebae4b3
chore: update storybook version
dannyhw Jan 19, 2024
d48243f
v7.6.10-alpha.0
dannyhw Jan 19, 2024
1911c47
docs: migration guide
dannyhw Jan 20, 2024
83ae5a1
fix: update addons readme
dannyhw Jan 20, 2024
c71a8ff
make storage configurable
patlux Nov 21, 2023
625f4d7
Merge remote-tracking branch 'origin/next' into feat/v7
dannyhw Jan 20, 2024
ff4038f
fix: warning when storage is not set
dannyhw Jan 20, 2024
5cec081
docs: more stuff
dannyhw Jan 20, 2024
988171a
empty test
dannyhw Jan 20, 2024
8b2e967
v7.6.10-alpha.1
dannyhw Jan 20, 2024
182c6e6
feat: first steps for v8
dannyhw Jan 21, 2024
90c9a2f
fix: story loading
dannyhw Jan 22, 2024
871c653
merge main
dannyhw Jan 29, 2024
2393b73
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Jan 29, 2024
71c280a
regen
dannyhw Jan 29, 2024
c9e13d9
wip
dannyhw Jan 29, 2024
af939b2
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Jan 30, 2024
612cdd8
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Jan 31, 2024
14ffe40
v8.0.0-alpha.0
dannyhw Jan 31, 2024
c214e9d
fix: example app
dannyhw Feb 1, 2024
94e5983
feat: update to v8 beta
dannyhw Feb 2, 2024
0441ccd
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Mar 3, 2024
19a0751
feat: update
dannyhw Mar 3, 2024
1865884
v8.0.0-alpha.1
dannyhw Mar 3, 2024
0d5e5b6
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Mar 7, 2024
6f18953
v8.0.0-alpha.2
dannyhw Mar 7, 2024
582329c
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Mar 9, 2024
f4a1516
fix: update to latest rc
dannyhw Mar 9, 2024
1695965
Feat/v8 UI (#564)
dannyhw Apr 4, 2024
bf76948
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Apr 4, 2024
9e1b8ee
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw May 27, 2024
304f40a
fix: update versions and convert color picker to ts
dannyhw May 27, 2024
d426c91
fix: tests
dannyhw May 27, 2024
62f5da8
keep old color
dannyhw May 27, 2024
4f37e01
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Jun 16, 2024
daef6bf
fix: bottom sheet scrolling at all snap points
dannyhw Jun 16, 2024
1d62ad1
fix: get working with v8.2 by introducing withStorybook metro helper
dannyhw Jul 20, 2024
eeb53d9
lock
dannyhw Jul 30, 2024
a349ec9
built in websocket server for withStorybook
dannyhw Aug 18, 2024
b1af9c7
fix: CalledPreviewMethodBeforeInitializationError (8.2) (#587)
stevoland Sep 14, 2024
21caee7
Merge remote-tracking branch 'origin/next' into feat/v8
dannyhw Sep 14, 2024
b41a297
feat: initial styling for controls
dannyhw Sep 14, 2024
ad4da8d
fix: padding
dannyhw Sep 14, 2024
209d707
feat: upgrade storybook and fix key
dannyhw Sep 14, 2024
e39a13d
focus for object input
dannyhw Sep 14, 2024
6bc0d01
use web theme values
dannyhw Sep 14, 2024
1c01c27
fix: dark mode
dannyhw Sep 14, 2024
79ac223
fix: no ui error
dannyhw Sep 14, 2024
b262923
v8.3.0-alpha.0
dannyhw Sep 15, 2024
3e43b40
fix: polyfill url
dannyhw Sep 15, 2024
44d795b
v8.3.0-alpha.1
dannyhw Sep 15, 2024
e7baacc
fix: warning about doc-tools import
dannyhw Sep 15, 2024
8021373
fix: reuse more stuff
dannyhw Sep 15, 2024
0fc76e0
fix: basic wide/web ui
dannyhw Sep 15, 2024
d1f38ea
fix: remove hacky workaround and use fixed version 8.3.1
dannyhw Sep 16, 2024
afcce3f
v8.3.0-alpha.2
dannyhw Sep 16, 2024
738ab83
fix: make sure not to run polyfill if on web
dannyhw Sep 17, 2024
52276d9
fix: jest
dannyhw Sep 17, 2024
bd184b2
v8.3.0-alpha.3
dannyhw Sep 17, 2024
9edf01c
fix: more accurate polyfill
dannyhw Sep 17, 2024
df88eb7
fix: websockets on web not working
dannyhw Sep 17, 2024
bddc796
v8.3.1-alpha.0
dannyhw Sep 17, 2024
16dcd8c
feat: minimize side and bottom bars
dannyhw Sep 18, 2024
c1104b8
ip
dannyhw Sep 18, 2024
2ec7f40
v8.3.1-alpha.1
dannyhw Sep 18, 2024
7fb6ae8
Update README.md
dannyhw Sep 18, 2024
fbd9783
fix: text color
dannyhw Sep 18, 2024
2db7054
v8.3.1-alpha.2
dannyhw Sep 18, 2024
cfdf9be
Use theme to populate the markdown styles (#602)
trajano Sep 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ aliases:
- &defaults
working_directory: /tmp/storybook
docker:
- image: cimg/node:16.20.0
- image: cimg/node:20.9.0

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
rules: {
'react-native/no-inline-styles': 'off',
'react/react-in-jsx-scope': 'off',
curly: ['error', 'multi-line'],
},
};
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ htpasswd
storybook-out
/addons/docs/common/config-*
built-storybooks
examples/expo-example/.storybook/storybook.requires.js
.yarn/*
!.yarn/patches
!.yarn/plugins
Expand Down
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
"typescript.tsdk": "node_modules/typescript/lib"
}
60 changes: 60 additions & 0 deletions .yarn/patches/jotai-npm-2.6.2-d482bf2d42.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/esm/vanilla.mjs b/esm/vanilla.mjs
index 59d78cf8e0490d98e104e4ba2ba58afb3bf97560..5f60e0f80f67546966f76333346790802b294e29 100644
--- a/esm/vanilla.mjs
+++ b/esm/vanilla.mjs
@@ -578,11 +578,6 @@ if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
}
const getDefaultStore = () => {
if (!defaultStore) {
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && globalThis.__NUMBER_OF_JOTAI_INSTANCES__ !== 1) {
- console.warn(
- "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
- );
- }
defaultStore = createStore();
}
return defaultStore;
diff --git a/system/vanilla.development.js b/system/vanilla.development.js
index 5045cde2971e1372ab48b82bbd161886d13eeccd..f7f3741f9cfdd9b200d0ea304a61f0d11847d013 100644
--- a/system/vanilla.development.js
+++ b/system/vanilla.development.js
@@ -580,11 +580,6 @@ System.register([], (function (exports) {
}
const getDefaultStore = exports("getDefaultStore", () => {
if (!defaultStore) {
- if (globalThis.__NUMBER_OF_JOTAI_INSTANCES__ !== 1) {
- console.warn(
- "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
- );
- }
defaultStore = createStore();
}
return defaultStore;
diff --git a/umd/vanilla.development.js b/umd/vanilla.development.js
index d9587e70701c3a4717c6be4951a65e40d60b90b1..f9fcbefe4d53a5910edb320643f8bfb7139081b5 100644
--- a/umd/vanilla.development.js
+++ b/umd/vanilla.development.js
@@ -671,9 +671,6 @@
}
var getDefaultStore = function getDefaultStore() {
if (!defaultStore) {
- if (globalThis.__NUMBER_OF_JOTAI_INSTANCES__ !== 1) {
- console.warn('Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044');
- }
defaultStore = createStore();
}
return defaultStore;
diff --git a/vanilla.js b/vanilla.js
index 946fa9155cc4120bffd0022c9e50f77011dfab02..234c958df45eaa5bf5240be5d707f6d48261ab85 100644
--- a/vanilla.js
+++ b/vanilla.js
@@ -672,9 +672,6 @@ if (process.env.NODE_ENV !== 'production') {
}
var getDefaultStore = function getDefaultStore() {
if (!defaultStore) {
- if (process.env.NODE_ENV !== 'production' && globalThis.__NUMBER_OF_JOTAI_INSTANCES__ !== 1) {
- console.warn('Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044');
- }
defaultStore = createStore();
}
return defaultStore;
129 changes: 66 additions & 63 deletions MANUAL_SETUP.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Setup for v6 React Native Storybook
# Setup for v7 React Native Storybook

Before getting into the guide consider using a template for a simpler setup process.

Expand All @@ -16,11 +16,6 @@ For react native cli you can use this [template](https://github.com/dannyhw/reac
npx react-native init MyApp --template react-native-template-storybook
```

You can also choose to use a bash script if you prefer, however it is more involved.

- [expo setup script](https://gist.github.com/dannyhw/92b3ff0d6ccaead9df2820a507154b87)
- [rn-cli setup script](https://gist.github.com/dannyhw/9b84973dcc6ff4fa2e86e32d571d294e)

# Manual setup

You may wish to setup everything yourself, you can use the following guide to do so.
Expand All @@ -30,18 +25,18 @@ You may wish to setup everything yourself, you can use the following guide to do
**Expo**

```sh
expo install @storybook/react-native @storybook/[email protected] @react-native-async-storage/async-storage react-dom react-native-safe-area-context
expo install @storybook/react-native @react-native-async-storage/async-storage react-dom react-native-safe-area-context
```

**React native CLI**

```sh
yarn add -D @storybook/react-native @storybook/[email protected] @react-native-async-storage/async-storage react-native-safe-area-context react-dom
yarn add -D @storybook/react-native @react-native-async-storage/async-storage react-native-safe-area-context react-dom
```

**IOS**

If running on an IOS device make sure to run pod install first
If running on an IOS device with rn cli make sure to run pod install first

```sh
cd ios; pod install; cd ..;
Expand All @@ -51,118 +46,132 @@ cd ios; pod install; cd ..;

## .storybook

Create a folder called `.storybook` with files: `main.js`, `preview.js`, `Storybook.tsx`
Create a folder called `.storybook` with files: `main.js`, `preview.js`, `index.tsx`

You can use this one-liner to quickly create those files:

```console
mkdir .storybook && cd .storybook && touch main.js preview.js Storybook.tsx
mkdir .storybook && touch .storybook/main.js .storybook/preview.js .storybook/index.tsx
```

### main.js
### .storybook/main.js

```js
module.exports = {
stories: [
'../components/**/*.stories.?(ts|tsx|js|jsx)'
],
stories: ['../components/**/*.stories.?(ts|tsx|js|jsx)'],
addons: [],
};
```

### preview.js
### .storybook/preview.js

```js
export const decorators = [];
export const parameters = {};
const preview = {
parameters: {},
decorators: [],
};

export default preview;
```

### Storybook.tsx
## package.json

Add the following to the scripts in your package.json.

```jsx
import { getStorybookUI } from '@storybook/react-native';
```json
{
"scripts": {
"storybook-generate": "sb-rn-get-stories"
}
}
```

### generate storybook.requires.js

import './storybook.requires';
run `yarn storybook-generate`

### .storybook/index.tsx

```jsx
import { view } from './storybook.requires';
import AsyncStorage from '@react-native-async-storage/async-storage';

const StorybookUIRoot = getStorybookUI({});
const StorybookUIRoot = view.getStorybookUI({
storage: {
getItem: AsyncStorage.getItem,
setItem: AsyncStorage.setItem,
},
});

export default StorybookUIRoot;
```

## metro.config.js

Update your metro config to include sbmodern in the resolverMainFields.
Update your metro config to enable `transformer.unstable_allowRequireContext`

**Expo**

First create metro config file if you don't have it yet.
First create metro config file if you don't have it yet.

```sh
npx expo customize metro.config.js
```

Then add sbmodern to the start of the `resolver.resolverMainFields` list.
Then set `transformer.unstable_allowRequireContext` to true

```js
const { getDefaultConfig } = require('expo/metro-config');

const { generate } = require('@storybook/react-native/scripts/generate');

generate({
configPath: path.resolve(__dirname, './.storybook'),
});

const defaultConfig = getDefaultConfig(__dirname);

defaultConfig.resolver.resolverMainFields.unshift('sbmodern');
defaultConfig.transformer.unstable_allowRequireContext = true;

module.exports = defaultConfig;
```

**React native**

```js
const { generate } = require('@storybook/react-native/scripts/generate');

generate({
configPath: path.resolve(__dirname, './.storybook'),
});

module.exports = {
/* existing config */
resolver: {
resolverMainFields: ['sbmodern', 'react-native', 'browser', 'main'],
transformer: {
unstable_allowRequireContext: true,
},
};
```

## package.json

Add the following to the scripts in your package.json, we use the name `prestart` to cause the script to run before every `yarn start`.

```json
{
"scripts": {
"prestart": "sb-rn-get-stories",
"storybook-watcher": "sb-rn-watcher",
}
}
```


# Adding stories

To render storybook update your App.tsx file to export the UI component.

```js
import StorybookUIRoot from './.storybook/Storybook';
export { StorybookUIRoot as default };
```

**Add a stories file**

In the main.js we created the path was set as `../components/**/*.stories.?(ts|tsx|js|jsx)` which matches any .stories file inside the components folder.

Create a file called `Button.stories.tsx` in the components folder.

```jsx
import {Button} from 'react-native';
import { Button } from 'react-native';

export default {
title: 'React Native Button',
component: Button,
};

export const Basic = {
args: {
title: 'Hello world',
},
};

export const Basic = args => <Button {...args} />;
```

This is a simple example you can do more by adding addons and exploring more features of storybook.
Expand All @@ -172,17 +181,11 @@ This is a simple example you can do more by adding addons and exploring more fea
The only thing left to do is return Storybook's UI in your app entry point (such as `App.js`) like this:

```jsx
export {default} from './.storybook'
export { default } from './.storybook';
```

If you want to be able to swap easily between storybook and your app, have a look at this [blog post](https://dev.to/dannyhw/how-to-swap-between-react-native-storybook-and-your-app-p3o)

# Run storybook

To run storybook first generate the stories list:

```sh
yarn sb-rn-get-stories
```

Then you can run `yarn ios` or `yarn android` to run the app.
Then you can run `yarn ios` or `yarn android` to run the app like normal.
Loading