Skip to content

Commit b201dfc

Browse files
authored
fix buttons on mobile (#21)
1 parent 6183bac commit b201dfc

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

components/deploy-button.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function DeployButton() {
2121
<title>Vercel logomark</title>
2222
<path d="m38 0 38 66H0z" />
2323
</svg>
24+
<span className="text-sm sm:hidden">Deploy</span>
2425
<span className="hidden text-sm sm:inline">Deploy Your Own</span>
2526
</a>
2627
</Button>

components/github-stars-button.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
"use client";
22

3+
import { useEffect, useState } from "react";
34
import { GitHubIcon } from "@/components/icons/github-icon";
45
import { Button } from "@/components/ui/button";
56
import { formatAbbreviatedNumber } from "@/lib/utils/format-number";
67

78
const GITHUB_REPO_URL =
89
"https://github.com/vercel-labs/workflow-builder-template";
910

10-
type GitHubStarsButtonProps = {
11-
initialStars?: number | null;
12-
};
11+
export function GitHubStarsButton() {
12+
const [stars, setStars] = useState<number | null>(null);
13+
14+
useEffect(() => {
15+
fetch("https://api.github.com/repos/vercel-labs/workflow-builder-template")
16+
.then((res) => res.json())
17+
.then((data) => setStars(data.stargazers_count))
18+
.catch(() => setStars(null));
19+
}, []);
1320

14-
export function GitHubStarsButton({ initialStars }: GitHubStarsButtonProps) {
1521
return (
1622
<Button
1723
asChild
@@ -26,9 +32,9 @@ export function GitHubStarsButton({ initialStars }: GitHubStarsButtonProps) {
2632
target="_blank"
2733
>
2834
<GitHubIcon className="size-4.5" />
29-
{initialStars && (
35+
{stars !== null && (
3036
<span className="text-sm">
31-
{formatAbbreviatedNumber(initialStars)}
37+
{formatAbbreviatedNumber(stars)} stars
3238
</span>
3339
)}
3440
</a>

components/workflow/workflow-toolbar.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,14 @@ function WorkflowMenuComponent({
951951
<DropdownMenuTrigger className="flex h-full cursor-pointer items-center gap-2 px-3 font-medium text-sm transition-all hover:bg-black/5 dark:hover:bg-white/5">
952952
<WorkflowIcon className="size-4" />
953953
<p className="font-medium text-sm">
954-
{workflowId ? state.workflowName : "New Workflow"}
954+
{workflowId ? (
955+
state.workflowName
956+
) : (
957+
<>
958+
<span className="sm:hidden">New</span>
959+
<span className="hidden sm:inline">New Workflow</span>
960+
</>
961+
)}
955962
</p>
956963
<ChevronDown className="size-3 opacity-50" />
957964
</DropdownMenuTrigger>
@@ -1181,9 +1188,15 @@ export const WorkflowToolbar = ({ workflowId }: WorkflowToolbarProps) => {
11811188
state={state}
11821189
workflowId={workflowId}
11831190
/>
1184-
<GitHubStarsButton />
1185-
<DeployButton />
1186-
<UserMenu />
1191+
<div className="flex items-center gap-2">
1192+
{!workflowId && (
1193+
<>
1194+
<GitHubStarsButton />
1195+
<DeployButton />
1196+
</>
1197+
)}
1198+
<UserMenu />
1199+
</div>
11871200
</Panel>
11881201

11891202
<WorkflowDialogsComponent actions={actions} state={state} />

0 commit comments

Comments
 (0)