Skip to content

Commit d0e39c6

Browse files
authored
refactor: card title and layout tweaks (#675)
* refactor: card title and layout tweaks * chore: review comments * refactor: update domain warning screen
1 parent 89da402 commit d0e39c6

20 files changed

Lines changed: 355 additions & 141 deletions

frontend/bun.lock

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"input-otp": "^1.4.2",
2929
"lucide-react": "^0.575.0",
3030
"next-themes": "^0.4.6",
31+
"radix-ui": "^1.4.3",
3132
"react": "^19.2.4",
3233
"react-dom": "^19.2.4",
3334
"react-hook-form": "^7.71.2",

frontend/src/components/auth/login-form.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import {
1010
FormLabel,
1111
FormMessage,
1212
} from "../ui/form";
13-
import { Button } from "../ui/button";
1413
import { loginSchema, LoginSchema } from "@/schemas/login-schema";
1514
import z from "zod";
1615

1716
interface Props {
1817
onSubmit: (data: LoginSchema) => void;
1918
loading?: boolean;
19+
formId?: string;
2020
}
2121

2222
export const LoginForm = (props: Props) => {
23-
const { onSubmit, loading } = props;
23+
const { onSubmit, loading, formId } = props;
2424
const { t } = useTranslation();
2525

2626
z.config({
@@ -34,7 +34,7 @@ export const LoginForm = (props: Props) => {
3434

3535
return (
3636
<Form {...form}>
37-
<form onSubmit={form.handleSubmit(onSubmit)}>
37+
<form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
3838
<FormField
3939
control={form.control}
4040
name="username"
@@ -57,7 +57,7 @@ export const LoginForm = (props: Props) => {
5757
control={form.control}
5858
name="password"
5959
render={({ field }) => (
60-
<FormItem className="mb-4 gap-0">
60+
<FormItem className="gap-0">
6161
<div className="relative mb-1">
6262
<FormLabel className="mb-2">{t("loginPassword")}</FormLabel>
6363
<FormControl>
@@ -71,7 +71,7 @@ export const LoginForm = (props: Props) => {
7171
</FormControl>
7272
<a
7373
href="/forgot-password"
74-
className="text-muted-foreground text-sm absolute right-0 bottom-[2.565rem]" // 2.565 is *just* perfect
74+
className="text-muted-foreground hover:text-muted-foreground/80 text-sm absolute right-0 bottom-[2.565rem]" // 2.565 is *just* perfect
7575
>
7676
{t("forgotPasswordTitle")}
7777
</a>
@@ -80,9 +80,6 @@ export const LoginForm = (props: Props) => {
8080
</FormItem>
8181
)}
8282
/>
83-
<Button className="w-full" type="submit" loading={loading}>
84-
{t("loginSubmit")}
85-
</Button>
8683
</form>
8784
</Form>
8885
);

frontend/src/components/domain-warning/domain-warning.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
22
Card,
3-
CardDescription,
3+
CardContent,
44
CardFooter,
55
CardHeader,
66
CardTitle,
77
} from "../ui/card";
88
import { Button } from "../ui/button";
9-
import { Trans, useTranslation } from "react-i18next";
9+
import { useTranslation } from "react-i18next";
1010
import { useLocation } from "react-router";
1111

1212
interface Props {
@@ -24,23 +24,26 @@ export const DomainWarning = (props: Props) => {
2424
const redirectUri = searchParams.get("redirect_uri");
2525

2626
return (
27-
<Card role="alert" aria-live="assertive" className="min-w-xs sm:min-w-sm">
27+
<Card role="alert" aria-live="assertive">
2828
<CardHeader>
29-
<CardTitle className="text-3xl">{t("domainWarningTitle")}</CardTitle>
30-
<CardDescription>
31-
<Trans
32-
t={t}
33-
i18nKey="domainWarningSubtitle"
34-
values={{ appUrl, currentUrl }}
35-
components={{ code: <code /> }}
36-
shouldUnescape={true}
37-
/>
38-
</CardDescription>
29+
<CardTitle className="text-xl">{t("domainWarningTitle")}</CardTitle>
3930
</CardHeader>
40-
<CardFooter className="flex flex-col items-stretch gap-2">
41-
<Button onClick={onClick} variant="warning">
42-
{t("ignoreTitle")}
43-
</Button>
31+
<CardContent className="flex flex-col gap-3 text-sm mb-1.25">
32+
<p className="text-muted-foreground">{t("domainWarningSubtitle")}</p>
33+
<pre>
34+
<span className="text-muted-foreground">
35+
{t("domainWarningExpected")}&nbsp;
36+
<span className="text-primary">{appUrl}</span>
37+
</span>
38+
</pre>
39+
<pre>
40+
<span className="text-muted-foreground">
41+
{t("domainWarningCurrent")}&nbsp;
42+
<span className="text-primary">{currentUrl}</span>
43+
</span>
44+
</pre>
45+
</CardContent>
46+
<CardFooter className="flex flex-col items-stretch gap-3">
4447
<Button
4548
onClick={() =>
4649
window.location.assign(
@@ -51,6 +54,9 @@ export const DomainWarning = (props: Props) => {
5154
>
5255
{t("goToCorrectDomainTitle")}
5356
</Button>
57+
<Button onClick={onClick} variant="warning">
58+
{t("ignoreTitle")}
59+
</Button>
5460
</CardFooter>
5561
</Card>
5662
);

frontend/src/components/layout/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ const BaseLayout = ({ children }: { children: React.ReactNode }) => {
1414

1515
return (
1616
<div
17-
className="relative flex flex-col justify-center items-center min-h-svh"
17+
className="flex flex-col justify-center items-center min-h-svh px-4"
1818
style={{
1919
backgroundImage: `url(${backgroundImage})`,
2020
backgroundSize: "cover",
2121
backgroundPosition: "center",
2222
}}
2323
>
24-
<div className="absolute top-5 right-5 flex flex-row gap-2">
24+
<div className="absolute top-4 right-4 flex flex-row gap-2">
2525
<ThemeToggle />
2626
<LanguageSelector />
2727
</div>
28-
{children}
28+
<div className="max-w-sm md:min-w-sm min-w-xs">{children}</div>
2929
</div>
3030
);
3131
};

frontend/src/components/ui/card.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Card({ className, ...props }: React.ComponentProps<"div">) {
77
<div
88
data-slot="card"
99
className={cn(
10-
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
10+
"bg-card text-card-foreground flex flex-col gap-3 rounded-xl border py-6 shadow-sm",
1111
className,
1212
)}
1313
{...props}
@@ -20,7 +20,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
2020
<div
2121
data-slot="card-header"
2222
className={cn(
23-
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
23+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
2424
className,
2525
)}
2626
{...props}
@@ -75,7 +75,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
7575
return (
7676
<div
7777
data-slot="card-footer"
78-
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
78+
className={cn("flex items-center px-6 [.border-t]:pt-6 mt-2", className)}
7979
{...props}
8080
/>
8181
);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import * as React from "react"
2+
import { Tooltip as TooltipPrimitive } from "radix-ui"
3+
4+
import { cn } from "@/lib/utils"
5+
6+
function TooltipProvider({
7+
delayDuration = 0,
8+
...props
9+
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
10+
return (
11+
<TooltipPrimitive.Provider
12+
data-slot="tooltip-provider"
13+
delayDuration={delayDuration}
14+
{...props}
15+
/>
16+
)
17+
}
18+
19+
function Tooltip({
20+
...props
21+
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
22+
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
23+
}
24+
25+
function TooltipTrigger({
26+
...props
27+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
28+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
29+
}
30+
31+
function TooltipContent({
32+
className,
33+
sideOffset = 0,
34+
children,
35+
...props
36+
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
37+
return (
38+
<TooltipPrimitive.Portal>
39+
<TooltipPrimitive.Content
40+
data-slot="tooltip-content"
41+
sideOffset={sideOffset}
42+
className={cn(
43+
"bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
44+
className
45+
)}
46+
{...props}
47+
>
48+
{children}
49+
<TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
50+
</TooltipPrimitive.Content>
51+
</TooltipPrimitive.Portal>
52+
)
53+
}
54+
55+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }

frontend/src/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ code {
160160
}
161161

162162
pre {
163-
@apply bg-accent border border-border rounded-md p-2 whitespace-break-spaces;
163+
@apply bg-accent border border-border rounded-md p-2 whitespace-break-spaces break-all;
164164
}
165165

166166
.lead {

frontend/src/lib/i18n/locales/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
"fieldRequired": "This field is required",
5858
"invalidInput": "Invalid input",
5959
"domainWarningTitle": "Invalid Domain",
60-
"domainWarningSubtitle": "This instance is configured to be accessed from <code>{{appUrl}}</code>, but <code>{{currentUrl}}</code> is being used. If you proceed, you may encounter issues with authentication.",
60+
"domainWarningSubtitle": "You are accessing this instance from an incorrect domain. If you proceed, you may encounter issues with authentication.",
61+
"domainWarningCurrent": "Current:",
62+
"domainWarningExpected": "Expected:",
6163
"ignoreTitle": "Ignore",
6264
"goToCorrectDomainTitle": "Go to correct domain",
6365
"authorizeTitle": "Authorize",

frontend/src/lib/i18n/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
"fieldRequired": "This field is required",
5858
"invalidInput": "Invalid input",
5959
"domainWarningTitle": "Invalid Domain",
60-
"domainWarningSubtitle": "This instance is configured to be accessed from <code>{{appUrl}}</code>, but <code>{{currentUrl}}</code> is being used. If you proceed, you may encounter issues with authentication.",
60+
"domainWarningSubtitle": "You are accessing this instance from an incorrect domain. If you proceed, you may encounter issues with authentication.",
61+
"domainWarningCurrent": "Current:",
62+
"domainWarningExpected": "Expected:",
6163
"ignoreTitle": "Ignore",
6264
"goToCorrectDomainTitle": "Go to correct domain",
6365
"authorizeTitle": "Authorize",

0 commit comments

Comments
 (0)