Skip to content

Commit

Permalink
feat(bridge): add position parameter in web_app_setup_secondary_butto…
Browse files Browse the repository at this point in the history
…n. Export SecondaryButtonPosition type
  • Loading branch information
heyqbnk committed Oct 1, 2024
1 parent 71aef19 commit 705e047
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
29 changes: 21 additions & 8 deletions packages/bridge/src/methods/types/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
OpenLinkBrowser,
BottomBarColor,
BackgroundColor,
SecondaryButtonPosition,
} from './misc.js';

interface ButtonParams {
Expand All @@ -20,30 +21,30 @@ interface ButtonParams {
*/
has_shine_effect?: boolean;
/**
* Should the Main Button be displayed.
* Should the button be displayed.
*/
is_visible?: boolean;
/**
* Should the Main Button be enabled.
* Should the button be enabled.
*/
is_active?: boolean;
/**
* Should loader inside the Main Button be displayed. Use this property in case, some
* Should loader inside the button be displayed. Use this property in case, some
* operation takes time. This loader will make user notified about it.
*/
is_progress_visible?: boolean;
/**
* Text inside the Main Button.
* Text inside the button.
*/
text?: string;
/**
* The Main Button background color in `#RRGGBB` format.
* The button background color in `#RRGGBB` format.
*/
color?: string;
color?: RGB;
/**
* The Main Button text color in `#RRGGBB` format.
*/
text_color?: string;
text_color?: RGB;
}

/**
Expand Down Expand Up @@ -368,7 +369,19 @@ export interface Methods {
* Updates the secondary button settings.
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-setup-secondary-button
*/
web_app_setup_secondary_button: CreateParams<ButtonParams>;
web_app_setup_secondary_button: CreateParams<ButtonParams & {
/**
* Position of the secondary button. It applies only if both the main and secondary buttons
* are visible.
*
* Supported values:
* - `left`, displayed to the left of the main button.
* - `right`, displayed to the right of the main button.
* - `top`, displayed above the main button.
* - `bottom`, displayed below the main button.
*/
position?: SecondaryButtonPosition;
}>;
/**
* Updates the current state of the Settings Button.
* @since v6.10
Expand Down
5 changes: 5 additions & 0 deletions packages/bridge/src/methods/types/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export type BackgroundColor = KnownColorKey | RGB;
*/
export type BottomBarColor = KnownColorKey | 'bottom_bar_bg_color' | RGB;

/**
* Position of the secondary button related to the main one.
*/
export type SecondaryButtonPosition = 'left' | 'right' | 'top' | 'bottom';

/**
* Values expected by the `web_app_open_link.try_browser` option.
*/
Expand Down

0 comments on commit 705e047

Please sign in to comment.