From 4f6ff6fc739ea3323c92faa38293463eb6c32f4e Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 6 Jan 2026 18:03:21 +0200 Subject: [PATCH] lazy load storybook (#9612) --- src/Navigation.tsx | 4 +- src/view/screens/Storybook/Forms.tsx | 37 ++---- src/view/screens/Storybook/Storybook.tsx | 148 +++++++++++++++++++++ src/view/screens/Storybook/index.tsx | 156 +---------------------- 4 files changed, 168 insertions(+), 177 deletions(-) create mode 100644 src/view/screens/Storybook/Storybook.tsx diff --git a/src/Navigation.tsx b/src/Navigation.tsx index bf43eec6f1..fde223bd06 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -68,7 +68,7 @@ import {PostThreadScreen} from '#/view/screens/PostThread' import {PrivacyPolicyScreen} from '#/view/screens/PrivacyPolicy' import {ProfileScreen} from '#/view/screens/Profile' import {ProfileFeedLikedByScreen} from '#/view/screens/ProfileFeedLikedBy' -import {Storybook} from '#/view/screens/Storybook' +import {StorybookScreen} from '#/view/screens/Storybook' import {SupportScreen} from '#/view/screens/Support' import {TermsOfServiceScreen} from '#/view/screens/TermsOfService' import {BottomBar} from '#/view/shell/bottom-bar/BottomBar' @@ -304,7 +304,7 @@ function commonScreens(Stack: typeof Flat, unreadCountLabel?: string) { /> Storybook} + getComponent={() => StorybookScreen} options={{title: title(msg`Storybook`), requireAuth: true}} /> ('US') const [phoneNumber, setPhoneNumber] = React.useState('') const [lang, setLang] = React.useState('en') @@ -55,24 +56,6 @@ export function Forms() { /> - - - setCountryCode(value)} - /> - - - - - - -

InputText

@@ -163,21 +146,23 @@ export function Forms() { label="Input" />
- - {/* commented out so it's not in the web bundle */} - {/*

InternationalPhoneCodeSelect

+

InternationalPhoneCodeSelect

setCountryCode(value)} /> - + - */} + diff --git a/src/view/screens/Storybook/Storybook.tsx b/src/view/screens/Storybook/Storybook.tsx new file mode 100644 index 0000000000..ee7892fa83 --- /dev/null +++ b/src/view/screens/Storybook/Storybook.tsx @@ -0,0 +1,148 @@ +import React from 'react' +import {View} from 'react-native' +import {useNavigation} from '@react-navigation/native' + +import {type NavigationProp} from '#/lib/routes/types' +import {useSetThemePrefs} from '#/state/shell' +import {ListContained} from '#/view/screens/Storybook/ListContained' +import {atoms as a, ThemeProvider} from '#/alf' +import {Button, ButtonText} from '#/components/Button' +import { + useDeviceGeolocationApi, + useRequestDeviceGeolocation, +} from '#/geolocation' +import {Admonitions} from './Admonitions' +import {Breakpoints} from './Breakpoints' +import {Buttons} from './Buttons' +import {Dialogs} from './Dialogs' +import {Forms} from './Forms' +import {Icons} from './Icons' +import {Links} from './Links' +import {Menus} from './Menus' +import {Settings} from './Settings' +import {Shadows} from './Shadows' +import {Spacing} from './Spacing' +import {Theming} from './Theming' +import {Toasts} from './Toasts' +import {Typography} from './Typography' + +export default function Storybook() { + const {setColorMode, setDarkTheme} = useSetThemePrefs() + const [showContainedList, setShowContainedList] = React.useState(false) + const navigation = useNavigation() + const requestDeviceGeolocation = useRequestDeviceGeolocation() + const {setDeviceGeolocation} = useDeviceGeolocationApi() + + return ( + <> + + {!showContainedList ? ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) : ( + <> + + + + )} + + + ) +} diff --git a/src/view/screens/Storybook/index.tsx b/src/view/screens/Storybook/index.tsx index e8c972c667..2bccb75e9c 100644 --- a/src/view/screens/Storybook/index.tsx +++ b/src/view/screens/Storybook/index.tsx @@ -1,33 +1,10 @@ -import React from 'react' -import {View} from 'react-native' -import {useNavigation} from '@react-navigation/native' +import {lazy, Suspense} from 'react' -import {type NavigationProp} from '#/lib/routes/types' -import {useSetThemePrefs} from '#/state/shell' -import {ListContained} from '#/view/screens/Storybook/ListContained' -import {atoms as a, ThemeProvider} from '#/alf' -import {Button, ButtonText} from '#/components/Button' import * as Layout from '#/components/Layout' -import { - useDeviceGeolocationApi, - useRequestDeviceGeolocation, -} from '#/geolocation' -import {Admonitions} from './Admonitions' -import {Breakpoints} from './Breakpoints' -import {Buttons} from './Buttons' -import {Dialogs} from './Dialogs' -import {Forms} from './Forms' -import {Icons} from './Icons' -import {Links} from './Links' -import {Menus} from './Menus' -import {Settings} from './Settings' -import {Shadows} from './Shadows' -import {Spacing} from './Spacing' -import {Theming} from './Theming' -import {Toasts} from './Toasts' -import {Typography} from './Typography' -export function Storybook() { +const Storybook = lazy(() => import('./Storybook')) + +export function StorybookScreen() { return ( @@ -38,129 +15,10 @@ export function Storybook() { - + + + ) } - -function StorybookInner() { - const {setColorMode, setDarkTheme} = useSetThemePrefs() - const [showContainedList, setShowContainedList] = React.useState(false) - const navigation = useNavigation() - const requestDeviceGeolocation = useRequestDeviceGeolocation() - const {setDeviceGeolocation} = useDeviceGeolocationApi() - - return ( - <> - - {!showContainedList ? ( - <> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ) : ( - <> - - - - )} - - - ) -}