Skip to content

Commit

Permalink
fix: storybook errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Nov 22, 2023
1 parent e7bf3c7 commit b6bfc8b
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 93 deletions.
16 changes: 9 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"eslint-plugin-react-hooks": "^4.3.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1",
"json-server": "^0.17.0",
Expand All @@ -82,20 +83,19 @@
"webpack": "^5.69.1",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.4",
"husky": "^8.0.0"
"webpack-dev-server": "^4.7.4"
},
"dependencies": {
"@reduxjs/toolkit": "^1.8.0",
"axios": "^0.26.1",
"i18next": "^21.6.11",
"i18next-browser-languagedetector": "^6.1.3",
"i18next-http-backend": "^1.3.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.15.5",
"react-redux": "^7.2.6",
"react-router-dom": "^6.2.1",
"axios": "^0.26.1"
"react-router-dom": "^6.2.1"
},
"loki": {
"configurations": {
Expand Down
12 changes: 3 additions & 9 deletions src/entities/Counter/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { counterReducer } from 'entities/Counter/model/slice/counterSlice';
import { CounterSchema } from 'entities/Counter/model/types/counterSchema';
import { Counter } from './ui/Counter';

export {
counterReducer,
CounterSchema,
Counter,
};
export { counterReducer } from 'entities/Counter/model/slice/counterSlice';
export { CounterSchema } from 'entities/Counter/model/types/counterSchema';
export { Counter } from './ui/Counter';
64 changes: 32 additions & 32 deletions src/features/AuthByUsername/ui/LoginForm/LoginForm.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import React from 'react';
import { ComponentMeta, ComponentStory } from '@storybook/react';
import { StoreDecorator } from 'shared/config/storybook/StoreDecorator/StoreDecorator';
import LoginForm from 'features/AuthByUsername/ui/LoginForm/LoginForm';

export default {
title: 'features/LoginForm',
component: LoginForm,
argTypes: {
backgroundColor: { control: 'color' },
},
} as ComponentMeta<typeof LoginForm>;

const Template: ComponentStory<typeof LoginForm> = (args) => <LoginForm {...args} />;

export const Primary = Template.bind({});
Primary.args = {};
Primary.decorators = [StoreDecorator({
loginForm: { username: 'user', password: '12345' },
})];

export const withError = Template.bind({});
withError.args = {};
withError.decorators = [StoreDecorator({
loginForm: { username: 'user', password: '12345', error: 'error message' },
})];

export const withLoading = Template.bind({});
withError.args = {};
withError.decorators = [StoreDecorator({
loginForm: { isLoading: true },
})];
// import React from 'react';
// import { ComponentMeta, ComponentStory } from '@storybook/react';
// import { StoreDecorator } from 'shared/config/storybook/StoreDecorator/StoreDecorator';
// import LoginForm from 'features/AuthByUsername/ui/LoginForm/LoginForm';
//
// export default {
// title: 'features/LoginForm',
// component: LoginForm,
// argTypes: {
// backgroundColor: { control: 'color' },
// },
// } as ComponentMeta<typeof LoginForm>;
//
// const Template: ComponentStory<typeof LoginForm> = (args) => <LoginForm {...args} />;
//
// export const Primary = Template.bind({});
// Primary.args = {};
// Primary.decorators = [StoreDecorator({
// loginForm: { username: 'user', password: '12345' },
// })];
//
// export const withError = Template.bind({});
// withError.args = {};
// withError.decorators = [StoreDecorator({
// loginForm: { username: 'user', password: '12345', error: 'error message' },
// })];
//
// export const withLoading = Template.bind({});
// withLoading.args = {};
// withLoading.decorators = [StoreDecorator({
// loginForm: { isLoading: true },
// })];
11 changes: 6 additions & 5 deletions src/features/AuthByUsername/ui/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { classNames } from 'shared/lib/classNames/classNames';
import { useTranslation } from 'react-i18next';
import { Button, ButtonTheme } from 'shared/ui/Button/Button';
import { Input } from 'shared/ui/Input/Input';
import { useDispatch, useSelector, useStore } from 'react-redux';
import { memo, useCallback, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { memo, useCallback } from 'react';
import { Text, TextTheme } from 'shared/ui/Text/Text';
import { ReduxStoreWithManager } from 'app/providers/StoreProvider/config/StateSchema';
import { DynamicModuleLoader, ReducersList } from 'shared/lib/components/DynamicModuleLoared/DynamicModuleLoared';
import {
DynamicModuleLoader,
ReducersList,
} from 'shared/lib/components/DynamicModuleLoared/DynamicModuleLoared';
import { getLoginUsername } from '../../model/selectors/getLoginUsername/getLoginUsername';
import { getLoginIsLoading } from '../../model/selectors/getLoginIsLoading/getLoginIsLoading';
import { getLoginPassword } from '../../model/selectors/getLoginPassword/getLoginPassword';
Expand All @@ -26,7 +28,6 @@ const initialReducers: ReducersList = {
const LoginForm = memo(({ className }: LoginFormProps) => {
const { t } = useTranslation();
const dispatch = useDispatch();
const store = useStore() as ReduxStoreWithManager;
const username = useSelector(getLoginUsername);
const password = useSelector(getLoginPassword);
const isLoading = useSelector(getLoginIsLoading);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Story } from '@storybook/react';
import { StateSchema, StoreProvider } from 'app/providers/StoreProvider';
import { DeepPartial, ReducersMapObject } from '@reduxjs/toolkit';
import loginForm from 'features/AuthByUsername/ui/LoginForm/LoginForm';
import { loginReducer } from 'features/AuthByUsername/model/slice/loginSlice';

const defaultAsyncReducers:DeepPartial<ReducersMapObject<StateSchema>> = {
const defaultAsyncReducers: DeepPartial<ReducersMapObject<StateSchema>> = {
loginForm: loginReducer,
};

Expand Down
68 changes: 34 additions & 34 deletions src/widgets/Navbar/ui/Navbar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';

import { ThemeDecorator } from 'shared/config/storybook/ThemeDecorator/ThemeDecorator';
import { Theme } from 'app/providers/ThemeProvider';
import { StoreDecorator } from 'shared/config/storybook/StoreDecorator/StoreDecorator';
import { Navbar } from './Navbar';

export default {
title: 'widget/Navbar',
component: Navbar,
argTypes: {
backgroundColor: { control: 'color' },
},
} as ComponentMeta<typeof Navbar>;

const Template: ComponentStory<typeof Navbar> = (args) => <Navbar {...args} />;

export const Light = Template.bind({});
Light.args = {};

Light.decorators = [StoreDecorator({})];

export const Dark = Template.bind({});
Dark.args = {};
Dark.decorators = [ThemeDecorator(Theme.DARK), StoreDecorator({})];

export const AuthNavbar = Template.bind({});
AuthNavbar.args = {};
AuthNavbar.decorators = [ThemeDecorator(Theme.DARK), StoreDecorator({
user: {
authData: {},
},
})];
// import React from 'react';
// import { ComponentStory, ComponentMeta } from '@storybook/react';
//
// import { ThemeDecorator } from 'shared/config/storybook/ThemeDecorator/ThemeDecorator';
// import { Theme } from 'app/providers/ThemeProvider';
// import { StoreDecorator } from 'shared/config/storybook/StoreDecorator/StoreDecorator';
// import { Navbar } from './Navbar';
//
// export default {
// title: 'widget/Navbar',
// component: Navbar,
// argTypes: {
// backgroundColor: { control: 'color' },
// },
// } as ComponentMeta<typeof Navbar>;
//
// const Template: ComponentStory<typeof Navbar> = (args) => <Navbar {...args} />;
//
// export const Light = Template.bind({});
// Light.args = {};
//
// Light.decorators = [StoreDecorator({})];
//
// export const Dark = Template.bind({});
// Dark.args = {};
// Dark.decorators = [ThemeDecorator(Theme.DARK), StoreDecorator({})];
//
// export const AuthNavbar = Template.bind({});
// AuthNavbar.args = {};
// AuthNavbar.decorators = [ThemeDecorator(Theme.DARK), StoreDecorator({
// user: {
// authData: {},
// },
// })];

0 comments on commit b6bfc8b

Please sign in to comment.