Skip to content

Commit ab26721

Browse files
Next, tsx, bootstrap components
1 parent 65659f7 commit ab26721

19 files changed

+177
-934
lines changed

next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
"start": "next start"
88
},
99
"dependencies": {
10-
"@chakra-ui/icons": "^1.0.0",
11-
"@chakra-ui/react": "^1.4.2",
1210
"@emotion/react": "^11.0.0",
1311
"@emotion/styled": "^11.0.0",
12+
"bootstrap": "^5.0.0-beta3",
1413
"framer-motion": "^4.0.3",
1514
"next": "latest",
1615
"react": "^17.0.2",
1716
"react-dom": "^17.0.2"
1817
},
19-
"license": "MIT"
18+
"license": "MIT",
19+
"devDependencies": {
20+
"@types/node": "^15.0.2",
21+
"@types/react": "^17.0.5",
22+
"typescript": "^4.2.4"
23+
}
2024
}

src/components/Button.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { ButtonHTMLAttributes } from 'react';
2+
3+
type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
4+
buttonText: string;
5+
buttonColor?: 'primary' | 'secondary' | 'light' | 'dark';
6+
buttonBackgroundColor: 'primary' | 'secondary' | 'light' | 'dark';
7+
buttonWidth?: 'w-25' | 'w-50' | 'w-75' | 'w-100';
8+
styles?: string;
9+
};
10+
11+
export const Button: React.FC<ButtonProps> = ({
12+
buttonText,
13+
buttonColor,
14+
buttonBackgroundColor,
15+
buttonWidth,
16+
styles,
17+
...props
18+
}) => {
19+
return <button className={`btn btn-${buttonBackgroundColor} ${buttonWidth} ${styles}`}>{buttonText}</button>;
20+
};
21+
export default Button;

src/components/CTA.js

-31
This file was deleted.

src/components/Container.js

-19
This file was deleted.

src/components/DarkModeSwitch.js

-16
This file was deleted.

src/components/Footer.js

-3
This file was deleted.

src/components/Hero.js

-17
This file was deleted.

src/components/InputField.tsx

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { InputHTMLAttributes } from 'react';
2+
3+
type InputFieldProps = InputHTMLAttributes<HTMLInputElement> & {
4+
labelText: string;
5+
formHandler?: (event) => void;
6+
};
7+
8+
export const InputField: React.FC<InputFieldProps> = ({
9+
labelText,
10+
formHandler,
11+
...props
12+
}) => {
13+
return (
14+
<React.Fragment>
15+
<label htmlFor={props.id}>{labelText}</label>
16+
<input
17+
id={props.id}
18+
type={props.type}
19+
name={props.name}
20+
className='form-control mb-2'
21+
onChange={formHandler}
22+
/>
23+
</React.Fragment>
24+
);
25+
};
26+
export default InputField;

src/components/Main.js

-13
This file was deleted.

src/components/Wrapper.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
3+
interface WrapperProps {
4+
width?: 'w-25' | 'w-50' | 'w-75';
5+
}
6+
7+
export const Wrapper: React.FC<WrapperProps> = ({ width, children }) => {
8+
return <div className={`${width} container`}>{children}</div>;
9+
};
10+
export default Wrapper;

src/pages/_app.js

-19
This file was deleted.

src/pages/_app.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Head from 'next/head';
2+
import 'bootstrap/dist/css/bootstrap.css'
3+
4+
function MyApp({ Component, pageProps }) {
5+
return <Component className="container" {...pageProps} />;
6+
}
7+
export default MyApp;

src/pages/_document.js

-18
This file was deleted.

src/pages/index.js

-54
This file was deleted.

src/pages/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const Index = () => <div>Hello world</div>;
2+
3+
export default Index;

src/pages/register.tsx

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React, { useState } from 'react';
2+
import Button from '../components/Button';
3+
import InputField from '../components/InputField';
4+
import Wrapper from '../components/Wrapper';
5+
6+
interface RegisterState {
7+
username: string;
8+
password: string;
9+
}
10+
11+
const Register: React.FC = () => {
12+
const [registerData, setRegisterData] = useState<RegisterState>({
13+
username: '',
14+
password: '',
15+
});
16+
17+
const formHandler = (e: React.ChangeEvent<HTMLInputElement>) => {
18+
setRegisterData({
19+
...registerData,
20+
[e.target.name]: e.target.value,
21+
});
22+
};
23+
24+
return (
25+
<Wrapper width='w-50'>
26+
<div className='card mt-5'>
27+
<div className='card-body'>
28+
<form>
29+
<InputField
30+
labelText='Username'
31+
id='username'
32+
type='text'
33+
name='username'
34+
formHandler={formHandler}
35+
/>
36+
<InputField
37+
labelText='Password'
38+
id='password'
39+
type='password'
40+
name='password'
41+
formHandler={formHandler}
42+
/>
43+
<Button
44+
buttonBackgroundColor='dark'
45+
buttonText='Submit'
46+
buttonWidth='w-100'
47+
styles='mt-4'
48+
/>
49+
</form>
50+
</div>
51+
</div>
52+
</Wrapper>
53+
);
54+
};
55+
56+
export default Register;

tsconfig.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
9+
"allowJs": true,
10+
"skipLibCheck": true,
11+
"strict": false,
12+
"forceConsistentCasingInFileNames": true,
13+
"noEmit": true,
14+
"esModuleInterop": true,
15+
"module": "esnext",
16+
"moduleResolution": "node",
17+
"resolveJsonModule": true,
18+
"isolatedModules": true,
19+
"jsx": "preserve"
20+
},
21+
"include": [
22+
"next-env.d.ts",
23+
"**/*.ts",
24+
"**/*.tsx"
25+
],
26+
"exclude": [
27+
"node_modules"
28+
]
29+
}

0 commit comments

Comments
 (0)