Skip to content

Commit

Permalink
DEAR-129: add styling to dashbaord and remove unused components
Browse files Browse the repository at this point in the history
  • Loading branch information
baurnick committed Jul 29, 2024
1 parent 20b0716 commit 1c97c38
Show file tree
Hide file tree
Showing 20 changed files with 362 additions and 481 deletions.
23 changes: 17 additions & 6 deletions app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import * as React from 'react';
import { motion } from 'framer-motion';
import Logo from '@components/ui/Logo/Logo';
import UserAuthForm from './components/UserAuthForm';

Expand All @@ -9,12 +10,22 @@ const LoginPage: React.FC = () => (
<div className="bg-primaryGreen-light dark:bg-primaryGreen-bg">
<div className="flex min-h-screen flex-col p-16">
<Logo className="h-8 w-8 flex-1" />
<h1 className="text-2xlx font-medium">Where productivity meets happiness</h1>
<p className="py-8 pr-12 text-lg font-light dark:text-black">
Discover a new way to track your happiness and boost your productivity. yappi helps you monitor your emotional
well-being, learn from your experiences, and achieve greater efficiency in your daily life. Join us now and
take the first step towards a happier, more productive you.
</p>
<motion.div
initial={{ opacity: 0.0, y: 40 }}
whileInView={{ opacity: 1, y: 0 }}
transition={{
delay: 0.1,
duration: 0.5,
ease: 'easeInOut',
}}
>
<h1 className="text-2xl font-medium">Where productivity meets happiness</h1>
<p className="py-8 pr-8 text-lg font-light dark:text-black">
Discover a new way to track your happiness and boost your productivity. yappi helps you monitor your
emotional well-being, learn from your experiences, and achieve greater efficiency in your daily life. Join
us now and take the first step towards a happier, more productive you.
</p>
</motion.div>
</div>
</div>
<div className="flex items-center justify-center">
Expand Down
12 changes: 6 additions & 6 deletions app/(main)/(home)/components/AlertWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import * as React from 'react';
import { Card, CardContent, CardHeader } from '@components/ui/Card/Card';
import { Siren } from 'lucide-react';

interface AlertWidgetProps {
icon: React.ReactNode;
days: number;
}

const AlertWidget: React.FC<AlertWidgetProps> = ({ icon, days }) => (
<Card className="group flex flex-col rounded-2xl border-none bg-primaryRed-light shadow-none hover:bg-primaryRed-main">
const AlertWidget: React.FC<AlertWidgetProps> = ({ days }) => (
<Card className="group flex flex-col rounded-2xl border-none bg-primaryYellow-light shadow-none hover:bg-primaryYellow-main">
<CardHeader className="flex flex-row">
<div className="flex-1" />
<div className="rounded-full bg-primaryRed-main p-2 text-white group-hover:animate-icon-bounce group-hover:bg-white group-hover:text-primaryRed-main">
{icon}
<div className="rounded-full bg-primaryYellow-main p-2 text-white group-hover:animate-icon-bounce group-hover:bg-white group-hover:text-primaryYellow-main">
<Siren className="h-5 w-5" />
</div>
</CardHeader>
<CardContent className="flex flex-grow flex-col justify-end">
<div className="space-y-1 text-primaryRed-main group-hover:text-white">
<div className="space-y-1 text-primaryYellow-main group-hover:text-white">
<h1 className="text-4xl md:text-4xl lg:text-6xl">{days}</h1>
<p className="md:text-md text-sm font-light">Days without any happiness tracking.</p>
</div>
Expand Down
46 changes: 22 additions & 24 deletions app/(main)/(home)/components/EmotionSurvey.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use client';

import * as React from 'react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@components/ui/Card/Card';
import { Card, CardContent, CardHeader } from '@components/ui/Card/Card';
import { User } from '@/types/UserType';
import { Emotion } from '@/types/EmotionType';
import { Badge } from '@components/ui/Badge/Badge';
import { toast } from '@components/ui/Toast/use-toast';
import useDashboardClient from '@hooks/useDashboardClient';
import { Button } from '@components/ui/Buttons/Button';
import SurveyHoverCard from './SurveyHoverCard';

interface EmotionSurveyProps {
emotions: Array<Emotion>;
Expand Down Expand Up @@ -36,29 +37,26 @@ const EmotionSurvey: React.FC<EmotionSurveyProps> = ({ fetchDashboardData, emoti
};

return (
<Card>
<CardHeader>
<CardTitle className="space-x-2 text-sm font-medium">Survey</CardTitle>
<CardTitle className="text-2xl font-bold">How do you feel?</CardTitle>
<CardDescription className="text-muted-foreground text-2lg">
We value your well-being and would love to know how you feel today. Please select the emotion that best
represents your current mood. Your feedback helps us understand your overall happiness and track changes over
time.
</CardDescription>
<Card className="flex h-full flex-col rounded-2xl border-black shadow-none">
<CardHeader className="flex flex-row">
<div className="flex-1" />
<SurveyHoverCard title="Track emotions" description="Text for emotions" />
</CardHeader>

<CardContent>
<div className="mt-4 flex flex-wrap gap-2">
{emotions.map((emotion) => (
<Badge
key={emotion.id}
variant="secondary"
onClick={() => handleClick(emotion.id)}
className="cursor-pointer p-4 text-sm transition-colors duration-200 ease-in-out hover:bg-primaryBlue-main"
>
{emotion.name}
</Badge>
))}
<CardContent className="flex flex-grow flex-col justify-end">
<div className="space-y-4">
<div className="flex flex-wrap gap-2">
{emotions.map((emotion) => (
<Button
key={emotion.id}
variant="outline"
className="rounded-xl border-black text-sm font-light"
onClick={() => handleClick(emotion.id)}
>
{emotion.name.toUpperCase()}
</Button>
))}
</div>
<p className="md:text-md text-sm font-light">How do you feel?</p>
</div>
</CardContent>
</Card>
Expand Down
78 changes: 30 additions & 48 deletions app/(main)/(home)/components/HappinessSurvey.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
'use client';

import * as React from 'react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@components/ui/Card/Card';
import { Annoyed, Frown, Laugh, Smile } from 'lucide-react';
import SurveyHappinessButton from '@components/Buttons/SurveyHappinessButton';
import { User } from '@/types/UserType';
import { Card, CardContent, CardHeader } from '@components/ui/Card/Card';
import useDashboardClient from '@hooks/useDashboardClient';
import { SubmitHappinessScoreDTO } from '@/types/SurveyType';
import { Annoyed, Frown, Laugh, Smile } from 'lucide-react';
import { Button } from '@components/ui/Buttons/Button';
import { toast } from '@components/ui/Toast/use-toast';
import useDashboardClient from '@hooks/useDashboardClient';
import { User } from '@/types/UserType';
import SurveyHoverCard from './SurveyHoverCard';

interface HappinessSurveyProps {
fetchDashboardData: () => void;
user: User;
}

const HappinessSurvey: React.FC<HappinessSurveyProps> = ({ fetchDashboardData, user }) => {
const [rotateButton, setRotateButton] = React.useState<number | null>(null);
const { submitHappinessScore } = useDashboardClient();

const iconClasses = (score: number) => `h-12 w-12 ${rotateButton === score ? 'rotate-360' : ''}`;

const handleHappinessSubmit = async (score: number) => {
const happinessScore: SubmitHappinessScoreDTO = {
score,
Expand All @@ -44,51 +42,35 @@ const HappinessSurvey: React.FC<HappinessSurveyProps> = ({ fetchDashboardData, u
};

const handleClick = (score: number) => {
setRotateButton(score);
setTimeout(() => setRotateButton(null), 1000);
handleHappinessSubmit(score);
};

return (
<Card>
<CardHeader>
<CardTitle className="text-sm font-medium">Survey</CardTitle>
<CardTitle className="text-2xl font-bold">How happy are you with your working day?</CardTitle>
<CardDescription className="text-muted-foreground text-2lg">
We want to know how satisfied you are with your workday today. Your feedback is important to us and helps us
understand your daily work experience.
</CardDescription>
<Card className="flex h-full flex-col rounded-2xl border-black shadow-none">
<CardHeader className="flex flex-row">
<div className="flex-1" />
<SurveyHoverCard
title="Track happiness"
description="We want to know how satisfied you are with your workday today. Your feedback is important to us and helps us understand your daily work experience."
/>
</CardHeader>
<CardContent>
<div className="flex flex-row items-center justify-between">
<SurveyHappinessButton
score={2}
size="mood"
onClick={handleClick}
className="bg-tertiaryBG-light"
icon={<Frown className={iconClasses(2)} />}
/>
<SurveyHappinessButton
score={8}
size="mood"
onClick={handleClick}
className="bg-primaryRed-light text-primaryRed-main"
icon={<Annoyed className={iconClasses(8)} />}
/>
<SurveyHappinessButton
score={14}
size="mood"
onClick={handleClick}
className="bg-primaryBlue-light text-primaryBlue-main"
icon={<Smile className={iconClasses(14)} />}
/>
<SurveyHappinessButton
score={20}
size="mood"
onClick={handleClick}
className="bg-primaryGreen-light text-primaryGreen-main"
icon={<Laugh className={iconClasses(20)} />}
/>
<CardContent className="flex flex-grow flex-col justify-end">
<div className="flex flex-col space-y-2">
<div className="mx-auto grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-4">
<Button variant="icon" size="mood" className="rounded-full" onClick={() => handleClick(2)}>
<Frown className="h-14 w-14" />
</Button>
<Button variant="icon" size="mood" className="rounded-full" onClick={() => handleClick(8)}>
<Annoyed className="h-14 w-14" />
</Button>
<Button variant="icon" size="mood" className="rounded-full" on Click={() => handleClick(14)}>
<Smile className="h-14 w-14" />
</Button>
<Button variant="icon" size="mood" className="rounded-full" onClick={() => handleClick(20)}>
<Laugh className="h-14 w-14" />
</Button>
</div>
<p className="md:text-md text-sm font-light">How happy are you with your working day?</p>
</div>
</CardContent>
</Card>
Expand Down
48 changes: 0 additions & 48 deletions app/(main)/(home)/components/InactivityAlert.tsx

This file was deleted.

52 changes: 36 additions & 16 deletions app/(main)/(home)/components/SprintWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
import * as React from 'react';
import { Card, CardContent, CardHeader } from '@components/ui/Card/Card';
import { motion, useAnimation } from 'framer-motion';

interface SprintWidgetProps {
icon: React.ReactNode;
content: React.ReactNode;
description: string;
}

const SprintWidget: React.FC<SprintWidgetProps> = ({ icon, content, description }) => (
<Card className="group flex flex-col rounded-2xl border-none bg-primaryGreen-light shadow-none hover:bg-primaryGreen-main">
<CardHeader className="flex flex-row">
<div className="flex-1" />
<div className="rounded-full bg-primaryGreen-main p-2 text-white group-hover:bg-white group-hover:text-primaryGreen-main">
{icon}
</div>
</CardHeader>
<CardContent className="flex flex-grow flex-col justify-end">
<div className="space-y-1 text-primaryGreen-main group-hover:text-white">
<h1 className="text-4xl md:text-4xl lg:text-6xl">{content}</h1>
<p className="md:text-md text-sm font-light">{description}</p>
</div>
</CardContent>
</Card>
);
const SprintWidget: React.FC<SprintWidgetProps> = ({ icon, content, description }) => {
const controls = useAnimation();

const handleHoverStart = () => {
controls.start({
x: [-30, 30],
});
};

const handleHoverEnd = () => {
controls.stop();
controls.set({ x: 0 });
};

return (
<motion.div onHoverStart={handleHoverStart} onHoverEnd={handleHoverEnd}>
<Card className="group flex h-full w-full flex-col rounded-2xl border-none bg-primaryGreen-light shadow-none hover:bg-primaryGreen-main">
<CardHeader className="flex flex-row">
<div className="flex-1" />
<div className="rounded-full bg-primaryGreen-main p-2 text-white group-hover:bg-white group-hover:text-primaryGreen-main">
<motion.div animate={controls} transition={{ duration: 1.5, repeat: Infinity, repeatType: 'loop' }}>
{icon}
</motion.div>
</div>
</CardHeader>
<CardContent className="flex flex-grow flex-col justify-end">
<div className="space-y-1 text-primaryGreen-main group-hover:text-white">
<h1 className="text-4xl md:text-4xl lg:text-6xl">{content}</h1>
<p className="md:text-md text-sm font-light">{description}</p>
</div>
</CardContent>
</Card>
</motion.div>
);
};

export default SprintWidget;
33 changes: 33 additions & 0 deletions app/(main)/(home)/components/SurveyHoverCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as React from 'react';
import { HoverCard, HoverCardTrigger, HoverCardContent } from '@components/ui/HoverCard/HoverCard';
import { FilePlus } from 'lucide-react';

interface SurveyHoverCardProps {
title: string;
description: string;
}

const SurveyHoverCard: React.FC<SurveyHoverCardProps> = ({ title, description }) => (
<HoverCard>
<HoverCardTrigger asChild>
<div className="rounded-full bg-slate-900 p-2 text-white">
<FilePlus className="h-5 w-5" />
</div>
</HoverCardTrigger>
<HoverCardContent className="w-auto rounded-2xl p-4 shadow-none">
<div className="flex flex-row gap-4">
<div className="w-auto self-start rounded-full bg-slate-900 p-2 text-white">
<FilePlus className="h-6 w-6" />
</div>
<div className="flex flex-col items-start">
<div className="space-y-1">
<h4 className="text-sm font-semibold">{title}</h4>
<p className="max-w-60 break-words text-sm font-thin">{description}</p>
</div>
</div>
</div>
</HoverCardContent>
</HoverCard>
);

export default SurveyHoverCard;
Loading

0 comments on commit 1c97c38

Please sign in to comment.