Skip to content

Commit 50af809

Browse files
authored
Kl/scrum 168 image + Ui/ux enhancements (#137)
Co-authored-by: kevin-lann <[email protected]>
1 parent 7d65b17 commit 50af809

File tree

17 files changed

+487
-35
lines changed

17 files changed

+487
-35
lines changed

course-matrix/frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/png" href="/img/logo.png" />
5+
<link rel="icon" type="image/png" href="/img/course-matrix-logo.png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Course Matrix </title>
88
</head>

course-matrix/frontend/package-lock.json

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

course-matrix/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@radix-ui/react-separator": "^1.1.2",
3131
"@radix-ui/react-slot": "^1.1.2",
3232
"@radix-ui/react-switch": "^1.1.3",
33+
"@radix-ui/react-toast": "^1.2.6",
3334
"@radix-ui/react-tooltip": "^1.1.8",
3435
"@reduxjs/toolkit": "^2.5.1",
3536
"@schedule-x/drag-and-drop": "^2.21.1",
14.1 KB
Loading
27.5 KB
Loading

course-matrix/frontend/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import SignupPage from "./pages/Signup/SignUpPage";
66
import AuthRoute from "./components/auth-route";
77
import SignupSuccessfulPage from "./pages/Signup/SignupSuccessfulPage";
88
import LoginRoute from "./components/login-route";
9+
import { Toaster } from "./components/ui/toaster";
910

1011
/**
1112
* App Component
@@ -44,6 +45,7 @@ function App() {
4445
element={<AuthRoute component={Dashboard} />}
4546
/>
4647
</Routes>
48+
<Toaster />
4749
</div>
4850
);
4951
}

course-matrix/frontend/src/components/UserMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function UserMenu({ setOpen }: UserMenuProps) {
111111
{username}
112112
<Avatar>
113113
{/* Avatar Image is the profile picture of the user. The default avatar is used as a placeholder for now. */}
114-
<AvatarImage src="/img/default-avatar.png" />
114+
<AvatarImage src="/img/grey-avatar.png" className="h-18 w-18" />
115115
{/* Avatar Fallback is the initials of the user. Avatar Fallback will be used if Avatar Image fails to load */}
116116
<AvatarFallback>{initials}</AvatarFallback>
117117
</Avatar>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const ImagePlaceholder = () => {
2+
const blurredImagePlaceholder =
3+
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAAAAAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCAAIAAgDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAhEAACAQMDBQAAAAAAAAAAAAABAgMABAUGIWEREiMxUf/EABUBAQEAAAAAAAAAAAAAAAAAAAMF/8QAGhEAAgIDAAAAAAAAAAAAAAAAAQIAAxEhMf/aAAwDAQACEQMRAD8ASlWzQwxoGsuragA8nk6c+ONWNeOixw2aRm2AMbs5JAJJPk9aUpAJViJIGenZEwn/2Q==";
4+
5+
return (
6+
<div
7+
className="absolute inset-0 rounded-lg bg-gray-200"
8+
style={{
9+
backgroundImage: `url(${blurredImagePlaceholder})`,
10+
backgroundSize: "cover",
11+
filter: "blur(8px)",
12+
transform: "scale(1.1)",
13+
}}
14+
></div>
15+
);
16+
};

course-matrix/frontend/src/components/logo.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
import logoImg from "/img/logo.png";
1+
import { useState, useEffect } from "react";
2+
import logoImg from "/img/course-matrix-logo.png";
3+
import { ImagePlaceholder } from "./imagePlaceholder";
24

35
const Logo = () => {
6+
const [imageLoaded, setImageLoaded] = useState(false);
7+
48
return (
59
<>
610
<div className="p-2 flex gap-2 items-center font-medium">
7-
<img
8-
src={logoImg}
9-
alt="profile-img"
10-
className="rounded-lg aspect-square object-cover w-8"
11-
></img>
11+
<div className="relative rounded-lg w-8 h-8">
12+
{!imageLoaded && <ImagePlaceholder />}
13+
14+
<img
15+
src={logoImg}
16+
alt="Course Matrix logo"
17+
className={`rounded-lg aspect-square object-cover w-8 h-8 transition-opacity duration-300 ${
18+
imageLoaded ? "opacity-100" : "opacity-0"
19+
}`}
20+
loading="lazy"
21+
onLoad={() => setImageLoaded(true)}
22+
/>
23+
</div>
24+
1225
<div className="flex items-center gap-1">
1326
<div>Course</div>
1427
<div className="text-green-500">Matrix</div>
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import * as React from "react";
2+
import * as ToastPrimitives from "@radix-ui/react-toast";
3+
import { cva, type VariantProps } from "class-variance-authority";
4+
import { X } from "lucide-react";
5+
6+
import { cn } from "@/lib/utils";
7+
8+
const ToastProvider = ToastPrimitives.Provider;
9+
10+
const ToastViewport = React.forwardRef<
11+
React.ElementRef<typeof ToastPrimitives.Viewport>,
12+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
13+
>(({ className, ...props }, ref) => (
14+
<ToastPrimitives.Viewport
15+
ref={ref}
16+
className={cn(
17+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
18+
className,
19+
)}
20+
{...props}
21+
/>
22+
));
23+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
24+
25+
const toastVariants = cva(
26+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
27+
{
28+
variants: {
29+
variant: {
30+
default: "border bg-background text-foreground",
31+
destructive:
32+
"destructive group border-destructive bg-destructive text-destructive-foreground",
33+
},
34+
},
35+
defaultVariants: {
36+
variant: "default",
37+
},
38+
},
39+
);
40+
41+
const Toast = React.forwardRef<
42+
React.ElementRef<typeof ToastPrimitives.Root>,
43+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
44+
VariantProps<typeof toastVariants>
45+
>(({ className, variant, ...props }, ref) => {
46+
return (
47+
<ToastPrimitives.Root
48+
ref={ref}
49+
className={cn(toastVariants({ variant }), className)}
50+
{...props}
51+
/>
52+
);
53+
});
54+
Toast.displayName = ToastPrimitives.Root.displayName;
55+
56+
const ToastAction = React.forwardRef<
57+
React.ElementRef<typeof ToastPrimitives.Action>,
58+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
59+
>(({ className, ...props }, ref) => (
60+
<ToastPrimitives.Action
61+
ref={ref}
62+
className={cn(
63+
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
64+
className,
65+
)}
66+
{...props}
67+
/>
68+
));
69+
ToastAction.displayName = ToastPrimitives.Action.displayName;
70+
71+
const ToastClose = React.forwardRef<
72+
React.ElementRef<typeof ToastPrimitives.Close>,
73+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
74+
>(({ className, ...props }, ref) => (
75+
<ToastPrimitives.Close
76+
ref={ref}
77+
className={cn(
78+
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
79+
className,
80+
)}
81+
toast-close=""
82+
{...props}
83+
>
84+
<X className="h-4 w-4" />
85+
</ToastPrimitives.Close>
86+
));
87+
ToastClose.displayName = ToastPrimitives.Close.displayName;
88+
89+
const ToastTitle = React.forwardRef<
90+
React.ElementRef<typeof ToastPrimitives.Title>,
91+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
92+
>(({ className, ...props }, ref) => (
93+
<ToastPrimitives.Title
94+
ref={ref}
95+
className={cn("text-sm font-semibold", className)}
96+
{...props}
97+
/>
98+
));
99+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
100+
101+
const ToastDescription = React.forwardRef<
102+
React.ElementRef<typeof ToastPrimitives.Description>,
103+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
104+
>(({ className, ...props }, ref) => (
105+
<ToastPrimitives.Description
106+
ref={ref}
107+
className={cn("text-sm opacity-90", className)}
108+
{...props}
109+
/>
110+
));
111+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
112+
113+
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
114+
115+
type ToastActionElement = React.ReactElement<typeof ToastAction>;
116+
117+
export {
118+
type ToastProps,
119+
type ToastActionElement,
120+
ToastProvider,
121+
ToastViewport,
122+
Toast,
123+
ToastTitle,
124+
ToastDescription,
125+
ToastClose,
126+
ToastAction,
127+
};

0 commit comments

Comments
 (0)