Skip to content

Commit ce0cedc

Browse files
CorentinThsharevb
authored andcommitted
refactor(home): removed n-grid to prevent layout shift (CorentinTh#881)
1 parent 6f7424b commit ce0cedc

File tree

1 file changed

+39
-55
lines changed

1 file changed

+39
-55
lines changed

src/pages/Home.page.vue

Lines changed: 39 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,76 +13,60 @@ const { t } = useI18n();
1313
</script>
1414

1515
<template>
16-
<div class="home-page">
16+
<div class="pt-50px">
1717
<div class="grid-wrapper">
18-
<n-grid v-if="config.showBanner" x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8">
19-
<n-gi>
20-
<ColoredCard :title="$t('home.follow.title')" :icon="Heart">
21-
{{ $t('home.follow.p1') }}
22-
<a
23-
href="https://github.com/CorentinTh/it-tools"
24-
rel="noopener"
25-
target="_blank"
26-
:aria-label="$t('home.follow.githubRepository')"
27-
>GitHub</a>
28-
{{ $t('home.follow.p2') }}
29-
<a
30-
href="https://twitter.com/ittoolsdottech"
31-
rel="noopener"
32-
target="_blank"
33-
:aria-label="$t('home.follow.twitterAccount')"
34-
>Twitter</a>.
35-
{{ $t('home.follow.thankYou') }}
36-
<n-icon :component="Heart" />
37-
</ColoredCard>
38-
</n-gi>
39-
</n-grid>
18+
<div v-if="config.showBanner" class="grid grid-cols-1 gap-12px lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 xl:grid-cols-4">
19+
<ColoredCard :title="$t('home.follow.title')" :icon="Heart">
20+
{{ $t('home.follow.p1') }}
21+
<a
22+
href="https://github.com/CorentinTh/it-tools"
23+
rel="noopener"
24+
target="_blank"
25+
:aria-label="$t('home.follow.githubRepository')"
26+
>GitHub</a>
27+
{{ $t('home.follow.p2') }}
28+
<a
29+
href="https://twitter.com/ittoolsdottech"
30+
rel="noopener"
31+
target="_blank"
32+
:aria-label="$t('home.follow.twitterAccount')"
33+
>Twitter</a>.
34+
{{ $t('home.follow.thankYou') }}
35+
<n-icon :component="Heart" />
36+
</ColoredCard>
37+
</div>
4038

4139
<transition name="height">
4240
<div v-if="toolStore.favoriteTools.length > 0">
43-
<n-h3>{{ $t('home.categories.favoriteTools') }}</n-h3>
44-
<n-grid x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8">
45-
<n-gi v-for="tool in toolStore.favoriteTools" :key="tool.name">
46-
<ToolCard :tool="tool" />
47-
</n-gi>
48-
</n-grid>
41+
<h3 class="mb-5px mt-25px font-500 text-neutral-400">
42+
{{ $t('home.categories.favoriteTools') }}
43+
</h3>
44+
<div class="grid grid-cols-1 gap-12px lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 xl:grid-cols-4">
45+
<ToolCard v-for="tool in toolStore.favoriteTools" :key="tool.name" :tool="tool" />
46+
</div>
4947
</div>
5048
</transition>
5149

5250
<div v-if="toolStore.newTools.length > 0">
53-
<n-h3>{{ t('home.categories.newestTools') }}</n-h3>
54-
<n-grid x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8">
55-
<n-gi v-for="tool in toolStore.newTools" :key="tool.name">
56-
<ToolCard :tool="tool" />
57-
</n-gi>
58-
</n-grid>
51+
<h3 class="mb-5px mt-25px font-500 text-neutral-400">
52+
{{ t('home.categories.newestTools') }}
53+
</h3>
54+
<div class="grid grid-cols-1 gap-12px lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 xl:grid-cols-4">
55+
<ToolCard v-for="tool in toolStore.newTools" :key="tool.name" :tool="tool" />
56+
</div>
5957
</div>
6058

61-
<n-h3>{{ $t('home.categories.allTools') }}</n-h3>
62-
<n-grid x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8">
63-
<n-gi v-for="tool in toolStore.tools" :key="tool.name">
64-
<transition>
65-
<ToolCard :tool="tool" />
66-
</transition>
67-
</n-gi>
68-
</n-grid>
59+
<h3 class="mb-5px mt-25px font-500 text-neutral-400">
60+
{{ $t('home.categories.allTools') }}
61+
</h3>
62+
<div class="grid grid-cols-1 gap-12px lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 xl:grid-cols-4">
63+
<ToolCard v-for="tool in toolStore.tools" :key="tool.name" :tool="tool" />
64+
</div>
6965
</div>
7066
</div>
7167
</template>
7268

7369
<style scoped lang="less">
74-
.home-page {
75-
padding-top: 50px;
76-
}
77-
78-
.n-h3 {
79-
margin-bottom: 10px;
80-
}
81-
82-
::v-deep(.n-grid) {
83-
margin-bottom: 30px;
84-
}
85-
8670
.height-enter-active,
8771
.height-leave-active {
8872
transition: all 0.5s ease-in-out;

0 commit comments

Comments
 (0)