diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/AnimatedSurveyBg.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/AnimatedSurveyBg.tsx
index 92b4a8042b..755ffa566a 100644
--- a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/AnimatedSurveyBg.tsx
+++ b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/AnimatedSurveyBg.tsx
@@ -95,6 +95,7 @@ export default function AnimatedSurveyBg({ localSurvey, handleBgChange }: Animat
className="absolute right-2 top-2 h-4 w-4 rounded-sm bg-white "
type="checkbox"
checked={color === value}
+ onChange={() => handleBg(value)}
/>
);
diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/ImageSurveyBg.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/ImageSurveyBg.tsx
index ba2c6c51fe..559881c276 100644
--- a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/ImageSurveyBg.tsx
+++ b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/ImageSurveyBg.tsx
@@ -14,10 +14,10 @@ export default function ImageSurveyBg({ localSurvey, handleBgChange }: ImageSurv
id="choices-file-input"
allowedFileExtensions={["png", "jpeg", "jpg"]}
environmentId={localSurvey?.environmentId}
- onFileUpload={(url: string) => {
- handleBgChange(url, "image");
+ onFileUpload={(url: string[]) => {
+ handleBgChange(url[0], "image");
}}
- fileUrl={localSurvey?.welcomeCard?.fileUrl}
+ // fileUrl={localSurvey?.surveyBackground?.bg}
/>
diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/StylingCard.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/StylingCard.tsx
index 26e9db7925..ca9bd5db05 100644
--- a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/StylingCard.tsx
+++ b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/components/StylingCard.tsx
@@ -23,10 +23,17 @@ export default function StylingCard({ localSurvey, setLocalSurvey }: StylingCard
const { type, productOverwrites, surveyBackground } = localSurvey;
const { brandColor, clickOutside, darkOverlay, placement, highlightBorderColor } = productOverwrites ?? {};
- const { bg, bgType } = surveyBackground ?? {};
+ const { bg, bgType, brightness } = surveyBackground ?? {};
const [tab, setTab] = useState(bgType || "image");
+ const [inputValue, setInputValue] = useState(100);
+
+ const handleInputChange = (e) => {
+ setInputValue(e.target.value);
+ handleBrightnessChange(parseInt(e.target.value));
+ };
+
const togglePlacement = () => {
setLocalSurvey({
...localSurvey,
@@ -58,6 +65,17 @@ export default function StylingCard({ localSurvey, setLocalSurvey }: StylingCard
});
};
+ const toggleBrightness = () => {
+ setLocalSurvey({
+ ...localSurvey,
+ surveyBackground: {
+ ...localSurvey.surveyBackground,
+ brightness: !!brightness ? undefined : 100,
+ },
+ });
+ setInputValue(100);
+ };
+
const toggleHighlightBorderColor = () => {
setLocalSurvey({
...localSurvey,
@@ -79,6 +97,7 @@ export default function StylingCard({ localSurvey, setLocalSurvey }: StylingCard
};
const handleBgChange = (color: string, type: string) => {
+ setInputValue(100);
setLocalSurvey({
...localSurvey,
surveyBackground: {
@@ -89,6 +108,16 @@ export default function StylingCard({ localSurvey, setLocalSurvey }: StylingCard
});
};
+ const handleBrightnessChange = (percent: number) => {
+ setLocalSurvey({
+ ...localSurvey,
+ surveyBackground: {
+ ...localSurvey.surveyBackground,
+ brightness: percent,
+ },
+ });
+ };
+
const handleBorderColorChange = (color: string) => {
setLocalSurvey({
...localSurvey,
@@ -173,8 +202,8 @@ export default function StylingCard({ localSurvey, setLocalSurvey }: StylingCard
{/* Background */}
-
-
+ {/* Overlay */}
+
+
+
+
+
+
Background Overlay
+
+ Darken or lighten background of your choice.
+
+
+
+
+ {brightness && (
+
+ )}
+
{/* positioning */}
{type !== "link" && (
diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgDeskstop.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgDeskstop.tsx
index 48802701f0..e28ecf11ec 100644
--- a/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgDeskstop.tsx
+++ b/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgDeskstop.tsx
@@ -3,9 +3,13 @@ export default function PreviewSurveyBgDeskstop({ children, survey, ContentRef }
- {children}
-
+ style={{
+ backgroundColor: survey.surveyBackground.bg || "#ffff",
+ filter: survey.surveyBackground.brightness
+ ? `brightness(${survey.surveyBackground.brightness}%)`
+ : "none",
+ }}>
+
{children}
) : survey.surveyBackground && survey.surveyBackground.bgType === "animation" ? (
@@ -13,22 +17,34 @@ export default function PreviewSurveyBgDeskstop({ children, survey, ContentRef }
className="relative flex w-full flex-grow flex-col items-center justify-center p-4 py-6"
style={{
background: `url(${survey.surveyBackground.bg}) no-repeat center center fixed`,
- // backgroundSize: 'cover',
}}>
-
) : survey.surveyBackground && survey.surveyBackground.bgType === "image" ? (
- {children}
-
+ style={{
+ backgroundImage: `url(${survey.surveyBackground.bg})`,
+ filter: survey.surveyBackground.brightness
+ ? `brightness(${survey.surveyBackground.brightness}%)`
+ : "none",
+ }}>
+ {children}
) : (
diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgMobile.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgMobile.tsx
index fcdfdb32dc..0795e6a3dd 100644
--- a/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgMobile.tsx
+++ b/apps/web/app/(app)/environments/[environmentId]/surveys/components/PreviewSurveyBgMobile.tsx
@@ -1,22 +1,24 @@
export default function PreviewSurveyBgMobile({ children, survey, ContentRef }) {
- console.log(survey.surveyBackground);
-
return survey.surveyBackground && survey.surveyBackground.bgType === "color" ? (
-
+
-
{children}
+ className="absolute top-0 z-10 flex h-full w-full flex-grow flex-col"
+ ref={ContentRef}
+ style={{
+ backgroundColor: survey.surveyBackground.bg,
+ filter: survey.surveyBackground.brightness
+ ? `brightness(${survey.surveyBackground.brightness}%)`
+ : "none",
+ }}>
+
+ {children}
) : survey.surveyBackground && survey.surveyBackground.bgType === "animation" ? (
+ ref={ContentRef}>
+ style={{
+ width: "100%",
+ height: "100%",
+ filter: survey.surveyBackground.brightness
+ ? `brightness(${survey.surveyBackground.brightness}%)`
+ : "none",
+ }}>
Your browser does not support the video tag.
@@ -34,23 +42,33 @@ export default function PreviewSurveyBgMobile({ children, survey, ContentRef })
) : survey.surveyBackground && survey.surveyBackground.bgType === "image" ? (
-
+
-
{children}
+ ref={ContentRef}
+ style={{
+ backgroundImage: `url(${survey.surveyBackground.bg})`,
+ filter: survey.surveyBackground.brightness
+ ? `brightness(${survey.surveyBackground.brightness}%)`
+ : "none",
+ }}>
+
+ {children}
) : (
-
+
-
{children}
+ className="absolute top-0 z-10 flex h-full w-full flex-grow flex-col"
+ ref={ContentRef}
+ style={{
+ backgroundColor: "#ffff",
+ filter: survey.surveyBackground.brightness
+ ? `brightness(${survey.surveyBackground.brightness}%)`
+ : "none",
+ }}>
+
+ {children}
);
diff --git a/apps/web/app/s/[surveyId]/components/SurveyBg.tsx b/apps/web/app/s/[surveyId]/components/SurveyBg.tsx
index d6a89afeb0..066e6e06f1 100644
--- a/apps/web/app/s/[surveyId]/components/SurveyBg.tsx
+++ b/apps/web/app/s/[surveyId]/components/SurveyBg.tsx
@@ -1,30 +1,57 @@
export default async function SurveyBg({ children, survey }) {
return survey.surveyBackground && survey.surveyBackground.bgType === "color" ? (
-
-
{children}
+
) : survey.surveyBackground && survey.surveyBackground.bgType === "animation" ? (
-
+
Your browser does not support the video tag.
{children}
) : survey.surveyBackground && survey.surveyBackground.bgType === "image" ? (
-
-
{children}
+
) : (
-
-
{children}
+
);
}
diff --git a/packages/types/surveys.ts b/packages/types/surveys.ts
index 80237d1ed3..17a2d51edd 100644
--- a/packages/types/surveys.ts
+++ b/packages/types/surveys.ts
@@ -44,6 +44,7 @@ export const ZSurveyProductOverwrites = z.object({
export const ZSurveyBackground = z.object({
bg: z.string().nullish(),
bgType: z.string().nullish(),
+ brightness: z.number().nullish(),
// darkOverlay: z.boolean().nullish(),
});
diff --git a/packages/ui/FileInput/index.tsx b/packages/ui/FileInput/index.tsx
index de5625b758..4cc0f2008e 100644
--- a/packages/ui/FileInput/index.tsx
+++ b/packages/ui/FileInput/index.tsx
@@ -17,7 +17,7 @@ interface FileInputProps {
id: string;
allowedFileExtensions: TAllowedFileExtensions[];
environmentId: string | undefined;
- onFileUpload: (uploadedUrl: string[] | string | undefined) => void;
+ onFileUpload: (uploadedUrl: string[] | undefined) => void;
fileUrl?: string | string[];
multiple?: boolean;
}