Skip to content

Commit

Permalink
🎨 Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Jan 28, 2024
1 parent e08ff31 commit 7a7dc4b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 47 deletions.
25 changes: 15 additions & 10 deletions server-data/resources/[esx]/esx_textui/TextUI.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
Debug = ESX.GetConfig().EnableDebug

local isShowing = false
---@param message string
---@param typ string
local function TextUI(message, typ)
isShowing = true
SendNUIMessage({
action = 'show',
message = message and message or 'ESX-TextUI',
type = type(typ) == "string" and typ or 'info'
action = "show",
message = message and message or "ESX-TextUI",
type = type(typ) == "string" and typ or "info",
})
end

local function HideUI()
if not isShowing then
return
end
isShowing = false
SendNUIMessage({
action = 'hide'
action = "hide",
})
end

exports('TextUI', TextUI)
exports('HideUI', HideUI)
RegisterNetEvent('ESX:TextUI', TextUI)
RegisterNetEvent('ESX:HideUI', HideUI)
exports("TextUI", TextUI)
exports("HideUI", HideUI)
RegisterNetEvent("ESX:TextUI", TextUI)
RegisterNetEvent("ESX:HideUI", HideUI)

if Debug then
RegisterCommand("textui:error", function()
Expand All @@ -37,4 +42,4 @@ if Debug then
RegisterCommand("textui:hide", function()
ESX.HideUI()
end)
end
end
2 changes: 1 addition & 1 deletion server-data/resources/[esx]/esx_textui/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fx_version 'adamant'
game 'gta5'
author 'ESX-Framework'
version '0.0.4'
version '1.0.0'
description 'ESX TextUI'
lua54 'yes'
client_scripts { 'TextUI.lua' }
Expand Down
23 changes: 9 additions & 14 deletions server-data/resources/[esx]/esx_textui/nui/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ body {
min-width: 15%;
width: fit-content;
height: 50px;
background: rgba(5,5,5,.9);
border-radius: .5rem;
background: rgba(5, 5, 5, 0.9);
border-radius: 0.5rem;
animation: growDown 300ms ease-in-out;
align-items: center;
}
Expand All @@ -43,8 +43,8 @@ body {
}

.innerText {
padding-left: .4rem;
padding-right: .4rem;
padding-left: 0.4rem;
padding-right: 0.4rem;
padding-top: 12.5px;
width: 100%;
height: 100%;
Expand All @@ -56,27 +56,22 @@ body {

.innerText .text {
display: inline-block;
margin-left: .5rem;
margin-left: 0.5rem;
margin-top: 4px;
}


@keyframes growDown {
0% {
transform: scaleY(0);
}
80% {
transform: scaleY(1.1)
transform: scaleY(1.1);
}
100% {
transform: scaleY(1)
transform: scaleY(1);
}
}

.material-symbols-outlined {
font-variation-settings:
'FILL' 0,
'wght' 400,
'GRAD' 0,
'opsz' 48
}
font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 48;
}
5 changes: 2 additions & 3 deletions server-data/resources/[esx]/esx_textui/nui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<script src="https://kit.fontawesome.com/a81368914c.js"></script>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/style.css" />
<script src="js/script.js"></script>

</head>
<body>
<div id="notifyInfo" class="notify info">
Expand All @@ -27,4 +26,4 @@
</div>
</div>
</body>
</html>
</html>
36 changes: 17 additions & 19 deletions server-data/resources/[esx]/esx_textui/nui/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const types = {
["info"]: {
["message"]: "infoMessage",
["id"]: "notifyInfo",
}
}
},
};

// the color codes example `i ~r~love~s~ donuts`
const codes = {
Expand All @@ -28,42 +28,41 @@ const codes = {
"~c~": "grey",
"~m~": "#212121",
"~u~": "black",
"~o~": "orange"
}
"~o~": "orange",
};

w.addEventListener('message', (event) => {
w.addEventListener("message", (event) => {
if (event.data.action === "show") {
if (lastType) {
doc.getElementById(lastType).style.display = "none";
notification({
type: event.data.type,
message: event.data.message
message: event.data.message,
});
} else {
notification({
type: event.data.type,
message: event.data.message
message: event.data.message,
});
}
} else
if (event.data.action === "hide") {
} else if (event.data.action === "hide") {
if (lastType !== "") {
doc.getElementById(lastType).style.display = "none"
doc.getElementById(lastType).style.display = "none";
} else {
console.log("There isn't a textUI displaying!?")
console.log("There isn't a textUI displaying!?");
}
}
});

const replaceColors = (str, obj) => {
let strToReplace = str
let strToReplace = str;

for (let id in obj) {
strToReplace = strToReplace.replace(new RegExp(id, 'g'), obj[id])
strToReplace = strToReplace.replace(new RegExp(id, "g"), obj[id]);
}

return strToReplace
}
return strToReplace;
};

notification = (data) => {
for (color in codes) {
Expand All @@ -79,7 +78,6 @@ notification = (data) => {
}

doc.getElementById(types[data.type]["id"]).style.display = "block";
lastType = types[data.type]["id"]
doc.getElementById(types[data.type]["message"]).innerHTML = data["message"]

}
lastType = types[data.type]["id"];
doc.getElementById(types[data.type]["message"]).innerHTML = data["message"];
};

0 comments on commit 7a7dc4b

Please sign in to comment.