-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
apps/docs/packages/typescript/tma-js-sdk/components/settings-button.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
``` |