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

Fix some storybook errors #25520

Merged
merged 6 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@ import ComposeProviders from '../src/components/ComposeProviders';
import HTMLEngineProvider from '../src/components/HTMLEngineProvider';
import OnyxProvider from '../src/components/OnyxProvider';
import {LocaleContextProvider} from '../src/components/withLocalize';
import {KeyboardStateProvider} from '../src/components/withKeyboardState';
import {EnvironmentProvider} from '../src/components/withEnvironment';
import {WindowDimensionsProvider} from '../src/components/withWindowDimensions';
import ONYXKEYS from '../src/ONYXKEYS';

Onyx.init({
keys: ONYXKEYS,
initialKeyStates: {
[ONYXKEYS.NETWORK]: {isOffline: false},
},
});

const decorators = [
(Story) => (
<ComposeProviders components={[OnyxProvider, LocaleContextProvider, HTMLEngineProvider, SafeAreaProvider, PortalProvider]}>
<ComposeProviders
components={[OnyxProvider, LocaleContextProvider, HTMLEngineProvider, SafeAreaProvider, PortalProvider, EnvironmentProvider, KeyboardStateProvider, WindowDimensionsProvider]}
>
<Story />
</ComposeProviders>
),
Expand Down
2 changes: 1 addition & 1 deletion src/components/MagicCodeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const propTypes = {
};

const defaultProps = {
value: undefined,
value: '',
name: '',
autoFocus: true,
errorText: '',
Expand Down
1 change: 1 addition & 0 deletions src/stories/Checkbox.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Default = Template.bind({});
Default.args = {
onPress: () => {},
isChecked: true,
accessibilityLabel: '',
};

export {Default};
7 changes: 5 additions & 2 deletions src/stories/Composer.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import styles from '../styles/styles';
import themeColors from '../styles/themes/default';
import * as StyleUtils from '../styles/StyleUtils';
import CONST from '../CONST';
import withNavigationFallback from '../components/withNavigationFallback';

const ComposerWithNavigation = withNavigationFallback(Composer);

/**
* We use the Component Story Format for writing stories. Follow the docs here:
Expand All @@ -16,7 +19,7 @@ import CONST from '../CONST';
*/
const story = {
title: 'Components/Composer',
component: Composer,
component: ComposerWithNavigation,
};

const parser = new ExpensiMark();
Expand All @@ -29,7 +32,7 @@ function Default(args) {
return (
<View>
<View style={[styles.border, styles.p4]}>
<Composer
<ComposerWithNavigation
// eslint-disable-next-line react/jsx-props-no-spreading
{...args}
multiline
Expand Down
13 changes: 10 additions & 3 deletions src/stories/MagicCodeInput.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useState} from 'react';
import MagicCodeInput from '../components/MagicCodeInput';

/**
Expand All @@ -12,8 +12,15 @@ const story = {
};

function Template(args) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <MagicCodeInput {...args} />;
const [value, setValue] = useState('');
return (
<MagicCodeInput
value={value}
onChangeText={setValue}
// eslint-disable-next-line react/jsx-props-no-spreading
{...args}
/>
);
}

// Arguments can be passed to the component by binding
Expand Down
Loading