Skip to content

Commit c242514

Browse files
committed
fix: modal split chart info and login FAQ
1 parent 2ffdc8c commit c242514

4 files changed

Lines changed: 97 additions & 48 deletions

File tree

src/components/react/KpiCards/ModalSplitChart.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ export default function ModalSplitChart({ data }: Props) {
4646
},
4747
};
4848

49-
const getChartDataAndOptions = (dataset: Dataset) => {
50-
const labels = dataset.data.map((d) => d.label);
51-
const values = normalizePercentages(dataset.data);
52-
const backgroundColor = dataset.data.map((d) => d.color);
49+
const getChartDataAndOptions = (dataset: ModalSplitChartDataset) => {
50+
const sortedData = [...dataset.data].sort((a, b) => b.value - a.value);
51+
const labels = sortedData.map((d) => d.label);
52+
const values = normalizePercentages(sortedData);
53+
const backgroundColor = sortedData.map((d) => d.color);
5354

5455
const chartData = {
5556
labels,
@@ -74,26 +75,23 @@ export default function ModalSplitChart({ data }: Props) {
7475
<Doughnut data={chartData} options={options} />
7576
</div>
7677
<div className="w-1/2 flex flex-col h-60 gap-0">
77-
{[...dataset.data]
78-
.map((item, i) => ({ ...item, percent: values[i] }))
79-
.sort((a, b) => b.percent - a.percent)
80-
.map((item, i) => (
81-
<li
82-
key={item.label}
83-
className="flex items-center gap-1 justify-between text-sm"
84-
>
85-
<span
86-
className="inline-block rounded-[3px] flex-shrink-0 w-3 h-3"
87-
style={{
88-
background: item.color ?? "#ccc",
89-
}}
90-
/>
91-
<small className="flex-1">{item.label}</small>
92-
<strong className="lg:min-w-[48px] text-right">
93-
{values[i]}%
94-
</strong>
95-
</li>
96-
))}
78+
{sortedData.map(({ label, value, color }, i) => (
79+
<li
80+
key={label}
81+
className="flex items-center gap-1 justify-between text-sm"
82+
>
83+
<span
84+
className="inline-block rounded-[3px] flex-shrink-0 w-3 h-3"
85+
style={{
86+
background: color ?? "#ccc",
87+
}}
88+
/>
89+
<small className="flex-1">{label}</small>
90+
<strong className="lg:min-w-[48px] text-right">
91+
{values[i]}%
92+
</strong>
93+
</li>
94+
))}
9795
</div>
9896
</div>
9997
</div>

src/components/react/form/LoginForm.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,7 @@ export default function LoginForm() {
7777
disabled={isLoading}
7878
/>
7979

80-
<RButton
81-
type="button"
82-
variant="secondary"
83-
text="Cancel"
84-
disabled={isLoading}
85-
onClick={() => {
86-
setEmail("");
87-
setPassword("");
88-
setError("");
89-
}}
90-
/>
80+
<RButton variant="secondary" text="Go back" href={getUrl("/")} />
9181
</div>
9282

9383
<div className="text-center mt-6">

src/components/react/ui/InfoAlert.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "@heroicons/react/20/solid";
88
import { RButton } from "./RButton";
99
export type AlertVariant =
10+
| "question"
1011
| "success"
1112
| "warning"
1213
| "danger"
@@ -28,12 +29,19 @@ export type InfoAlertProps = {
2829
actionHref?: string;
2930
onAction?: () => void;
3031
className?: string;
32+
hideIcon?: boolean;
3133
};
3234

3335
const variantClasses: Record<
3436
AlertVariant,
3537
{ bg: string; border: string; text: string; buttonBg: string }
3638
> = {
39+
question: {
40+
bg: "bg-info/50",
41+
border: "border-sky-200",
42+
text: "text-primary",
43+
buttonBg: "border-primary hover:border-primary/90 text-primary",
44+
},
3745
success: {
3846
bg: "bg-success/50",
3947
border: "border-green-200",
@@ -67,12 +75,12 @@ const variantClasses: Record<
6775
};
6876

6977
const heroIconsVariants = {
70-
info: <InformationCircleIcon className="h-10 w-10" />,
71-
question: <QuestionMarkCircleIcon className="h-10 w-10" />,
72-
success: <CheckCircleIcon className="h-10 w-10" />,
73-
warning: <ExclamationTriangleIcon className="h-10 w-10" />,
74-
danger: <ExclamationTriangleIcon className="h-10 w-10" />,
75-
neutral: <InformationCircleIcon className="h-10 w-10" />,
78+
info: <InformationCircleIcon className="h-8 w-8" />,
79+
question: <QuestionMarkCircleIcon className="h-8 w-8" />,
80+
success: <CheckCircleIcon className="h-8 w-8" />,
81+
warning: <ExclamationTriangleIcon className="h-8 w-8" />,
82+
danger: <ExclamationTriangleIcon className="h-8 w-8" />,
83+
neutral: <InformationCircleIcon className="h-8 w-8" />,
7684
};
7785

7886
export function InfoAlert({
@@ -84,6 +92,7 @@ export function InfoAlert({
8492
actionHref,
8593
onAction,
8694
className = "",
95+
hideIcon = false,
8796
}: InfoAlertProps) {
8897
const v = variantClasses[variant];
8998

@@ -94,10 +103,14 @@ export function InfoAlert({
94103
aria-live="polite"
95104
>
96105
<div className="flex items-start gap-2">
97-
<div className={`${v.text}`}>{heroIconsVariants[icon ?? variant]}</div>
106+
{!hideIcon && (
107+
<div className={`${v.text}`}>
108+
{heroIconsVariants[icon ?? variant]}
109+
</div>
110+
)}
98111

99112
<div className="flex-1 gap-0">
100-
{title && <h5 className={`${v.text}`}>{title}</h5>}
113+
{title && <h6 className={`${v.text}`}>{title}</h6>}
101114
<p className={`${v.text}`}>{children}</p>
102115
</div>
103116

src/pages/lab-admin/login.astro

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,64 @@
11
---
22
import Layout from "../../layouts/Layout.astro";
33
import LoginForm from "../../components/react/form/LoginForm";
4+
import { InfoAlert } from "../../components/react";
45
---
56

67
<Layout role="visitor">
78
<div class="px-6 py-12">
8-
<section class="max-w-3xl mx-auto">
9-
<h2>Sign in to your account</h2>
10-
<p class="text-warning italic mb-6">
11-
Access your lab management dashboard with your credentials.
9+
<section class="max-w-3xl mx-auto gap-2 flex flex-col">
10+
<h2>Sign in as Living Lab editor</h2>
11+
<p class="text-primary italic mb-6">
12+
Access your living lab management dashboard with your credentials.
1213
</p>
1314
<LoginForm client:load />
15+
16+
<div class="gap-4 flex flex-col mt-8">
17+
<h4>Need help ?</h4>
18+
<InfoAlert
19+
variant="question"
20+
title="Are you a SUM Living Lab ?"
21+
actionHref="/lab-admin/signup"
22+
actionText="Sign up"
23+
hideIcon
24+
client:load
25+
>
26+
<small>
27+
If this is your first time accessing the platform, create a new
28+
account and select your Living Lab from the list.
29+
</small>
30+
</InfoAlert>
31+
32+
<InfoAlert
33+
variant="question"
34+
title="Are you a SUM project partner ?"
35+
hideIcon
36+
client:load
37+
>
38+
<small>
39+
For administrator access, please contact the administrator at
40+
<a class="underline" href="mailto:odp@sum-project.eu"
41+
>odp@sum-project.eu</a
42+
> to request special access to the platform.
43+
</small>
44+
</InfoAlert>
45+
46+
<InfoAlert
47+
variant="question"
48+
title="Do you want to create a new Living Lab?"
49+
hideIcon
50+
client:load
51+
>
52+
<small>
53+
Thank you for your interest in contributing to the SUM project! The
54+
feature is currently under construction. Please reach out to the
55+
platform administrator at <a
56+
class="underline"
57+
href="mailto:odp@sum-project.eu">odp@sum-project.eu</a
58+
> for more information.
59+
</small>
60+
</InfoAlert>
61+
</div>
1462
</section>
1563
</div>
16-
</Layout>
64+
</Layout>

0 commit comments

Comments
 (0)