Skip to content

Commit 97e804e

Browse files
committed
Handle the signup buttons
1 parent 6b77f85 commit 97e804e

File tree

2 files changed

+130
-75
lines changed

2 files changed

+130
-75
lines changed

front/components/Button.tsx

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { Button } from "@dust-tt/sparkle";
1+
import {
2+
Button,
3+
DropdownMenu,
4+
GithubLogo,
5+
GoogleLogo,
6+
Icon,
7+
LoginIcon,
8+
RocketIcon,
9+
} from "@dust-tt/sparkle";
210

311
import { classNames } from "@app/lib/utils";
412

@@ -41,3 +49,94 @@ export function SignInButton({
4149
></Button>
4250
);
4351
}
52+
53+
export function SignInDropDownButton({
54+
buttonVariant = "tertiary",
55+
buttonLabel = "Sign in",
56+
buttonIcon = LoginIcon,
57+
buttonClassname = "",
58+
shouldDisplayGithub,
59+
onClickGithub,
60+
onClickGoogle,
61+
}: {
62+
buttonVariant?: "primary" | "secondary" | "tertiary";
63+
buttonLabel?: string;
64+
buttonIcon?: typeof Icon;
65+
buttonClassname?: string;
66+
shouldDisplayGithub: boolean;
67+
onClickGithub: () => void;
68+
onClickGoogle: () => void;
69+
}) {
70+
return (
71+
<DropdownMenu>
72+
<DropdownMenu.Button>
73+
<Button
74+
variant={buttonVariant}
75+
className={buttonClassname}
76+
size="sm"
77+
label={buttonLabel}
78+
icon={buttonIcon}
79+
/>
80+
</DropdownMenu.Button>
81+
<DropdownMenu.Items origin="topRight" width={240}>
82+
<div className="flex flex-col gap-2 p-4">
83+
<Button
84+
variant="tertiary"
85+
size="md"
86+
label="With Google"
87+
icon={GoogleLogo}
88+
onClick={onClickGoogle}
89+
/>
90+
{shouldDisplayGithub && (
91+
<Button
92+
variant="tertiary"
93+
size="md"
94+
label="With GitHub"
95+
icon={GithubLogo}
96+
onClick={onClickGithub}
97+
/>
98+
)}
99+
</div>
100+
</DropdownMenu.Items>
101+
</DropdownMenu>
102+
);
103+
}
104+
105+
export function SignUpDropDownButton({
106+
buttonVariant = "primary",
107+
buttonLabel = "Start with Dust",
108+
buttonIcon = RocketIcon,
109+
buttonClassname = "",
110+
onClickGoogle,
111+
}: {
112+
buttonVariant?: "primary" | "secondary" | "tertiary";
113+
buttonLabel?: string;
114+
buttonIcon?: typeof Icon;
115+
buttonClassname?: string;
116+
onClickGoogle: () => void;
117+
}) {
118+
return (
119+
<DropdownMenu>
120+
<DropdownMenu.Button>
121+
<Button
122+
variant={buttonVariant}
123+
className={buttonClassname}
124+
size="sm"
125+
label={buttonLabel}
126+
icon={buttonIcon}
127+
/>
128+
</DropdownMenu.Button>
129+
<DropdownMenu.Items origin="topRight" width={260}>
130+
<div className="flex flex-col gap-2 p-4">
131+
<Button
132+
variant="tertiary"
133+
size="md"
134+
label="Sign up with Google"
135+
icon={GoogleLogo}
136+
onClick={onClickGoogle}
137+
/>
138+
</div>
139+
</DropdownMenu.Items>
140+
</DropdownMenu>
141+
);
142+
}

front/pages/index.tsx

Lines changed: 30 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@ import {
22
AnthropicLogo,
33
Button,
44
DriveLogo,
5-
DropdownMenu,
6-
GithubLogo,
75
GithubWhiteLogo,
86
GoogleLogo,
9-
LoginIcon,
107
Logo,
118
LogoHorizontalWhiteLogo,
129
MicrosoftLogo,
1310
MistralLogo,
1411
MoreIcon,
1512
NotionLogo,
1613
OpenaiLogo,
17-
PlayIcon,
18-
RocketIcon,
1914
SlackLogo,
2015
} from "@dust-tt/sparkle";
2116
import { GetServerSideProps, InferGetServerSidePropsType } from "next";
@@ -41,7 +36,10 @@ import {
4136

4237
const defaultFlexClasses = "flex flex-col gap-4";
4338

44-
import { GoogleSignInButton } from "@app/components/Button";
39+
import {
40+
SignInDropDownButton,
41+
SignUpDropDownButton,
42+
} from "@app/components/Button";
4543
import Particles from "@app/components/home/particles";
4644
import ScrollingHeader from "@app/components/home/scrollingHeader";
4745
import { PricePlans } from "@app/components/PlansTables";
@@ -133,68 +131,30 @@ export default function Home({
133131
</P> */}
134132
</div>
135133
<div className="flex-grow" />
136-
<div className="flex items-center gap-2">
137-
{!(router.query.signIn && router.query.signIn !== "github") && (
138-
<div className="font-regular font-objektiv text-xs text-slate-400">
139-
Sign in with{" "}
140-
<span
141-
className="cursor-pointer font-bold hover:text-blue-400"
142-
onClick={() => {
143-
void signIn("github", {
144-
callbackUrl: getCallbackUrl(router.query),
145-
});
146-
}}
147-
>
148-
GitHub
149-
</span>{" "}
150-
or
151-
</div>
152-
)}
153-
<GoogleSignInButton
154-
onClick={() =>
134+
<Button.List>
135+
<SignUpDropDownButton
136+
buttonClassname="invisibleFirst hidden opacity-0 transition-all duration-500 ease-out lg:flex"
137+
onClickGoogle={() =>
138+
signIn("google", {
139+
callbackUrl: getCallbackUrl(router.query),
140+
})
141+
}
142+
/>
143+
<SignInDropDownButton
144+
shouldDisplayGithub={
145+
!(router.query.signIn && router.query.signIn !== "github")
146+
}
147+
onClickGithub={() => {
148+
void signIn("github", {
149+
callbackUrl: getCallbackUrl(router.query),
150+
});
151+
}}
152+
onClickGoogle={() =>
155153
signIn("google", {
156154
callbackUrl: getCallbackUrl(router.query),
157155
})
158156
}
159-
>
160-
<img src="/static/google_white_32x32.png" className="h-4 w-4" />
161-
<span className="ml-2 mr-1">Sign in with Google</span>
162-
</GoogleSignInButton>
163-
</div>
164-
<Button.List>
165-
<Button
166-
variant="primary"
167-
size="sm"
168-
label="Start with Dust"
169-
className="invisibleFirst hidden opacity-0 transition-all duration-500 ease-out lg:block"
170-
icon={RocketIcon}
171157
/>
172-
<DropdownMenu>
173-
<DropdownMenu.Button>
174-
<Button
175-
variant="tertiary"
176-
size="sm"
177-
label="Sign-in"
178-
icon={LoginIcon}
179-
/>
180-
</DropdownMenu.Button>
181-
<DropdownMenu.Items origin="topRight" width={240}>
182-
<div className="flex flex-col gap-2 p-4">
183-
<Button
184-
variant="tertiary"
185-
size="md"
186-
label="With Google"
187-
icon={GoogleLogo}
188-
/>
189-
<Button
190-
variant="tertiary"
191-
size="md"
192-
label="With GitHub"
193-
icon={GithubLogo}
194-
/>
195-
</div>
196-
</DropdownMenu.Items>
197-
</DropdownMenu>
198158
</Button.List>
199159
</div>
200160
</ScrollingHeader>
@@ -250,17 +210,13 @@ export default function Home({
250210
is a&nbsp;competitive&nbsp;edge.
251211
</H3>
252212
<div className="sm: flex w-full flex-wrap gap-4 sm:justify-start sm:gap-4 md:gap-6">
253-
<Button
254-
variant="primary"
255-
size="md"
256-
label="Start with Dust now"
257-
icon={RocketIcon}
258-
/>
259-
<Button
260-
variant="secondary"
261-
size="md"
262-
label="Watch the video"
263-
icon={PlayIcon}
213+
<SignUpDropDownButton
214+
buttonLabel="Start with Dust Now"
215+
onClickGoogle={() =>
216+
signIn("google", {
217+
callbackUrl: getCallbackUrl(router.query),
218+
})
219+
}
264220
/>
265221
</div>
266222
</div>

0 commit comments

Comments
 (0)