Skip to content

Commit 3a08a6c

Browse files
init commit
0 parents  commit 3a08a6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+11871
-0
lines changed

.babelrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
"presets": ["next/babel"]
3+
}

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NEXT_PUBLIC_MAP_API_KEY=""

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.next
2+
/.locales
3+
/src/pages
4+
/public

.eslintrc.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* eslint-disable no-undef */
2+
module.exports = {
3+
root: true,
4+
parser: '@typescript-eslint/parser', // the TypeScript parser we installed earlier
5+
parserOptions: {
6+
ecmaFeatures: { jsx: true }, // Allows for the parsing of JSX
7+
},
8+
env: {
9+
browser: true,
10+
node: true,
11+
},
12+
plugins: ['prettier'],
13+
extends: [
14+
'eslint:recommended', // eslint default rules
15+
'plugin:@typescript-eslint/eslint-recommended', // eslint TypeScript rules (github.com/typescript-eslint/typescript-eslint)
16+
'plugin:@typescript-eslint/recommended',
17+
'plugin:react/recommended', // eslint react rules (github.com/yannickcr/eslint-plugin-react)
18+
'plugin:jsx-a11y/recommended', // accessibility plugin
19+
// Prettier plugin and recommended rules
20+
'prettier/@typescript-eslint',
21+
'plugin:prettier/recommended',
22+
],
23+
rules: {
24+
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
25+
'react/react-in-jsx-scope': 'off',
26+
'@typescript-eslint/explicit-module-boundary-types': 'off',
27+
'react/prop-types': 'off', // We turn off prop-types rule, as we will use TypeScript's types instead.
28+
'no-undef': 'error',
29+
'no-restricted-imports': [
30+
'error',
31+
{
32+
patterns: ['@material-ui/*/*/*', '!@material-ui/core/test-utils/*'],
33+
},
34+
],
35+
},
36+
settings: {
37+
react: { version: 'latest' },
38+
},
39+
};

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
21+
# debug
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
26+
# local env files
27+
.env.local
28+
.env.development.local
29+
.env.test.local
30+
.env.production.local
31+
32+
/public/static/locales
33+
/.locales
34+
/src/pages
35+
/i18n.json
36+
#built pages
37+
/src/pages

.prettierrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
// Change your rules accordingly to your coding style preferencies.
3+
// https://prettier.io/docs/en/options.html
4+
semi: true,
5+
trailingComma: 'all',
6+
singleQuote: true,
7+
printWidth: 120,
8+
tabWidth: 2,
9+
useTabs: false,
10+
}

.vscode/launch.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "chrome",
9+
"request": "launch",
10+
"name": "Chrome",
11+
"url": "http://localhost:8000",
12+
"webRoot": "${workspaceFolder}",
13+
},
14+
{
15+
"type": "node",
16+
"request": "launch",
17+
"name": "Node",
18+
"runtimeExecutable": "yarn",
19+
"runtimeArgs": [
20+
"run",
21+
"dev",
22+
],
23+
"port": 9230,
24+
"console": "integratedTerminal",
25+
}
26+
],
27+
"compounds": [
28+
{
29+
"name": "Full",
30+
"configurations": ["Node", "Chrome"]
31+
}
32+
]
33+
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"editor.formatOnSave": false,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": true
5+
},
6+
"tslint.configFile": "tslint.json",
7+
"git.ignoreLimitWarning": true
8+
}

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
This is a [Next.js](https://nextjs.org/) based project to style react components similar to on in tesla website.
2+
3+
## Getting Started
4+
Clone code:
5+
git clone https://github.com/saigonbitmaster/teslaLikeReact
6+
7+
Change data, images:
8+
src/pages_/api/data.js
9+
public
10+
11+
Run app:
12+
#install node modules
13+
yarn
14+
15+
#run dev
16+
yarn run dev
17+
18+
#build and run app
19+
yarn run build
20+
yarn run start
21+
22+
Open [http://localhost:8000](http://localhost:8000) with your browser to see the result.
23+
24+
You can start editing the page by modifying `pages_/index.tsx`. The page auto-updates as you edit the file.
25+
26+
## Learn More
27+
28+
To learn more about Next.js, take a look at the following resources:
29+
30+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
31+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
32+
33+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
34+
35+
## Deploy on Vercel
36+
37+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
38+
39+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

copy-i18n.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint-disable no-undef */
2+
/* eslint-disable @typescript-eslint/no-var-requires */
3+
const fs = require('fs');
4+
const path = require('path');
5+
const { execSync } = require('child_process');
6+
7+
const dirs = [
8+
['i18n/vi', '.locales/vi'],
9+
['i18n/en', '.locales/en'],
10+
];
11+
12+
dirs.map((dir) => {
13+
const srcPath = path.join(__dirname, dir[0]);
14+
const dstPath = path.join(__dirname, dir[1]);
15+
// console.log(dstPath);
16+
execSync(`mkdir -p ${dstPath}`);
17+
execSync(`rm -f ${dstPath}/*.json`);
18+
19+
// create i18n.json
20+
execSync(`rm -f ` + path.join(process.cwd(), `i18n.json`));
21+
const i18n = require('./i18n');
22+
fs.writeFileSync(path.join(process.cwd(), `i18n.json`), JSON.stringify(i18n, null, ' '), {
23+
encoding: 'utf8',
24+
flag: 'w',
25+
});
26+
27+
const files = fs.readdirSync(srcPath);
28+
files.forEach((fileName) => {
29+
const fileInfo = path.parse(fileName);
30+
// console.log(fileInfo);
31+
if (fileInfo.ext === '.js') {
32+
const contentObj = require(`./${dir[0]}/${fileName}`);
33+
const contentString = JSON.stringify(contentObj, null, ' ');
34+
// write to public folder
35+
fs.writeFileSync(path.join(dstPath, `${fileInfo.name}.json`), contentString, { encoding: 'utf8', flag: 'w' });
36+
}
37+
});
38+
});

i18n/en/common.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable no-undef */
2+
module.exports = {
3+
'site-name': 'My site',
4+
copyright: 'Copyright © 2020 My site',
5+
'change-locale': 'Change locale',
6+
'error-without-status': 'Page not found',
7+
home: 'Home',
8+
logoName: 'mylogo',
9+
login: 'Login',
10+
product01: 'poductI',
11+
product02: 'poductII',
12+
product03: 'poductIII',
13+
product04: 'poductIV',
14+
product05: 'poductV',
15+
product06: 'poductVI',
16+
samplePages: 'samplePages',
17+
'about-us': 'About us',
18+
'contact-us': 'Contact us',
19+
components: 'components',
20+
submit: 'SUBMIT',
21+
support: 'SUPPORT',
22+
};

i18n/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// const defaultLangsFromHost = {
2+
// vi: 'vi',
3+
// default: 'en', // localhost
4+
// };
5+
6+
// function getDomain(host) {
7+
// const domain = host.split('.');
8+
// return domain[domain.length - 1];
9+
// }
10+
11+
module.exports = {
12+
allLanguages: ['en', 'vi'],
13+
defaultLanguage: 'en',
14+
currentPagesDir: 'src/pages_',
15+
finalPagesDir: 'src/pages',
16+
localesPath: '.locales',
17+
pages: {
18+
'*': ['common'],
19+
},
20+
};

i18n/vi/common.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable no-undef */
2+
module.exports = {
3+
'site-name': 'Mysite Operation System',
4+
copyright: 'Copyright © 2020 MysiteOS',
5+
'change-locale': 'Change locale',
6+
'error-without-status': 'Page not found',
7+
home: 'Home',
8+
logoName: 'mylogo',
9+
login: 'Login',
10+
product01: 'poductI',
11+
product02: 'poductII',
12+
product03: 'poductIII',
13+
product04: 'poductIV',
14+
product05: 'poductV',
15+
product06: 'poductVI',
16+
samplePages: 'samplePages',
17+
'about-us': 'About us',
18+
'contact-us': 'Contact us',
19+
components: 'components',
20+
submit: 'SUBMIT',
21+
support: 'SUPPORT',
22+
};

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
const { setConfig } = require('next/config');
3+
var path = require('path');
4+
global.appRoot = path.resolve(__dirname);
5+
6+
setConfig(require('./next.config'));
7+
8+
require('./server');

next-env.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* eslint-disable prettier/prettier */
2+
/// <reference types="next" />
3+
/// <reference types="next/types/global" />

next.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
const withBundleAnalyzer = require('@next/bundle-analyzer')({
3+
enabled: process.env.ANALYZE === 'true',
4+
});
5+
/* eslint-disable no-undef */
6+
const settings = {
7+
publicRuntimeConfig: {
8+
localeSubpaths: typeof process.env.LOCALE_SUBPATHS === 'string' ? process.env.LOCALE_SUBPATHS : 'none',
9+
},
10+
webpack: (config, { isServer }) => {
11+
// Fixes npm packages that depend on `fs` module
12+
if (!isServer) {
13+
config.node = {
14+
fs: 'empty',
15+
};
16+
}
17+
18+
return config;
19+
},
20+
typescript: {
21+
// !! WARN !!
22+
// Dangerously allow production builds to successfully complete even if
23+
// your project has type errors.
24+
// !! WARN !!
25+
ignoreBuildErrors: true,
26+
},
27+
};
28+
29+
module.exports = withBundleAnalyzer(settings);

0 commit comments

Comments
 (0)