-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added front end for target matching mechanism.
- Loading branch information
1 parent
8b4c5f1
commit ca91960
Showing
5 changed files
with
195 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
.flex-box { | ||
display: flex; | ||
flex:19; | ||
justify-content: center; | ||
justify-items: center; | ||
align-content: center; | ||
align-items: center; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.left-box { | ||
justify-content: center; | ||
justify-items: center; | ||
align-items: center; | ||
align-content: center; | ||
display: flex; | ||
flex: 1; | ||
} | ||
|
||
.right-box { | ||
justify-content: center; | ||
justify-items: center; | ||
align-items: center; | ||
align-content: center; | ||
display: flex; | ||
flex: 2; | ||
} | ||
|
||
.form-container { | ||
background-color: goldenrod; | ||
border-radius: 20px; | ||
padding: 20px; | ||
text-align: center; | ||
} | ||
|
||
.bottle { | ||
display: flex; | ||
align-items: center; | ||
gap: 30px; | ||
} | ||
|
||
.input-field { | ||
margin: 30px 0; | ||
font-size: 30px; | ||
padding: 10px; | ||
width: 250px; | ||
border: 1px solid rgb(253, 76, 0, 0.5); | ||
border-top: none; | ||
border-left: none; | ||
border-right: none; | ||
background: rgba(20, 20, 20, .2); | ||
color: white; | ||
outline: none; | ||
caret-color: black; | ||
} | ||
|
||
.submit-button { | ||
background-color: initial; | ||
background-image: linear-gradient(-180deg, #FF7E31, #E62C03); | ||
border-radius: 6px; | ||
box-shadow: rgba(0, 0, 0, 0.1) 0 2px 4px; | ||
color: #FFFFFF; | ||
cursor: pointer; | ||
display: inline-block; | ||
font-family: Inter,-apple-system,system-ui,Roboto,"Helvetica Neue",Arial,sans-serif; | ||
font-size: x-large; | ||
height: 50px; | ||
line-height: 40px; | ||
outline: 0; | ||
overflow: hidden; | ||
padding: 0 20px; | ||
pointer-events: auto; | ||
position: relative; | ||
text-align: center; | ||
touch-action: manipulation; | ||
user-select: none; | ||
-webkit-user-select: none; | ||
vertical-align: top; | ||
white-space: nowrap; | ||
width: 25%; | ||
z-index: 9; | ||
border: 0; | ||
transition: box-shadow .2s; | ||
margin-top: 5px; | ||
} | ||
|
||
.submit-button:hover { | ||
box-shadow: rgba(253, 76, 0, 0.5) 0 3px 8px; | ||
} | ||
|
||
.image-gallery { | ||
width: 90%; | ||
height: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import "./TargetMatch.css" | ||
|
||
import ReactImageGallery from "react-image-gallery"; | ||
import { useState } from "react"; | ||
|
||
interface LatLng { | ||
lat: string; | ||
lng: string; | ||
} | ||
|
||
interface BottleData { | ||
[key: string]: LatLng; | ||
} | ||
|
||
/** | ||
* @returns Returns manual target matching page. | ||
*/ | ||
function TargetMatch() { | ||
const bottle_list = ['A', 'B', 'C', 'D', 'E']; | ||
|
||
const [lat_lng, set_lat_lng] = useState([ | ||
{ lat: '', lng: '', setLat: (value:number) => handleUpdate(0, 'lat', value), setLng: (value:number) => handleUpdate(0, 'lng', value) }, | ||
{ lat: '', lng: '', setLat: (value:number) => handleUpdate(1, 'lat', value), setLng: (value:number) => handleUpdate(1, 'lng', value) }, | ||
{ lat: '', lng: '', setLat: (value:number) => handleUpdate(2, 'lat', value), setLng: (value:number) => handleUpdate(2, 'lng', value) }, | ||
{ lat: '', lng: '', setLat: (value:number) => handleUpdate(3, 'lat', value), setLng: (value:number) => handleUpdate(3, 'lng', value) }, | ||
{ lat: '', lng: '', setLat: (value:number) => handleUpdate(4, 'lat', value), setLng: (value:number) => handleUpdate(4, 'lng', value) } | ||
]); | ||
|
||
const handleUpdate = (index:number, key:string, value:number) => { | ||
set_lat_lng(pre_lat_lng => { | ||
const new_lat_lng = [...pre_lat_lng]; | ||
new_lat_lng[index] = { ...new_lat_lng[index], [key]: value }; | ||
return new_lat_lng; | ||
}); | ||
}; | ||
|
||
const images = [ | ||
{ | ||
original: "https://picsum.photos/id/1018/1000/600/", | ||
thumbnail: "https://picsum.photos/id/1018/250/150/", | ||
}, | ||
{ | ||
original: "https://picsum.photos/id/1015/1000/600/", | ||
thumbnail: "https://picsum.photos/id/1015/250/150/", | ||
}, | ||
{ | ||
original: "https://picsum.photos/id/1019/1000/600/", | ||
thumbnail: "https://picsum.photos/id/1019/250/150/", | ||
}, | ||
]; | ||
|
||
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
|
||
const bottle_data: BottleData = {}; | ||
|
||
bottle_list.forEach((bottle:string, index: number) => { | ||
bottle_data[`bottle${bottle}`] = {'lat': lat_lng[index].lat, 'lng': lat_lng[index].lng} | ||
}); | ||
|
||
console.log('Form Data:', bottle_data); | ||
}; | ||
|
||
return ( | ||
<div className="flex-box"> | ||
<div className="left-box"> | ||
<div className="form-container"> | ||
<form onSubmit={handleSubmit} > | ||
{ | ||
bottle_list.map((bottle, index) => { | ||
return ( | ||
<div className="bottle" key={index}> | ||
<h1>Bottle {bottle}</h1> | ||
<input className="input-field" type="number" placeholder="lat" value={lat_lng[index].lat} onChange={(e) => lat_lng[index].setLat(parseInt(e.target.value))} ></input> | ||
<input className="input-field" type="number" placeholder="lng" value={lat_lng[index].lng} onChange={(e) => lat_lng[index].setLng(parseInt(e.target.value))} ></input> | ||
</div> | ||
) | ||
}) | ||
} | ||
<input className="submit-button" type="submit" value="Submit"></input> | ||
</form> | ||
</div> | ||
</div> | ||
<div className="right-box"> | ||
<ReactImageGallery items={images} showPlayButton={false}> | ||
|
||
</ReactImageGallery> | ||
</div> | ||
</div> | ||
|
||
) | ||
} | ||
export default TargetMatch; |