Skip to content

Commit

Permalink
Merge pull request #19 from SkwalExe/fix-typing
Browse files Browse the repository at this point in the history
fix typing
  • Loading branch information
SkwalExe authored May 25, 2024
2 parents 64851e3 + 49a08f9 commit d9bb48b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
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

0 comments on commit d9bb48b

Please sign in to comment.