Skip to content

Commit e89349b

Browse files
authored
Merge pull request #163 from JerryI/canary
prompt window improvs
2 parents c069ccf + 7fe99e7 commit e89349b

29 files changed

+1275
-703
lines changed

.DS_Store

2 KB
Binary file not shown.

Electron/.DS_Store

0 Bytes
Binary file not shown.

Electron/main.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ const windows = {
715715
win = new BrowserWindow({
716716
vibrancy: "sidebar", // in my case...
717717
frame: true,
718+
718719
titleBarStyle: 'hiddenInset',
719720
width: 600,
720721
height: 400,
@@ -730,7 +731,7 @@ const windows = {
730731
win = new BrowserWindow({
731732
vibrancy: "sidebar", // in my case...
732733
frame: true,
733-
734+
autoHideMenuBar: true,
734735
width: 600,
735736
height: 400,
736737
resizable: false,
@@ -1315,8 +1316,12 @@ const powerSaver = () => {
13151316

13161317
app.whenReady().then(() => {
13171318
if (!isMac) {
1318-
tray = new Tray(path.join(__dirname, 'build', '256x256_new.ico'));
1319-
console.log(path.join(__dirname, 'build', '256x256_new.ico'));
1319+
if (!isWindows) {
1320+
tray = new Tray(path.join(__dirname, 'build', '512x512.png'));
1321+
} else {
1322+
tray = new Tray(path.join(__dirname, 'build', '256x256_new.ico'));
1323+
}
1324+
//console.log(path.join(__dirname, 'build', '256x256_new.ico'));
13201325
tray.setToolTip('Sorry, I am buzy');
13211326
tray.setContextMenu(Menu.buildFromTemplate([
13221327
{
@@ -1565,7 +1570,7 @@ function create_first_window() {
15651570
server.wasUpdated = false;
15661571
}
15671572

1568-
const prompt = require('native-prompt')
1573+
const prompt = require('./native-prompt-leo/')
15691574

15701575
const promts_hash = {}
15711576
class promt {
6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.npmignore
2+
dist
3+
tsconfig.tsbuildinfo
4+
desktop.ini
5+
node_modules
6+
bun.lockb
7+
native-prompt-*.tgz

Electron/native-prompt-leo/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 ssight
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# `native-prompt`
2+
Create native prompts with Node.js and Electron
3+
4+
# What is this?
5+
While `alert` and `confirm` are both supported in Electron, `prompt` isn't (see [this issue](https://github.com/electron/electron/issues/472)). `native-prompt` aims to fix this by allowing you to create prompt boxes that are native to the user's OS. As an added bonus, it also works in Node.js.
6+
7+
# Screenshots
8+
## Windows
9+
![A prompt showing on Windows](https://raw.githubusercontent.com/ssight/native-prompt/master/screenshots/Windows.png)
10+
## Linux
11+
![A prompt showing on Linux](https://raw.githubusercontent.com/ssight/native-prompt/master/screenshots/Linux.png)
12+
## MacOS
13+
![A prompt showing on MacOS](https://raw.githubusercontent.com/ssight/native-prompt/master/screenshots/MacOS.png)
14+
15+
# Installation
16+
### Through [NPM](https://www.npmjs.com/package/native-prompt):
17+
>`npm i native-prompt`
18+
### ...or the long way:
19+
>`npm install native-prompt@latest --save`
20+
21+
# Usage
22+
## Synopsis
23+
```js
24+
prompt (title, body, options)
25+
```
26+
### `title:string`
27+
>The title you want to display at the top of the window
28+
### `body:string`
29+
>Any helpful text to go inside the message box
30+
### `options: { defaultText?: string; mask?: boolean; okButtonLabel?: string; cancelButtonLabel?: string }`
31+
>Any (optional) extra options (see below)
32+
33+
## Options
34+
### `defaultText?: string`
35+
>The text you want to already be in the input box beforehand
36+
### `mask?: boolean`
37+
>Whether you want the box to have a hidden input
38+
### `okButtonLabel?: string`
39+
>The label for the "ok" button, it only works on windows and linux and by default in linux it is not set and in windows it is set as "Ok"
40+
### `cancelButtonLabel?: string`
41+
>The label for the "cancel" button, it only works on windows and linux and by default in linux it is not set and in windows it is set as "Cancel"
42+
43+
## Examples
44+
### Importing
45+
#### Javascript
46+
```js
47+
const prompt = require('native-prompt')
48+
```
49+
#### Typescript
50+
```ts
51+
import prompt from 'native-prompt'
52+
```
53+
---
54+
### Async function usage
55+
```js
56+
(async () => {
57+
const text = await prompt("This is a title.", "What would you really like to see next?", { defaultText: "Nothing" });
58+
if (text) {
59+
// Do something with the input
60+
} else {
61+
// The user either clicked cancel or left the space blank
62+
}
63+
})()
64+
```
65+
### Regular promise usage
66+
```js
67+
prompt("This is a title.", "What would you really like to see next?", { defaultText: "Nothing" }).then(text => {
68+
if (text) {
69+
// Do something with the input
70+
} else {
71+
// The user either clicked cancel or left the space blank
72+
}
73+
})
74+
```
75+
76+
### Masked textbox example
77+
```js
78+
(async () => {
79+
const password = await prompt("Login", "Enter your password to log back in.", { mask: true });
80+
if (isCorrectPassword(password)) {
81+
// Log the user in
82+
} else {
83+
// The user's entered their username or password incorrect
84+
}
85+
})()
86+
```
87+
88+
### Ok and Cancel buttons modified example
89+
```js
90+
(async () => {
91+
const text = await prompt("Your Name", "Write your name.", { okButtonLabel: "Submit", cancelButtonLabel: "Abort" });
92+
if (text) {
93+
// Do something with the input
94+
} else {
95+
// The user either clicked cancel or left the space blank
96+
}
97+
})()
98+
```
99+
100+
# Notes
101+
* If you plan on using `asar` to package your electron app, make sure to read [this](https://github.com/ssight/native-prompt/wiki/Usage-with-asar)
102+
* For differences between 1.x and 2.x, see [this](https://github.com/ssight/native-prompt/wiki/Differences-between-1.x-and-2.x) wiki page.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
on run (clp)
2+
display dialog clp's item 2 with title clp's item 1 default answer clp's item 3 buttons {"Cancel", "OK"} default button 2
3+
end run
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
on run (clp)
2+
display dialog clp's item 2 with title clp's item 1 default answer clp's item 3 buttons {"Cancel", "OK"} default button 2 with hidden answer
3+
end run
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
zenity --entry --title="$1" --text="$2" --entry-text="$3" $4 $5 $6

0 commit comments

Comments
 (0)