Skip to content

Commit

Permalink
docs(sdk): add SettingsButton docs
Browse files Browse the repository at this point in the history
  • Loading branch information
heyqbnk committed Dec 15, 2023
1 parent 2e60a34 commit a02d01c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/docs/.vitepress/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export const packagesSidebar = {
text: 'QRScanner',
link: prefixed('/typescript/tma-js-sdk/components/qr-scanner'),
},
{
text: 'SettingsButton',
link: prefixed('/typescript/tma-js-sdk/components/settings-button'),
},
{
text: 'ThemeParams',
link: prefixed('/typescript/tma-js-sdk/components/theme-params'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# `SettingsButton`

Implements Telegram Mini Apps [Settings Button](../../../../platform/ui/settings-button.md).

## Initialization

Component constructor accepts visibility state, Telegram Mini Apps version and optional function
to call Telegram Mini Apps methods.

```typescript
import { SettingsButton, postEvent } from '@tma.js/sdk';

const settingsButton = new SettingsButton(false, '6.3', postEvent);
```

## Showing and hiding

To show and hide the `SettingsButton`, it is required to use `show()` and `hide()` methods. These
methods update the button's `isVisible` property:

```typescript
settingsButton.show();
console.log(settingsButton.isVisible); // true

settingsButton.hide();
console.log(settingsButton.isVisible); // false
```

## Events

List of events, which could be used in `on` and `off` component instance methods:

| Event | Listener | Triggered when |
|------------------|----------------------------|--------------------------------|
| click | `() => void` | Settings Button was clicked |
| change | `() => void` | Something in component changed |
| change:isVisible | `(value: boolean) => void` | `isVisible` property changed |

## Methods support

List of methods, which could be used in `supports` component instance method:

- `show`
- `hide`

```typescript
import { SettingsButton } from '@tma.js/sdk';

const settingsButton = new SettingsButton(...);
settingsButton.supports('show');
settingsButton.supports('hide');
```

0 comments on commit a02d01c

Please sign in to comment.