Skip to content

Commit b991abc

Browse files
authored
feat(): add app launch action (#22)
1 parent ac73074 commit b991abc

File tree

10 files changed

+655
-3
lines changed

10 files changed

+655
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.boxStylesAddNewWorld {
2+
border: "solid";
3+
border-color: "#FD7014";
4+
border-width: "4";
5+
padding-left: "20vw";
6+
padding-right: "20vw";
7+
padding-top: "2vh";
8+
padding-bottom: "2vh";
9+
background-color: "#222831";
10+
border-radius: "15px";
11+
align-items: "center";
12+
cursor: "pointer";
13+
}
14+
15+
.IconStylesAddNewWorld {
16+
padding-left: "15px";
17+
font-size: "30px";
18+
width: "50px";
19+
}
20+
21+
.TextStylesAddNewWorld {
22+
display: "flex";
23+
align-items: "center";
24+
text-align: "center";
25+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { Box } from "@mui/system";
2+
import React from "react";
3+
import {
4+
IoIosAddCircleOutline,
5+
} from "react-icons/io";
6+
import CSS from "csstype";
7+
import { AppLaunchModal } from "./AppLaunchModal/AppLaunchModal"
8+
import { SelectChangeEvent } from "@mui/material/Select";
9+
10+
const boxStyles: CSS.Properties = {
11+
border: "solid",
12+
borderColor: "#FD7014",
13+
borderWidth: "50",
14+
paddingLeft: "20vw",
15+
paddingRight: "20vw",
16+
paddingTop: "2vh",
17+
paddingBottom: "2vh",
18+
backgroundColor: "#222831",
19+
borderRadius: "15px",
20+
alignItems: "center",
21+
cursor: "pointer",
22+
};
23+
24+
const IconStyles: CSS.Properties = {
25+
paddingLeft: "15px",
26+
fontSize: "30px",
27+
width: "50px",
28+
};
29+
30+
const TextStyles: CSS.Properties = {
31+
display: "flex",
32+
alignItems: "center",
33+
textAlign: "center",
34+
};
35+
36+
interface event {
37+
id: number;
38+
keyword: string[];
39+
source: String[];
40+
}
41+
42+
export const AddAppLaunch = (props: any) => {
43+
const [open, setOpen] = React.useState(false);
44+
const [sources, setsources] = React.useState("");
45+
const handleOpen = () => setOpen(true);
46+
const handleClose = () => setOpen(false);
47+
48+
const save = () => {
49+
if (props.newEvent.length !== 0 && props.newEvent.source && props.newEvent.source.name) {
50+
props.addNewEvent(props.newEvent);
51+
handleClose();
52+
} else {
53+
alert("Please insert at least one source.")
54+
}
55+
};
56+
57+
const closeWithoutSave = () => {
58+
props.setnewEvent({ id: props.newEvent, keywords: [], sources: [] });
59+
handleClose();
60+
};
61+
62+
const handleChange = (e: any) => {
63+
if (e.key === "Enter" && e.currentTarget.value !== "") {
64+
65+
let cpy = {...props.newEvent};
66+
67+
cpy.keywords[0] = (e.currentTarget.value);
68+
e.currentTarget.value = "";
69+
props.setnewEvent(cpy);
70+
return
71+
}
72+
};
73+
74+
const addSource = (event: SelectChangeEvent) => {
75+
let cpy = {...props.newEvent};
76+
77+
cpy.source = props.sources.find((elem: any) => elem.name === event.target.value)
78+
props.setnewEvent(cpy);
79+
};
80+
81+
return (
82+
<>
83+
<Box style={boxStyles} onClick={handleOpen}>
84+
<h3 style={TextStyles}>
85+
Click to add new App Launch Event
86+
<i style={IconStyles}>
87+
<IoIosAddCircleOutline />
88+
</i>
89+
</h3>
90+
</Box>
91+
<AppLaunchModal
92+
handleOpen={handleOpen}
93+
handleClose={handleClose}
94+
save={save}
95+
closeWithoutSave={closeWithoutSave}
96+
handleChange={handleChange}
97+
addSource={addSource}
98+
99+
sources={props.sources}
100+
newEvent={props.newEvent}
101+
setnewEvent={props.setnewEvent}
102+
addNewEvent={props.addNewEvent}
103+
open={open}
104+
/>
105+
</>
106+
);
107+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
styleModal {
2+
position: "absolute" as "absolute";
3+
top: "50%";
4+
left: "50%";
5+
transform: "translate(-50%, -50%)";
6+
width: 400;
7+
background-color: "#222831";
8+
border: "2px solid #FD7014";
9+
box-shadow: 24;
10+
padding: 4;
11+
border-radius: "15px";
12+
}
13+
14+
IconStylesModal {
15+
padding-left: "85%";
16+
font-size: "15px";
17+
width: "50px";
18+
}
19+
20+
TextStylesModal {
21+
display: "flex";
22+
align-items: "center";
23+
text-align: "center";
24+
word-wrap: "break-word";
25+
width: "10px";
26+
max-width: "10px";
27+
white-space: "nowrap";
28+
padding-left: "1vw";
29+
}
30+
31+
SelectStylesModal {
32+
color: red;
33+
}
34+
35+
/* hover typography-item */
36+
.typography-item:hover {
37+
color: #FD7014;
38+
}

0 commit comments

Comments
 (0)