From 4707e711f6e9681432f9e5e90b5840b9b209ad0c Mon Sep 17 00:00:00 2001 From: Arnau Giralt Date: Tue, 20 Feb 2024 11:26:48 +0100 Subject: [PATCH] Add option to show a back button to Navigation and View components --- components/src/stories/Navigation.stories.js | 7 +++- components/src/stories/View.stories.js | 12 +++++- components/src/widgets/navigation/widget.vue | 39 ++++++++++++++++++++ components/src/widgets/view/widget.vue | 9 +++++ 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/components/src/stories/Navigation.stories.js b/components/src/stories/Navigation.stories.js index 2052ddf9..4934c6f0 100644 --- a/components/src/stories/Navigation.stories.js +++ b/components/src/stories/Navigation.stories.js @@ -8,11 +8,14 @@ export const Component = { setup() { return { args }; }, - template: '
', + template: '
', methods: { setTab({ detail }) { this.args.currentTab = detail; }, + goBack() { + alert('The back button was clicked!'); + }, }, }), @@ -24,6 +27,7 @@ export const Component = { { value: 'first', label: 'First tab' }, { value: 'second', label: 'Second tab' }, ], + showBackButton: false, }, }; @@ -43,5 +47,6 @@ export default { control: 'select', options: Component.args.tabs.map(v => v.value), }, + showBackButton: 'boolean', }, }; diff --git a/components/src/stories/View.stories.js b/components/src/stories/View.stories.js index d083f5b8..da1f2ef3 100644 --- a/components/src/stories/View.stories.js +++ b/components/src/stories/View.stories.js @@ -9,12 +9,18 @@ export const Component = { return { args }; }, template: ` - +
Loader slot: Loading...

First tab content

Second tab content

-
`, +
+ `, + methods: { + goBack() { + alert('The back button was clicked!'); + }, + }, }), args: { @@ -27,6 +33,7 @@ export const Component = { { value: 'first', label: 'First tab' }, { value: 'second', label: 'Second tab' }, ], + showBackButton: false, }, }; @@ -45,5 +52,6 @@ export default { control: 'object', }, currentTab: 'text', + showBackButton: 'boolean', }, }; diff --git a/components/src/widgets/navigation/widget.vue b/components/src/widgets/navigation/widget.vue index 8ccf3996..24270feb 100644 --- a/components/src/widgets/navigation/widget.vue +++ b/components/src/widgets/navigation/widget.vue @@ -1,5 +1,16 @@