Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ declare namespace LocalJSX {
interface PwaActionSheet {
"cancelable"?: boolean;
"header"?: string;
"onOnCanceled"?: (event: PwaActionSheetCustomEvent<any>) => void;
"onOnSelection"?: (event: PwaActionSheetCustomEvent<any>) => void;
"options"?: ActionSheetOption[];
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/action-sheet/action-sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class PWAActionSheet {

@Event() onSelection: EventEmitter;

@Event() onCanceled: EventEmitter;

@State() open = false;

componentDidLoad() {
Expand All @@ -28,6 +30,7 @@ export class PWAActionSheet {

dismiss() {
if (this.cancelable) {
this.onCanceled.emit();
this.close();
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@
b.addEventListener('click', async (ev) => {
const actionSheet = document.createElement('pwa-action-sheet');
actionSheet.header = 'choose option';
actionSheet.cancelable = false;
actionSheet.cancelable = true;
actionSheet.options = [{title: 'hi'},{title: 'bye', style: "DESTRUCTIVE"},{title: 'cancel', style: "CANCEL"}]
document.body.appendChild(actionSheet);
actionSheet.addEventListener('onSelection', async (e) => {
const selection = e.detail;
console.log('selected', selection);
})
actionSheet.addEventListener('onCanceled', async () => {
console.log('sheet was canceled');
})
});
</script>

Expand Down