Skip to content

Commit cc41987

Browse files
authored
[vercel-tutor] Move files / add loading indicator (#1043)
### Description - Rename files from `<step-name>/page.tsx` to `<step-name>.tsx` to prevent them from being built - Add simple loading states to links https://github.com/user-attachments/assets/251f8dd3-7a04-4a33-9862-5d4266145a47 https://github.com/user-attachments/assets/998c9a36-8af3-4bb6-8951-f50f9ccc8802 ### Type of Change - [ ] New Example - [x] Example updates (Bug fixes, new features, etc.) - [ ] Other (changes to the codebase, but not to examples)
1 parent 12cc0c2 commit cc41987

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed
File renamed without changes.

vercel-tutor/app/page.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function Circle() {
2727

2828
export default function Home() {
2929
const [nextUrl, setNextUrl] = useState("#");
30+
const [isLoading, setIsLoading] = useState(false);
3031

3132
useEffect(() => {
3233
const host = window.location.hostname;
@@ -74,8 +75,15 @@ export default function Home() {
7475
<a
7576
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground font-medium text-background hover:bg-[#383838] dark:hover:bg-[#ccc] h-12 font-[family-name:var(--font-geist-sans)]"
7677
href={nextUrl}
78+
onClick={(e) => {
79+
if (isLoading) {
80+
e.preventDefault();
81+
} else {
82+
setIsLoading(true);
83+
}
84+
}}
7785
>
78-
View Pull Request
86+
{isLoading ? 'Loading…' : 'View Pull Request'}
7987
</a>
8088
<a
8189
className="font-[family-name:var(--font-geist-sans)] text-secondary hover:underline flex items-center justify-center h-12 font-medium"

vercel-tutor/app/smaller-triangle/page.tsx renamed to vercel-tutor/app/smaller-triangle.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function Check() {
4747

4848
export default function Home() {
4949
const [nextUrl, setNextUrl] = useState("#");
50+
const [isLoading, setIsLoading] = useState(false);
5051

5152
useEffect(() => {
5253
const host = window.location.hostname;
@@ -119,8 +120,15 @@ export default function Home() {
119120
<a
120121
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground font-medium text-background hover:bg-[#383838] dark:hover:bg-[#ccc] h-12 font-[family-name:var(--font-geist-sans)]"
121122
href={nextUrl}
123+
onClick={(e) => {
124+
if (isLoading) {
125+
e.preventDefault();
126+
} else {
127+
setIsLoading(true);
128+
}
129+
}}
122130
>
123-
Push Commit and Merge Pull Request
131+
{isLoading ? 'Loading…' : 'Push Commit and Merge Pull Request'}
124132
</a>
125133
<a
126134
className="font-[family-name:var(--font-geist-sans)] text-secondary hover:underline flex items-center justify-center h-12 font-medium"

vercel-tutor/steps.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"branchName": "main"
77
},
88
"target": {
9-
"templatePath": "app/smaller-triangle/page.tsx",
9+
"templatePath": "app/smaller-triangle.tsx",
1010
"branchName": "vercel-bot-patch"
1111
},
1212
"path": "app/page.tsx",
@@ -17,11 +17,11 @@
1717
"helpful-links": {
1818
"type": "commit-merge-comment",
1919
"base": {
20-
"templatePath": "app/smaller-triangle/page.tsx",
20+
"templatePath": "app/smaller-triangle.tsx",
2121
"branchName": "vercel-bot-patch"
2222
},
2323
"target": {
24-
"templatePath": "app/helpful-links/page.tsx",
24+
"templatePath": "app/helpful-links.tsx",
2525
"branchName": "vercel-bot-patch"
2626
},
2727
"path": "app/page.tsx",

0 commit comments

Comments
 (0)