Skip to content

Commit

Permalink
feat: add modals stories
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Nov 7, 2023
1 parent 37bb475 commit fb2d178
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ module.exports = {
globals: {
__IS_DEV__: true,
},
overrides: [
{
files: ['**/src/**/*.{test,stories}.{ts,tsx}'],
rules: {
'i18next/no-literal-string': 'off',
'max-len': 'off',
},
},
],

};
Binary file modified .loki/reference/chrome_iphone7_pages_AboutPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_pages_MainPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_pages_NotFoundPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_shared_ThemeSwitcher_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_widget_ErrorPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_widget_Navbar_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_widget_Navbar_Light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_widget_Sidebar_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_pages_AboutPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_pages_MainPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_pages_NotFoundPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_shared_ThemeSwitcher_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_widget_ErrorPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_widget_Navbar_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_widget_Navbar_Light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_laptop_widget_Sidebar_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions src/app/providers/ThemeProvider/ui/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import { LOCAL_STORAGE_THEME_KEY, Theme, ThemeContext } from '../lib/ThemeContex

const defaultTheme = localStorage.getItem(LOCAL_STORAGE_THEME_KEY) as Theme || Theme.LIGHT;

const ThemeProvider: FC = ({ children }) => {
const [theme, setTheme] = useState<Theme>(defaultTheme);
interface ThemeProviderProps {
initialTheme?: Theme
}

const ThemeProvider: FC<ThemeProviderProps> = (props) => {
const { initialTheme, children } = props;

const [theme, setTheme] = useState<Theme>(initialTheme || defaultTheme);

const defaultProps = useMemo(() => ({
theme,
Expand Down
3 changes: 2 additions & 1 deletion src/shared/config/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ i18n
.use(initReactI18next)
.init({
fallbackLng: 'en',
debug: __IS_DEV__,
// debug: __IS_DEV__,
debug: false,

interpolation: {
escapeValue: false, // not needed for react as it escapes by default
Expand Down
10 changes: 6 additions & 4 deletions src/shared/config/storybook/ThemeDecorator/ThemeDecorator.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Story } from '@storybook/react';
import { Theme } from 'app/providers/ThemeProvider';
import { Theme, ThemeProvider } from 'app/providers/ThemeProvider';

export const ThemeDecorator = (theme: Theme) => (StoryComponent: Story) => (
<div className={`app ${theme}`}>
<StoryComponent />
</div>
<ThemeProvider initialTheme={theme}>
<div className={`app ${theme}`}>
<StoryComponent />
</div>
</ThemeProvider>
);
35 changes: 35 additions & 0 deletions src/shared/ui/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { ComponentMeta, ComponentStory } from '@storybook/react';
import { Modal } from 'shared/ui/Modal/Modal';
import { ThemeDecorator } from 'shared/config/storybook/ThemeDecorator/ThemeDecorator';
import { Theme } from 'app/providers/ThemeProvider';

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

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

export const Primary = Template.bind({});
Primary.args = {
children: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. A ab\n'
+ ' accusantium aliquid architecto autem consequuntur debitis et facere,\n'
+ ' laudantium modi nostrum nulla obcaecati odit quas quod sapiente,\n'
+ ' veritatis? Illo, veritatis.',
isOpen: true,
};

export const Dark = Template.bind({});
Dark.args = {
children: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. A ab\n'
+ ' accusantium aliquid architecto autem consequuntur debitis et facere,\n'
+ ' laudantium modi nostrum nulla obcaecati odit quas quod sapiente,\n'
+ ' veritatis? Illo, veritatis.',
isOpen: true,
};

Dark.decorators = [ThemeDecorator(Theme.DARK)];

0 comments on commit fb2d178

Please sign in to comment.