Skip to content

Commit be0b707

Browse files
authored
style: take feedback dialog little right (calcom#27892)
1 parent fad64a0 commit be0b707

File tree

1 file changed

+55
-26
lines changed

1 file changed

+55
-26
lines changed

apps/web/modules/feature-opt-in/components/FeedbackDialog.tsx

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22

3+
import { RATING_OPTIONS } from "@calcom/features/bookings/lib/rating";
34
import { useLocale } from "@calcom/lib/hooks/useLocale";
45
import { trpc } from "@calcom/trpc/react";
56
import { Button } from "@coss/ui/components/button";
@@ -9,7 +10,6 @@ import { cn } from "@coss/ui/lib/utils";
910
import { XIcon } from "lucide-react";
1011
import type { ReactElement } from "react";
1112
import { useState } from "react";
12-
import { RATING_OPTIONS } from "@calcom/features/bookings/lib/rating";
1313

1414
export interface FeedbackDialogProps {
1515
isOpen: boolean;
@@ -44,15 +44,19 @@ export function FeedbackDialog({
4444
const [comment, setComment] = useState("");
4545
const [isSuccess, setIsSuccess] = useState(false);
4646

47-
const submitFeedbackMutation = trpc.viewer.feedback.submitFeedback.useMutation({
48-
onSuccess: () => {
49-
setIsSuccess(true);
50-
onSubmitSuccess?.();
51-
},
52-
onError: () => {
53-
toastManager.add({ title: t("error_submitting_feedback"), type: "error" });
54-
},
55-
});
47+
const submitFeedbackMutation =
48+
trpc.viewer.feedback.submitFeedback.useMutation({
49+
onSuccess: () => {
50+
setIsSuccess(true);
51+
onSubmitSuccess?.();
52+
},
53+
onError: () => {
54+
toastManager.add({
55+
title: t("error_submitting_feedback"),
56+
type: "error",
57+
});
58+
},
59+
});
5660

5761
const handleSubmit = async (): Promise<void> => {
5862
if (selectedRating === null) return;
@@ -82,32 +86,46 @@ export function FeedbackDialog({
8286
}
8387

8488
// Visibility classes based on showOn
85-
const visibilityClass = showOn === "desktop" ? "hidden sm:block" : showOn === "mobile" ? "sm:hidden" : "";
89+
const visibilityClass =
90+
showOn === "desktop"
91+
? "hidden sm:block"
92+
: showOn === "mobile"
93+
? "sm:hidden"
94+
: "";
8695
const showMobileBackdrop = showOn !== "desktop";
8796

8897
if (isSuccess) {
8998
return (
9099
<>
91100
{/* Mobile-only backdrop */}
92101
{showMobileBackdrop && (
93-
<div className="fixed inset-0 z-40 bg-black/50 sm:hidden" onClick={resetAndClose} />
102+
<div
103+
className="fixed inset-0 z-40 bg-black/50 sm:hidden"
104+
onClick={resetAndClose}
105+
/>
94106
)}
95107
<div
96108
data-testid="feedback-success-dialog"
97109
className={cn(
98-
"bg-default border-subtle fixed bottom-24 left-5 right-5 z-50 rounded-lg border shadow-lg sm:bottom-5 sm:left-auto sm:max-w-sm",
110+
"fixed right-5 bottom-24 left-5 z-50 rounded-lg border border-subtle bg-default shadow-lg sm:right-20 sm:bottom-5 sm:left-auto sm:max-w-sm",
99111
visibilityClass
100-
)}>
112+
)}
113+
>
101114
<div className="relative p-4">
102115
<button
103116
type="button"
104117
onClick={resetAndClose}
105118
className="absolute top-2 right-2 rounded-md p-1 hover:bg-subtle"
106-
aria-label={t("close")}>
119+
aria-label={t("close")}
120+
>
107121
<XIcon className="h-4 w-4" />
108122
</button>
109-
<h3 className="text-emphasis text-lg font-semibold">{t("feedback_submitted_title")}</h3>
110-
<p className="text-subtle mt-1 text-sm">{t("feedback_submitted_description")}</p>
123+
<h3 className="font-semibold text-emphasis text-lg">
124+
{t("feedback_submitted_title")}
125+
</h3>
126+
<p className="mt-1 text-sm text-subtle">
127+
{t("feedback_submitted_description")}
128+
</p>
111129
<div className="mt-4 flex justify-end">
112130
<Button size="sm" onClick={resetAndClose}>
113131
{t("done")}
@@ -123,24 +141,29 @@ export function FeedbackDialog({
123141
<>
124142
{/* Mobile-only backdrop */}
125143
{showMobileBackdrop && (
126-
<div className="fixed inset-0 z-40 bg-black/50 sm:hidden" onClick={handleSkip} />
144+
<div
145+
className="fixed inset-0 z-40 bg-black/50 sm:hidden"
146+
onClick={handleSkip}
147+
/>
127148
)}
128149
<div
129150
data-testid="feedback-dialog"
130151
className={cn(
131-
"bg-default border-subtle fixed bottom-24 left-5 right-5 z-50 rounded-lg border shadow-lg sm:bottom-5 sm:left-auto sm:max-w-sm",
152+
"fixed right-5 bottom-24 left-5 z-50 rounded-lg border border-subtle bg-default shadow-lg sm:right-20 sm:bottom-5 sm:left-auto sm:max-w-sm",
132153
visibilityClass
133-
)}>
154+
)}
155+
>
134156
<div className="relative p-4">
135157
<button
136158
type="button"
137159
onClick={handleSkip}
138160
className="absolute top-2 right-2 rounded-md p-1 hover:bg-subtle"
139-
aria-label={t("close")}>
161+
aria-label={t("close")}
162+
>
140163
<XIcon className="h-4 w-4" />
141164
</button>
142-
<h3 className="text-emphasis text-lg font-semibold">{t(titleKey)}</h3>
143-
<p className="text-subtle mt-1 text-sm">{t(descriptionKey)}</p>
165+
<h3 className="font-semibold text-emphasis text-lg">{t(titleKey)}</h3>
166+
<p className="mt-1 text-sm text-subtle">{t(descriptionKey)}</p>
144167

145168
<div className="mt-4 flex justify-center gap-2">
146169
{RATING_OPTIONS.map((option) => (
@@ -150,9 +173,12 @@ export function FeedbackDialog({
150173
onClick={() => setSelectedRating(option.value)}
151174
className={cn(
152175
"flex h-10 w-10 items-center justify-center rounded-lg text-xl transition-all",
153-
selectedRating === option.value ? "bg-emphasis" : "hover:bg-subtle"
176+
selectedRating === option.value
177+
? "bg-emphasis"
178+
: "hover:bg-subtle"
154179
)}
155-
aria-label={`Rating ${option.value}`}>
180+
aria-label={`Rating ${option.value}`}
181+
>
156182
{option.emoji}
157183
</button>
158184
))}
@@ -173,7 +199,10 @@ export function FeedbackDialog({
173199
<Button
174200
size="sm"
175201
onClick={handleSubmit}
176-
disabled={selectedRating === null || submitFeedbackMutation.isPending}>
202+
disabled={
203+
selectedRating === null || submitFeedbackMutation.isPending
204+
}
205+
>
177206
{t("submit_feedback")}
178207
</Button>
179208
</div>

0 commit comments

Comments
 (0)