Skip to content

Commit

Permalink
feat: add toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Jan 8, 2025
1 parent 4001124 commit 428eff8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/elements/sidebar/sidebar/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ The `sbb-sidebar` is a component . . .

## Methods

| Name | Privacy | Description | Parameters | Return | Inherited From |
| ------- | ------- | ------------------- | --------------- | ------ | ----------------------- |
| `close` | public | Closes the sidebar. | `skipAnimation` | `void` | SbbOpenCloseBaseElement |
| `open` | public | Opens the sidebar. | `skipAnimation` | `void` | SbbOpenCloseBaseElement |
| Name | Privacy | Description | Parameters | Return | Inherited From |
| -------- | ------- | ------------------------------- | ---------- | ------ | ----------------------- |
| `close` | public | Closes the sidebar. | | `void` | SbbOpenCloseBaseElement |
| `open` | public | Opens the sidebar. | | `void` | SbbOpenCloseBaseElement |
| `toggle` | public | Toggles the sidebar visibility. | | `void` | |

## Events

Expand Down
9 changes: 9 additions & 0 deletions src/elements/sidebar/sidebar/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ class SbbSidebarElement extends SbbOpenCloseBaseElement {
this.didClose.emit();
}

/** Toggles the sidebar visibility. */
public toggle(): void {
if (this.state === 'opened') {
this.close();
} else if (this.state === 'closed') {
this.open();
}
}

private _updateSidebarWidth(oldPosition?: 'start' | 'end'): void {
const container = this.container;
if (!container) {
Expand Down

0 comments on commit 428eff8

Please sign in to comment.