feat(webui): polish the GitHub star invitation
This commit is contained in:
1 parent
33dddaaa46
commit
57a4655451
15 files changed
+257
-64
No files matched your search
@@ -0,0 +1,69 @@
|
||||
.star-prompt-decoration {
|
||||
position: absolute;
|
||||
top: -12px;
|
||||
right: 16px;
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transform: translateY(12px) rotate(-125deg) scale(.25);
|
||||
transform-origin: 50% 85%;
|
||||
color: #f7c955;
|
||||
transition: opacity 120ms ease-out, transform 180ms ease-out;
|
||||
}
|
||||
|
||||
.star-prompt-star {
|
||||
display: block;
|
||||
stroke: #c68718;
|
||||
filter: drop-shadow(0 2px 3px rgb(122 75 8 / .16));
|
||||
}
|
||||
|
||||
.star-prompt-sparkle { position: absolute; opacity: 0; color: #efb840; }
|
||||
.star-prompt-sparkle-first { top: -6px; right: -9px; }
|
||||
.star-prompt-sparkle-second { bottom: -3px; left: -7px; }
|
||||
|
||||
.star-prompt-action:focus-visible .star-prompt-decoration {
|
||||
opacity: 1;
|
||||
transform: rotate(8deg);
|
||||
animation: star-prompt-pop 640ms cubic-bezier(.22, 1, .36, 1) both;
|
||||
}
|
||||
.star-prompt-action:focus-visible .star-prompt-sparkle {
|
||||
animation: star-prompt-twinkle 420ms ease-out 250ms both;
|
||||
}
|
||||
.star-prompt-action:focus-visible .star-prompt-sparkle-second { animation-delay: 370ms; }
|
||||
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.star-prompt-action:hover .star-prompt-decoration {
|
||||
opacity: 1;
|
||||
transform: rotate(8deg);
|
||||
animation: star-prompt-pop 640ms cubic-bezier(.22, 1, .36, 1) both;
|
||||
}
|
||||
.star-prompt-action:hover .star-prompt-sparkle {
|
||||
animation: star-prompt-twinkle 420ms ease-out 250ms both;
|
||||
}
|
||||
.star-prompt-action:hover .star-prompt-sparkle-second { animation-delay: 370ms; }
|
||||
}
|
||||
|
||||
@keyframes star-prompt-pop {
|
||||
0% { opacity: 0; transform: translateY(12px) rotate(-125deg) scale(.25); }
|
||||
18% { opacity: 1; }
|
||||
48% { opacity: 1; transform: translateY(-6px) rotate(23deg) scale(1.18); }
|
||||
70% { transform: translateY(2px) rotate(-8deg) scale(.93); }
|
||||
86% { transform: translateY(-1px) rotate(11deg) scale(1.04); }
|
||||
100% { opacity: 1; transform: translateY(0) rotate(8deg) scale(1); }
|
||||
}
|
||||
|
||||
@keyframes star-prompt-twinkle {
|
||||
0%, 100% { opacity: 0; transform: scale(.35) rotate(-15deg); }
|
||||
45% { opacity: 1; transform: scale(1.15) rotate(10deg); }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.star-prompt-action .star-prompt-decoration,
|
||||
.star-prompt-action .star-prompt-sparkle {
|
||||
animation: none;
|
||||
transition: none;
|
||||
transform: none;
|
||||
}
|
||||
.star-prompt-action .star-prompt-sparkle { display: none; }
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { ExternalLink, Star } from "lucide-react";
|
||||
import { ExternalLink, Sparkle, Star, X } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import starInvitation from "@/assets/star-invitation.webp";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
|
||||
import { starPromptAction } from "@/lib/api";
|
||||
import { useClient } from "@/providers/ClientProvider";
|
||||
|
||||
import "./StarPrompt.css";
|
||||
|
||||
const REPOSITORY_URL = "https://github.com/HKUDS/nanobot";
|
||||
const actionClassName = "h-full min-h-[46px] min-w-0 !whitespace-normal px-3 py-2.5 text-center text-[15px] font-medium max-[480px]:text-sm";
|
||||
|
||||
export function StarLink({ onSaved, fullWidth = false }: {
|
||||
onSaved?: () => void;
|
||||
@@ -28,12 +32,18 @@ export function StarLink({ onSaved, fullWidth = false }: {
|
||||
<span className="min-w-0">
|
||||
{t(fullWidth ? "starPrompt.action" : "starPrompt.footerAction")}
|
||||
</span>
|
||||
<ExternalLink className={fullWidth ? "ml-2 h-3.5 w-3.5 shrink-0" : "h-3.5 w-3.5 shrink-0 text-muted-foreground"} aria-hidden />
|
||||
{fullWidth ? (
|
||||
<span className="star-prompt-decoration" aria-hidden="true">
|
||||
<Star className="star-prompt-star" size={23} strokeWidth={1.5} fill="currentColor" />
|
||||
<Sparkle className="star-prompt-sparkle star-prompt-sparkle-first" size={10} strokeWidth={1.5} fill="currentColor" />
|
||||
<Sparkle className="star-prompt-sparkle star-prompt-sparkle-second" size={7} strokeWidth={1.5} fill="currentColor" />
|
||||
</span>
|
||||
) : <ExternalLink className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />}
|
||||
</a>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{fullWidth ? <Button asChild className="h-full min-h-11 w-full !whitespace-normal px-3 py-2.5 text-center text-sm font-medium">{link}</Button> : link}
|
||||
{fullWidth ? <Button asChild className={`star-prompt-action relative isolate w-full overflow-visible ${actionClassName}`}>{link}</Button> : link}
|
||||
{error && <p role="alert" className="text-sm text-destructive">{t("starPrompt.saveError")}</p>}
|
||||
</>
|
||||
);
|
||||
@@ -93,7 +103,8 @@ export function StarPrompt({ ready }: { ready: boolean }) {
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogContent className="max-w-[440px] gap-0 p-6 text-center outline-none"
|
||||
<DialogContent showCloseButton={false}
|
||||
className="flex max-h-[calc(100dvh-32px)] max-w-[520px] flex-col gap-0 overflow-y-auto overscroll-contain p-5 pb-2.5 outline-none max-[480px]:p-4 max-[480px]:pb-2"
|
||||
onOpenAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
titleRef.current?.focus({ preventScroll: true });
|
||||
@@ -101,22 +112,33 @@ export function StarPrompt({ ready }: { ready: boolean }) {
|
||||
event.preventDefault();
|
||||
previousFocus.current?.focus({ preventScroll: true });
|
||||
}}>
|
||||
<img src="/brand/nanobot_mark.svg" alt="" className="mx-auto mb-4 h-10 w-10 select-none" draggable={false} />
|
||||
<DialogTitle ref={titleRef} tabIndex={-1}
|
||||
className="text-xl font-semibold leading-tight tracking-normal outline-none">
|
||||
{t("starPrompt.title")}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="mt-3 text-sm leading-6 text-muted-foreground">
|
||||
{t("starPrompt.description")}
|
||||
</DialogDescription>
|
||||
<div className="mt-6 grid grid-cols-2 items-stretch gap-2">
|
||||
<Button variant="ghost" className="h-full min-h-11 !whitespace-normal bg-muted/70 px-3 py-2.5 text-sm font-medium settings-hover"
|
||||
<img src={starInvitation} alt="" width={1672} height={941} draggable={false}
|
||||
className="aspect-[1672/941] w-full shrink-0 select-none rounded-control bg-muted object-cover" />
|
||||
<DialogClose aria-label={t("common.close")}
|
||||
className="absolute right-[23px] top-[23px] grid h-11 w-11 place-items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-white max-[480px]:right-[18px] max-[480px]:top-[18px]">
|
||||
<span className="grid h-[30px] w-[30px] place-items-center rounded-full bg-black/40 text-white backdrop-blur-sm transition-colors hover:bg-black/60 motion-reduce:transition-none">
|
||||
<X size={18} strokeWidth={1.75} aria-hidden />
|
||||
</span>
|
||||
</DialogClose>
|
||||
<div className="shrink-0 px-2 pt-[27px] text-left max-[480px]:px-1 max-[480px]:pt-[23px]">
|
||||
<DialogTitle ref={titleRef} tabIndex={-1}
|
||||
className="text-[26px] font-semibold leading-[1.4] tracking-[-0.035em] outline-none [overflow-wrap:anywhere] max-[480px]:text-[clamp(18px,5.6vw,24px)]">
|
||||
{t("starPrompt.title")}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="mt-[15px] text-[15px] leading-[1.9] text-muted-foreground max-[480px]:mt-3 max-[480px]:text-[13px] max-[480px]:leading-[1.95]">
|
||||
<span className="block">{t("starPrompt.intro")}</span>{" "}
|
||||
<span className="block">{t("starPrompt.invitation")}</span>{" "}
|
||||
<span className="block">{t("starPrompt.thanks")}</span>
|
||||
</DialogDescription>
|
||||
</div>
|
||||
<div className="mt-[27px] grid shrink-0 grid-cols-2 items-stretch gap-3 px-2 max-[480px]:mt-[23px] max-[480px]:gap-2.5 max-[480px]:px-1">
|
||||
<Button variant="outline" className={actionClassName}
|
||||
onClick={() => setOpen(false)}>{t("starPrompt.later")}</Button>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex min-w-0 flex-col gap-2">
|
||||
<StarLink fullWidth onSaved={() => setOpen(false)} />
|
||||
</div>
|
||||
</div>
|
||||
<Button variant="ghost" className="mx-auto mt-3 h-9 px-3 text-xs font-normal text-muted-foreground" disabled={saving}
|
||||
<Button variant="ghost" className="mt-[7px] min-h-11 shrink-0 self-center !whitespace-normal px-4 text-xs font-normal text-muted-foreground" disabled={saving}
|
||||
onClick={() => void dismissForever()}>{t("starPrompt.never")}</Button>
|
||||
{error && <p role="alert" className="text-sm text-destructive">{t("starPrompt.saveError")}</p>}
|
||||
</DialogContent>
|
||||
|
||||
Reference in new issue
Block a user