Skip to content

Commit

Permalink
Format configuration files and add Storybook support (#35)
Browse files Browse the repository at this point in the history
This pull request includes various commits that format configuration
files for consistency and readability. It also adds support for
Storybook configuration in the client app, including the initialization
of Storybook configuration files and the addition of necessary
dependencies. These changes enhance the development experience with
stories and improve UI component testing and documentation.
  • Loading branch information
codemile authored Aug 23, 2024
1 parent 1cd2af6 commit e3744e8
Show file tree
Hide file tree
Showing 70 changed files with 5,669 additions and 773 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ apps/server/src/client

# Ignored for testing
.aigraphr

storybook-static
14 changes: 13 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,17 @@
"trailingComma": "none",
"arrowParens": "always",
"jsxSingleQuote": false,
"jsxBracketSameLine": false
"jsxBracketSameLine": false,
"overrides": [
{
"files": [
"*.json",
"*.yaml",
"*.yml"
],
"options": {
"tabWidth": 2
}
}
]
}
12 changes: 6 additions & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"ms-playwright.playwright",
"firsttris.vscode-jest-runner"
]
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"ms-playwright.playwright",
"firsttris.vscode-jest-runner"
]
}
40 changes: 20 additions & 20 deletions apps/client-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"extends": ["plugin:playwright/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["src/**/*.{ts,js,tsx,jsx}"],
"rules": {}
}
]
"extends": ["plugin:playwright/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["src/**/*.{ts,js,tsx,jsx}"],
"rules": {}
}
]
}
14 changes: 7 additions & 7 deletions apps/client-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "client-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/client-e2e/src",
"implicitDependencies": ["client"],
"// targets": "to see all targets run: nx show project client-e2e --web",
"targets": {}
"name": "client-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/client-e2e/src",
"implicitDependencies": ["client"],
"// targets": "to see all targets run: nx show project client-e2e --web",
"targets": {}
}
34 changes: 17 additions & 17 deletions apps/client-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"sourceMap": false
},
"include": [
"**/*.ts",
"**/*.js",
"playwright.config.ts",
"src/**/*.spec.ts",
"src/**/*.spec.js",
"src/**/*.test.ts",
"src/**/*.test.js",
"src/**/*.d.ts"
]
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"sourceMap": false
},
"include": [
"**/*.ts",
"**/*.js",
"playwright.config.ts",
"src/**/*.spec.ts",
"src/**/*.spec.js",
"src/**/*.test.ts",
"src/**/*.test.js",
"src/**/*.d.ts"
]
}
61 changes: 29 additions & 32 deletions apps/client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
{
"extends": [
"plugin:@nx/react-typescript",
"next",
"next/core-web-vitals",
"../../.eslintrc.json"
],
"ignorePatterns": ["!**/*", ".next/**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@next/next/no-html-link-for-pages": [
"error",
"apps/client/pages"
]
}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
}
}
]
"extends": [
"plugin:@nx/react-typescript",
"next",
"next/core-web-vitals",
"../../.eslintrc.json"
],
"ignorePatterns": ["!**/*", ".next/**/*", "storybook-static"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@next/next/no-html-link-for-pages": ["error", "apps/client/pages"]
}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
}
}
]
}
13 changes: 13 additions & 0 deletions apps/client/.storybook/decorators/AppDecorator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {ReactRenderer} from '@storybook/react';
import {DecoratorFunction} from '@storybook/types';
import {AppProvider} from '../../src/components/app/AppProvider';

export const AppDecorator =
// eslint-disable-next-line react/display-name
(): DecoratorFunction<ReactRenderer> => (Story, context) => {
return (
<AppProvider>
<Story />
</AppProvider>
);
};
16 changes: 16 additions & 0 deletions apps/client/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type {StorybookConfig} from '@storybook/nextjs';

const config: StorybookConfig = {
stories: ['../**/*.stories.tsx'],
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'],
framework: {
name: '@storybook/nextjs',
options: {}
}
};

export default config;

// To customize your webpack configuration you can use the webpackFinal field.
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
// and https://nx.dev/recipes/storybook/custom-builder-configs
6 changes: 6 additions & 0 deletions apps/client/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {ReactRenderer} from '@storybook/react';
import {DecoratorFunction} from '@storybook/types';
import {AppDecorator} from './decorators/AppDecorator';
import './../app/global.css';

export const decorators: DecoratorFunction<ReactRenderer>[] = [AppDecorator()];
2 changes: 1 addition & 1 deletion apps/client/app/global.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../node_modules/@mantine/core/styles.css';
@import '@mantine/core/styles.css';

@tailwind base;
@tailwind components;
Expand Down
8 changes: 3 additions & 5 deletions apps/client/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './global.css';
import {ColorSchemeScript, MantineProvider} from '@mantine/core';
import {ColorSchemeScript} from '@mantine/core';
import {FC, PropsWithChildren} from 'react';
import {mantineTheme} from '../src/mantine-theme';
import {AppProvider} from '../src/components/app/AppProvider';

export const metadata = {
title: 'Welcome to website',
Expand All @@ -20,9 +20,7 @@ const Layout: FC<PropsWithChildren> = ({children}) => {
<ColorSchemeScript />
</head>
<body>
<MantineProvider theme={mantineTheme}>
{children}
</MantineProvider>
<AppProvider>{children}</AppProvider>
</body>
</html>
);
Expand Down
14 changes: 14 additions & 0 deletions apps/client/app/page.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Meta, StoryObj} from '@storybook/react';
import Index from './page';

const meta = {
title: 'Pages/Home',
component: Index,
args: {}
} satisfies Meta<typeof Index>;

export default meta;

export const Home = {
render: (props) => <Index {...props} />
} satisfies StoryObj<typeof meta>;
10 changes: 5 additions & 5 deletions apps/client/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {FC} from 'react';
import {Faq} from '../src/components/Faq';
import {Features} from '../src/components/Features';
import {Footer} from '../src/components/Footer';
import {Header} from '../src/components/Header';
import {Hero} from '../src/components/Hero';
import {Faq} from '../src/components/home/Faq';
import {Features} from '../src/components/home/Features';
import {Footer} from '../src/components/home/Footer';
import {Header} from '../src/components/home/Header';
import {Hero} from '../src/components/home/Hero';

const Index: FC = () => {
return (
Expand Down
4 changes: 2 additions & 2 deletions apps/client/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export default {
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/next/babel'] }]
'^.+\\.[tj]sx?$': ['babel-jest', {presets: ['@nx/next/babel']}]
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/client',
setupFilesAfterEnv: ['./apps/client/jest.setup.ts']
setupFilesAfterEnv: ['./jest.setup.ts']
};
6 changes: 6 additions & 0 deletions apps/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "client",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
14 changes: 7 additions & 7 deletions apps/client/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "client",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/client",
"projectType": "application",
"tags": [],
"// targets": "to see all targets run: nx show project website --web",
"targets": {}
"name": "client",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/client",
"projectType": "application",
"tags": [],
"// targets": "to see all targets run: nx show project website --web",
"targets": {}
}
2 changes: 1 addition & 1 deletion apps/client/specs/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {MantineProvider} from '@mantine/core';
import {render as testingLibraryRender} from '@testing-library/react';
import React from 'react';
import Page from '../app/page';
import {mantineTheme} from '../src/mantine-theme';
import {mantineTheme} from '../src/configs/mantine-theme';

function render(ui: React.ReactNode) {
return testingLibraryRender(<>{ui}</>, {
Expand Down
9 changes: 9 additions & 0 deletions apps/client/src/components/app/AppProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client';

import {MantineProvider} from '@mantine/core';
import {FC, PropsWithChildren} from 'react';
import {mantineTheme} from '../../configs/mantine-theme';

export const AppProvider: FC<PropsWithChildren> = ({children}) => {
return <MantineProvider theme={mantineTheme}>{children}</MantineProvider>;
};
File renamed without changes.
14 changes: 14 additions & 0 deletions apps/client/src/components/home/Faq.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Meta, StoryObj} from '@storybook/react';
import {Faq as Component} from './Faq';

const meta = {
title: 'Components/Home/Faq',
component: Component,
args: {}
} satisfies Meta<typeof Component>;

export default meta;

export const Faq = {
render: (props) => <Component {...props} />
} satisfies StoryObj<typeof meta>;
File renamed without changes.
14 changes: 14 additions & 0 deletions apps/client/src/components/home/Features.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Meta, StoryObj} from '@storybook/react';
import {Features as Component} from './Features';

const meta = {
title: 'Components/Home/Features',
component: Component,
args: {}
} satisfies Meta<typeof Component>;

export default meta;

export const Features = {
render: (props) => <Component {...props} />
} satisfies StoryObj<typeof meta>;
File renamed without changes.
14 changes: 14 additions & 0 deletions apps/client/src/components/home/Footer.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Meta, StoryObj} from '@storybook/react';
import {Footer as Component} from './Footer';

const meta = {
title: 'Components/Home/Footer',
component: Component,
args: {}
} satisfies Meta<typeof Component>;

export default meta;

export const Footer = {
render: (props) => <Component {...props} />
} satisfies StoryObj<typeof meta>;
File renamed without changes.
Loading

0 comments on commit e3744e8

Please sign in to comment.