Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typing #19

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.1.3 - 2024-05-25

### Fixed
- Type errors

# 0.1.2 - 2024-05-10

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import WinMB from '@skwalexe/winmb'
If you use this method, the library will be available globally as `WinMB`.

```js
<script src="https://cdn.jsdelivr.net/npm/@skwalexe/[email protected].2/dist/winmb.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@skwalexe/[email protected].3/dist/winmb.umd.js"></script>
```

# Using this library 📦
Expand All @@ -58,7 +58,7 @@ This library exports a `WinMB` class which acccepts the following parameters:
- `assetsUrl / required`: WinMB needs to load **remote assets** such as css stylesheets, sounds, and images, which you can host on your own servers. This parameter is used to tell WinMB where it can find these assets. You must provide a **base url**, to which WinMB will just append the requested asset's file name. If you don't want to host the assets yourself, you can use JSDelivr like in the example below.

```js
const wmbEngine = WinMB('https://cdn.jsdelivr.net/gh/SkwalExe/[email protected].2/src/assets/')
const wmbEngine = WinMB('https://cdn.jsdelivr.net/gh/SkwalExe/[email protected].3/src/assets/')
```

Once you instanciated the `WinMB` class, it exposes the follwing methods:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skwalexe/winmb",
"version": "0.1.2",
"version": "0.1.3",
"description": "Windows-like dialogue boxes for your website",
"main": "./dist/lib-cjs/main.js",
"module": "./dist/lib-esm/main.js",
Expand Down
8 changes: 5 additions & 3 deletions src/winmb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ const cssFileName = 'winmb.css'
// Must be the same as in winmb.css
const cssClass = 'winmb'

interface Button {
type ButtonValue = string | number | boolean

type Button = {
text: string
value: string | number | boolean
value?: ButtonValue
}

export default class WinMB {
Expand Down Expand Up @@ -57,7 +59,7 @@ export default class WinMB {
type: string = 'error',
buttons: Button[] = [{text: 'ok', value: true}],
position: string | Array<number> = 'default'
): Promise<boolean | string | number> => {
): Promise<ButtonValue> => {
if (typeof position === 'string' && !['random', 'default'].includes(position))
throw new Error(
'Position must be either "random", "default", or an array of two numbers [x, y].'
Expand Down