Skip to content

Commit

Permalink
typescript add
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankenDeba committed Oct 6, 2023
1 parent 0a23f39 commit e639fe9
Show file tree
Hide file tree
Showing 19 changed files with 201 additions and 49 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@radix-ui/themes": "^2.0.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"dayjs": "^1.11.10",
"react": "^18.2.0",
"react-datetime-picker": "^5.5.2",
"react-dom": "^18.2.0",
"react-router": "^6.16.0",
"react-router-dom": "^6.16.0",
"react-scripts": "5.0.1",
"tsc": "^2.0.4",
"typescript": "^5.2.2",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand All @@ -36,5 +41,10 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/react": "^18.2.25",
"@types/react-dom": "^18.2.10",
"file-loader": "^6.2.0"
}
}
50 changes: 47 additions & 3 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@
max-height: 450px;
margin-bottom: 50px;
z-index: 5;

box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);

max-height: 500px;
max-width: 500px;

border-radius: 50%;
overflow: hidden;

transform: translateX(-50px);
}

.parlour-img-holder img {
/* width: 75%; */
max-height: 100%;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
/* max-height: 100%; */
height: 500px;
width: 500px;
border-radius: 50%;
cursor: pointer;
}

.parlour-img-holder img:hover {
transition: transform 0.6s;
transform: scale(1.5);
}

.skew-bg1 {
Expand All @@ -35,7 +53,7 @@
position: absolute;
top: -100px;
right: -300px;
transform: skew(20deg) rotate(-45deg);
transform: skew(20deg) rotate(-40deg);
z-index: 0;
background: rgb(56, 179, 236);
background: linear-gradient(
Expand All @@ -62,3 +80,29 @@
transform: skew(20deg) rotate(45deg);
z-index: 0;
}

.skew-bg1-square {
width: 50px;
height: 50px;
background-color: burlywood;
animation: sqew-sq1 5s linear infinite;
position: relative;
right: -100%;
}

@keyframes sqew-sq1 {
0% {
transform: rotate(0deg);
opacity: 100%;
}

50% {
transform: rotate(180deg);
opacity: 80%;
}

100% {
transform: rotate(360deg);
opacity: 100%;
}
}
48 changes: 16 additions & 32 deletions src/App.js → src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import Services from "./components/Services";
import React from "react";
import "./App.css";
import HaircutImg from "./assets/haircut1.jpg";

import facialImg from "./assets/facial.jpg";
import parlourImg from "./assets/parlour.jpg";
import servicesList from "./constants/services";

// import HaircutImg from "./assets/haircut1.jpg";
import { useEffect, useState } from "react";
import DatePicker from "./components/DatePicker";
import DateSelected from "./components/DateSelected";
import Slots from "./components/Slots";
import dayjs from "dayjs";
import Header from "./components/Header";
import Home from "./pages/Home";

function App() {
const [services, setServices] = useState({});
Expand Down Expand Up @@ -45,15 +39,10 @@ function App() {
});
}, []);

const selectedServicesHandler = (service, isSelected) => {
setSelectedServices(
(prevSel) => {
return new Set([...prevSel, service]);
},
() => {
console.log({ selectedServices });
}
);
const selectedServicesHandler = (service: any, isSelected: boolean) => {
setSelectedServices((prevSel) => {
return new Set([...prevSel, service]);
});
};

const setDateHandler = (value) => {
Expand Down Expand Up @@ -85,21 +74,16 @@ function App() {
return (
<div className="App">
<Header />
<div>
<div className="parlour-and-services">
<div className="skew-bg2"></div>
<Services services={services} onSelect={selectedServicesHandler} />
<div className="parlour-img-holder">
<img src={parlourImg} alt="parlour" />
</div>
<div className="skew-bg1"></div>
</div>
{selectedServices.size > 0 && (
<DatePicker setDateHandler={setDateHandler} />
)}
<DateSelected date={date} />
<Slots slots={slots} setSlot={setSlotHandler} slotSelected={slot?.id} />
</div>
<Home
setDateHandler={setDateHandler}
setSlotHandler={setSlotHandler}
selectedServicesHandler={selectedServicesHandler}
date={date}
slots={slots}
slot={slot}
services={services}
selectedServices={selectedServices}
/>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-ignore
import React, { useState } from "react";
import DateTimePicker from "react-datetime-picker";
import "./DatePicker.css";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-ignore
import dayjs from "dayjs";
import React from "react";
import "./DateSelected.css";
Expand Down
File renamed without changes.
14 changes: 12 additions & 2 deletions src/components/NavBar/NavBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
.nav-bar--container ul li {
margin: 0 5px;
padding: 10px 15px;
border: 1px solid #9f86c0;
border: 2px solid #9f86c0;
border-radius: 50px;
min-width: 100px;
/* min-width: 100px; */
width: 150px;
cursor: pointer;
box-sizing: border-box;
font-size: 16px;
transition: background-color 0.6s;
}

.nav-bar--container ul li:hover {
background-color: #9f86c0;
color: white;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ function NavBar() {
return (
<nav className="nav-bar--container">
<ul>
<li>Home</li>
<li>Dashboard</li>
<li>🏠 Home</li>
<li>⚙️ Dashboard</li>
<li>🛒 Cart</li>
</ul>
</nav>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import React, { useState } from "react";
import React, { ReactElement, useEffect, useState } from "react";
import "./ServiceCard.css";

function ServiceCard({ onSelect, service }) {
const [selected, setSelected] = useState();
function ServiceCard({ onSelect, service }): ReactElement {
const [selected, setSelected] = useState<boolean | undefined>();
const onSelectedHandler = (ser) => {
onSelect(ser, !selected);
setSelected((sel) => !sel);
};

useEffect(() => {
console.log("service.imgSrc: ", service.imgSrc);
}, []);

return (
<div
className={`service-card--container ${selected ? "selected" : ""}`}
onClick={() => onSelectedHandler(service)}
>
{selected && <div className="tick"></div>}
<div className="service-card--img-holder">
<img src={service.imgSrc} />
<img src={`${service.imgSrc}`} />
</div>
<div className="service-card--title">{service.title}</div>
</div>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import "./SlotPicker.css";

function SlotPicker({ slot, setSlot = () => {}, slotSelected }) {
function SlotPicker({ slot, setSlot, slotSelected }) {
// const [selected, isSelected] = useState(false);
const setSlotHandler = () => {
// isSelected(true);
Expand All @@ -14,7 +14,7 @@ function SlotPicker({ slot, setSlot = () => {}, slotSelected }) {
}
${slot.isAvailable ? "" : "not-available"}
`}
onClick={() => setSlotHandler(slot)}
onClick={() => setSlotHandler()}
>
<p className="not-allowed-tick">x</p>
{slotSelected === slot?.id && <span className="slot-tick"></span>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import "./Slots.css";

function Slots({ slots, setSlot, slotSelected }) {
const slotsRef = React.createRef();
useEffect(() => {
slotsRef?.current?.scrollIntoView({ behavior: "smooth" });
}, []);
// useEffect(() => {
// slotsRef?.current?.scrollIntoView({ behavior: "smooth" });
// }, []);
return (
<div
className="slots--container"
Expand All @@ -19,7 +19,7 @@ function Slots({ slots, setSlot, slotSelected }) {
<SlotPicker slot={slot} setSlot={setSlot} slotSelected={slotSelected} />
))}
{slotSelected && <button>SUBMIT</button>}
<div ref={slotsRef} />
{/* <div ref={slotsRef} /> */}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/constants/services.js → src/constants/services.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// const HaircutImg = "haircut1.jpg";
import HaircutImg from "../assets/haircut1.jpg";
import facialImg from "../assets/facial.jpg";

Expand Down
File renamed without changes.
50 changes: 50 additions & 0 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { ReactElement } from "react";
import DatePicker from "../../components/DatePicker";
import DateSelected from "../../components/DateSelected";
import Services from "../../components/Services";
import Slots from "../../components/Slots";
import parlourImg from "../../assets/parlour.jpg";

type homeTypes = {
services: any;
selectedServicesHandler: Function;
setDateHandler: Function;
setSlotHandler: Function;
slots: any[];
selectedServices: any;
date: any;
slot: any;
};

function Home({
services,
selectedServicesHandler,
setDateHandler,
setSlotHandler,
slots,
selectedServices,
date,
slot,
}: homeTypes): ReactElement {
return (
<div>
<div className="parlour-and-services">
<div className="skew-bg2"></div>
<Services services={services} onSelect={selectedServicesHandler} />
<div className="parlour-img-holder">
<img src={parlourImg} alt="parlour" />
</div>
<div className="skew-bg1">
<div className="skew-bg1-square"></div>
</div>
</div>
{selectedServices.size > 0 && (
<DatePicker setDateHandler={setDateHandler} />
)}
<DateSelected date={date} />
<Slots slots={slots} setSlot={setSlotHandler} slotSelected={slot?.id} />
</div>
);
}

export default Home;
Empty file added src/utils/index.js
Empty file.
32 changes: 32 additions & 0 deletions src/utils/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const users = [
{
id: "001",
name: "debashis",
role: "admin",
phoneNumber: "9876543210",
password: "deba1996",
},
{
id: "002",
name: "raman",
role: "client",
phoneNumber: "9876543211",
password: "ram123",
},
{
id: "003",
name: "ronald",
role: "client",
phoneNumber: "9876543212",
password: "ronxyz",
},
{
id: "004",
name: "ravi",
role: "client",
phoneNumber: "9876543213",
password: "r12345",
},
];

export default users;
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"jsx": "react",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"--downlevelIteration": true
},
"include": ["./src/**/*"]
}
2 changes: 2 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module "*.jpg";
declare module "*.png";

0 comments on commit e639fe9

Please sign in to comment.