Skip to content

Commit 2001a3f

Browse files
committed
Loading lists only after tab selection
1 parent c820dcd commit 2001a3f

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

src/pages/Popup.vue

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,25 @@
77
</div>
88
</div>
99
<div class="tabs">
10-
<input type="radio" id="todayTab" name="tab-control" checked />
11-
<input type="radio" id="allTimeTab" name="tab-control" />
12-
<input type="radio" id="byDaysTab" name="tab-control" />
10+
<input
11+
type="radio"
12+
id="todayTab"
13+
name="tab-control"
14+
checked
15+
v-on:change="selectTab(TypeOfList.Today)"
16+
/>
17+
<input
18+
type="radio"
19+
id="allTimeTab"
20+
name="tab-control"
21+
v-on:change="selectTab(TypeOfList.All)"
22+
/>
23+
<input
24+
type="radio"
25+
id="byDaysTab"
26+
name="tab-control"
27+
v-on:change="selectTab(TypeOfList.ByDays)"
28+
/>
1329
<ul>
1430
<li title="Today">
1531
<label for="todayTab" role="button"><span>Today</span></label>
@@ -25,10 +41,14 @@
2541
<div class="slider"><div class="indicator"></div></div>
2642
<div class="content">
2743
<section>
28-
<TabList :type="TypeOfList.Today" :showAllStats="false" />
44+
<TabList
45+
v-if="activeTab == TypeOfList.Today"
46+
:type="TypeOfList.Today"
47+
:showAllStats="false"
48+
/>
2949
</section>
3050
<section>
31-
<TabList :type="TypeOfList.All" :showAllStats="true" />
51+
<TabList v-if="activeTab == TypeOfList.All" :type="TypeOfList.All" :showAllStats="true" />
3252
</section>
3353
<section>
3454
<h2>Shipping</h2>
@@ -38,6 +58,7 @@
3858
</template>
3959

4060
<script lang="ts" setup>
61+
import { onMounted, ref } from 'vue';
4162
import Browser from 'webextension-polyfill';
4263
import TabList from '../components/TabList.vue';
4364
import { TypeOfList } from '../utils/enums';
@@ -48,6 +69,16 @@ async function openSettings() {
4869
active: true,
4970
});
5071
}
72+
73+
const activeTab = ref<TypeOfList>();
74+
75+
onMounted(() => {
76+
activeTab.value = TypeOfList.Today;
77+
});
78+
79+
function selectTab(type: TypeOfList) {
80+
activeTab.value = type;
81+
}
5182
</script>
5283

5384
<style scoped>

0 commit comments

Comments
 (0)