Skip to content

Commit a1624ec

Browse files
committed
[#47] fix layout sidebar visibility in storybook
1 parent f94ddb2 commit a1624ec

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

components/LayoutSidebar/LayoutSidebar.vue

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,14 @@ export default defineComponent({
7070
type: Boolean,
7171
required: true,
7272
},
73-
},
74-
// TODO: fix visible component story with async setup
75-
async setup() {
76-
if (process.client) {
77-
const { $config, $api } = useNuxtApp();
78-
79-
const apiVersion = await $api.getVersion();
80-
81-
return {
82-
apiVersion: String(apiVersion).match(/^[0-9.]+.*$/)
83-
? `v${apiVersion}`
84-
: `@${apiVersion}`,
85-
clientVersion:
86-
!$config?.version || $config.version === "0.0.1"
87-
? "@dev"
88-
: `v${$config.version}`,
89-
};
90-
}
91-
92-
return {
93-
clientVersion: "@dev",
94-
apiVersion: "@dev",
95-
};
73+
apiVersion: {
74+
type: String,
75+
default: "@dev",
76+
},
77+
clientVersion: {
78+
type: String,
79+
default: "@dev",
80+
},
9681
},
9782
});
9883
</script>

layouts/default.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<template>
22
<div class="main-layout">
33
<div class="main-layout__sidebar-wrap">
4-
<LayoutSidebar :is-connected="isConnected" />
4+
<LayoutSidebar
5+
:is-connected="isConnected"
6+
:api-version="apiVersion"
7+
:client-version="clientVersion"
8+
/>
59
</div>
610

711
<div class="main-layout__content">
@@ -22,20 +26,36 @@ export default defineComponent({
2226
LayoutSidebar,
2327
},
2428
25-
setup() {
29+
async setup() {
2630
const themeStore = useThemeStore();
2731
const { themeType } = storeToRefs(themeStore);
32+
const { $config, $api } = useNuxtApp();
33+
34+
const apiVersion = await $api.getVersion();
2835
2936
if (process.client) {
3037
const { $events } = useNuxtApp();
3138
3239
if (!$events?.items?.length) {
3340
$events.getAll();
3441
}
42+
43+
return {
44+
themeType,
45+
apiVersion: String(apiVersion).match(/^[0-9.]+.*$/)
46+
? `v${apiVersion}`
47+
: `@${apiVersion}`,
48+
clientVersion:
49+
!$config?.version || $config.version === "0.0.1"
50+
? "@dev"
51+
: `v${$config.version}`,
52+
};
3553
}
3654
3755
return {
3856
themeType,
57+
clientVersion: "@dev",
58+
apiVersion: "@dev",
3959
};
4060
},
4161
computed: {

0 commit comments

Comments
 (0)