Skip to content

Commit

Permalink
feat(): Adding more boilerplate code (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
onemanfighter authored Oct 19, 2024
1 parent 76a2406 commit 67b9eb0
Show file tree
Hide file tree
Showing 82 changed files with 4,078 additions and 322 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"plugins": ["react", "@tanstack/query"],
"rules": {
"react/react-in-jsx-scope": "off",
"@tanstack/query/exhaustive-deps": "error",
"no-unused-vars": "off",
"no-undef": "off",
"no-console": "warn",
Expand All @@ -34,8 +35,7 @@
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-var-requires": "off",
"@tanstack/query/exhaustive-deps": "error"
"@typescript-eslint/no-var-requires": "off"
},
"settings": {
"react": {
Expand Down
1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module.exports = {
presets: ['@babel/preset-env'],
};
w;
9 changes: 9 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ const path = require('path');
module.exports = {
webpack: {
alias: {
'@assets': path.resolve(__dirname, './src/assets'),
'@assets/*': path.resolve(__dirname, './src/assets/*'),
'@components': path.resolve(__dirname, './src/components'),
'@data': path.resolve(__dirname, './src/data'),
'@data/*': path.resolve(__dirname, './src/data/*'),
'@providers': path.resolve(__dirname, './src/providers'),
'@localization': path.resolve(__dirname, './src/localization'),
'@routes': path.resolve(__dirname, './src/routes'),
'@uiStore': path.resolve(__dirname, './src/store/ui'),
'@screens': path.resolve(__dirname, './src/screens'),
'@screens/*': path.resolve(__dirname, './src/screens/*'),
'@appStore': path.resolve(__dirname, './src/store/app'),
'@services': path.resolve(__dirname, './src/services'),
'@testUtils': path.resolve(__dirname, './src/testUtils'),
},
},
};
20 changes: 14 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.js'],
roots: ['./'],
testEnvironment: 'jsdom',
coverageReporters: ['lcov'],
coverageDirectory: './coverage',
collectCoverageFrom: [
'src/**/*.ts',
'src/**/*.tsx',
Expand All @@ -20,20 +22,26 @@ module.exports = {
'!src/**/setupTests.ts',
],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
moduleDirectories: ['node_modules', 'src'],
moduleDirectories: ['node_modules'],
moduleNameMapper: {
// '@assets/(.*)': '<rootDir>/src/assets/$1',
'@assets': '<rootDir>/src/assets',
'@assets/*': '<rootDir>/src/assets/*',
'@components': '<rootDir>/src/components',
'@data': '<rootDir>/src/data',
'@data/*': '<rootDir>/src/data/*',
'@providers': '<rootDir>/src/providers',
// '@router': '<rootDir>/src/router',
'@localization': '<rootDir>/src/localization',
// '@screens': '<rootDir>/src/screens',
'@routes': '<rootDir>/src/routes',
'@screens': '<rootDir>/src/screens',
'@screens/*': '<rootDir>/src/screens/*',
'@uiStore': '<rootDir>/src/store/ui',
'@appStore': '<rootDir>/src/store/app',
'@selectors': '<rootDir>/src/store/selectors',
'@services': '<rootDir>/src/services',
'@testUtils': '<rootDir>/src/testUtils',
},
transform: {
'.+\\.(css|scss|png|jpg|svg)$': 'jest-transform-stub',
'^.+.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
'jest-transform-stub',
'^.+\\.(js|jsx|ts|tsx)$': 'ts-jest',
},
// coverageThreshold: {
Expand Down
14 changes: 14 additions & 0 deletions jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,17 @@ import '@localization/config';

jest.useFakeTimers();
jest.mock('zustand');

// Font source mocks.
jest.mock('@fontsource/bungee-shade', () => ({
__esModule: true,
default: 'bungee-shade',
}));

/**
* Mock helmet module
*/
jest.mock('react-helmet-async', () => ({
Helmet: jest.fn(({ children }) => <div>{children}</div>),
HelmetProvider: () => jest.fn(),
}));
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ commit: ## Uses staged files and some questions to help you write commit message
echo "${RESET}$${BODY}" && \
echo "" && \
eval "$$COMMIT_CMD"; \
fi
fi
65 changes: 31 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-clean-react-app",
"version": "0.1.0",
"description": "Boilerplate code repository for creating react app",
"name": "template-boilerplate",
"description": "Template-boilerplate",
"version": "0.0.1",
"main": "index.tsx",
"scripts": {
"start": "craco start",
Expand All @@ -26,44 +26,33 @@
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@fontsource-variable/karla": "^5.0.22",
"@fontsource/bungee-shade": "^5.0.22",
"@supabase/supabase-js": "^2.45.1",
"@tanstack/react-query": "^5.51.23",
"@tanstack/react-query-devtools": "^5.51.23",
"@types/node": "^16.18.91",
"@types/react": "^18.2.69",
"@types/react-dom": "^18.2.22",
"@uiw/react-markdown-preview": "^5.1.3",
"framer-motion": "^11.3.2",
"i18next": "^23.11.2",
"i18next-browser-languagedetector": "^7.2.1",
"immer": "^10.0.4",
"lodash": "^4.17.21",
"npm": "^10.8.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet-async": "^2.0.5",
"react-i18next": "^14.1.1",
"react-router-dom": "^6.26.1",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4",
"zustand": "^4.5.2"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.8",
"@babel/preset-env": "^7.24.4",
"@babel/preset-react": "^7.24.1",
"@babel/preset-typescript": "^7.24.1",
Expand Down Expand Up @@ -93,17 +82,25 @@
"react-test-renderer": "^18.3.0",
"ts-jest": "^29.1.2"
},
"repository": "git@github.com:onemanfighter/amitraikwar.git",
"author": "Amit Raikwar",
"license": "MIT",
"jest": {
"collectCoverage": true,
"coverageReporters": [
"lcov"
],
"collectCoverageFrom": [
"src/**/*.ts*"
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"coverageDirectory": "./"
}
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"repository": "git@github.com:onemanfighter/hourcoding-tools.git",
"author": "Amit Raikwar",
"license": "MIT"
}
5 changes: 1 addition & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Template-boilerplate" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
</head>
Expand Down
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App boiler plate code",
"short_name": "Template-boilerplate",
"name": "Template-boilerplate",
"icons": [
{
"src": "favicon.ico",
Expand Down
55 changes: 34 additions & 21 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { LocalizationProvider, ModalProvider, ThemeProvider } from '@providers';
import { Button } from '@chakra-ui/react';
import { useShallow } from 'zustand/react/shallow';
import { appStore, modalSelector, ModalID } from '@uiStore';
import { HelmetProvider } from 'react-helmet-async';
import {
LocalizationProvider,
ModalProvider,
RouterProvider,
ThemeProvider,
} from '@providers';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

function App() {
const { t } = useTranslation();
const { openModal } = appStore(useShallow(modalSelector));
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 5,
retryDelay: 1000,
},
},
});

const App = () => {
return (
<ThemeProvider>
<ModalProvider>
<React.StrictMode>
<LocalizationProvider>
<Button onClick={() => openModal(ModalID.SEARCH, () => {})}>
{t('Click me')}
</Button>
<div>{t('App')}</div>
</LocalizationProvider>
</React.StrictMode>
</ModalProvider>
</ThemeProvider>
<QueryClientProvider client={queryClient}>
<React.StrictMode>
<LocalizationProvider>
<HelmetProvider>
<ThemeProvider>
<ModalProvider>
<RouterProvider />
</ModalProvider>
</ThemeProvider>
</HelmetProvider>
</LocalizationProvider>
</React.StrictMode>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
}
};

export default App;
17 changes: 17 additions & 0 deletions src/assets/icons/IconExport.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IconDay, IconHourcoding, IconNight } from './IconsAssets';
import { HourcodingIconProps, IconHc } from './types';

const HourcodingIcon = ({ icon, ...rest }: HourcodingIconProps) => {
switch (icon) {
case IconHc.DAY:
return <IconDay {...rest} />;
case IconHc.HOURCODING:
return <IconHourcoding {...rest} />;
case IconHc.NIGHT:
return <IconNight {...rest} />;
default:
return null;
}
};

export default HourcodingIcon;
15 changes: 15 additions & 0 deletions src/assets/icons/IconsAssets/Day.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';

export const IconDay = (props: React.SVGProps<SVGSVGElement>) => {
return (
<svg
fill="currentColor"
viewBox="0 0 16 16"
height="1em"
width="1em"
{...props}
>
<path d="M8 11a3 3 0 110-6 3 3 0 010 6zm0 1a4 4 0 100-8 4 4 0 000 8zM8 0a.5.5 0 01.5.5v2a.5.5 0 01-1 0v-2A.5.5 0 018 0zm0 13a.5.5 0 01.5.5v2a.5.5 0 01-1 0v-2A.5.5 0 018 13zm8-5a.5.5 0 01-.5.5h-2a.5.5 0 010-1h2a.5.5 0 01.5.5zM3 8a.5.5 0 01-.5.5h-2a.5.5 0 010-1h2A.5.5 0 013 8zm10.657-5.657a.5.5 0 010 .707l-1.414 1.415a.5.5 0 11-.707-.708l1.414-1.414a.5.5 0 01.707 0zm-9.193 9.193a.5.5 0 010 .707L3.05 13.657a.5.5 0 01-.707-.707l1.414-1.414a.5.5 0 01.707 0zm9.193 2.121a.5.5 0 01-.707 0l-1.414-1.414a.5.5 0 01.707-.707l1.414 1.414a.5.5 0 010 .707zM4.464 4.465a.5.5 0 01-.707 0L2.343 3.05a.5.5 0 11.707-.707l1.414 1.414a.5.5 0 010 .708z" />
</svg>
);
};
12 changes: 12 additions & 0 deletions src/assets/icons/IconsAssets/Hourcoding.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

export const IconHourcoding = (props: React.SVGProps<SVGSVGElement>) => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" {...props}>
<path
fill="currentColor"
d="M26 13h76c0 13.656-.583 24.046-10 34-3.795 3.652-7.614 7.076-12 10l1 3c.068 1.478.085 2.958.063 4.438l-.028 2.308L81 69v4c1.95 1.406 3.96 2.73 6 4 8.07 7.263 12.317 14.475 15 25v14H26c0-14.766 1.283-24.99 11-36 2.532-2.243 5.158-4.171 8-6l3-2-1-3a72.563 72.563 0 01-.063-4.438l.028-2.308L47 60v-4c-1.978-1.677-1.978-1.677-4.563-3.125C32.89 46.515 28.733 37.93 26 27V13zm13 12c1.21 7.265 3.525 12.159 9.293 16.875C55.479 46.752 61.323 47.92 70 47c7.682-2.39 13.208-6.84 17.027-13.898C88.324 30.269 89 28.134 89 25H39zm21.063 36.125c-1.327 1.91-1.327 1.91-.75 4.563L60 68c4.095 1.142 4.095 1.142 7.938-.125 1.326-1.91 1.326-1.91.75-4.563L68 61c-4.095-1.142-4.095-1.142-7.938.125zm-15.5 29.25C41.404 94.472 39 98.722 39 104h50c-1.21-7.265-3.525-12.159-9.293-16.875-11.574-7.854-25.332-7.43-35.144 3.25z"
></path>
</svg>
);
};
15 changes: 15 additions & 0 deletions src/assets/icons/IconsAssets/Night.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';

export const IconNight = (props: React.SVGProps<SVGSVGElement>) => {
return (
<svg
viewBox="0 0 24 24"
fill="currentColor"
height="1em"
width="1em"
{...props}
>
<path d="M9.57 3.38a8 8 0 0010.4 10.4 1 1 0 011.31 1.3 10 10 0 11-13-13 1 1 0 011.3 1.3zM7.1 5.04a8 8 0 1011.2 11.23A10 10 0 017.08 5.04z" />
</svg>
);
};
3 changes: 3 additions & 0 deletions src/assets/icons/IconsAssets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { IconDay } from './Day';
export { IconHourcoding } from './Hourcoding';
export { IconNight } from './Night';
20 changes: 20 additions & 0 deletions src/assets/icons/__tests__/Icons.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { render } from '@testing-library/react';

import { IconDay, IconHourcoding, IconNight } from '../IconsAssets';

describe('Icons', () => {
it('should render IconDay icon', () => {
const { container } = render(<IconDay />);
expect(container).toMatchSnapshot();
});

it('should render IconHourcoding icon', () => {
const { container } = render(<IconHourcoding />);
expect(container).toMatchSnapshot();
});

it('should render IconNight icon', () => {
const { container } = render(<IconNight />);
expect(container).toMatchSnapshot();
});
});
Loading

0 comments on commit 67b9eb0

Please sign in to comment.