Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Login and error page redesign #4777

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions apps/builder/app/auth/brand-button.tsx

This file was deleted.

132 changes: 55 additions & 77 deletions apps/builder/app/auth/login.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
import { TooltipProvider } from "@radix-ui/react-tooltip";
import {
AccessibleIcon,
Box,
css,
Button,
Flex,
globalCss,
rawTheme,
Text,
theme,
} from "@webstudio-is/design-system";
import { GithubIcon, GoogleIcon, WebstudioIcon } from "@webstudio-is/icons";
import { BrandButton } from "./brand-button";
import { Form } from "@remix-run/react";
import { authPath } from "~/shared/router-utils";
import { SecretLogin } from "./secret-login";

const globalStyles = globalCss({
body: {
margin: 0,
background: theme.colors.backgroundPanel,
},
});

const layoutStyle = css({
display: "flex",
height: "100vh",
flexDirection: "column",
"@tablet": {
flexDirection: "row",
},
});

const sidebarStyle = css({
flexBasis: "35%",
"@tablet": {
background: `
radial-gradient(65.88% 47.48% at 50% 50%, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%),
linear-gradient(0deg, rgba(255, 255, 255, 0) 49.46%, rgba(255, 255, 255, 0.33) 100%),
linear-gradient(180deg, rgba(255, 174, 60, 0) 0%, rgba(230, 60, 254, 0.33) 100%),
radial-gradient(211.58% 161.63% at 3.13% 100%, rgba(255, 174, 60, 0.3) 0%, rgba(227, 53, 255, 0) 100%),
radial-gradient(107.1% 32.15% at 92.96% 5.04%, rgba(53, 255, 182, 0.2) 0%, rgba(74, 78, 250, 0.2) 100%), #EBFFFC;
`,
background: theme.colors.brandBackgroundDashboard,
overflow: "hidden",
},
});

@@ -58,63 +35,64 @@ export const Login = ({
}: LoginProps) => {
globalStyles();
return (
<Box className={layoutStyle()}>
<Flex align="center" justify="center" css={{ height: "100vh" }}>
<Flex
align="center"
justify="center"
as="aside"
className={sidebarStyle()}
>
<a href="https://webstudio.is" aria-label="Go to webstudio.is">
<AccessibleIcon label="Logo">
<WebstudioIcon size="100" />
</AccessibleIcon>
</a>
</Flex>
<Flex
align="center"
direction="column"
grow
as="main"
gap={6}
align="center"
gap="6"
css={{
"@tablet": {
justifyContent: "center",
width: theme.spacing[35],
minWidth: theme.spacing[20],
padding: theme.spacing[17],
borderRadius: theme.spacing[5],
[`@media (min-width: ${rawTheme.spacing[35]})`]: {
backgroundColor: `rgba(255, 255, 255, 0.5)`,
},
}}
>
<Text variant="brandMediumTitle" color="main" as="h1">
Sign In
<WebstudioIcon size={48} />
<Text variant="brandSectionTitle" as="h1" align="center">
Welcome to Webstudio
</Text>
<Flex direction="column" gap="4">
<TooltipProvider>
<Flex gap="3" direction="column">
<Form action={authPath({ provider: "google" })} method="post">
<BrandButton
disabled={isGoogleEnabled === false}
icon={<GoogleIcon size={22} />}
>
Sign in with Google
</BrandButton>
</Form>
<Form action={authPath({ provider: "github" })} method="post">
<BrandButton
disabled={isGithubEnabled === false}
icon={<GithubIcon size={22} fill="currentColor" />}
>
Sign in with GitHub
</BrandButton>
</Form>
{isSecretLoginEnabled && <SecretLogin />}
</Flex>
</TooltipProvider>
{errorMessage ? (
<Text align="center" color="destructive">
{errorMessage}
</Text>
) : null}
</Flex>

<TooltipProvider>
<Flex
as={Form}
method="post"
direction="column"
gap="3"
css={{ width: "100%" }}
>
<Button
disabled={isGoogleEnabled === false}
prefix={<GoogleIcon size={22} />}
color="primary"
css={{ height: theme.spacing[15] }}
formAction={authPath({ provider: "google" })}
>
Sign in with Google
</Button>
<Button
disabled={isGithubEnabled === false}
prefix={<GithubIcon size={22} fill="currentColor" />}
color="ghost"
css={{
border: `1px solid ${theme.colors.borderDark}`,
height: theme.spacing[15],
}}
formAction={authPath({ provider: "github" })}
>
Sign in with GitHub
</Button>
{isSecretLoginEnabled && <SecretLogin />}
</Flex>
</TooltipProvider>
{errorMessage ? (
<Text align="center" color="destructive">
{errorMessage}
</Text>
) : null}
</Flex>
</Box>
</Flex>
);
};
41 changes: 21 additions & 20 deletions apps/builder/app/auth/secret-login.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
import { Button, Flex, InputField, theme } from "@webstudio-is/design-system";
import { CommitIcon } from "@webstudio-is/icons";
import { useState } from "react";
import { authPath } from "~/shared/router-utils";
import { BrandButton } from "./brand-button";

export const SecretLogin = () => {
const [isSecretLoginOpen, setIsSecretLoginOpen] = useState(false);
if (isSecretLoginOpen) {
const [show, setShow] = useState(false);
if (show) {
const action = authPath({ provider: "dev" });
return (
<Flex
as="form"
action={authPath({ provider: "dev" })}
method="post"
css={{
width: "fit-content",
flexDirection: "row",
gap: theme.spacing[5],
}}
>
<Flex gap="2">
<InputField
name="secret"
type="text"
type="password"
minLength={2}
required
autoFocus
placeholder="Auth secret"
css={{ flexGrow: 1 }}
formAction={authPath({ provider: "dev" })}
onKeyDown={(event) => {
const form = event.currentTarget.form;
if (event.key === "Enter" && form) {
form.action = action;
form.submit();
}
}}
/>
<Button>Login</Button>
<Button type="submit" formAction={action}>
Login
</Button>
</Flex>
);
}

return (
<BrandButton
onClick={() => setIsSecretLoginOpen(true)}
icon={<CommitIcon size={22} />}
<Button
onClick={() => setShow(true)}
color="neutral"
css={{ height: theme.spacing[15] }}
>
Login with Secret
</BrandButton>
</Button>
);
};
Loading