Skip to content

Commit e0b120d

Browse files
committed
minor fixes and prettier
1 parent 9451c97 commit e0b120d

File tree

16 files changed

+129
-139
lines changed

16 files changed

+129
-139
lines changed

examples/nuxt/template-hierarchy-data-fetching/example-app/assets/scss/components/button.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
&.button-primary {
1111
background-color: $primary-color;
12+
border-color: $primary-color;
1213
&:hover {
1314
background-color: color.scale($primary-color, $lightness: -15%);
1415
}

examples/nuxt/template-hierarchy-data-fetching/example-app/assets/scss/components/comments/comment-form.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
gap: 1rem;
55
background-color: #f9f9f9;
66
padding: 1rem;
7+
margin-top: 1rem;
78
}
89
.message-container {
910
margin-bottom: 1rem;

examples/nuxt/template-hierarchy-data-fetching/example-app/assets/scss/components/comments/comment-item.scss

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
border: 1px solid #ccc;
66
border-radius: 5px;
77
margin-bottom: 10px;
8+
background: #f9fafb;
9+
border-radius: 0.5rem;
10+
padding: 1rem;
11+
margin-bottom: 1rem;
812
.comment-header {
913
display: flex;
1014
justify-content: space-between;
@@ -37,3 +41,62 @@
3741
margin-left: 15px;
3842
}
3943
}
44+
.comment-meta {
45+
display: flex;
46+
align-items: flex-start;
47+
margin-bottom: 0.75rem;
48+
}
49+
50+
.comment-avatar {
51+
width: 40px;
52+
height: 40px;
53+
border-radius: 50%;
54+
margin-right: 0.75rem;
55+
flex-shrink: 0;
56+
}
57+
58+
.comment-info {
59+
flex: 1;
60+
}
61+
62+
.comment-author {
63+
font-weight: 600;
64+
margin-bottom: 0.25rem;
65+
}
66+
67+
.author-link {
68+
color: #3b82f6;
69+
text-decoration: none;
70+
}
71+
72+
.author-link:hover {
73+
text-decoration: underline;
74+
}
75+
76+
.author-name {
77+
color: #374151;
78+
}
79+
80+
.comment-date {
81+
color: #6b7280;
82+
font-size: 0.875rem;
83+
}
84+
85+
.comment-content {
86+
margin-bottom: 0.75rem;
87+
line-height: 1.6;
88+
}
89+
90+
.comment-content :deep(p) {
91+
margin-bottom: 0.5rem;
92+
}
93+
94+
.comment-content :deep(p:last-child) {
95+
margin-bottom: 0;
96+
}
97+
98+
.comment-actions {
99+
display: flex;
100+
justify-content: flex-end;
101+
gap: 1rem;
102+
}

examples/nuxt/template-hierarchy-data-fetching/example-app/assets/scss/components/header/header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515

1616
.site-title-wrapper a {
17-
font-size: 1.5rem;
17+
font-size: 1.25rem;
1818
font-weight: bold;
1919
text-decoration: none;
2020
color: #333;

examples/nuxt/template-hierarchy-data-fetching/example-app/assets/scss/components/post-card.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
}
4343
.categories-container, .tags-container {
4444
display: flex;
45-
4645
font-size: 0.75rem;
47-
gap: 0.5rem;
4846
margin-bottom: 0.5rem;
4947
list-style-type: none;
5048

@@ -53,6 +51,7 @@
5351
font-size: 0.75rem;
5452
color: #555;
5553
text-decoration: none;
54+
margin-left: .25rem
5655
}
5756
}
5857
.featured-image-container {

examples/nuxt/template-hierarchy-data-fetching/example-app/components/Comments.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ const showCommentForm = ref(true);
8989
// Recursive function to build nested comment structure
9090
const buildCommentTree = (comments, parentId = null) => {
9191
return comments
92-
.filter(comment => comment.parentId === parentId)
93-
.map(comment => ({
92+
.filter((comment) => comment.parentId === parentId)
93+
.map((comment) => ({
9494
...comment,
95-
replies: buildCommentTree(comments, comment.id)
95+
replies: buildCommentTree(comments, comment.id),
9696
}));
9797
};
9898
@@ -278,4 +278,4 @@ const handleCommentError = (error) => {
278278
color: #6b7280;
279279
font-size: 0.9rem;
280280
}
281-
</style>
281+
</style>

examples/nuxt/template-hierarchy-data-fetching/example-app/components/blog/LoadMore.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ const loadMorePosts = async () => {
6565
6666
// Update pageInfo
6767
pageInfo.value = data.posts.pageInfo;
68+
69+
await nextTick();
70+
scrollToNewContent(newPosts.length);
6871
} else {
6972
// No new posts found
7073
pageInfo.value = { ...pageInfo.value, hasNextPage: false };
@@ -77,6 +80,19 @@ const loadMorePosts = async () => {
7780
emit("loading", false);
7881
}
7982
};
83+
const scrollToNewContent = async (newPostsCount) => {
84+
// Wait for the specified delay
85+
await new Promise((resolve) => setTimeout(resolve, 100));
86+
87+
try {
88+
window.scrollTo({
89+
top: document.documentElement.scrollHeight - window.innerHeight,
90+
behavior: "smooth",
91+
});
92+
} catch (error) {
93+
console.warn("Error during scroll:", error);
94+
}
95+
};
8096
</script>
8197
8298
<template>

examples/nuxt/template-hierarchy-data-fetching/example-app/components/templates/comments/CommentForm.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const props = defineProps({
1010
replyData: {
1111
type: Object,
1212
default: null, // 0 means it's a root comment, not a reply
13-
}
13+
},
1414
});
1515
1616
const emit = defineEmits(["submit", "cancel", "success", "error"]);
@@ -179,7 +179,9 @@ const cancelReply = () => {
179179
<template>
180180
<div id="comment-form" class="comment-form">
181181
<h3 class="text-center">
182-
{{ replyData ? `Reply to "${replyData.author}" comment` : "Leave a Comment" }}
182+
{{
183+
replyData ? `Reply to "${replyData.author}" comment` : "Leave a Comment"
184+
}}
183185
</h3>
184186
<!-- Success/Error Message -->
185187
<div v-if="showMessage" class="message-container">
@@ -242,7 +244,7 @@ const cancelReply = () => {
242244
></textarea>
243245
</div>
244246
245-
<div class="gap-4 flex justify-end">
247+
<div class="">
246248
<button
247249
type="submit"
248250
class="button button-primary"
Lines changed: 23 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
11
<script setup>
2-
import { computed } from 'vue';
3-
2+
import { computed } from "vue";
3+
import { formatDate } from "~/lib/utils";
44
const props = defineProps({
55
comment: {
66
type: Object,
7-
required: true
8-
}
7+
required: true,
8+
},
99
});
1010
11-
defineEmits(['reply']);
12-
13-
// Format the comment date
14-
const formattedDate = computed(() => {
15-
if (!props.comment.date) return '';
16-
return new Date(props.comment.date).toLocaleDateString('en-US', {
17-
year: 'numeric',
18-
month: 'long',
19-
day: 'numeric',
20-
hour: '2-digit',
21-
minute: '2-digit'
22-
});
23-
});
11+
defineEmits(["reply"]);
2412
25-
// Get avatar URL with fallback
2613
const avatarUrl = computed(() => {
27-
return props.comment.author?.node?.avatar?.url ||
28-
`https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&f=y`;
14+
return (
15+
props.comment.author?.node?.avatar?.url ||
16+
`https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&f=y`
17+
);
2918
});
3019
31-
// Get author name with fallback
3220
const authorName = computed(() => {
33-
return props.comment.author?.node?.name || 'Anonymous';
21+
return props.comment.author?.node?.name || "Anonymous";
3422
});
3523
36-
// Get author URL
3724
const authorUrl = computed(() => {
3825
return props.comment.author?.node?.url;
3926
});
@@ -42,17 +29,17 @@ const authorUrl = computed(() => {
4229
<template>
4330
<article class="comment-item">
4431
<div class="comment-meta">
45-
<img
46-
:src="avatarUrl"
32+
<img
33+
:src="avatarUrl"
4734
:alt="`${authorName}'s avatar`"
4835
class="comment-avatar"
4936
/>
5037
<div class="comment-info">
5138
<div class="comment-author">
52-
<a
53-
v-if="authorUrl"
54-
:href="authorUrl"
55-
target="_blank"
39+
<a
40+
v-if="authorUrl"
41+
:href="authorUrl"
42+
target="_blank"
5643
rel="noopener noreferrer"
5744
class="author-link"
5845
>
@@ -61,17 +48,17 @@ const authorUrl = computed(() => {
6148
<span v-else class="author-name">{{ authorName }}</span>
6249
</div>
6350
<time class="comment-date" :datetime="comment.date">
64-
{{ formattedDate }}
51+
{{ formatDate(comment.date) }}
6552
</time>
6653
</div>
6754
</div>
68-
55+
6956
<div class="comment-content" v-html="comment.content"></div>
70-
57+
7158
<div class="comment-actions">
72-
<button
59+
<button
7360
@click="$emit('reply', comment)"
74-
class="reply-button"
61+
class="button button-secondary button-small reply-button"
7562
>
7663
Reply
7764
</button>
@@ -80,82 +67,5 @@ const authorUrl = computed(() => {
8067
</template>
8168
8269
<style scoped>
83-
.comment-item {
84-
background: #f9fafb;
85-
border-radius: 0.5rem;
86-
padding: 1rem;
87-
margin-bottom: 1rem;
88-
}
89-
90-
.comment-meta {
91-
display: flex;
92-
align-items: flex-start;
93-
margin-bottom: 0.75rem;
94-
}
95-
96-
.comment-avatar {
97-
width: 40px;
98-
height: 40px;
99-
border-radius: 50%;
100-
margin-right: 0.75rem;
101-
flex-shrink: 0;
102-
}
103-
104-
.comment-info {
105-
flex: 1;
106-
}
107-
108-
.comment-author {
109-
font-weight: 600;
110-
margin-bottom: 0.25rem;
111-
}
112-
113-
.author-link {
114-
color: #3b82f6;
115-
text-decoration: none;
116-
}
117-
118-
.author-link:hover {
119-
text-decoration: underline;
120-
}
121-
122-
.author-name {
123-
color: #374151;
124-
}
125-
126-
.comment-date {
127-
color: #6b7280;
128-
font-size: 0.875rem;
129-
}
130-
131-
.comment-content {
132-
margin-bottom: 0.75rem;
133-
line-height: 1.6;
134-
}
135-
136-
.comment-content :deep(p) {
137-
margin-bottom: 0.5rem;
138-
}
139-
140-
.comment-content :deep(p:last-child) {
141-
margin-bottom: 0;
142-
}
143-
144-
.comment-actions {
145-
display: flex;
146-
gap: 1rem;
147-
}
148-
149-
.reply-button {
150-
background: none;
151-
border: none;
152-
color: #3b82f6;
153-
cursor: pointer;
154-
font-size: 0.875rem;
155-
padding: 0.25rem 0;
156-
}
157-
158-
.reply-button:hover {
159-
text-decoration: underline;
160-
}
161-
</style>
70+
@import "/assets/scss/components/comments/comment-item.scss";
71+
</style>

0 commit comments

Comments
 (0)