Skip to content

Commit 4d6609a

Browse files
committed
New Example - Frameless
1 parent 8ed4475 commit 4d6609a

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

examples/frameless/frameless.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// To run this script:
2+
// deno run --allow-read --allow-write --allow-net --allow-env --allow-ffi frameless.ts
3+
4+
// To import from local (Debugging and Development)
5+
// import { WebUI } from "../../mod.ts";
6+
7+
// To import from online package registry (Production)
8+
import { WebUI } from "@webui/deno-webui"; // import {WebUI} from "https://deno.land/x/[email protected]/mod.ts";
9+
10+
const myHtml = `
11+
<html>
12+
<head>
13+
<meta charset='UTF-8'>
14+
<script src="webui.js"></script>
15+
<style>
16+
* { margin: 0; padding: 0; box-sizing: border-box; }
17+
html, body { height: 100%; width: 100%; overflow: hidden; background: transparent; }
18+
#titlebar {
19+
height: 40px;
20+
background: linear-gradient(to right, #2c3e50, #34495e);
21+
color: white;
22+
display: flex;
23+
align-items: center;
24+
justify-content: space-between;
25+
padding: 0 15px;
26+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
27+
-webkit-app-region: drag;
28+
--webui-app-region: drag;
29+
font-family: Arial, sans-serif;
30+
}
31+
#title { font-size: 16px; font-weight: bold; }
32+
#buttons { -webkit-app-region: no-drag; }
33+
.button {
34+
display: inline-block;
35+
width: 24px;
36+
height: 24px;
37+
margin-left: 8px;
38+
border-radius: 50%;
39+
text-align: center;
40+
line-height: 24px;
41+
cursor: pointer;
42+
transition: all 0.2s;
43+
}
44+
.minimize { background: #f1c40f; }
45+
.maximize { background: #2ecc71; }
46+
.close { background: #e74c3c; }
47+
.button:hover { filter: brightness(120%); }
48+
#content {
49+
height: calc(100% - 40px);
50+
background: rgba(0, 0, 0, 0.7);
51+
display: flex;
52+
align-items: center;
53+
justify-content: center;
54+
}
55+
#message {
56+
color: white;
57+
font-size: 32px;
58+
font-family: Arial, sans-serif;
59+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
60+
}
61+
</style>
62+
</head>
63+
<body>
64+
<div id='titlebar'>
65+
<span id='title'>WebUI Deno Frameless Window</span>
66+
<div id='buttons'>
67+
<span class='button minimize' onclick='minimize()'>–</span>
68+
<span class='button close' onclick='close_win()'>✕</span>
69+
</div>
70+
</div>
71+
<div id='content'>
72+
<span id='message'>This is a WebUI Deno frameless example</span>
73+
</div>
74+
</body>
75+
</html>`;
76+
77+
// Create new window
78+
const myWindow = new WebUI();
79+
80+
// Bind
81+
myWindow.bind("minimize", () => {
82+
myWindow.minimize();
83+
});
84+
myWindow.bind("close_win", () => {
85+
WebUI.exit();
86+
});
87+
88+
myWindow.setSize(800, 600);
89+
myWindow.setFrameless(true);
90+
myWindow.setTransparent(true);
91+
myWindow.setResizable(false);
92+
myWindow.setCenter();
93+
94+
// Show the window
95+
await myWindow.showWebView(myHtml); // in Microsoft Windows you may need `WebView2Loader.dll`
96+
97+
// Wait until all windows get closed
98+
await WebUI.wait();
99+
100+
console.log("Thank you.");

0 commit comments

Comments
 (0)