Skip to content

Commit 028b574

Browse files
committed
feat: styling with tailwindcss
1 parent 38b23c0 commit 028b574

16 files changed

+4446
-3875
lines changed

.prettierrc.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
module.exports = {
2-
semi: false,
3-
trailingComma: 'es5',
4-
singleQuote: true,
5-
jsxSingleQuote: false,
6-
printWidth: 80,
7-
tabWidth: 2,
8-
endOfLine: 'auto',
9-
}
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'es5',
4+
singleQuote: true,
5+
jsxSingleQuote: false,
6+
printWidth: 80,
7+
tabWidth: 2,
8+
endOfLine: 'auto',
9+
}

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
This template is built with the following technologies:
1010

1111
- Language: **TypeScript**
12+
- Styling: **TailwindCSS**
1213
- Testing: **Jest**
1314
- Linting: **ESLint**
1415
- Formatting: **Prettier**
@@ -55,6 +56,7 @@ npm run build
5556
## Features
5657

5758
- [x] TypeScript for improved code quality and developer experience
59+
- [x] TailwindCSS for responsive styling
5860
- [x] Jest for unit testing
5961
- [x] ESLint for linting and maintaining code consistency
6062
- [x] Prettier for automatic code formatting

package-lock.json

+4,303-3,672
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+29-29
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,53 @@
1616
"author": "Divyanshu Shekhar",
1717
"license": "ISC",
1818
"dependencies": {
19-
"@emotion/react": "^11.11.1",
20-
"@emotion/styled": "^11.11.0",
21-
"@mui/icons-material": "^5.14.1",
22-
"@mui/material": "^5.14.1",
23-
"axios": "^1.4.0",
19+
"axios": "^1.5.0",
2420
"react": "^18.2.0",
2521
"react-dom": "^18.2.0"
2622
},
2723
"devDependencies": {
28-
"@babel/core": "^7.22.9",
29-
"@babel/plugin-transform-runtime": "^7.22.9",
30-
"@babel/preset-env": "^7.22.9",
31-
"@babel/preset-react": "^7.22.5",
32-
"@babel/preset-typescript": "^7.22.5",
33-
"@babel/runtime": "^7.22.6",
34-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
35-
"@testing-library/jest-dom": "^5.17.0",
24+
"@babel/core": "^7.22.20",
25+
"@babel/plugin-transform-runtime": "^7.22.15",
26+
"@babel/preset-env": "^7.22.20",
27+
"@babel/preset-react": "^7.22.15",
28+
"@babel/preset-typescript": "^7.22.15",
29+
"@babel/runtime": "^7.22.15",
30+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
31+
"@testing-library/jest-dom": "^6.1.3",
3632
"@testing-library/react": "^14.0.0",
37-
"@testing-library/user-event": "^14.4.3",
38-
"@types/jest": "^29.5.3",
39-
"@types/react": "^18.2.15",
33+
"@testing-library/user-event": "^14.5.1",
34+
"@types/jest": "^29.5.5",
35+
"@types/react": "^18.2.22",
4036
"@types/react-dom": "^18.2.7",
41-
"@typescript-eslint/eslint-plugin": "^6.1.0",
42-
"@typescript-eslint/parser": "^6.1.0",
37+
"@typescript-eslint/eslint-plugin": "^6.7.2",
38+
"@typescript-eslint/parser": "^6.7.2",
39+
"autoprefixer": "^10.4.16",
4340
"babel-loader": "^9.1.3",
4441
"copy-webpack-plugin": "^11.0.0",
4542
"css-loader": "^6.8.1",
46-
"eslint": "^8.45.0",
47-
"eslint-config-prettier": "^8.8.0",
43+
"eslint": "^8.49.0",
44+
"eslint-config-prettier": "^9.0.0",
4845
"eslint-plugin-eslint-comments": "^3.2.0",
49-
"eslint-plugin-import": "^2.27.5",
50-
"eslint-plugin-jest": "^27.2.3",
46+
"eslint-plugin-import": "^2.28.1",
47+
"eslint-plugin-jest": "^27.4.0",
5148
"eslint-plugin-jsx-a11y": "^6.7.1",
5249
"eslint-plugin-prettier": "^5.0.0",
53-
"eslint-plugin-react": "^7.33.0",
50+
"eslint-plugin-react": "^7.33.2",
5451
"eslint-plugin-react-hooks": "^4.6.0",
5552
"html-webpack-plugin": "^5.5.3",
5653
"husky": "^8.0.3",
57-
"jest": "^29.6.1",
58-
"jest-environment-jsdom": "^29.6.1",
59-
"lint-staged": "^13.2.3",
60-
"prettier": "^3.0.0",
54+
"jest": "^29.7.0",
55+
"jest-environment-jsdom": "^29.7.0",
56+
"lint-staged": "^14.0.1",
57+
"postcss": "^8.4.30",
58+
"postcss-loader": "^7.3.3",
59+
"prettier": "^3.0.3",
6160
"react-refresh": "^0.14.0",
6261
"style-loader": "^3.3.3",
63-
"typescript": "^5.1.6",
62+
"tailwindcss": "^3.3.3",
63+
"typescript": "^5.2.2",
6464
"webpack": "^5.88.2",
65-
"webpack-bundle-analyzer": "^4.9.0",
65+
"webpack-bundle-analyzer": "^4.9.1",
6666
"webpack-cli": "^5.1.4",
6767
"webpack-dev-server": "^4.15.1",
6868
"webpack-merge": "^5.9.0"

postcss.config.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const tailwindcss = require('tailwindcss');
2+
const autoprefixer = require('autoprefixer');
3+
4+
module.exports = {
5+
plugins: [tailwindcss('./tailwind.config.js'), autoprefixer],
6+
};

src/App.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { FC } from 'react'
2-
import HomePage from './components/Home/HomePage'
1+
import React from 'react';
2+
import HomePage from './components/Home/HomePage';
33
// import './App.css'
44

5-
const App: FC = () => {
5+
const App: React.FC = () => {
66
return (
77
<div id="App">
88
<HomePage />
99
</div>
10-
)
11-
}
10+
);
11+
};
1212

13-
export default App
13+
export default App;
Loading

src/components/Home/HomePage.tsx

+15-86
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,18 @@
1-
import React, { useState, useEffect } from 'react'
2-
import axios from 'axios'
3-
import {
4-
List,
5-
ListItem,
6-
ListItemAvatar,
7-
Avatar,
8-
ListItemText,
9-
ListItemSecondaryAction,
10-
IconButton,
11-
AppBar,
12-
Toolbar,
13-
Typography,
14-
Container,
15-
} from '@mui/material'
16-
import { Refresh as RefreshIcon } from '@mui/icons-material'
17-
18-
// Models
19-
import { ITrain } from '../../models/train'
20-
21-
const TrainList: React.FC = () => {
22-
const [trains, setTrains] = useState<ITrain[]>([])
23-
24-
const fetchTrainsData = async () => {
25-
try {
26-
// Replace the URL with your backend API endpoint
27-
const response = await axios.get<ITrain[]>(
28-
'http://localhost:5000/trains/all'
29-
)
30-
console.log('Trains List ', response.data)
31-
setTrains(response.data)
32-
} catch (error) {
33-
console.error('Failed to fetch train data:', error)
34-
}
35-
}
36-
37-
useEffect(() => {
38-
console.log('Use Effect Called')
39-
fetchTrainsData()
40-
}, [])
41-
42-
const handleRefresh = () => {
43-
console.log('Refresh Button Clicked')
44-
fetchTrainsData()
45-
}
1+
import { FC } from 'react';
2+
import ReactTypescriptTemplateLogo from '../../assets/images/react-typescript-template.png';
463

4+
const HomePage: FC = () => {
475
return (
48-
<Container>
49-
<AppBar position="static">
50-
<Toolbar>
51-
<Typography variant="h6">Train Schedules</Typography>
52-
<ListItemSecondaryAction>
53-
<IconButton edge="end" color="inherit" onClick={handleRefresh}>
54-
<RefreshIcon />
55-
</IconButton>
56-
</ListItemSecondaryAction>
57-
</Toolbar>
58-
</AppBar>
59-
<List>
60-
{trains.map((train) => (
61-
<ListItem key={train.trainNumber} alignItems="flex-start">
62-
<ListItemAvatar>
63-
<Avatar>{train.trainNumber}</Avatar>
64-
</ListItemAvatar>
65-
<ListItemText
66-
primary={train.trainName}
67-
secondary={`Departure Time: ${train.departureTime.Hours}hrs:${train.departureTime.Minutes}mins:${train.departureTime.Seconds}secs | Delayed By: ${train.delayedBy}`}
68-
/>
69-
<ListItemSecondaryAction>
70-
<IconButton edge="end" aria-label="seats" color="inherit">
71-
<Typography variant="subtitle2" color="inherit">
72-
Seats:
73-
</Typography>
74-
<Typography variant="body2" color="inherit">
75-
Sleeper: {train.seatsAvailable.sleeper}
76-
</Typography>
77-
<Typography variant="body2" color="inherit">
78-
AC: {train.seatsAvailable.AC}
79-
</Typography>
80-
</IconButton>
81-
</ListItemSecondaryAction>
82-
</ListItem>
83-
))}
84-
</List>
85-
</Container>
86-
)
87-
}
6+
<div className="text-center">
7+
<h1 className="text-4xl font-bold my-2">React Typescript Template</h1>
8+
<img
9+
src={ReactTypescriptTemplateLogo}
10+
width={500}
11+
className="mx-auto"
12+
alt="React-Typescript-Template"
13+
/>
14+
</div>
15+
);
16+
};
8817

89-
export default TrainList
18+
export default HomePage;

src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8-
<title>DS Train Central</title>
8+
<title>React Typescript Template</title>
99
</head>
1010

1111
<body>

src/index.tsx

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import React from 'react'
2-
import ReactDOM from 'react-dom/client'
3-
import './styles.css'
4-
import App from './App'
5-
6-
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
7-
root.render(
8-
<React.StrictMode>
9-
<App />
10-
</React.StrictMode>
11-
)
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import './styles.css';
4+
import App from './App';
5+
6+
const root = ReactDOM.createRoot(
7+
document.getElementById('root') as HTMLElement
8+
);
9+
10+
root.render(
11+
<React.StrictMode>
12+
<App />
13+
</React.StrictMode>
14+
);

src/styles.css

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
body {
2-
margin: 0;
3-
font-family: -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
4-
-webkit-font-smoothing: antialiased;
5-
-moz-osx-font-smoothing: grayscale;
6-
}
7-
8-
code {
9-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
10-
monospace;
11-
}
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

tailwind.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ['./index.html', './src/**/*.{js,jsx,ts,tsx}'],
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
};

webpack/webpack.common.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const path = require('path')
2-
const HtmlWebpackPlugin = require('html-webpack-plugin')
3-
const CopyWebpackPlugin = require('copy-webpack-plugin')
1+
const path = require('path');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const CopyWebpackPlugin = require('copy-webpack-plugin');
44

55
module.exports = {
66
entry: path.resolve(__dirname, '..', './src/index.tsx'),
@@ -22,8 +22,8 @@ module.exports = {
2222

2323
// Loader for css files
2424
{
25-
test: /\.css$/,
26-
use: ['style-loader', 'css-loader'],
25+
test: /\.css$/i,
26+
use: ['style-loader', 'css-loader', 'postcss-loader'],
2727
},
2828

2929
// Loader for image files
@@ -61,4 +61,4 @@ module.exports = {
6161
],
6262
}),
6363
],
64-
}
64+
};

webpack/webpack.config.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const { merge } = require('webpack-merge');
2-
const commonConfig = require('./webpack.common.js');
3-
4-
module.exports = (envVar) => {
5-
const {env} = envVar;
6-
const envConfig = require(`./webpack.${env}.js`);
7-
return merge(commonConfig, envConfig);
8-
}
1+
const { merge } = require('webpack-merge');
2+
const commonConfig = require('./webpack.common.js');
3+
4+
module.exports = (envVar) => {
5+
const { env } = envVar;
6+
const envConfig = require(`./webpack.${env}.js`);
7+
return merge(commonConfig, envConfig);
8+
};

webpack/webpack.dev.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
// const webpack = require('webpack');
2-
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
3-
4-
module.exports = {
5-
mode: 'development',
6-
devServer: {
7-
hot: true,
8-
open: true,
9-
},
10-
devtool: 'cheap-module-source-map',
11-
plugins: [
12-
// Specify development API URL
13-
// new webpack.DefinePlugin({
14-
// "process.env": {
15-
// NODE_ENV: JSON.stringify("development"),
16-
// },
17-
// }),
18-
new ReactRefreshWebpackPlugin(),
19-
],
20-
}
1+
// const webpack = require('webpack');
2+
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
3+
4+
module.exports = {
5+
mode: 'development',
6+
devServer: {
7+
hot: true,
8+
open: true,
9+
},
10+
devtool: 'cheap-module-source-map',
11+
plugins: [
12+
// Specify development API URL
13+
// new webpack.DefinePlugin({
14+
// "process.env": {
15+
// NODE_ENV: JSON.stringify("development"),
16+
// },
17+
// }),
18+
new ReactRefreshWebpackPlugin(),
19+
],
20+
};

0 commit comments

Comments
 (0)